Class: SpreeClient::API::V1
- Inherits:
-
Object
- Object
- SpreeClient::API::V1
show all
- Includes:
- HTTParty
- Defined in:
- lib/spree_client/api/v1.rb,
lib/spree_client/api/v1/products.rb,
lib/spree_client/api/v1/variants.rb,
lib/spree_client/api/v1/resources.rb,
lib/spree_client/api/v1/properties.rb,
lib/spree_client/api/v1/taxonomies.rb,
lib/spree_client/api/v1/stock_items.rb,
lib/spree_client/api/v1/stock_locations.rb,
lib/spree_client/api/v1/stock_movements.rb
Defined Under Namespace
Classes: Products, Properties, Resources, StockItems, StockLocations, StockMovements, Taxonomies, Variants
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(api_key:, spree_url: 'http://localhost:3000', store: nil) ⇒ V1
16
17
18
19
20
|
# File 'lib/spree_client/api/v1.rb', line 16
def initialize(api_key:, spree_url: 'http://localhost:3000', store: nil)
@api_key = api_key
@store = HTTParty.normalize_base_uri(store) if store
self.class.default_options[:base_uri] = HTTParty.normalize_base_uri(spree_url)
end
|
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
14
15
16
|
# File 'lib/spree_client/api/v1.rb', line 14
def api_key
@api_key
end
|
#store ⇒ Object
Returns the value of attribute store.
14
15
16
|
# File 'lib/spree_client/api/v1.rb', line 14
def store
@store
end
|
Instance Method Details
48
49
50
|
# File 'lib/spree_client/api/v1.rb', line 48
def ( = {})
.merge({ 'Content-Type' => 'application/json', 'X-Spree-Token' => api_key, 'Origin' => store })
end
|
#products(**args) ⇒ Object
23
24
25
26
|
# File 'lib/spree_client/api/v1.rb', line 23
def products(**args)
@products ||= {}
@products[args.hash.to_s] ||= Products.new **{ api: self }.merge(args)
end
|
#stock_items(**args) ⇒ Object
43
44
45
46
|
# File 'lib/spree_client/api/v1.rb', line 43
def stock_items(**args)
@stock_items ||= {}
@stock_items[args.hash.to_s] ||= StockItems.new **{ api: self }.merge(args)
end
|
#stock_locations(**args) ⇒ Object
33
34
35
36
|
# File 'lib/spree_client/api/v1.rb', line 33
def stock_locations(**args)
@stock_locations ||= {}
@stock_locations[args.hash.to_s] ||= StockLocations.new **{ api: self }.merge(args)
end
|
#stock_movements(**args) ⇒ Object
38
39
40
41
|
# File 'lib/spree_client/api/v1.rb', line 38
def stock_movements(**args)
@stock_movements ||= {}
@stock_movements[args.hash.to_s] ||= StockMovements.new **{ api: self }.merge(args)
end
|
#variants(**args) ⇒ Object
28
29
30
31
|
# File 'lib/spree_client/api/v1.rb', line 28
def variants(**args)
@variants ||= {}
@variants[args.hash.to_s] ||= Variants.new **{ api: self }.merge(args)
end
|