class DuodealerAPI::FulfillmentOrder
Constants
- MINIMUM_VERSION
Public Class Methods
find(scope, *args)
click to toggle source
Calls superclass method
# File lib/duodealer_api/resources/fulfillment_order.rb, line 10 def self.find(scope, *args) DuodealerAPI::Base.version_validation!(MINIMUM_VERSION) if scope == :all order_id = args.first&.dig(:params, :order_id) raise DuodealerAPI::ValidationException, "'order_id' is required" if order_id.blank? order = ::DuodealerAPI::Order.new(id: order_id) order.fulfillment_orders(args.first[:params].except(:order_id)) else super(scope, *args) end end
new(attributes = {}, persisted = false)
click to toggle source
Calls superclass method
# File lib/duodealer_api/resources/fulfillment_order.rb, line 5 def initialize(attributes = {}, persisted = false) DuodealerAPI::Base.version_validation!(MINIMUM_VERSION) super(attributes, persisted) end
Public Instance Methods
accept_cancellation_request(message: nil)
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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
cancel()
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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 = {})
click to toggle source
# File lib/duodealer_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_move()
click to toggle source
# File lib/duodealer_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:)
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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)
click to toggle source
# File lib/duodealer_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
Private Instance Methods
keyed_fulfillment_orders_from_response(response)
click to toggle source
# File lib/duodealer_api/resources/fulfillment_order.rb, line 128 def keyed_fulfillment_orders_from_response(response) return load_attributes_from_response(response) if response.code != '200' keyed_fulfillment_orders = ActiveSupport::JSON.decode(response.body) keyed_fulfillment_orders.transform_values do |fulfillment_order_attributes| FulfillmentOrder.new(fulfillment_order_attributes) if fulfillment_order_attributes end end
load_keyed_fulfillment_order(keyed_fulfillment_orders, key)
click to toggle source
# File lib/duodealer_api/resources/fulfillment_order.rb, line 122 def load_keyed_fulfillment_order(keyed_fulfillment_orders, key) if keyed_fulfillment_orders[key]&.attributes load(keyed_fulfillment_orders[key].attributes, false, true) end end