Loading gists…
A Text snippet, saved for reference.
| 1 | # Manakamana Printing Backend API Documentation |
| 2 | |
| 3 | This document provides a comprehensive list of API endpoints, request formats, and response examples for the Manakamana Printing e-commerce platform. |
| 4 | |
| 5 | **Base URL**: `/api/v1` |
| 6 | **Authentication**: Bearer Token required for protected routes. |
| 7 | **Content-Type**: `application/json` |
| 8 | |
| 9 | --- |
| 10 | |
| 11 | ## 🔐 Authentication |
| 12 | |
| 13 | ### Admin Login |
| 14 | Logs in an administrator and returns a JWT token. |
| 15 | - **Endpoint**: `POST /admin/auth/login` |
| 16 | - **Request Body**: |
| 17 | ```json |
| 18 | { |
| 19 | "email": "admin@example.com", |
| 20 | "password": "plain_text_password" |
| 21 | } |
| 22 | ``` |
| 23 | - **Response (200 OK)**: |
| 24 | ```json |
| 25 | { |
| 26 | "message": "Admin login successful", |
| 27 | "token": "JWT_TOKEN", |
| 28 | "admin": { |
| 29 | "id": "uuid", |
| 30 | "name": "Admin Name", |
| 31 | "email": "admin@example.com", |
| 32 | "role": "ADMIN" |
| 33 | } |
| 34 | } |
| 35 | ``` |
| 36 | |
| 37 | ### Client Login |
| 38 | Logs in a client and returns a JWT token. |
| 39 | - **Endpoint**: `POST /auth/login` |
| 40 | - **Request Body**: |
| 41 | ```json |
| 42 | { |
| 43 | "phone_number": "9812345678", |
| 44 | "password": "plain_text_password" |
| 45 | } |
| 46 | ``` |
| 47 | - **Response (200 OK)**: |
| 48 | ```json |
| 49 | { |
| 50 | "message": "Login successful", |
| 51 | "token": "JWT_TOKEN", |
| 52 | "client": { |
| 53 | "id": "uuid", |
| 54 | "client_code": "MP-XXXXXXXX", |
| 55 | "phone": "9812345678", |
| 56 | "business_name": "Business Name", |
| 57 | "role": "CLIENT" |
| 58 | } |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | ### Logout |
| 63 | - **Endpoint**: `POST /auth/logout` |
| 64 | - **Response (200 OK)**: `{"message": "Logout successful"}` |
| 65 | |
| 66 | ### Get Current User (Me) |
| 67 | Fetches details of the currently authenticated user (Admin or Client). |
| 68 | - **Endpoint**: `GET /auth/me` (for clients) or `GET /admin/auth/me` (for admins) |
| 69 | - **Header**: `Authorization: Bearer <TOKEN>` |
| 70 | - **Response (200 OK)**: |
| 71 | ```json |
| 72 | { |
| 73 | "message": "Current user fetched", |
| 74 | "user": { ... } |
| 75 | } |
| 76 | ``` |
| 77 | |
| 78 | --- |
| 79 | |
| 80 | ## 📝 Public Registration |
| 81 | |
| 82 | ### Submit Registration Request |
| 83 | Allows new businesses to submit a request to join the platform. |
| 84 | - **Endpoint**: `POST /register-request` |
| 85 | - **Request Body**: |
| 86 | ```json |
| 87 | { |
| 88 | "business_name": "ABC Traders", |
| 89 | "owner_name": "Ram Sharma", |
| 90 | "email": "abc@example.com", |
| 91 | "phone_number": "9812345678", |
| 92 | "business_address": "Kathmandu, Nepal", |
| 93 | "notes": "Bulk order inquiry" |
| 94 | } |
| 95 | ``` |
| 96 | - **Response (201 Created)**: |
| 97 | ```json |
| 98 | { |
| 99 | "message": "Registration request submitted successfully", |
| 100 | "data": { ... } |
| 101 | } |
| 102 | ``` |
| 103 | |
| 104 | --- |
| 105 | |
| 106 | ## 👤 Client Profile |
| 107 | |
| 108 | ### Get Profile |
| 109 | - **Endpoint**: `GET /user/profile` |
| 110 | - **Header**: `Authorization: Bearer <CLIENT_TOKEN>` |
| 111 | - **Response (200 OK)**: `{"message": "Profile fetched", "data": { ... }}` |
| 112 | |
| 113 | ### Update Profile |
| 114 | - **Endpoint**: `PATCH /user/profile` |
| 115 | - **Header**: `Authorization: Bearer <CLIENT_TOKEN>` |
| 116 | - **Request Body**: |
| 117 | ```json |
| 118 | { |
| 119 | "business_name": "Updated Name", |
| 120 | "owner_name": "Updated Owner", |
| 121 | "email": "updated@example.com", |
| 122 | "address": "Updated Address" |
| 123 | } |
| 124 | ``` |
| 125 | - **Response (200 OK)**: `{"message": "Profile updated successfully", "data": { ... }}` |
| 126 | |
| 127 | --- |
| 128 | |
| 129 | ## 🛠 Admin Management |
| 130 | |
| 131 | ### List Registration Requests |
| 132 | - **Endpoint**: `GET /admin/registration-requests` |
| 133 | - **Query Parameters**: |
| 134 | - `status`: Filter by status (`PENDING`, `APPROVED`, `REJECTED`). |
| 135 | - `search`: Search by business name or phone number. |
| 136 | - **Response (200 OK)**: `{"message": "...", "data": [ ... ]}` |
| 137 | |
| 138 | ### Get Request Details |
| 139 | - **Endpoint**: `GET /admin/registration-requests/:request_id` |
| 140 | |
| 141 | ### Approve Registration Request |
| 142 | Approves a request, creates a Client account, and generates temporary credentials. |
| 143 | - **Endpoint**: `POST /admin/registration-requests/:request_id/approve` |
| 144 | - **Response (200 OK)**: |
| 145 | ```json |
| 146 | { |
| 147 | "message": "Client approved and created successfully", |
| 148 | "credentials": { |
| 149 | "phone_number": "...", |
| 150 | "password": "..." |
| 151 | }, |
| 152 | "client": { ... } |
| 153 | } |
| 154 | ``` |
| 155 | |
| 156 | ### Reject Registration Request |
| 157 | - **Endpoint**: `PATCH /admin/registration-requests/:request_id/reject` |
| 158 | - **Request Body**: `{"reason": "Insufficient documentation"}` |
| 159 | |
| 160 | ### Mark Credentials Sent |
| 161 | Updates the request to indicate that the credentials have been communicated to the client. |
| 162 | - **Endpoint**: `PATCH /admin/registration-requests/:request_id/credentials-sent` |
| 163 | |
| 164 | ### List Clients |
| 165 | - **Endpoint**: `GET /admin/clients` |
| 166 | |
| 167 | ### Get Client Details |
| 168 | - **Endpoint**: `GET /admin/clients/:id` |
| 169 | |
| 170 | --- |
| 171 | |
| 172 | ## 🏥 Health Check |
| 173 | - **Endpoint**: `GET /` |
| 174 | - **Response**: `{"message": "API is running"}` |
| 175 |