Hi, we have a resource credit-card-payments
and another resource wire-transfer-payments
. We want them to be accessible through a general payment
endpoint:
POST /payments
PATCH /payments/:id
GET /payments
GET /payments/:id
When creating or updating the resources, we specify the type
so the server knows which resource (wire-transfer-payments
or credit-card-payments
) is dealing with. Also, when fetching all the payments, we get a mixed list of wire-transfer-payments
and credit-card-payments
, so there’s no problem there either.
The problem comes when fetching a specific payments
resource. Where the type
of the resource (wire-transfer-payments
or a credit-card-payments
) be passed so the server can handle it?
We thought of using a query-param like GET /payments/:id?type='credit-card-payments'
but it doesn’t feel like the best approach.
What would you recommend?