Skip to content

Instantly share code, notes, and snippets.

@vinchi777
Created October 4, 2021 08:17
Show Gist options
  • Save vinchi777/d1c945fb7c0b368d2b17590f79544225 to your computer and use it in GitHub Desktop.
Save vinchi777/d1c945fb7c0b368d2b17590f79544225 to your computer and use it in GitHub Desktop.
### 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