From 6fc2312813f921c8eaf8be0d137b38e8705c2d60 Mon Sep 17 00:00:00 2001 From: Keith Kim Date: Tue, 7 Jan 2020 16:29:22 -0500 Subject: [PATCH] Define `find` rather than `all` for AssignedFulfillmentOrder and FulfillmentOrder --- .../resources/assigned_fulfillment_order.rb | 4 ++-- lib/shopify_api/resources/fulfillment_order.rb | 14 +++++++++----- test/fulfillment_order_test.rb | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/shopify_api/resources/assigned_fulfillment_order.rb b/lib/shopify_api/resources/assigned_fulfillment_order.rb index 803ab653d..dea713bcc 100644 --- a/lib/shopify_api/resources/assigned_fulfillment_order.rb +++ b/lib/shopify_api/resources/assigned_fulfillment_order.rb @@ -1,7 +1,7 @@ module ShopifyAPI class AssignedFulfillmentOrder < Base - def self.all(options = {}) - assigned_fulfillment_orders = super(options) + def self.find(scope, *args) + assigned_fulfillment_orders = super(scope, *args) assigned_fulfillment_orders.map { |afo| FulfillmentOrder.new(afo.attributes) } end end diff --git a/lib/shopify_api/resources/fulfillment_order.rb b/lib/shopify_api/resources/fulfillment_order.rb index 2a20c6dc4..501805068 100644 --- a/lib/shopify_api/resources/fulfillment_order.rb +++ b/lib/shopify_api/resources/fulfillment_order.rb @@ -1,11 +1,15 @@ module ShopifyAPI class FulfillmentOrder < Base - def self.all(options = {}) - order_id = options.dig(:params, :order_id) - raise ShopifyAPI::ValidationException, "'order_id' is required" if order_id.nil? || order_id == '' + def self.find(scope, *args) + 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 + order = ::ShopifyAPI::Order.new(id: order_id) + order.fulfillment_orders(args.first[:params].except(:order_id)) + else + super(scope, *args) + end end def fulfillments(options = {}) diff --git a/test/fulfillment_order_test.rb b/test/fulfillment_order_test.rb index 353e859a1..056f07c33 100644 --- a/test/fulfillment_order_test.rb +++ b/test/fulfillment_order_test.rb @@ -5,6 +5,9 @@ def setup super fake "fulfillment_orders/519788021", method: :get, body: load_fixture('fulfillment_order') + + fake "orders/450789469/fulfillment_orders", method: :get, + body: load_fixture('fulfillment_orders') end context "FulfillmentOrder" do