# Onboarding Task API documentation
## Database Schemas - Lenders
### Clients
```json
{
"id": String
"userId": String,
"name": String,
"dob":Date,
"birthplace":String
}
```
## JSON CONFIG-AGGREGATOR
### Config
```json
{
"id": String,
"lender_name": String,
"database_url": String,
"port": Number,
"groups": Array,
}
```
## API Overview - Lenders
The API provides access to CRUD operations on lenders DB:
* Add client
* Read client
* Update client
* Delete client
<hr>
### Client Routes
#### [POST] /client
Add client into the lenders database
+ **Request Body**
+ userId: (string) - UserId of the user to be added
+ name: (string) - Name of the user to be added
+ dob: (Date) - Date of birth of user
+ birthplace: (string) - Country where the user was born
+ **Example**
```json
{
"userId": "389de9a9c98c6d78d7d68",
"name": "Steve",
"dob":"19-12-2022",
"birthplace":"India"
}
```
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>201</td>
<td>true</td>
<td>Client added successfully</td>
<td>None</td>
<td>
```json
{
"success": true,
"message": "Client added successfully"
}
```
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
#### [GET] /clients
Get all clients details.
+ **Request Body**
+ None
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>All clients fetched successfully</td>
<td>
```json
{
"clients": [{
"id": String,
"userId": String,
"name": String,
"dob": Date,
"birthplace": String,
},
.
.
.]
}
```
</td>
<td>
```json
{
"success": true,
"message": "Clients fetched successfully",
"data": {
"clients": [{
"id": "1",
"userId":"93J924Hbe82h4"
"name": "Steve",
"dob": "19-05-2001",
"birthplace": "India",
}]
}
```
</td>
</tr>
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
#### [GET] /clients/:clientId
Get details of particular client.
+ **Request Body**
+ None
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>Client details fetched successfully</td>
<td>
```json
{
"client": {
"id": String,
"userId": String,
"name": String,
"dob": Date,
"birthplace": String,
}
```
</td>
<td>
```json
{
"success": true,
"message": "Client fetched successfully",
"data": {
"client": {
"id": "1",
"userId":"93J924Hbe82h4"
"name": "Steve",
"dob": "19-05-2001",
"birthplace": "India",
}
}
```
</td>
</tr>
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
#### [PATCH] /clients
Update the details of the client.
+ **Request Body**
+ userId: (string) - UserId of the user to be added
+ name: (string) - Name of the user to be added
+ dob: (Date) - Date of birth of user
+ birthplace: (string) - Country where the user was born
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>Client details updated successfully</td>
<td>
```json
{
"client": {
"id": String,
"userId": String,
"name": String,
"dob": Date,
"birthplace": String,
}
```
</td>
<td>
```json
{
"success": true,
"message": "Client details updated successfully",
"data": {
"client": {
"id": 1,
"userId": "JO933104nB",
"name": "Steve",
"dob": "21-05-2001",
"birthplace": "India",
}
}
}
```
</td>
</tr>
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
#### [DEL] /clients
Delete a client
+ **Request Body**
+ id: (string) - id of the client to be removed
+ **Example**
```json
{
"id": "7",
}
```
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>Client removed successfully</td>
<td>None</td>
<td>
```json
{
"success": true,
"message": "Client removed successfully"
}
```
</td>
</tr>
<tr>
<td>404</td>
<td>false</td>
<td>id not found</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "id not found"
}
```
</td>
</tr>
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
## API Overview - Aggregators
The API provides access to config of aggregator and allows checking of fraud
* Get config
* Check duplication
<hr>
### Config Routes
#### [POST] /config
#### [GET] /config
Get config details.
+ **Headers**
```json
{
"appId": String,
"appkey": String
}
```
+ **Request Body**
+ None
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>Config details fetched</td>
<td>
```json
{
"config": [{
"id": String,
"lender_name": String,
"database_url": String,
"port": Number,
"groups": Array,
},
.
.
.]
}
```
</td>
<td>
```json
{
"success": true,
"message": "Clients fetched successfully",
"data": [
{
"id": "yU4K99"
"lender_name": "Lender A"
"database_url": "localhost://postgres:newPassword@postgres:5432/todo-db",
"port": 5432,
"groups": ["open","common"]
}
]
}
```
</td>
</tr>
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>
### Duplication Routes
#### [POST] /check_dupication
Check if input details are fraud or not
+ **Headers**
```json
{
"appId": String,
"appkey": String
}
```
+ **Request Body**
+ lender_id: (string) - Id of the lender
+ userId: (string) - UserId of the user to be added
+ name: (string) - Name of the user to be added
+ dob: (Date) - Date of birth of user
+ birthplace: (string) - Country where the user was born
+ **Example**
```json
{
"lender_id":"P0O993"
"userId": "389de9a9c98c6d78d7d68",
"name": "Steve",
"dob":"19-12-2022",
"birthplace":"India"
}
```
+ **Response**
<table>
<tr>
<th>Status Code</th>
<th>Success</th>
<th>Message</th>
<th>Data</th>
<th>Example</th>
</tr>
<tr>
<td>200</td>
<td>true</td>
<td>Fraud detected</td>
<td>
```json
{
"matches":{
"internalCount":Number,
"externalCount":Number,
"totalCounts":Number,
"internal":[
{
"userId":{
"value":String,
"match":Boolean
},
"name":{
"value":String,
"match":Boolean
},
"dob":{
"value":String,
"match":Boolean
},
"birthplace":{
"value":String,
"match":Boolean
}
}
],
"external":[
{
"userId":{
"value":String,
"match":Boolean
},
"name":{
"value":String,
"match":Boolean
},
"dob":{
"value":Date,
"match":Boolean
},
"birthplace":{
"value":String,
"match":Boolean
}
}
],
}
}
```
</td>
<td>
```json
{
"success": true,
"message": "Fraud detected"
"data":{
"matches":{
"internalCount":1,
"externalCount":0,
"totalCounts":1,
"internal":[
{
"userId":{
"value":"30OOMWB271",
"match":true
},
"name":{
"value":"Steve",
"match":true
},
"dob":{
"value":"19-01-2001",
"match":"true"
},
"birthplace":{
"value":"Mumbai",
"match":"false"
}
}
],
"external":[],
}
}
}
```
<tr>
<td>500</td>
<td>false</td>
<td>Internal Server Error</td>
<td>None</td>
<td>
```json
{
"success": false,
"message": "Internal Server Error",
}
```
</td>
</tr>
</table>