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

Keep associations #11

Open
excid3 opened this issue Aug 12, 2024 · 2 comments
Open

Keep associations #11

excid3 opened this issue Aug 12, 2024 · 2 comments

Comments

@excid3
Copy link

excid3 commented Aug 12, 2024

Currently, the API responses delete the association data.

For example, it would be helpful to be able to retrieve an Order and ask for it's associated subscriptions. Same for all the other associations.

order = LemonSqueezy::Order.retrieve(id: "x")
order.subscriptions => [<LemonSqueezy::Subscription>, ...}

If this is implemented using the JSON API data, this can be future proofed for any other associations added.

@deanpcmad
Copy link
Owner

I remove relationships and links as they don't contain any useful information really.

An example of a product:

"relationships"=>
    {"store"=>
      {"links"=>
        {"related"=>"https://api.lemonsqueezy.com/v1/products/166741/store",
         "self"=>"https://api.lemonsqueezy.com/v1/products/166741/relationships/store"}},
     "variants"=>
      {"links"=>
        {"related"=>"https://api.lemonsqueezy.com/v1/products/166741/variants",
         "self"=>"https://api.lemonsqueezy.com/v1/products/166741/relationships/variants"}}},
"links"=>{"self"=>"https://api.lemonsqueezy.com/v1/products/166741"}}}

@excid3
Copy link
Author

excid3 commented Aug 12, 2024

You can use that to generate the associations and connect them to the other models.

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

No branches or pull requests

2 participants