Class: TophatterMerchant::Order
- Defined in:
- lib/tophatter_merchant/order.rb
Instance Attribute Summary collapse
-
#address1 ⇒ Object
Returns the value of attribute address1.
-
#address2 ⇒ Object
Returns the value of attribute address2.
-
#available_refunds ⇒ Object
Returns the value of attribute available_refunds.
-
#carrier ⇒ Object
Returns the value of attribute carrier.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#customer_id ⇒ Object
Returns the value of attribute customer_id.
-
#customer_name ⇒ Object
Returns the value of attribute customer_name.
-
#disbursement_amount ⇒ Object
Returns the value of attribute disbursement_amount.
-
#line_items ⇒ Object
Returns the value of attribute line_items.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#paid_at ⇒ Object
Returns the value of attribute paid_at.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#product_identifier ⇒ Object
Returns the value of attribute product_identifier.
-
#product_name ⇒ Object
Returns the value of attribute product_name.
-
#refund_amount ⇒ Object
Returns the value of attribute refund_amount.
-
#seller_fees ⇒ Object
Returns the value of attribute seller_fees.
-
#seller_fees_amount ⇒ Object
Returns the value of attribute seller_fees_amount.
-
#state ⇒ Object
Returns the value of attribute state.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
-
#variation_identifier ⇒ Object
Returns the value of attribute variation_identifier.
Class Method Summary collapse
-
.all(filter: nil, page: 1, per_page: 50) ⇒ Object
ap TophatterMerchant::Order.all.map(&:to_h) ap TophatterMerchant::Order.all(filter: ‘unfulfilled’).map(&:to_h) ap TophatterMerchant::Order.all(filter: ‘fulfilled’).map(&:to_h).
-
.fulfill(id, carrier:, tracking_number:) ⇒ Object
ap TophatterMerchant::Order.fulfill(417953232, carrier: ‘other’, tracking_number: ‘ABC123’).to_h.
-
.refund(id, type:, reason:, fees: []) ⇒ Object
ap TophatterMerchant::Order.refund(417953232, type: ‘full’, reason: ‘delay_in_shipping’).to_h ap TophatterMerchant::Order.refund(417953232, type: ‘partial’, reason: ‘other’, fees: [‘shipping_fee’]).to_h.
-
.retrieve(id) ⇒ Object
ap TophatterMerchant::Order.retrieve(681195262).to_h.
-
.schema ⇒ Object
ap TophatterMerchant::Order.schema.
Instance Method Summary collapse
Methods inherited from Resource
attr_accessor, #attributes, attributes, #attributes=, #initialize, #persisted?, #to_h
Constructor Details
This class inherits a constructor from TophatterMerchant::Resource
Instance Attribute Details
#address1 ⇒ Object
Returns the value of attribute address1.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def address1 @address1 end |
#address2 ⇒ Object
Returns the value of attribute address2.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def address2 @address2 end |
#available_refunds ⇒ Object
Returns the value of attribute available_refunds.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def available_refunds @available_refunds end |
#carrier ⇒ Object
Returns the value of attribute carrier.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def carrier @carrier end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def country @country end |
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def created_at @created_at end |
#customer_id ⇒ Object
Returns the value of attribute customer_id.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def customer_id @customer_id end |
#customer_name ⇒ Object
Returns the value of attribute customer_name.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def customer_name @customer_name end |
#disbursement_amount ⇒ Object
Returns the value of attribute disbursement_amount.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def disbursement_amount @disbursement_amount end |
#line_items ⇒ Object
Returns the value of attribute line_items.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def line_items @line_items end |
#order_id ⇒ Object
Returns the value of attribute order_id.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def order_id @order_id end |
#paid_at ⇒ Object
Returns the value of attribute paid_at.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def paid_at @paid_at end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def postal_code @postal_code end |
#product_identifier ⇒ Object
Returns the value of attribute product_identifier.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def product_identifier @product_identifier end |
#product_name ⇒ Object
Returns the value of attribute product_name.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def product_name @product_name end |
#refund_amount ⇒ Object
Returns the value of attribute refund_amount.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def refund_amount @refund_amount end |
#seller_fees ⇒ Object
Returns the value of attribute seller_fees.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def seller_fees @seller_fees end |
#seller_fees_amount ⇒ Object
Returns the value of attribute seller_fees_amount.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def seller_fees_amount @seller_fees_amount end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def state @state end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def status @status end |
#tracking_number ⇒ Object
Returns the value of attribute tracking_number.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def tracking_number @tracking_number end |
#variation_identifier ⇒ Object
Returns the value of attribute variation_identifier.
3 4 5 |
# File 'lib/tophatter_merchant/order.rb', line 3 def variation_identifier @variation_identifier end |
Class Method Details
.all(filter: nil, page: 1, per_page: 50) ⇒ Object
ap TophatterMerchant::Order.all.map(&:to_h) ap TophatterMerchant::Order.all(filter: ‘unfulfilled’).map(&:to_h) ap TophatterMerchant::Order.all(filter: ‘fulfilled’).map(&:to_h)
25 26 27 28 29 |
# File 'lib/tophatter_merchant/order.rb', line 25 def all(filter: nil, page: 1, per_page: 50) get(url: "#{path}.json", params: { filter: filter, page: page, per_page: per_page }).map do |hash| Order.new(hash) end end |
.fulfill(id, carrier:, tracking_number:) ⇒ Object
ap TophatterMerchant::Order.fulfill(417953232, carrier: ‘other’, tracking_number: ‘ABC123’).to_h
37 38 39 |
# File 'lib/tophatter_merchant/order.rb', line 37 def fulfill(id, carrier:, tracking_number:) Order.new post(url: "#{path}/fulfill.json", params: { order_id: id, carrier: carrier, tracking_number: tracking_number }) end |
.refund(id, type:, reason:, fees: []) ⇒ Object
ap TophatterMerchant::Order.refund(417953232, type: ‘full’, reason: ‘delay_in_shipping’).to_h ap TophatterMerchant::Order.refund(417953232, type: ‘partial’, reason: ‘other’, fees: [‘shipping_fee’]).to_h
43 44 45 |
# File 'lib/tophatter_merchant/order.rb', line 43 def refund(id, type:, reason:, fees: []) Order.new post(url: "#{path}/refund.json", params: { order_id: id, type: type, reason: reason, fees: fees }) end |
.retrieve(id) ⇒ Object
ap TophatterMerchant::Order.retrieve(681195262).to_h
32 33 34 |
# File 'lib/tophatter_merchant/order.rb', line 32 def retrieve(id) Order.new get(url: "#{path}/retrieve.json", params: { order_id: id }) end |
.schema ⇒ Object
ap TophatterMerchant::Order.schema
18 19 20 |
# File 'lib/tophatter_merchant/order.rb', line 18 def schema get(url: "#{path}/schema.json") end |
Instance Method Details
#id ⇒ Object
12 13 14 |
# File 'lib/tophatter_merchant/order.rb', line 12 def id created_at.present? ? identifier : nil end |