Class: ShopifyAPI::Order

Inherits:
Base
  • Object
show all
Includes:
Events, Metafields
Defined in:
lib/shopify_api/resources/order.rb

Defined Under Namespace

Classes: ClientDetails

Instance Method Summary collapse

Methods included from Metafields

#add_metafield, #metafields

Methods included from Events

#events

Methods inherited from Base

activate_session, api_version, api_version=, #as_json, clear_session, early_july_pagination?, #encode, headers, init_prefix, init_prefix_explicit, #persisted?, prefix, prefix=, prefix_source, resource_prefix, resource_prefix=, version_validation!

Methods included from Countable

#count

Instance Method Details

#cancel(options = {}) ⇒ Object


14
15
16
# File 'lib/shopify_api/resources/order.rb', line 14

def cancel(options = {})
  load_attributes_from_response(post(:cancel, {}, options.to_json))
end

#capture(amount = "", currency: nil) ⇒ Object


22
23
24
25
26
27
28
29
30
31
# File 'lib/shopify_api/resources/order.rb', line 22

def capture(amount = "", currency: nil)
  capture_transaction = {
    amount: amount,
    kind: "capture",
    order_id: id,
  }
  capture_transaction[:currency] = currency if currency

  Transaction.create(capture_transaction)
end

#closeObject


6
7
8
# File 'lib/shopify_api/resources/order.rb', line 6

def close
  load_attributes_from_response(post(:close, {}, only_id))
end

#fulfillment_orders(options = {}) ⇒ Object


33
34
35
36
37
38
# File 'lib/shopify_api/resources/order.rb', line 33

def fulfillment_orders(options = {})
  ShopifyAPI::Base.version_validation!(FulfillmentOrder::MINIMUM_VERSION)

  fulfillment_order_hashes = get(:fulfillment_orders, options)
  fulfillment_order_hashes.map { |fulfillment_order_hash| FulfillmentOrder.new(fulfillment_order_hash) }
end

#openObject


10
11
12
# File 'lib/shopify_api/resources/order.rb', line 10

def open
  load_attributes_from_response(post(:open, {}, only_id))
end

#transactionsObject


18
19
20
# File 'lib/shopify_api/resources/order.rb', line 18

def transactions
  Transaction.find(:all, params: { order_id: id })
end