Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 9.3.0

- Add `Castle::PaymentRequiredError` for HTTP 402 responses.

## 9.2.0

**Changes:**
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
castle-rb (9.2.0)
castle-rb (9.3.0)
base64 (~> 0.2)

GEM
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ All exceptions inherit from `Castle::Error`. The most useful ones:
| `Castle::InvalidRequestTokenError` | The `request_token` is missing or invalid. |
| `Castle::InvalidParametersError` | 422 response with validation details. |
| `Castle::RateLimitError` | 429 response — back off and retry. |
| `Castle::PaymentRequiredError` | 402 response. |
| `Castle::UnauthorizedError` | 401 — bad API secret. |
| `Castle::InternalServerError` | 5xx response from Castle. |
| `Castle::WebhookVerificationError` | Webhook signature did not match. |
Expand Down
1 change: 1 addition & 0 deletions lib/castle/core/process_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module ProcessResponse
RESPONSE_ERRORS = {
400 => Castle::BadRequestError,
401 => Castle::UnauthorizedError,
402 => Castle::PaymentRequiredError,
403 => Castle::ForbiddenError,
404 => Castle::NotFoundError,
419 => Castle::UserUnauthorizedError,
Expand Down
3 changes: 3 additions & 0 deletions lib/castle/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class UnauthorizedError < Castle::ApiError
class RateLimitError < Castle::ApiError
end

class PaymentRequiredError < Castle::ApiError
end

# all internal server errors
class InternalServerError < Castle::ApiError
end
Expand Down
2 changes: 1 addition & 1 deletion lib/castle/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Castle
VERSION = '9.2.0'
VERSION = '9.3.0'
end
1 change: 1 addition & 0 deletions spec/lib/castle/core/process_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@

it_behaves_like 'response_failed', '400', Castle::BadRequestError
it_behaves_like 'response_failed', '401', Castle::UnauthorizedError
it_behaves_like 'response_failed', '402', Castle::PaymentRequiredError
it_behaves_like 'response_failed', '403', Castle::ForbiddenError
it_behaves_like 'response_failed', '404', Castle::NotFoundError
it_behaves_like 'response_failed', '419', Castle::UserUnauthorizedError
Expand Down
Loading