raystack / frontier

Frontier is an all-in-one user management platform that provides identity, access and billing management to help organizations secure their systems and data. (Open source alternative to Clerk)
https://raystack-frontier.vercel.app/
Apache License 2.0
273 stars 34 forks source link

feat: add pagination to list all invoice API #753

Closed AmanGIT07 closed 3 months ago

AmanGIT07 commented 3 months ago

Description

Adds pagination to list all invoice API. page_num and page_size params can be used to modulate the pages. count returns the total number of items (not the count of items in response) so that it can be consumed for different logics if needed.

API Testing

  1. Default behaviour

Request:

curl --location 'http://localhost:8400/frontier-api/v1beta1/admin/billing/invoices' 

Response:

{
    "invoices": [
        {
            "id": "",
            "customer_id": "",
            "provider_id": "",
            "state": "",
            "currency": "",
            "amount": "",
            "hosted_url": "",
            "due_date": null,
            "effective_at": null,
            "period_start_at": null,
            "period_end_at": null,
            "metadata": {},
            "created_at": "",
            "customer": null
        },
        {
            "id": "",
            "customer_id": "",
            "provider_id": "",
            "state": "",
            "currency": "",
            "amount": "",
            "hosted_url": "",
            "due_date": null,
            "effective_at": null,
            "period_start_at": null,
            "period_end_at": null,
            "metadata": {},
            "created_at": "",
            "customer": null
        },
        {
            "id": "",
            "customer_id": "",
            "provider_id": "",
            "state": "",
            "currency": "",
            "amount": "",
            "hosted_url": "",
            "due_date": null,
            "effective_at": null,
            "period_start_at": null,
            "period_end_at": null,
            "metadata": {},
            "created_at": "",
            "customer": null
        }
    ],
    "count": 3
}
  1. Request specific page & size

Request:

curl --location 'http://localhost:8400/frontier-api/v1beta1/admin/billing/invoices?page_num=2&page_size=2

Response:

{
    "invoices": [
        {
            "id": "",
            "customer_id": "",
            "provider_id": "",
            "state": "",
            "currency": "",
            "amount": "",
            "hosted_url": "",
            "due_date": null,
            "effective_at": null,
            "period_start_at": null,
            "period_end_at": null,
            "metadata": {},
            "created_at": "",
            "customer": null
        }
    ],
    "count": 3
}
vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2024 6:23am
coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 10609812154

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1/billing_invoice.go 0 6 0.0%
proto/v1beta1/admin.pb.go 0 15 0.0%
internal/store/postgres/billing_invoice_repository.go 0 21 0.0%
proto/v1beta1/admin.pb.validate.go 0 22 0.0%
<!-- Total: 0 64 0.0% -->
Files with Coverage Reduction New Missed Lines %
internal/api/v1beta1/billing_invoice.go 1 0.0%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 10590915744: -0.005%
Covered Lines: 10463
Relevant Lines: 110278

💛 - Coveralls