class Prodigi::OrderResource

Public Instance Methods

actions(prodigi_order_id:) click to toggle source
# File lib/prodigi/resources/orders.rb, line 23
def actions(prodigi_order_id:)
  response = get_request("orders/#{prodigi_order_id}/actions")
  if response.body.dig("outcome") == "Ok"
    Object.new response.body
  end
end
cancel(prodigi_order_id:, **attributes) click to toggle source
# File lib/prodigi/resources/orders.rb, line 53
def cancel(prodigi_order_id:, **attributes)
  response = post_request("orders/#{prodigi_order_id}/actions/cancel", 
                          body: attributes)
  if response.body.dig('outcome') == "Cancelled"
    Order.new response.body.dig('order')
  end
end
create(**attributes) click to toggle source
# File lib/prodigi/resources/orders.rb, line 9
def create(**attributes)
  response = post_request("orders", body: attributes)
  if response.body.dig("outcome") == "Created"
    Order.new response.body.dig("order")
  end
end
list(**params) click to toggle source
# File lib/prodigi/resources/orders.rb, line 4
def list(**params)
  response = get_request("orders", params: params)
  Collection.from_response(response, key: "orders", type: Order)
end
retrieve(prodigi_order_id:) click to toggle source
# File lib/prodigi/resources/orders.rb, line 16
def retrieve(prodigi_order_id:)
  response = get_request("orders/#{prodigi_order_id}")
  if response.body.dig("outcome") == "Ok"
    Order.new response.body.dig("order")
  end
end
update_metadata(prodigi_order_id:, **attributes) click to toggle source
# File lib/prodigi/resources/orders.rb, line 46
def update_metadata(prodigi_order_id:, **attributes)
  response = post_request("orders/#{prodigi_order_id}/actions/updateMetadata", body: attributes)
  if response.body.dig("outcome") == "Updated"
    Order.new response.body.dig("order")
  end
end
update_recipient(prodigi_order_id:, **attributes) click to toggle source
# File lib/prodigi/resources/orders.rb, line 38
def update_recipient(prodigi_order_id:, **attributes)
  response = post_request("orders/#{prodigi_order_id}/actions/updateRecipient",
                          body: attributes)
  if response.body.dig("outcome") == "Updated"
    Order.new response.body.dig("order")
  end
end
update_shipping(prodigi_order_id:, **attributes) click to toggle source
# File lib/prodigi/resources/orders.rb, line 30
def update_shipping(prodigi_order_id:, **attributes)
  response = post_request("orders/#{prodigi_order_id}/actions/updateShipping",
                          body: attributes)
  if response.body.dig("outcome") == "Updated"
    Order.new response.body.dig("order")
  end
end