Class: Printaura::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/printaura/product.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(brand, colors, image_id, mock_image_id, price, app_ids, title, product_id, sku, shopify) ⇒ Product

Returns a new instance of Product.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/printaura/product.rb', line 14

def initialize(brand, colors, image_id, mock_image_id, price, app_ids, title, product_id, sku, shopify)
  store_images = {"0" => {"image_id" => image_id, "default" => "0"}, "1" => {"image_id" => mock_image_id, "default"=>"1"}}
  args = {brand_id: brand, colors: Base64.encode64(colors.to_json), front_print: image_id, front_mockup: mock_image_id, title: title, description: "", product_price: price, apps: Base64.encode64(app_ids.to_json), product_id: product_id, sku: sku, storeimages: Base64.encode64(store_images.to_json)}
  if shopify
    args = args.merge(shopify)
  end

  result = Api.addproduct(args)
  @shopify_product_id = result["results"]["shopify_id"]
  @printaura_product_id = result["results"]["product_id"]
end

Instance Attribute Details

#printaura_product_idObject

Returns the value of attribute printaura_product_id.



6
7
8
# File 'lib/printaura/product.rb', line 6

def printaura_product_id
  @printaura_product_id
end

#shopify_product_idObject

Returns the value of attribute shopify_product_id.



5
6
7
# File 'lib/printaura/product.rb', line 5

def shopify_product_id
  @shopify_product_id
end

Class Method Details

.allObject



8
9
10
11
12
# File 'lib/printaura/product.rb', line 8

def self.all
  Api.viewproducts.each do |prod|
    puts prod
  end
end