We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There's no ActiveResource exception for HTTP status 402. It is already used by Shopify (https://shopify.dev/docs/api/usage/response-codes).
It can be an easy PR.
diff --git a/lib/active_resource/base.rb b/lib/active_resource/base.rb index 766338b..f1189cb 100644 --- a/lib/active_resource/base.rb +++ b/lib/active_resource/base.rb @@ -213,6 +213,7 @@ module ActiveResource # * 301, 302, 303, 307 - ActiveResource::Redirection # * 400 - ActiveResource::BadRequest # * 401 - ActiveResource::UnauthorizedAccess + # * 402 - ActiveResource::PaymentRequired # * 403 - ActiveResource::ForbiddenAccess # * 404 - ActiveResource::ResourceNotFound # * 405 - ActiveResource::MethodNotAllowed diff --git a/lib/active_resource/connection.rb b/lib/active_resource/connection.rb index e997a0a..b7168f0 100644 --- a/lib/active_resource/connection.rb +++ b/lib/active_resource/connection.rb @@ -140,6 +140,8 @@ module ActiveResource raise(BadRequest.new(response)) when 401 raise(UnauthorizedAccess.new(response)) + when 402 + raise(PaymentRequired.new(response)) when 403 raise(ForbiddenAccess.new(response)) when 404 diff --git a/lib/active_resource/exceptions.rb b/lib/active_resource/exceptions.rb index 08daeca..916ed8a 100644 --- a/lib/active_resource/exceptions.rb +++ b/lib/active_resource/exceptions.rb @@ -57,6 +57,10 @@ module ActiveResource class UnauthorizedAccess < ClientError # :nodoc: end + # 402 Payment Required + class PaymentRequired < ClientError # :nodoc: + end + # 403 Forbidden class ForbiddenAccess < ClientError # :nodoc: end diff --git a/test/cases/connection_test.rb b/test/cases/connection_test.rb index c879f4c..3dba252 100644 --- a/test/cases/connection_test.rb +++ b/test/cases/connection_test.rb @@ -74,6 +74,9 @@ class ConnectionTest < ActiveSupport::TestCase # 401 is an unauthorized request assert_response_raises ActiveResource::UnauthorizedAccess, 401 + # 402 is a payment required error. + assert_response_raises ActiveResource::PaymentRequired, 402 + # 403 is a forbidden request (and authorizing will not help) assert_response_raises ActiveResource::ForbiddenAccess, 403
The text was updated successfully, but these errors were encountered:
Can you please send the PR?
Sorry, something went wrong.
@rafaelfranca #401
Merged #401
No branches or pull requests
There's no ActiveResource exception for HTTP status 402.
It is already used by Shopify (https://shopify.dev/docs/api/usage/response-codes).
It can be an easy PR.
The text was updated successfully, but these errors were encountered: