Class: Supai::Order
Instance Attribute Summary collapse
-
#fulfillment_type ⇒ Object
Returns the value of attribute fulfillment_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
- .all(chain_id:, store_id:, params: {}, token:, api: API.new) ⇒ Object
-
.all_in_batches(chain_id:, store_id:, params: {}, batch_size: 100, token:, api: API.new) {|response| ... } ⇒ Object
yields batches (no larger than batch_size) of orders fetched from the API.
- .endpoint(chain_id:, store_id:) ⇒ Object
Instance Method Summary collapse
-
#initialize(hash) ⇒ Order
constructor
A new instance of Order.
Methods inherited from Resource
#as_json, attr_accessor, attr_collections, attr_objects, attr_timestamp_accessor, attributes, #inspect, #parse_collection, #parse_object, #parse_timestamp, #set_attribute, #set_attributes, #underscore
Constructor Details
#initialize(hash) ⇒ Order
Returns a new instance of Order.
40 41 42 |
# File 'lib/supai/order.rb', line 40 def initialize(hash) set_attributes(hash) end |
Instance Attribute Details
#fulfillment_type ⇒ Object
Returns the value of attribute fulfillment_type.
3 4 5 |
# File 'lib/supai/order.rb', line 3 def fulfillment_type @fulfillment_type end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/supai/order.rb', line 3 def id @id end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/supai/order.rb', line 3 def status @status end |
Class Method Details
.all(chain_id:, store_id:, params: {}, token:, api: API.new) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/supai/order.rb', line 13 def self.all(chain_id:, store_id:, params: {}, token:, api: API.new) response = api.request( :get, endpoint(chain_id: chain_id, store_id: store_id), params: params, headers: { accept: "application/vnd.mywebgrocer.mgmt-orders+json" }, token: token, ) raise response.error unless response.success? OrdersResponse.new(response.json_body, chain_id, store_id, params) end |
.all_in_batches(chain_id:, store_id:, params: {}, batch_size: 100, token:, api: API.new) {|response| ... } ⇒ Object
yields batches (no larger than batch_size) of orders fetched from the API
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/supai/order.rb', line 27 def self.all_in_batches(chain_id:, store_id:, params: {}, batch_size: 100, token:, api: API.new) params[:take] = batch_size params[:skip] = 0 response = all(chain_id: chain_id, store_id: store_id, params: params, token: token, api: api) yield response loop do response = response.next(token: token, api: api) break if response.nil? yield response end end |
.endpoint(chain_id:, store_id:) ⇒ Object
9 10 11 |
# File 'lib/supai/order.rb', line 9 def self.endpoint(chain_id:, store_id:) "/api/ordermanagement/v7/chains/#{chain_id}/stores/#{store_id}/orders" end |