class SpreeClient::API::V1
Attributes
api_key[R]
store[R]
Public Class Methods
new(api_key:, spree_url: 'http://localhost:3000', store: nil)
click to toggle source
# File lib/spree_client/api/v1.rb 16 def initialize(api_key:, spree_url: 'http://localhost:3000', store: nil) 17 @api_key = api_key 18 @store = HTTParty.normalize_base_uri(store) if store 19 self.class.default_options[:base_uri] = HTTParty.normalize_base_uri(spree_url) 20 end
Public Instance Methods
headers(extra = {})
click to toggle source
# File lib/spree_client/api/v1.rb 48 def headers(extra = {}) 49 extra.merge({ 'Content-Type' => 'application/json', 'X-Spree-Token' => api_key, 'Origin' => store }) 50 end
products(**args)
click to toggle source
TODO: Meta programming
# File lib/spree_client/api/v1.rb 23 def products(**args) 24 @products ||= {} 25 @products[args.hash.to_s] ||= Products.new **{ api: self }.merge(args) 26 end
stock_items(**args)
click to toggle source
# File lib/spree_client/api/v1.rb 43 def stock_items(**args) 44 @stock_items ||= {} 45 @stock_items[args.hash.to_s] ||= StockItems.new **{ api: self }.merge(args) 46 end
stock_locations(**args)
click to toggle source
# File lib/spree_client/api/v1.rb 33 def stock_locations(**args) 34 @stock_locations ||= {} 35 @stock_locations[args.hash.to_s] ||= StockLocations.new **{ api: self }.merge(args) 36 end
stock_movements(**args)
click to toggle source
# File lib/spree_client/api/v1.rb 38 def stock_movements(**args) 39 @stock_movements ||= {} 40 @stock_movements[args.hash.to_s] ||= StockMovements.new **{ api: self }.merge(args) 41 end
variants(**args)
click to toggle source
# File lib/spree_client/api/v1.rb 28 def variants(**args) 29 @variants ||= {} 30 @variants[args.hash.to_s] ||= Variants.new **{ api: self }.merge(args) 31 end