Class: Levelup::Requests::CreateOrder
- Inherits:
-
Base
- Object
- Templates::DataParcel
- Base
- Levelup::Requests::CreateOrder
- Includes:
- Templates::MerchantAndUserAuthenticated
- Defined in:
- lib/levelup/requests/create_order.rb
Overview
Represents a request to create an order for the specified user at the specified merchant.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#identifier_from_merchant ⇒ Object
A merchant-supplied unique ID for this order.
-
#items ⇒ Object
An array of Item objects (or hashes representing them) representing all items purchased by this order.
-
#location_id ⇒ Object
The LevelUp ID for the location from which this order was requested.
-
#spend_amount ⇒ Object
The total amount (in cents) spent on this order.
Attributes included from Templates::MerchantAndUserAuthenticated
#merchant_access_token, #user_access_token
Instance Method Summary collapse
Methods included from Templates::MerchantAndUserAuthenticated
Methods inherited from Base
#auth_type, #headers, instance_variables_excluded_from_hash, #send_to_api
Methods inherited from Templates::DataParcel
excluded?, #initialize, instance_variables_excluded_from_hash
Constructor Details
This class inherits a constructor from Levelup::Templates::DataParcel
Instance Attribute Details
#identifier_from_merchant ⇒ Object
A merchant-supplied unique ID for this order. Optional.
10 11 12 |
# File 'lib/levelup/requests/create_order.rb', line 10 def identifier_from_merchant @identifier_from_merchant end |
#items ⇒ Object
An array of Item objects (or hashes representing them) representing all items purchased by this order.
8 9 10 |
# File 'lib/levelup/requests/create_order.rb', line 8 def items @items end |
#location_id ⇒ Object
The LevelUp ID for the location from which this order was requested.
12 13 14 |
# File 'lib/levelup/requests/create_order.rb', line 12 def location_id @location_id end |
#spend_amount ⇒ Object
The total amount (in cents) spent on this order.
14 15 16 |
# File 'lib/levelup/requests/create_order.rb', line 14 def spend_amount @spend_amount end |
Instance Method Details
#body ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/levelup/requests/create_order.rb', line 16 def body items = (@items || []).map do |item| if item.empty? next end { item: item } end order_hash = to_hash order_hash[:items] = items { order: order_hash } end |
#response_from_hash(hash) ⇒ Object
31 32 33 |
# File 'lib/levelup/requests/create_order.rb', line 31 def response_from_hash(hash) Responses::Success.new(hash['order']) end |