Class: Supai::OrdersResponse

Inherits:
Resource show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/supai/orders_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#as_json, attr_accessor, attr_collections, attr_objects, attr_timestamp_accessor, attributes, #parse_collection, #parse_object, #parse_timestamp, #set_attribute, #set_attributes, #underscore

Constructor Details

#initialize(hash, chain_id, store_id, params) ⇒ OrdersResponse

Returns a new instance of OrdersResponse.



13
14
15
16
17
18
# File 'lib/supai/orders_response.rb', line 13

def initialize(hash, chain_id, store_id, params)
  set_attributes(hash)
  @chain_id = chain_id
  @store_id = store_id
  @params = params
end

Instance Attribute Details

#total_ordersObject

Returns the value of attribute total_orders.



8
9
10
# File 'lib/supai/orders_response.rb', line 8

def total_orders
  @total_orders
end

Instance Method Details

#inspectObject



32
33
34
# File 'lib/supai/orders_response.rb', line 32

def inspect
  "#<#{self.class} count: #{count}}>"
end

#next(token:, api: API.new) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/supai/orders_response.rb', line 24

def next(token:, api: API.new)
  skip = (@params[:skip] || 0) + count
  return nil if skip >= total_orders

  @params[:skip] = skip
  Order.all(chain_id: @chain_id, store_id: @store_id, params: @params, token: token, api: api)
end

#paramsObject



20
21
22
# File 'lib/supai/orders_response.rb', line 20

def params
  @params
end