Skip to content

Commit

Permalink
Fixes invalid typing of ShopifyAPI::DiscountCode#errors
Browse files Browse the repository at this point in the history
  • Loading branch information
garethson committed Aug 28, 2023
1 parent 95a1847 commit eabd31a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2022_04/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2022_07/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2022_10/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2023_01/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2023_04/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
3 changes: 0 additions & 3 deletions lib/shopify_api/rest/resources/2023_07/discount_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def initialize(session: ShopifyAPI::Context.active_session)

@code = T.let(nil, T.nilable(String))
@created_at = T.let(nil, T.nilable(String))
@errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
@id = T.let(nil, T.nilable(Integer))
@price_rule_id = T.let(nil, T.nilable(Integer))
@updated_at = T.let(nil, T.nilable(String))
Expand All @@ -44,8 +43,6 @@ def initialize(session: ShopifyAPI::Context.active_session)
attr_reader :code
sig { returns(T.nilable(String)) }
attr_reader :created_at
sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
attr_reader :errors
sig { returns(T.nilable(Integer)) }
attr_reader :id
sig { returns(T.nilable(Integer)) }
Expand Down
22 changes: 22 additions & 0 deletions test/rest/2023_07/discount_code_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,26 @@ def test_9()
end
end

sig do
void
end
def test_11
stub_request(:put, "https://test-shop.myshopify.io/admin/api/2023-07/price_rules/507328175/discount_codes/507328175.json")
.with(
headers: {"X-Shopify-Access-Token"=>"this_is_a_test_token", "Accept"=>"application/json", "Content-Type"=>"application/json"},
body: { "discount_code" => hash_including({"code" => "WINTERSALE20OFF"}) }
)
.to_return(status: 404, body: { errors: "Not Found" }.to_json, headers: {})

discount_code = ShopifyAPI::DiscountCode.new
discount_code.price_rule_id = 507328175
discount_code.id = 507328175
discount_code.code = "WINTERSALE20OFF"
begin
discount_code.save
rescue ShopifyAPI::Errors::HttpResponseError
end
assert_equal(ShopifyAPI::Rest::BaseErrors, discount_code.errors.class)
assert_equal(404, discount_code.errors.errors[0].code)
end
end

0 comments on commit eabd31a

Please sign in to comment.