class Supai::Order

Attributes

fulfillment_type[RW]
id[RW]
status[RW]

Public Class Methods

all(chain_id:, store_id:, params: {}, token:, api: API.new) click to toggle source
# 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| ... } click to toggle source

yields batches (no larger than batch_size) of orders fetched from the API

# 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:) click to toggle source
# 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
new(hash) click to toggle source
# File lib/supai/order.rb, line 40
def initialize(hash)
  set_attributes(hash)
end