Categorygithub.com/GSabadini/go-transactions
modulepackage
0.0.0-20231113191602-a94af40aa850
Repository: https://github.com/gsabadini/go-transactions.git
Documentation: pkg.go.dev

# README

Go Transactions :bank:

Build Build

Arquitetura

  • A arquitetura é baseada nos conceitos de Arquitetura Limpa propostas por Uncle Bob. Para mais detalhes clique aqui.

Clean Architecture

Requisitos

  • Docker
  • Docker-compose

Começando

  • Iniciar aplicação na porta :3001
make start
  • Rodar os testes utilizando um container
make test
  • Rodar os testes utilizando a máquina local
make test-local
  • Gerar coverage
make coverage
  • Ver os logs da aplicação
make logs
  • Destruir aplicação
make down

API Endpoint

EndpointMétodo HTTPDescrição
/v1/accountsPOSTCriar conta
/v1/accounts/{:accountId}GETBuscar conta por ID
/v1/transactionsPOSTCriar transação
/v1/healthGETHealth check

Operações

IDDescriçãoTipo
1COMPRA A VISTADEBIT
2COMPRA PARCELADADEBIT
3SAQUEDEBIT
4PAGAMENTOCREDIT

Testar API usando curl

  • Criar conta

ParâmetroObrigatórioTipoRegras
documentSimObject
document.numberSimStringMáximo 30 caracteres
available_credit_limitSimFloat

Request

curl -i --request POST 'http://localhost:3001/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
    "document": {
        "number": "12345678900"
    },
    "available_credit_limit": 100
}'

Response

{
    "id": "1a4028ea-3c18-4714-b650-d1058ae7a053",
    "document": {
        "number": "12345678900"
    },
    "available_credit_limit": 100,
    "created_at": "2020-10-17T02:28:05Z"
}
  • Buscar conta por ID

Request

curl -i --request GET 'http://localhost:3001/v1/accounts/{:acountId}'

Response

{
    "id": "1a4028ea-3c18-4714-b650-d1058ae7a053",
    "document": {
        "number": "12345678900"
    },
    "available_credit_limit": 100,
    "created_at": "2020-10-17T02:28:05Z"
}
  • Criar transação

ParâmetroObrigatórioTipoRegras
account_idSimString
operation_idSimString
amountSimFloatMaior que zero

Request

curl -i --request POST 'http://localhost:3001/v1/transactions' \
--header 'Content-Type: application/json' \
--data-raw '{
    "account_id": "deeb291c-18a0-45c3-b28b-df7ebcabe4f8",
    "operation_id": "3",
    "amount": 100
}'

Response

{
    "id": "22985ca3-c777-4ab2-b433-ba3b6844578d",
    "account_id": "deeb291c-18a0-45c3-b28b-df7ebcabe4f8",
    "operation": {
        "id": "3",
        "description": "SAQUE",
        "type": "DEBIT"
    },
    "amount": -100,
    "balance": -100,
    "created_at": "2020-10-17T22:17:40Z"
}

Regras

  • Todos os valores monetários são representados em centavos.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author