# OBANANA WALLET API This API allows you to: ### USER: - AUTHENTICATE via LOGIN - REGISTER A USER - GET A USER - GET ALL USERS - UPDATE A USER - UPDATE USER DETAILS WITH ANY PARAM EXCEPT PHOTO AND PASSWORD - UPDATE USER PASSWORD - UPDATE USER PHOTO - ADD FRIEND TO USER - UPDATE A FRIEND DETAILS - DELETE A USER - DELETE A FRIEND ### KYCS - CREATE A KYC - GET ALL KYCS - GET A SINGLE KYC - DELETE A KYC - UPDATE KYC ### EMAIL - SEND EMAIL ### UPLOAD IMAGE - UPLOAD AN IMAGE The API is available at `http://obpay.online` ## Endpoints ## API Authentication ### LOGIN POST `/api/auth/login` The request body needs to be in JSON format and include the following properties: - `email` - String || `phone` - String - `password` - String Example ``` { "users": "meme1@gmail.com" or "09123456789", "password": "123456" } ``` The response body will contain the access token. The access token is valid for 7 days. ### REGISTER POST `/api/auth/register` The request body needs to be in JSON format and include the following properties: - `fName` - String - Required - `lName` - String - Required - `email` - String - Required - `password` - String - Required - `phone` - String - Required - `photo` - String --NEW-- - `address1` - String - `address2` - String - `city` - String - `province` - String - `country` - String - `zip` - String - `type` - String - Default client Automatically generating ID The photo param is `picture` send the photo on the input type file and name is picture Example ``` POST /api/auth/register { "fName":"Sana", "lName":"Di", "email":"meme1@gmail.com", "password":"123456", "phone":"123456", "address1":"Blk 123 Makati City", "address2":"Blk 123 Makati City", "city":"Makati", "province":"Metro Manila", "country":"Philippines", "zip":"1300", "type":"Admin", } ``` ## Access Users Data ### List of all Users GET `/api/users/` Authorization: Bearer Returns detailed list of All Users. ### Get a single User by PHONE and EMAIL GET `/api/users/:id` Retrieve detailed information about a User. Example ``` GET /api/users/615a9f6d236abe2dbb2e424c Authorization: Bearer Output: { "user": { "_id": "642a1b830ec9ced62dfbc778", "fName": "Sana", "lName": "Di", "email": "meme1@gmail.com", "password": "$2b$10$al2mB9HCdwaUEuK5ODfVqe/IpsAq8tfT4xDLxCduSkpD7dM8KvWjW", "phone": "09112344556", "photo": "", "address1": "", "address2": "", "city": "", "province": "", "country": "", "zip": "", "type": "client", "createdAt": "2023-04-03T00:19:15.051Z", "updatedAt": "2023-04-03T00:19:15.051Z", "__v": 0 }, "balance": 0 ------- The User balance is automatically retireved by calculating the transaction involving the user by comparing the userID with the to_id and from_id from the Transaction then after sum when the user is the receiver and deduct when the user is the sender } ``` ### Get a single User by ID GET `/api/users/id/:id` Retrieve detailed information about a User. Example ``` GET /api/users/615a9f6d236abe2dbb2e424c Authorization: Bearer Output: { "user": { "_id": "642a1b830ec9ced62dfbc778", "fName": "Sana", "lName": "Di", "email": "meme1@gmail.com", "password": "$2b$10$al2mB9HCdwaUEuK5ODfVqe/IpsAq8tfT4xDLxCduSkpD7dM8KvWjW", "phone": "09112344556", "photo": "", "address1": "", "address2": "", "city": "", "province": "", "country": "", "zip": "", "type": "client", "createdAt": "2023-04-03T00:19:15.051Z", "updatedAt": "2023-04-03T00:19:15.051Z", "__v": 0 }, "balance": 0 ------- The User balance is automatically retireved by calculating the transaction involving the user by comparing the userID with the to_id and from_id from the Transaction then after sum when the user is the receiver and deduct when the user is the sender } ``` ### Update a user PATCH `/api/users/:id` Update an existing User. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: The photo param is `picture` send the photo on the input type file and name is picture - `fName` - String - Required - `lName` - String - Required - `email` - String - Required - `password` - String - Required - `phone` - String - Required - `photo` - String --NEW-- - `address1` - String - `address2` - String - `city` - String - `province` - String - `country` - String - `zip` - String - `type` - String - Default client - `status` String -Default new - `kycStatus` String -Default new - `kycRef` String - ID of the kyc of the user that was validated Example ``` PATCH /api/users/615a9f6d236abe2dbb2e424c Authorization: Bearer { "fName":"SanaNew", "lName":"Di", "email":"meme1@gmail.com", "password":"123456", "phone":"123456", "address1":"Blk 123 Makati City", "address2":"Blk 123 Makati City", "city":"Makati", "province":"Metro Manila", "country":"Philippines", "zip":"1300", "type":"Admin", } ``` ### Update a user with any parameters PATCH `/api/users/:id/sub` You can update the user details with only few or selected parameters except photo and password. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: - `fName` - String - OPTIONAL - `lName` - String - OPTIONAL - `email` - String - OPTIONAL - `phone` - String - OPTIONAL - `address1` - String - OPTIONAL - `address2` - String - OPTIONAL - `city` - String - OPTIONAL - `province` - String - OPTIONAL - `country` - String - OPTIONAL - `zip` - String - OPTIONAL - `type` - String - Default client - OPTIONAL - `status` String - OPTIONAL - `kycStatus` String -Default new - `kycRef` String - ID of the kyc of the user that was validated Example ``` PATCH /api/users/615a9f6d236abe2dbb2e424c Authorization: Bearer { "fName":"SanaNew1", "lName":"Di", } ``` ### Update a user Password PATCH `/api/users/:id/password` Update the password of an existing User. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: automatically hash the passwords - `password` - String - Required Example ``` PATCH /api/users/615a9f6d236abe2dbb2e424c/password Authorization: Bearer { "password":"123456", } ``` ### Update a user PHOTO PATCH `/api/users/:id/photo` Update the photo of an existing User. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: The photo param is `picture` send the photo on the input type file and name is picture - `photo` - String Required Example ``` PATCH /api/users/615a9f6d236abe2dbb2e424c/photo Authorization: Bearer { "photo":"image link", } ``` ### Delete User DELETE `/api/users/:id` Delete a user by id. Requires authentication. The request parameter requires: -`id` - String - Required. The id of the user to be deleted. Example ``` DELETE /api/users/615a9f6d236abe2dbb2e424c Authorization: Bearer ``` ### Add Friends to User POST /api/users/:id/friends Add friends to a user by their ID. Requires authentication. The request body needs to be in JSON format and allows you to add the following properties: - `number` - String - Required - `favorite` - Boolean - `nickname` - String - Required Example: ``` POST /api/users/6450c39d34c51843e1dd6852/friends Authorization: Bearer { "number": "09567890544", "favorite": true, "nickname": "Buddy" } ``` ### Update Friend of User PATCH /api/users/:id/friends/:friendId Updates a specific friend of a user by their ID. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: - `number` - String - Required - `favorite` - Boolean - `nickname` - String - Required Example: ``` PATCH /api/users/6450c39d34c51843e1dd6852/friends/6450c39d34c51843e1dd6852 Authorization: Bearer { "number": "09567890544", "favorite": false, "nickname": "Pal" } ``` ### Delete Friend of User DELETE /api/users/:id/friends/:friendId Deletes a specific friend of a user by their ID. Requires authentication. Example: ``` DELETE /api/users/6450c39d34c51843e1dd6852/friends/6450c39d34c51843e1dd6852 Authorization: Bearer ``` ## Access Kyc Data ### List of all Kycs GET `/api/kycs/` Authorization: Bearer Returns detailed list of All Kyc. ### Get a single Kyc GET `/api/kycs/:id` Retrieve detailed information about a single Kyc base on the `id`. Example ``` GET /api/kycs/6424d962fcb1e4f824546c89 Authorization: Bearer { "_id": "65d7fce8637f8e8fd8e84124", "full_name": "San Man", "date_of_birth": "Feb 23, 2001", "userRef": "651b7e256faf1180905d613c", "id_num": "01-234-567", "address": "San Man st. Makati City", "images": [ { "link": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-729660ff-2703-46ee-b823-3d2cedd61f90.png", "_id": "65d7fce8637f8e8fd8e84125" }, { "link": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-8e91f5bc-75c2-4974-b329-d106df3aa17f.png", "_id": "65d7fce8637f8e8fd8e84126" } ], "selfie": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-53cbf0fe-28fe-4f06-ad7f-0640b6db5f98.jpeg", "status": "pending", "createdAt": "2024-02-23T02:03:20.503Z", "updatedAt": "2024-02-23T02:03:20.503Z", "__v": 0 } ``` ### Create a Kyc POST `/api/kycs/create` Create a Kyc. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: - `full_name` - String - `date_of_birth` - String - `userRef` - String - `id_num` - String - `address` - Number - `images` - String - `selfie` - String - `status` - String Example ``` Post /api/kycs/create Authorization: Bearer { "full_name": "San Man", "date_of_birth": "Feb 23, 2001", "userRef": "651b7e256faf1180905d613c", "id_num": "01-234-567", "address": "San Man st. Makati City", "images": [ { "link": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-729660ff-2703-46ee-b823-3d2cedd61f90.png", "_id": "65d7fce8637f8e8fd8e84125" }, { "link": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-8e91f5bc-75c2-4974-b329-d106df3aa17f.png", "_id": "65d7fce8637f8e8fd8e84126" } ], "selfie": "https://testapi.obpay.online/assets/651b7e256faf1180905d613c-53cbf0fe-28fe-4f06-ad7f-0640b6db5f98.jpeg", "status": "pending" } ``` ### Update a Kyc POST `/api/kycs/update/:id` Update a Notification. Requires authentication. The request body needs to be in JSON format and allows you to update the following properties: - `status` - String Example ``` Post /api/kycs/update/6424d962fcb1e4f824546c89 Authorization: Bearer { "status":"validated", } ``` ### Delete a Kyc DELETE `/api/kycs/:id/delete` Delete an existing Kyc. Requires authentication. The request body needs to be empty. Example ``` DELETE /api/kycs/6424d962fcb1e4f824546c89/delete Authorization: Bearer ``` ## Send Email POST `/api/send-email/` Sending Email. The request body needs to be in JSON format and allows you to send the following properties: - `email` - String - Required ---Receiver of the email - `html` - String - Required - `subject` - String - Required Example ``` Post /api/send-email/ { "email":"hello@example.com", "subject":"This is your notif", "html":"

hello!

" } ``` ## Upload Image POST `/api/send-email/` Sending Email. The request body needs to be in Form Data format and allows you to send the following properties: - `image` - File - Required - 1 file only - `category` - String - Required - `image_id` - String - Required Example ``` Post /api/upload_images ```