Skip to content
New issue

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

Switch responses to pure-ish faraday #57

Merged
merged 9 commits into from
Feb 12, 2024
Merged

Switch responses to pure-ish faraday #57

merged 9 commits into from
Feb 12, 2024

Conversation

ksol
Copy link
Contributor

@ksol ksol commented Feb 11, 2024

This PR introduces breaking changes to the gem; readme and changelog will be updated subsequently.

In this PR, the Scalingo::API::Response is removed altogether. Instead, we use regular faraday objects, although with some minor additions:

  1. boolean methods to quickly categorise the kind of error
  2. exposes meta as a property on the response
  3. exposes if the response is paginated, and the pagination info
  4. exposes if the response if cursor-paginated, and the cursor info

On top of this, the unpack mechanism is now automated. If the response is successful and there is a single root key after dealing with the metadata, we automatically extract it. This

Each of those two functions is dealt with using faraday middlewares - both could be extract from this lib, but with so few code lines in each of them, the value is really low

@ksol ksol changed the title feat: rework response handling Switch responses to pure-ish faraday Feb 11, 2024
Copy link
Contributor

@aurelien-reeves-scalingo aurelien-reeves-scalingo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Yet it could be nice to update the unreleased section of the changelog accordingly in the PR.

@ksol ksol merged commit cfc8ca6 into master Feb 12, 2024
6 checks passed
@ksol ksol deleted the refactor/responses branch February 12, 2024 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants