Module: Fulfillment::Resources::Inventories

Extended by:
Inventories
Included in:
Inventories
Defined in:
lib/fulfillment/resources/inventories.rb

Constant Summary collapse

FIND_ALL_RESPONSE_MODELS =
{
  "outbox" => ::Outbox::Models::Event
}
FIND_RESPONSE_MODELS =
{
  "outbox" => ::Outbox::Models::PriceLevelSeat
}

Instance Method Summary collapse

Instance Method Details

#find(fulfillment_method:, wrap: true, **params) ⇒ Object

We don’t use a resource ID here but rather the fulfillment method as the ID because different fulfillment methods use different ways of finding resources other than just a plain ID. Any applicable resource ID should be passed to the params.



27
28
29
30
31
32
33
34
35
# File 'lib/fulfillment/resources/inventories.rb', line 27

def find(fulfillment_method:, wrap: true, **params)
  response = Request.new("inventories/#{fulfillment_method}", query: params).get
  return if response.body.nil? || response.body.empty?
  if wrap
    Models::Collection.new(FIND_RESPONSE_MODELS[fulfillment_method], response.body)
  else
    response.body
  end
end

#find_all(fulfillment_method:, wrap: true, **params) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fulfillment/resources/inventories.rb', line 15

def find_all(fulfillment_method:, wrap: true, **params)
  response = Request.new("inventories", id: fulfillment_method, query: params).get
  if wrap
    Models::Collection.new(FIND_ALL_RESPONSE_MODELS[fulfillment_method], response.body)
  else
    response.body
  end
end

#update(fulfillment_method:, **params) ⇒ Object



37
38
39
40
# File 'lib/fulfillment/resources/inventories.rb', line 37

def update(fulfillment_method:, **params)
  response = Request.new("inventories/#{fulfillment_method}", query: params).put
  response.success?
end