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

Added refresh method #225

Merged
merged 6 commits into from
Sep 28, 2021
Merged

Added refresh method #225

merged 6 commits into from
Sep 28, 2021

Conversation

Pimm
Copy link
Collaborator

@Pimm Pimm commented Sep 27, 2021

API

Objects returned by the API now have a refresh method, which returns a fresh copy of said object.

let payment = await mollieClient.payments.get('tr_44aKxzEbr8');
// Later…
payment = await payment.refresh();

This is a more JavaScript-like interface to the "self" link included in objects returned by the Mollie server. It obsoletes that "self" link, allowing us to hide it from users in the next major release.

Internal

Previously, every binder encapsulated the logic for transforming the objects it received. To facilitate the refresh method ‒ but especially other future links, such as a getOrder method ‒ all transformation logic now lives inside the TransformingNetworkClient and is shared across binders.

… the resource type.

Previously, every binder encapsulated the logic for transforming the objects it received. However, this makes cross type links (payment.getOrder()) challenging. Logic for transforming objects is now accessible across binders, making such links possible.
This method takes advantage of the "self" link to get a fresh copy of itself.
This might be easier to read for JavaScript developers.
src/TransformingNetworkClient.ts Outdated Show resolved Hide resolved
@Pimm Pimm merged commit 2705f07 into master Sep 28, 2021
@Pimm Pimm deleted the pimm/v3.6.0 branch September 28, 2021 10:03
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