An API to handle contracts from home equity loans.
This is a proposed solution to this challenge.
This project uses Claudia.JS to deploy to AWS.
Configure it and run the script npm run deploy
to deploy or claudia create
to deploy first time.
It is necessary to configure an env.json
file to set the Lambdas environment variables.
The only required variable is the "NODE_ENV" to route the database endpoint to the correct value.
This project is live in https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/.
This is a Restful API, so it follows it conventions for routes.
curl -X GET \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/users
Response format:
{
"success": "bool",
"resources": [
{
"id": "uuid",
"firstName": "text",
"lastName": "text",
"cpf": "text",
"email": "text",
"montlyIncome": "number",
"dateOfBirth": "timestamp",
"maritalStatus": "text",
"address": {
"street": "text",
"zipCode": "text",
"city": "text",
"state": "text",
"country": "text"
}
}
],
"count": "number"
}
curl -X POST \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/users \
-H 'Content-Type: application/json' \
-d '{
"firstName": "text",
"lastName": "text",
"cpf": "text",
"email": "text",
"montlyIncome": "number",
"dateOfBirth": "timestamp",
"maritalStatus": "text",
"address": {
"street": "text",
"zipCode": "text",
"city": "text",
"state": "text",
"country": "text"
}
}'
Response format:
{
"success": "bool",
"resources": {
"id": "uuid",
"firstName": "text",
"lastName": "text",
"cpf": "text",
"email": "text",
"montlyIncome": "number",
"dateOfBirth": "timestamp",
"maritalStatus": "text",
"address": {
"street": "text",
"zipCode": "text",
"city": "text",
"state": "text",
"country": "text"
}
}
}
curl -X POST \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/users/user_id/contracts \
-H 'Content-Type: application/json' \
-d '{
"amount": "number"
}'
Response format:
{
"success": "bool",
"resource": {
"id": "uuid",
"amount": "number",
"status": "text",
"userId": "uuid",
"approvalState": "text",
"userSnapshot": {
"...ofTypeUser"
}
}
}
curl -X GET \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/users/user_id/contracts
Response format:
{
"success": "bool",
"resources": [
{
"id": "uuid",
"amount": "number",
"status": "text",
"userId": "uuid",
"approvalState": "text",
"userSnapshot": {
"...ofTypeUser"
}
}
],
"count": "number"
}
Possible approvalStates:
- "approved"
- "rejected"
curl -X PUT \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/contracts/contract_id \
-H 'Content-Type: application/json' \
-d '{
"amount": "number",
"approvalState": "text"
}'
Response format:
{
"success": "bool",
"resource": {
"id": "uuid",
"amount": "number",
"status": "text",
"userId": "uuid",
"approvalState": "text",
"userSnapshot": {
"...ofTypeUser"
}
}
}
Possible types:
- "cpf",
- "cnh",
- "proof_of_income",
- "property_photo"
curl -X POST \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/contracts/contract_id/documents \
-H 'Content-Type: application/json' \
-d '{
"type": "text",
"publicUrl": "text"
}'
Response format:
{
"success": "bool",
"resource": {
"id": "uuid",
"type": "text",
"publicUrl": "text",
"contractId": "uuid"
}
}
curl -X GET \
https://479p120d33.execute-api.sa-east-1.amazonaws.com/latest/contracts/contract_id/documents
Response format:
{
"success": "bool",
"resources": [
{
"id": "uuid",
"type": "text",
"publicUrl": "text",
"contractId": "uuid"
}
],
"count": "number"
}
This project uses Jest as its testing tool.
To run the entire test suite, run:
npm run test
Licensed under the MIT license, see the separate LICENSE file.