hngprojects / hng_boilerplate_expressjs

75 stars 83 forks source link

[FEAT]: Super Admin - Get All Payments with Pagination #131

Open onielsteve2003 opened 1 month ago

onielsteve2003 commented 1 month ago

Description:

Implement an API endpoint for retrieving all payments. This endpoint allows authenticated super admin users to fetch all payments with pagination support.

Endpoint Feature:

  1. This endpoint enables authenticated super admin users to fetch all payments.
  2. Supports pagination to manage the number of payments returned per request.

Acceptance Criteria:

Request Example:

GET /api/v1/payments?page=1&limit=10 Content-Type: application/json

Response Example:

{
  "status": "success",
  "status_code": 200,
  "data": [
    {
      "payment_id": "1",
      "amount": 100.00,
      "user_id": "666434838cc76672",
      "date": "2024-07-21T12:34:56Z"
    },
    {
      "payment_id": "2",
      "amount": 200.00,
      "user_id": "666434838cc76672",
      "date": "2024-07-20T11:33:55Z"
    }
  ],
  "pagination": {
    "current_page": 1,
    "per_page": 10,
    "total_pages": 5,
    "total_items": 50
  }
}

Data Validation:

Input Validation:

Output Validation:

{
  "status": "unsuccessful",
  "status_code": 500,
  "message": "Failed to retrieve payments. Please try again later."
}

Authentication and Authorization:

Authentication:

Authorization:

Error Handling:

Error Responses:

{
  "status": "unsuccessful",
  "status_code": 500,
  "message": "Failed to retrieve payments. Please try again later."
}

Edge Cases:

{
  "status": "unsuccessful",
  "status_code": 404,
  "message": "No payments found."
}

Test Requirements:

Unit Tests:

Integration Tests:

AdeGneus commented 1 month ago

Good issue. Not setting the pagination parameters shouldn't be an error technically, unless you want pagination to always be strictly handled at the backend always

onielsteve2003 commented 1 month ago

Okay no problem, Noted that down