Class: PrintfulAPI::Product
Instance Attribute Summary
Attributes inherited from APIResource
#raw_data
Class Method Summary
collapse
Instance Method Summary
collapse
included
included
Methods inherited from APIResource
api_attributes, belongs_to, camelize, has_many, singularize, #to_h
Class Method Details
.resource_path ⇒ Object
19
20
21
|
# File 'lib/printful_api/product.rb', line 19
def self.resource_path
'/products'
end
|
Instance Method Details
#load_data(data) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/printful_api/product.rb', line 23
def load_data( data )
if data['product'].present?
super(data['product'])
@variants = data['variants'].collect do |variant_data|
variant = PrintfulAPI::Variant.new.load_data( variant_data )
variant.product = self
variant
end
else
super( data )
end
end
|
#variants ⇒ Object
14
15
16
17
|
# File 'lib/printful_api/product.rb', line 14
def variants
@variants ||= PrintfulAPI::Variant.list( product_id: self.id )
@variants
end
|