Class: PrintfulAPI::ShippingRate

Inherits:
APIResource show all
Defined in:
lib/printful_api/shipping_rate.rb

Instance Attribute Summary

Attributes inherited from APIResource

#raw_data

Class Method Summary collapse

Methods inherited from APIResource

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

Class Method Details

.list(recipient = {}, items = [], currency = 'USD', opts = {}) ⇒ Object

PrintfulAPI::ShippingRate.list( { address1: ‘12372 Carmel Country Rd’, city: ‘San Diego’, country_code: ‘US’, state_code: ‘CA’, zip: 92130}, [2, variant_id: PrintfulAPI::Product.get(1).variants.first.id], ‘USD’ )



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/printful_api/shipping_rate.rb', line 8

def self.list( recipient = {}, items = [], currency = 'USD', opts = {} )

	request_data = {
		recipient: recipient,
		items: items,
		currency: currency
	}

	results = PrintfulAPI.request( :POST, "/shipping/rates", data: request_data, params: opts )

	results.collect do |data|
		model = self.new
		model.load_data( data )

		model
	end

end