meta {
  name: 01 Get subscription
  type: http
  seq: 1
}

get {
  url: {{baseUrl}}/api/v1/billing/subscription
  body: none
  auth: bearer
}

auth:bearer {
  token: {{token}}
}

tests {
  test("200 OK", function () {
    expect(res.getStatus()).to.equal(200);
  });
  test("plan dans l'enum", function () {
    expect(res.getBody().data.plan).to.be.oneOf(["free", "pro", "business"]);
  });
  test("caps présents", function () {
    expect(res.getBody().data.caps).to.have.property("activeInvoicesLimit");
    expect(res.getBody().data.caps).to.have.property("seatsLimit");
  });
  test("flags grace + cancel exposés", function () {
    expect(res.getBody().data).to.have.property("inGracePeriod");
    expect(res.getBody().data).to.have.property("cancelAtPeriodEnd");
  });
}

docs {
  GET /api/v1/billing/subscription — auth requise

  Retourne l'état de la souscription pour l'org de l'user courant.

  Réponse :
  ```json
  {
    "data": {
      "plan": "free" | "pro" | "business",
      "caps": {
        "activeInvoicesLimit": 5 | null,
        "seatsLimit": 1 | 5 | null,
        "multiUsers": false | true,
        "replyFromUserEmail": false | true,
        "smsEnabled": false
      },
      "activeInvoicesCount": 12,
      "inGracePeriod": true | false,
      "gracePeriodEndsAt": "2026-08-06T..." | null,
      "subscriptionStatus": "active" | "past_due" | "canceled" | null,
      "billingCycle": "monthly" | "yearly" | null,
      "currentPeriodEnd": "2026-06-07T..." | null,
      "hasStripeCustomer": true | false,
      "cancelAtPeriodEnd": false | true
    }
  }
  ```

  Utilisé par `/parametres/abonnement` côté SPA pour afficher le plan
  courant + les caps + l'état d'annulation.
}
