Skip to content

Commit

Permalink
Update V2 for PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
karmakaze committed Nov 26, 2019
1 parent c72bff7 commit fde9c1e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 31 deletions.
16 changes: 0 additions & 16 deletions lib/shopify_api/resources/assigned_fulfillment_order.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
module ShopifyAPI
class AssignedFulfillmentOrder < Base
CANCELLATION_REQUESTED = 'cancellation_requested'
FULFILLMENT_REQUESTED = 'fulfillment_requested'
FULFILLMENT_ACCEPTED = 'fulfillment_accepted'

ALL_ASSIGNED_STATUSES = [
CANCELLATION_REQUESTED = 'cancellation_requested',
FULFILLMENT_REQUESTED = 'fulfillment_requested',
FULFILLMENT_ACCEPTED = 'fulfillment_accepted'
].freeze

def self.all(options = {})
params = options[:params] || options['params'] || {}
assigned_status = params[:assigned_status] || params['assigned_status']
if assigned_status && !ALL_ASSIGNED_STATUSES.include?(assigned_status)
raise ValidationException, "Invalid 'assigned_status': #{assigned_status}"
end

assigned_fulfillment_orders = super(options)
assigned_fulfillment_orders.map { |afo| FulfillmentOrder.new(afo.as_json) }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/resources/fulfillment_order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.all(options = {})

def fulfillments(options = {})
fo_fulfillments = get(:fulfillments, options)
fo_fulfillments.map { |fof| FulfillmentOrderFulfillment.new(fof.as_json) }
fo_fulfillments.map { |fof| FulfillmentV2.new(fof.as_json) }
end
end
end
4 changes: 0 additions & 4 deletions lib/shopify_api/resources/fulfillment_order_fulfillment.rb

This file was deleted.

4 changes: 4 additions & 0 deletions lib/shopify_api/resources/fulfillment_v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ShopifyAPI
class FulfillmentV2 < Base
end
end
10 changes: 1 addition & 9 deletions test/assigned_fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@
class AssignedFulFillmentOrderTest < Test::Unit::TestCase
context "AssignedFulfillmentOrder" do
context "#all" do
should "raise ValidationException if assigned_status is invalid" do
assert_raises ShopifyAPI::ValidationException do
assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
params: { assigned_status: 'bogus_status' }
)
end
end

should "list assigned fulfillment orders by assigned_status" do
fo_fixture = load_fixture('assigned_fulfillment_orders')
fake 'assigned_fulfillment_orders.json?assigned_status=cancellation_requested', method: :get,
body: fo_fixture, extension: false

assigned_fulfillment_orders = ShopifyAPI::AssignedFulfillmentOrder.all(
params: { assigned_status: ShopifyAPI::AssignedFulfillmentOrder::CANCELLATION_REQUESTED }
params: { assigned_status: 'cancellation_requested' }
)

assert_equal 2, assigned_fulfillment_orders.count
Expand Down
2 changes: 1 addition & 1 deletion test/fulfillment_order_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def setup

assert_equal 1, fulfillments.count
fulfillment = fulfillments.first
assert_equal 'ShopifyAPI::FulfillmentOrderFulfillment', fulfillment.class.name
assert_equal 'ShopifyAPI::FulfillmentV2', fulfillment.class.name
assert_equal 450789469, fulfillment.order_id
end
end
Expand Down

0 comments on commit fde9c1e

Please sign in to comment.