What goes in the meta attribute?


#1

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).


#2

As for me amountLeftForToday looks like attribute of the offer.
And about eligible - is it check if user could use this offer? If yes, maybe it’s better not to show this resource to this user at all?


#3

Customers are still able to see the offer. It just says if they are currently eligible for it or not. In which case. where do you think eligible should go?