Class: Zinc::Order
Instance Attribute Summary collapse
-
#_type ⇒ Object
Returns the value of attribute _type.
-
#account_status ⇒ Object
Returns the value of attribute account_status.
-
#code ⇒ Object
Returns the value of attribute code.
-
#delivery_dates ⇒ Object
Returns the value of attribute delivery_dates.
-
#error ⇒ Object
Returns the value of attribute error.
-
#merchant_order_ids ⇒ Object
Returns the value of attribute merchant_order_ids.
-
#message ⇒ Object
Returns the value of attribute message.
-
#price_components ⇒ Object
Returns the value of attribute price_components.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#status_updates ⇒ Object
Returns the value of attribute status_updates.
-
#tracking ⇒ Object
Returns the value of attribute tracking.
Class Method Summary collapse
- .abort(request_id) ⇒ Object
- .all(offset: 0, limit: 20) ⇒ Object
- .cancel(request_id) ⇒ Object
- .create(retailer:, retailer_credentials:, products:, payment_method:, billing_address:, shipping_address:, shipping:, options: {}) ⇒ Object
- .retrieve(request_id) ⇒ Object
Instance Method Summary collapse
-
#initialize(hash) ⇒ Order
constructor
A new instance of Order.
Methods inherited from Model
Constructor Details
#initialize(hash) ⇒ Order
Returns a new instance of Order.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zinc/order.rb', line 16 def initialize(hash) @request_id = hash['request_id'] if hash['request_id'] @_type = hash['_type'] if hash['_type'] @code = hash['code'] if hash['code'] = hash['message'] if hash['message'] @status_updates = hash['status_updates'] if hash['status_updates'] @error = hash['error'] if hash['error'] @price_components = PriceComponents.new(hash['price_components']) if hash['price_components'] @merchant_order_ids = hash['merchant_order_ids'].map { |hash| MerchantOrderId.new(hash) } if hash['merchant_order_ids'] @tracking = hash['tracking'].map { |hash| Tracking.new(hash) } if hash['tracking'] @request = hash['request'] if hash['request'] @delivery_dates = hash['delivery_dates'] if hash['delivery_dates'] @account_status = AccountStatus.new(hash['account_status']) if hash['account_status'] end |
Instance Attribute Details
#_type ⇒ Object
Returns the value of attribute _type.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def _type @_type end |
#account_status ⇒ Object
Returns the value of attribute account_status.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def account_status @account_status end |
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def code @code end |
#delivery_dates ⇒ Object
Returns the value of attribute delivery_dates.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def delivery_dates @delivery_dates end |
#error ⇒ Object
Returns the value of attribute error.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def error @error end |
#merchant_order_ids ⇒ Object
Returns the value of attribute merchant_order_ids.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def merchant_order_ids @merchant_order_ids end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def end |
#price_components ⇒ Object
Returns the value of attribute price_components.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def price_components @price_components end |
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def request @request end |
#request_id ⇒ Object
Returns the value of attribute request_id.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def request_id @request_id end |
#status_updates ⇒ Object
Returns the value of attribute status_updates.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def status_updates @status_updates end |
#tracking ⇒ Object
Returns the value of attribute tracking.
3 4 5 |
# File 'lib/zinc/order.rb', line 3 def tracking @tracking end |
Class Method Details
.abort(request_id) ⇒ Object
68 69 70 71 |
# File 'lib/zinc/order.rb', line 68 def abort(request_id) response = post(path: "orders/#{request_id}/abort") Order.new(response) end |
.all(offset: 0, limit: 20) ⇒ Object
32 33 34 35 |
# File 'lib/zinc/order.rb', line 32 def all(offset: 0, limit: 20) response = get(path: 'orders', params: { offset: offset, limit: limit }) response['orders'].map { |hash| Order.new(hash) } end |
.cancel(request_id) ⇒ Object
73 74 75 76 |
# File 'lib/zinc/order.rb', line 73 def cancel(request_id) response = post(path: "orders/#{request_id}/cancel") Order.new(response) end |
.create(retailer:, retailer_credentials:, products:, payment_method:, billing_address:, shipping_address:, shipping:, options: {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/zinc/order.rb', line 42 def create(retailer:, retailer_credentials:, products:, payment_method:, billing_address:, shipping_address:, shipping:, options: {}) params = { retailer: retailer, retailer_credentials: retailer_credentials.to_hash, products: products.map(&:to_hash), payment_method: payment_method.to_hash, billing_address: billing_address.to_hash, shipping_address: shipping_address.to_hash, shipping: shipping.to_hash } # Valid options: # - is_gift # - gift_message # - max_price # - webhooks # - client_notes # - promo_codes # - po_number # - bundled params.merge!() unless params.empty? response = post(path: 'orders', params: params) Order.new(response) end |
.retrieve(request_id) ⇒ Object
37 38 39 40 |
# File 'lib/zinc/order.rb', line 37 def retrieve(request_id) response = get(path: "orders/#{request_id}") Order.new(response) end |