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

Update client library to support entitlements #595

Merged
merged 2 commits into from
Oct 26, 2022

Conversation

ELepolt
Copy link
Contributor

@ELepolt ELepolt commented Oct 10, 2022

Add Entitlements support to library. Callable by account.entitlements()

self.assertEqual(customer_permission.name, 'Meet the team!')
self.assertEqual(customer_permission.description, 'All VIP members can meet the team.')
self.assertEqual(entitlement.granted_by, [
'https://api.recurly.com/v2/subscriptions/rhind9aehvrt',

Choose a reason for hiding this comment

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

From the client lib perspective, do we really want to respond with the resource link? I mean, I know that the entitlements API endpoint already responds with the granted_by node with one array that contains the resource links, but there it makes sense because, in my opinion, it's better to keep the API response clean and it is easy to navigate and check out the resource(by just click into the resource link, for example). But for the client lib, we should expect that someone is embedding calls from this lib into their code. For example:

try {
  $entitlements = Recurly_EntitlementList::get('<ACCOUNT_CODE>');
  foreach ($entitlements as $entitlement) {
    print "Entitlement: {$entitlement->granted_by}\n";
  }
} catch (Recurly_NotFoundError $e) {
  print "Invalid account code: $e";
}

So what the consumer of this lib is supposed to do with the subscription/external subscription resource link? Isn't better to respond with the full subscription or external subscription object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I somewhat disagree with the client lib doing more than the API response. Why would they be any different? If we wanted the user to have more detail we would include it in the presenter.

When the API discussion occurred the idea was that if the merchant wanted more details, they would make the request themselves. I think that the logic process is "First and foremost does this user have this entitlement?" and that typically the answer is yes or no and that's the end.

If the merchant thinks the user shouldn't have it, then they can go digging on which granted_by is giving them the details.

I see this as a similar way that we show plan_codes in the coupon request. We simply return the plan_code and no other details about the plan.

Copy link

@lsfernandes92 lsfernandes92 Oct 12, 2022

Choose a reason for hiding this comment

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

Why would they be any different?

I don't know really and I am just questioning hehehehe. Why does the merchant prefer to use the client lib instead of just requesting the entitlements API?

What's the value of having the resource link in the client lib response? What really matters here is the subscriptions IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value is that they don't have to write their own API wrapper. In theory what we publish is 'official' and won't break, unlike a piece of code written by a dev who leaves a year later and no one understands it.

I think the point is that we as developers don't actually know what the client wants or what the value is, we rely on Chris and Dom to figure that out for us.

@lsfernandes92 lsfernandes92 added the V2 V2 Client label Oct 12, 2022
@lsfernandes92 lsfernandes92 force-pushed the Client-Lib-Updates-V2-For-Entitlements branch from 4005d13 to d62f5ea Compare October 26, 2022 18:37
@lsfernandes92 lsfernandes92 merged commit 17f5ceb into v2 Oct 26, 2022
@lsfernandes92 lsfernandes92 deleted the Client-Lib-Updates-V2-For-Entitlements branch October 26, 2022 18:40
recurly-integrations pushed a commit that referenced this pull request Oct 27, 2022
[Full Changelog](2.9.32...2.9.33)

**Merged Pull Requests**

- Update client library to support entitlements [#595](#595) ([ELepolt](https://github.com/ELepolt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V2 V2 Client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants