Class: ShopifyAPI::FulfillmentOrder

Inherits:
Base
  • Object
show all
Defined in:
lib/shopify_api/resources/fulfillment_order.rb

Constant Summary collapse

MINIMUM_VERSION =
'2020-01'

Class Method Summary collapse

Instance Method Summary collapse

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

Constructor Details

#initialize(attributes = {}, persisted = false) ⇒ FulfillmentOrder

Returns a new instance of FulfillmentOrder.


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

def initialize(attributes = {}, persisted = false)
  ShopifyAPI::Base.version_validation!(MINIMUM_VERSION)
  super(attributes, persisted)
end

Class Method Details

.find(scope, *args) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 10

def self.find(scope, *args)
  ShopifyAPI::Base.version_validation!(MINIMUM_VERSION)

  if scope == :all
    order_id = args.first&.dig(:params, :order_id)
    raise ShopifyAPI::ValidationException, "'order_id' is required" if order_id.blank?

    order = ::ShopifyAPI::Order.new(id: order_id)
    order.fulfillment_orders(args.first[:params].except(:order_id))
  else
    super(scope, *args)
  end
end

Instance Method Details

#accept_cancellation_request(message: nil) ⇒ Object


102
103
104
105
106
107
108
109
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 102

def accept_cancellation_request(message: nil)
  body = {
    cancellation_request: {
      message: message
    }
  }
  load_attributes_from_response(post('cancellation_request/accept', {}, body.to_json))
end

#accept_fulfillment_request(message: nil) ⇒ Object


75
76
77
78
79
80
81
82
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 75

def accept_fulfillment_request(message: nil)
  body = {
    fulfillment_request: {
      message: message
    }
  }
  load_attributes_from_response(post('fulfillment_request/accept', {}, body.to_json))
end

#cancelObject


48
49
50
51
52
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 48

def cancel
  keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:cancel, {}, only_id))
  load_keyed_fulfillment_order(keyed_fulfillment_orders, 'fulfillment_order')
  keyed_fulfillment_orders
end

#close(message: nil) ⇒ Object


54
55
56
57
58
59
60
61
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 54

def close(message: nil)
  body = {
    fulfillment_order: {
      message: message
    }
  }
  load_attributes_from_response(post(:close, {}, body.to_json))
end

#fulfillments(options = {}) ⇒ Object


24
25
26
27
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 24

def fulfillments(options = {})
  fulfillment_hashes = get(:fulfillments, options)
  fulfillment_hashes.map { |fulfillment_hash| Fulfillment.new(fulfillment_hash) }
end

#locations_for_moveObject


29
30
31
32
33
34
35
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 29

def locations_for_move
  locations_for_move_hashes = get(:locations_for_move, {})

  locations_for_move_hashes.map do |locations_for_move_hash|
    FulfillmentOrderLocationsForMove.new(locations_for_move_hash)
  end
end

#move(new_location_id:) ⇒ Object


37
38
39
40
41
42
43
44
45
46
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 37

def move(new_location_id:)
  body = {
    fulfillment_order: {
      new_location_id: new_location_id
    }
  }
  keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:move, {}, body.to_json))
  load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
  keyed_fulfillment_orders
end

#reject_cancellation_request(message: nil) ⇒ Object


111
112
113
114
115
116
117
118
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 111

def reject_cancellation_request(message: nil)
  body = {
    cancellation_request: {
      message: message
    }
  }
  load_attributes_from_response(post('cancellation_request/reject', {}, body.to_json))
end

#reject_fulfillment_request(message: nil) ⇒ Object


84
85
86
87
88
89
90
91
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 84

def reject_fulfillment_request(message: nil)
  body = {
    fulfillment_request: {
      message: message
    }
  }
  load_attributes_from_response(post('fulfillment_request/reject', {}, body.to_json))
end

#request_cancellation(message: nil) ⇒ Object


93
94
95
96
97
98
99
100
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 93

def request_cancellation(message: nil)
  body = {
    cancellation_request: {
      message: message
    }
  }
  load_attributes_from_response(post(:cancellation_request, {}, body.to_json))
end

#request_fulfillment(fulfillment_order_line_items: nil, message: nil) ⇒ Object


63
64
65
66
67
68
69
70
71
72
73
# File 'lib/shopify_api/resources/fulfillment_order.rb', line 63

def request_fulfillment(fulfillment_order_line_items: nil, message: nil)
  body = {
    fulfillment_request: {
      fulfillment_order_line_items: fulfillment_order_line_items,
      message: message
    }
  }
  keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:fulfillment_request, {}, body.to_json))
  load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
  keyed_fulfillment_orders
end