I have data similar to the following:
{
"data": {
"type": "offer",
"id": "1",
"attributes": {
"title": "50% off!",
},
"meta": {
"eligible": true,
"amountLeftForToday": 20
},
"links": {
"self": "http://example.com/offers/1"
}
}
}
I am unsure as to where to put the “eligible” and “numberOfOrdersLeftToday” attributes.
- “eligible” depends on the authenticated user who request it, and if they qualify for the offer.
- “amountLeftForToday” depends on the time the resource is requested, and can change quite often throughout the day as more people take the offer.
The API defines attributes as:
attributes: an attributes object representing some of the resource’s data.
and meta as:
meta: a meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
I am unsure which ones these two attributes fall under.
Note that I also want to filter on these attributes.
For eligible
, it could be in meta
, as it can be considered as not the resource’s data, but instead the user’s relationship to the data. But then again it can still be regarded as " some of the resource’s data".
For amountLeftForToday
, I think it should be in attributes, as it’s part of the resources data (even if it changes regularly).