Skip to content

MileneGJ/projeto18-valex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


VALEX - API DOCUMENTATION

Back-end Development Project for Driven Bootcamp course
Browse TypeScript code»

Built With

Table of Contents

Getting Started

This Api can be used in two different ways: by cloning the project or by running in your preferred client, such as Insomnia or Postman.

To clone the project, run the following command:

git clone https://github.com/MileneGJ/projeto18-valex.git

Then, navigate to the project folder and run the following command:

npm install

Finally, start the server:

npm start

You can now access the API's endpoints by navigating to http://localhost:5000/

Database

This project used as reference a postgres database that can be created using these scripts

Since this application is not deployed, it is recommended to create a local database with the scripts above for the correct functioning of the project resources.

API Reference

In this section, you will find the API's endpoints and their descriptions, along with the request and response examples. All data is sent and received as JSON.

Routes

Cards /card

Payments /purchase

Recharges /recharge

Cards

Create a card

POST /new-card

Request

Body
{
  "employeeId": "1",
  "cardType": "health"
}
Headers
{
  "Content-Type": "application/json",
  "x-api-key": "placeholder-api-key"
}

Responses

Status Code Description Properties
201 Created data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Activate a card

POST /card/activate/:cardId

Request

Body
{
  "securityCode": "616",
  "password": "1234"
}
Headers
{
  "Content-Type": "application/json"
}
Params
cardId:3

Responses

Status Code Description Properties
200 OK data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

See balance for a card

GET /balance/:cardId

Request

Params
cardId:3

Responses

Status Code Description Properties
200 OK data: {}
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Block a card

POST /card/block/:cardId

Request

Body
{
  "password": "1234"
}
Headers
{
  "Content-Type": "application/json"
}
Params
cardId:3

Responses

Status Code Description Properties
200 OK data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Unblock a card

POST /card/unblock/:cardId

Request

Body
{
  "password": "1234"
}
Headers
{
  "Content-Type": "application/json"
}
Params
cardId:3

Responses

Status Code Description Properties
200 OK data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Payments

POS payment

POST /pos-purchase/:businessId

Request

Body
{
  
  "password": "1234"
  "cardId": 3,
  "amount": 1000
}
Headers
{
  "Content-Type": "application/json"
}
Params
businessId:5

Responses

Status Code Description Properties
201 Created data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Online payment

POST /online-purchase/:businessId

Request

Body
{
  
  "cardNumber": "1234-1234-1234-1234"
  "cardholderName": "JOHN S SMITH",
  "expirationDate": "09/27",
  "securityCode": "277",
  "amount": 1000
}
Headers
{
  "Content-Type": "application/json"
}
Params
businessId:5

Responses

Status Code Description Properties
201 Created data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

Recharges

New recharge

POST /recharge/:cardId

Request

Body
{
  "amount": 1000
}
Headers
{
  "Content-Type": "application/json",
  "x-api-key": "placeholder-api-key"
}
Params
businessId:5

Responses

Status Code Description Properties
201 Created data: {}
401 Unauthorized error: { message }
404 Not Found error: { message }
409 Conflict error: { message }
422 Invalid Input error: { message }
500 Internal Server Error error: { message }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published