Class: PrintfulAPI::Product

Inherits:
APIResource show all
Includes:
APIOperations::Get, APIOperations::List
Defined in:
lib/printful_api/product.rb

Instance Attribute Summary

Attributes inherited from APIResource

#raw_data

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Get

included

Methods included from APIOperations::List

included

Methods inherited from APIResource

api_attributes, belongs_to, camelize, has_many, singularize, #to_h

Class Method Details

.resource_pathObject



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

#variantsObject



14
15
16
17
# File 'lib/printful_api/product.rb', line 14

def variants
	@variants ||= PrintfulAPI::Variant.list( product_id: self.id )
	@variants
end