Skip to content

fabiofaleiros/simplecashtransaction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Cash Transaction Service

@DevCollab Challenge

API to manage cash transaction challenge.

Video Source link.

Technologies

Adopted practices

  • SOLID
  • Automated tests
  • DTOs
  • Dependency injection
  • Swagger automatic doc withGeração automática do Swagger com OpenAPI 3
  • Entity Auditing to date(create and update)
  • JWT

Initial Considerations

New mocky created to replace the original one:

New wiremock created to replace the original [one] (http://o4d9z.mocklab.io/notify):

How to load

Locally

  • Clone git repository
  • Initialize Postgres DB via docker:
cd db-docker
docker compose up
  • Build project:
./mvnw clean package
  • Execute:
java -jar simplecashtransaction/target/simplecashtransaction-0.0.1-SNAPSHOT.jar

API Endpoints

Tool insomnia:

  • All requests to /api/* require token received by /auth/login. Before is necessary to register a existent user throw /auth/register.

  • POST localhost:8080/api/v1/users

Request:
{
	"firstName": "Joao",
	"lastName": "Siqueira",
	"password": "senha",
	"document": "1234563",
	"email": "j@ffs.com",
	"userType": "ENTERPRISE",
	"balance": 200
}

HTTP/1.1 201 CREATED
Content-Type: application/json

{
	"firstName": "Joao",
	"lastName": "Siqueira",
	"document": "1234563",
	"email": "j@ffs.com",
	"balance": 200,
	"userType": "ENTERPRISE",
	"role": null,
	"updatedAt": "2023-10-09T18:48:05.9371241"
}
  • GET localhost:8080/api/v1/users
HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "firstName": "Fran",
        "lastName": "Faleiros",
        "document": "1234562",
        "balance": 200.00,
        "email": "ff@ffs.com",
        "role": "USER",
        "userType": "PERSONAL",
        "updatedAt": "2023-09-26T12:02:17.720958"
    },
    {
        "firstName": "Empresa",
        "lastName": "XPTO 2",
        "document": "1234564",
        "balance": 200.00,
        "email": "exe@ffs.com",
        "role": "USER",
        "userType": "ENTERPRISE",
        "updatedAt": "2023-09-26T17:29:30.935671"
    },
    {
        "firstName": "Fabio",
        "lastName": "Faleiros",
        "document": "1234561",
        "balance": 200.00,
        "email": "admin@ffs.com",
        "role": "ADMIN",
        "userType": "PERSONAL",
        "updatedAt": "2023-10-09T17:34:14.882944"
    }
]
  • POST localhost:8080/api/v1/transactions
Request:
{
	"senderID": 1,
	"receiverID": 2,
	"value": 10
}

HTTP/1.1 201 CREATED
Content-Type: application/json

{
    "value": 10,
    "senderID": 1,
    "receiverID": 4,
    "transactionCode": "3b4ab7fe-906d-414e-9ed0-6c946f3ff9e1"
}
  • GET localhost:8080/api/v1/transactions
HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "value": 10.00,
        "senderID": 1,
        "receiverID": 4,
        "transactionCode": "3b4ab7fe-906d-414e-9ed0-6c946f3ff9e1"
    }
]
  • POST localhost:8080/auth/register
Request:
{
		"login": "admin@ffs.com",
		"password": "senha",
		"role": "ADMIN"
}

HTTP/1.1 201 CREATED
Content-Type: application/json

{
	"firstName": "Joao",
	"lastName": "Siqueira",
	"document": "1234563",
	"email": "j@ffs.com",
	"balance": 200,
	"userType": "ENTERPRISE",
	"role": null,
	"updatedAt": "2023-10-09T18:48:05.9371241"
}
  • GET localhost:8080/auth/login
HTTP/1.1 200 OK
Content-Type: application/json

{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJhdXRoLWFwaSIsInN1YiI6ImFkbWluQGZmcy5jb20iLCJleHAiOjE2OTY4ODM5MTh9.vjRywJfMbflrwBNI8_OSqiFrgLKgTH7GM1nB7O160p0"
}

About

Simple Cash Transaction API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages