jimmacur / hang_in_there_api

1 stars 0 forks source link

Merchants #39

Closed jimmacur closed 1 month ago

jimmacur commented 1 month ago

Update the merchants index endpoint to include a count of coupons for each merchant and a count of invoices with coupons applied for each merchant.

Request

GET /api/v1/merchants
Content-Type: application/json
Accept: application/json

Response

{
  "data": [
    {
      "id": "1",
        "type": "merchant",
        "attributes": {
          "name": "Mike's Awesome Store",
          "coupons_count": 3,
          "invoice_coupon_count": 2
        }
    },
    {
      "id": "2",
      "type": "merchant",
      "attributes": {
        "name": "Store of Fate",
        "coupons_count": 0,
        "invoice_coupon_count": 0
      }
    },
    {
      "id": "3",
      "type": "merchant",
      "attributes": {
        "name": "This is the limit of my creativity",
        "coupons_count": 1,
        "invoice_coupon_count": 4
      }
    }
  ]
}