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

Values requested via the embed parameter are not easy accessible in the response objects #256

Open
Meess opened this issue Aug 27, 2022 · 4 comments

Comments

@Meess
Copy link

Meess commented Aug 27, 2022

Issue:

The response when adding the embed parameter for e.g. the payments resource will not lead to a response with the embedded values in the Payment object.

There is a static method in ResourceBase called extract_embed, however only used in the orders resource. Currently I'm not using the orders resource but don't see what the functionality of it is. It splits the input provided for the embed parameter and then adds it to the response. It doesn't seem to be doing anything with the _embedded object that will be returned by the mollie API, but maybe I'm overseeing something.

Expected behaviour:

I would expect an embedded value on e.g. the Payment ( or Order ) object representing the resources added through the embed parameter. For this embedded value I would expect the following values:

  • embed parameter not set in the request to the mollie API
    • If no embed parameters were set, embedded would be None. So in the response it can be checked if anything was embedded when calling the mollie API.
  • embed = 'chargebacks' but there are no chargebacks
    • embedded = { 'chargeback': None }, for the similar reason as above, so we can check if the chargeback was actually added to the request or not. The Mollie API simply leaves the full _embedded object out if e.g. you make a request with the parameter embed='chargebacks' but there are no chargebacks. This makes it difficult in the response to determine if the embed='chargebacks' was added to the request or if the embed was not set at all. By setting the embed parameters to None if there there were no entires of that resource we can easily see if there were none of that resource, or we didn't provide it in the embed parameter in the request to the mollie API.
  • embed = 'chargebacks' and there are chargebacks:
    • embedded = { 'chargeback': List(Chargeback)}

With similar behaviour for refunds as chargebacks, or if both are included in the embed parameter.

@whyscream
Copy link
Contributor

Hi @Meess ,

Some details on the implementation of embed in the Order API are available in #202. As you see, it's a work in progress (for quite some time now). I'll try to put some more work into it soon.

@whyscream
Copy link
Contributor

We'll look into this after we have resolved #255.

@whyscream
Copy link
Contributor

Note: what we want to achieve in general:

  • We want to have an interface on the resulting object that can help the developer to retrieve the embed easily, or tell the developer to request the embed/include if it was missing, but useful to have.
  • To do this, we need to transfer the knowledge about requested embeds and includes from the Resource object (which performs the request) to the resulting object (which represents the result data). If that works properly, we can do neat things with that knowledge in the result object.

@geertjanvdenbosch
Copy link
Collaborator

Hi @Meess ,

Is this issue still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants