Class: TophatterMerchant::Order

Inherits:
Resource
  • Object
show all
Defined in:
lib/tophatter_merchant/order.rb

Instance Attribute Summary collapse

Class Method Summary collapse

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

#address1Object

Returns the value of attribute address1.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def address1
  @address1
end

#address2Object

Returns the value of attribute address2.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def address2
  @address2
end

#available_refundsObject

Returns the value of attribute available_refunds.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def available_refunds
  @available_refunds
end

#carrierObject

Returns the value of attribute carrier.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def carrier
  @carrier
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def city
  @city
end

#countryObject

Returns the value of attribute country.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def country
  @country
end

#created_atObject

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_idObject

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_nameObject

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_amountObject

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_itemsObject

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_idObject

Returns the value of attribute order_id.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def order_id
  @order_id
end

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_codeObject

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_identifierObject

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_nameObject

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_amountObject

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_feesObject

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_amountObject

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

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def state
  @state
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/tophatter_merchant/order.rb', line 3

def status
  @status
end

#tracking_numberObject

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_identifierObject

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

.schemaObject

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

#idObject



12
13
14
# File 'lib/tophatter_merchant/order.rb', line 12

def id
  created_at.present? ? identifier : nil
end