It really depends on how you define a notification
resource and the relation with its category
type (whatsapp
, facebook
...).
Non category
dependent
If the structure of a notification is not dependent on its category, then you want to access it without any category context:
/users/test@abc.com/notifications/{notification-id}
And you can use the category as a filter to a collection of notifications:
/users/test@abc.com/notifications?category=whatsapp,facebook
category
dependent
Otherwise, if a notification is structurally dependent on its category (e.g., if you want to define different actions when you deal with whatsapp
notifications than when you deal with facebook
notifications), then you might want to distinguish a notification according to its category:
/users/test@abc.com/notifications/whatsapp/{whatsapp-notification-id}
/users/test@abc.com/notifications/facebook/{facebook-notification-id}
In this case, you could have:
/users/test@abc.com/notifications/whatsapp/1
/users/test@abc.com/notifications/facebook/1
That define 2 different notifications (although it uses the same identifier).
Now requesting a collection of this kind of notifications is a bit different than the previous "non category dependent" case.
If you only want to have whatsapp
notifications then simply call the category resource does the job:
/users/test@abc.com/notifications/whatsapp
But if you want to search on different categories, then you cannot apply your request to a specific category resource. Indeed, it makes no sense to ask for facebook
notifications when you deal with whatsapp
ones:
/users/test@abc.com/notifications/whatsapp?category=facebook # weird
One solution would be to make as many requests as there are categories requested:
/users/test@abc.com/notifications/whatsapp
/users/test@abc.com/notifications/facebook
But you will have to merge your results later.
Another solution would be to apply your query directly from
/users/test@abc.com/notifications?category=whatsapp,facebook
But the result will be different than the "non category dependent" case. Indeed, you won't be able to directly have your list of notifications, but a list of categories to access to your list of notifications.