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


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

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

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


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

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


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

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

#fulfillment_orders(options = {}) ⇒ Object


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

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


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

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

#transactionsObject


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

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