Created
October 4, 2021 08:17
-
-
Save vinchi777/d1c945fb7c0b368d2b17590f79544225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Old | |
ap1/v1/products | |
filter[purchased] = true | |
products | |
attributes | |
- name | |
- amount | |
... etc | |
for (product in response[:included].select{ |resoue| resouece[type] == 'product'}) { | |
... | |
} | |
### New | |
purchased-products M:1 products | |
api/v1/purchased-products | |
purchased-products | |
attributes | |
- purchased-count | |
- purchased-at | |
- product_id | |
relationships | |
- product | |
for (purchased-product in response[:data]) { | |
//display product | |
product = response[:included] | |
.filter{|resource| resource.type == 'products'} | |
.find{ |resouce| resource[:id] == purchased_product[:relationshiop][:product][:data][:id] } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment