Skip to content

maiceljunior/DevCobre

Repository files navigation

DevCobre

O sistema é focado na parte de cobrança de dividas, nas quais ele recebe a informação de dividendos dos banco, assim organizamos de uma forma pratica e rapida para realizar o contato e assim realizar um acordo com o dividendo.

ObjetivoApiTecnologiasDevs


Para utilizar o DevCobre você precisará:

Clonar o repositorio

Git clone

git clone <link abaixo>

GIT HUB

Após o clone do repositório sera necessario seguir os seguintes comandos:

Install

yarn install

Docker

(caso esteja usando um docker)

$ sudo docker-compose up --build

Migration

$ sudo docker exec api yarn typeorm migration:generate src/migrations/client -d src/data-source.ts

Migration Run

$ sudo docker exec api yarn typeorm migration:run -d src/data-source.ts


API

Métodos 🛠️

Requisições para a API devem seguir os padrões:

Método Descrição
GET Retorna informações de um ou mais registros.
POST Utilizado para criar um novo registro.
PATCH Atualiza dados de um registro ou altera sua situação.
DELETE Remove um registro do sistema.

Respostas

Código Descrição
200 Requisição executada com sucesso (success).
201 Envio de dados para criação exectuado com sucesso (created).
400 Erros de validação ou os campos informados não existem no sistema.
404 Registro pesquisado não encontrado (Not found).
409 Conflict.


| LoginClientBankDebtsAgreementUserContact History |

⚠ ⚠ ⚠ Obs: visando que esta aplicação é utilizada em uma empresa, é necessario a criação primeiramente da conta ADM, desta forma não sera possivel criar as demais rotas sem este usuario ADM ⚠ ⚠ ⚠

Login

Post /adm/ti/create/user

Regras:

  • name,emaile password: string
{
	"name":"teste",
	"email":"[email protected]",
	"password":"2132"
}

Resposta: Status 201 Created

{
	"message":"Adm Created Width Sucess."
}

Post /login

Regras:

  • email,password:string
{
	"email": "[email protected]",
	"password": "test123-"
}

Resposta: Status 200

{
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywicG9zaXRpb24iOiJ1c2VyIiwiZW1haWwiOiJ0ZXN0QG1haWwuY29tIiwiaWF0IjoxNjU4MjYxNjg3LCJleHAiOjE2NTgzNDgwODd9.clFa-cBGhLRnzLLdpyYyIsG8ceOa45izasNNwu-q2QQ"
}

⚠ ⚠ ⚠ Obs: visando que esta aplicação é utilizada em uma empresa, é necessario a criação primeiramente da conta ADM, desta forma não sera possivel criar as demais rotas sem este usuario ADM ⚠ ⚠ ⚠


Client

Post /client

Regras:

  • name,typee document: string
{
	"document": "89999999999998",
	"name": "Empresa Devedora LTDA",
	"type": "Juridico"
}

Resposta: Status 201 Created

{
	"document": "89999999999998",
	"name": "Empresa Devedora LTDA",
	"type": "Juridico"
}

Resposta: Status 409 Conflict

{
  "message": "Client already exists"
}

Get /client (Listar todos os clients)

Resposta: Status 200

{
 {
		"document": "11111111111111",
		"name": "Empresa Devedora LTDA",
		"type": "Juridico",
		"clientInfo": []
	},
	{
		"document": "89999999999998",
		"name": "Empresa Devedora LTDA",
		"type": "Juridico",
		"clientInfo": []
	}
}

Get /client/:document

Resposta: Status 200

{
	"document": "89999999999999",
	"name": "Empresa Devedora LTDA",
	"type": "Juridico",
	"clientInfo": []
}

Patch /client/:document

Resposta: Status 200 Update

{
  "message": "Updated client"
}

Resposta: Status 404 Not Found

{
  "message": "Client not found!"
}

Delete /client/:document

Resposta: Status 200 OK

{
  "message": "Client deleted with sucess!"
}

Resposta: Status 404 Not Found

{
  "message": "Client not found!"
}



Client info

Post /client/:document/info

Regras:

  • email : string
  • telephone : number
{
  "telephone": 5465448,
  "email": "[email protected]"
}

Resposta: Status 201 Created

{
  "message": "Information entered successfully!"
}

Resposta: Status 404 Not Found

{
  "message": "Client not found!"
}

Get /client/:document/info

Resposta: Status 200

{
	"document": "89999999999999",
	"name": "Empresa Devedora LTDA",
	"type": "Juridico",
	"clientInfo": [
		{
			"id": 5,
			"telephone": 5465448,
			"email": "[email protected]"
		}
	]
}

Resposta: Status 404 Not Found

{
  "message": "Client not found"
}

Patch /client/:document/info/:idContact

{
  "telephone": 22222222,
  "email": "[email protected]"
}

Resposta: Status 200 Update

{
  "message": "Contact updated with sucess!"
}

Resposta: Status 400 Bad Request

{
  "message": "Client contact not found!"
}

Resposta: Status 404 Not Found

{
  "message": "Client not found"
}

Delete /client/:document/info/:idContact

Resposta: Status 200

{
  "message": "Contact deleted with sucess!"
}

Resposta: Status 400 Bad Request

{
  "message": "Client contact not found!"
}

Resposta: Status 404 Not Found

{
  "message": "Client not found"
}

Inicio API


Bank

Regras :

name : string, status : boolean

Post /bank

{
  "name": "Banco MaxDev",
  "status": true
}

Resposta: Status 201 Created

{
  "name": "Banco MaxDev",
  "status": true,
  "id": 7
}

Resposta: Status 409 Conflict

{
  "message": "Bank already exists!"
}

Get /bank

Resposta: Status 200

{
  "id": 7,
  "name": "Banco MaxDev",
  "status": true,
  "bankContact": []
}

Patch /bank/:id

{
  "name": "Banco MaxProPlus"
}

Resposta: Status 200

{
  "message": "Updated Bank!"
}

Resposta: Status 404 Not Found

{
  "message": "Bank not found!"
}

Delete /bank/:id

Resposta: Status 200

{
  "message": "Bank deleted witdh sucess!"
}

Resposta: Status 404 Not Found

{
  "message": "Bank not found!"
}



Bank Info

Regras :

email : string, telephone : number

Post /bank/:id/contact

{
  "telephone": 122222,
  "email": "[email protected]"
}

Resposta: Status 200 OK

{
  "message": "Information entered successfully!"
}

Resposta: Status 404 Not Found

{
  "message": "Bank not found!"
}

Resposta: Status 404 Not Found

{
  "message": "information already exists!"
}

Get /bank/id/contact

Resposta: Status 200

{
  "id": 7,
  "name": "Banco MaxProPlus",
  "status": true,
  "bankContact": [
    {
      "id": 2,
      "telephone": 122222,
      "email": "[email protected]"
    }
  ]
}

Resposta: Status 404 Not Found

{
  "message": "Bank not found!"
}

Patch /bank/:id/contact/:idContact

{
  "telephone": 999999999,
  "email": "[email protected]"
}

Resposta: Status 200

{
  "message": "Bank Contact updated sucess!"
}

Resposta: Status 404 Not Found

{
  "message": "Bank not found!"
}

Resposta: Status 404 Not Found

{
  "message": "Bank Contact not found!"
}

Delete /bank/:id/contact/:idContact

Resposta: Status 200

{
  "message": "Bank contact deleted witdh sucess!"
}

Resposta: Status 404 Not Found

{
	"message": "Bank not found!"
}

Resposta: Status 404 Not Found

{
	"message": "Bank contact not found!"
}

Inicio API


Debts

Post /debts

  • bankId,debtValue,debtOrigin,ipoc : number

  • debType,dateDebt,documentClient, : string (debType - "emprestimo","credito")

{
		"bankId": 1,
	 "documentClient": "334556232147",
    "debtType": "emprestimo",
    "debtValue": 1000,
    "ipoc": 166445411,
    "debtOrigin": 500,
    "dateDebt": "2020-01-01"
}

Resposta: Status 201 Created

{
	"bank": {
		"id": 1,
		"name": "Caixa",
		"status": true,
		"bankContact": []
	},
	"client": {
		"document": "334556232147",
		"name": "Pereira",
		"type": "Fisico",
		"clientInfo": []
	},
	"dateDebt": "2020-01-01T00:00:00.000Z",
	"debtOrigin": 500,
	"debtValue": 1000,
	"ipoc": "166445411",
	"debtType": "emprestimo",
	"id": 1,
	"registration": "2022-07-20T20:22:53.676Z",
	"debtStatus": true
}

Resposta: Status 400 Bad Request

{
	"error": "ValidationError",
	"message": "Document Client required."
}

Resposta: Status 400 Bad Request

{
	"error": "ValidationError",
	"message": "Ipoc required."
}

Resposta: Status 400 Bad Request

{
	"error": "ValidationError",
	"message": "Bank ID required."
}

Obs: caso não possua todos os dados no JSON sera dado a resposta de Bad Request


Get all debts/debts

Resposta: Status 200 OK

{
		"id": 1,
		"ipoc": "166445411",
		"debtValue": "1000.00",
		"debtOrigin": "500.00",
		"debtType": "emprestimo",
		"registration": "2022-07-20T20:22:53.676Z",
		"dateDebt": "2020-01-01T00:00:00.000Z",
		"debtStatus": true
	},
	{
		"id": 2,
		"ipoc": "166445711",
		"debtValue": "2000.00",
		"debtOrigin": "1100.00",
		"debtType": "credito",
		"registration": "2022-07-20T20:28:30.621Z",
		"dateDebt": "2021-01-01T00:00:00.000Z",
		"debtStatus": true
	}

Get /debts/:id

Resposta: Status 200 OK

{
	"id": 2,
	"ipoc": "166445711",
	"debtValue": "2000.00",
	"debtOrigin": "1100.00",
	"debtType": "credito",
	"registration": "2022-07-20T20:28:30.621Z",
	"dateDebt": "2021-01-01T00:00:00.000Z",
	"debtStatus": true,
	"client": {
		"document": "334556232147",
		"name": "Pereira",
		"type": "Fisico",
		"clientInfo": []
	},
	"bank": {
		"id": 1,
		"name": "Caixa",
		"status": true,
		"bankContact": []
	}
}

Resposta: Status 400 Not Found

{
  "message": "Debt not found"
}

Inicio API


UserDebts

Post /debts/:userId

  • debts : string
{

	"debts": ["1", "2"]

}

Resposta: Status 200 OK

{
	"message": "Successfully allocated debts"
}

Resposta: Status 404 Not Found

{
	"message": "Debt not found!"
}

Get /user/debts/me

Resposta: Status 200 OK

[
	{
		"id": 1,
		"name": "teste",
		"position": "ADM",
		"debts": [
			{
				"id": 1,
				"ipoc": "166445411",
				"debtValue": "1000.00",
				"debtOrigin": "500.00",
				"debtType": "emprestimo",
				"registration": "2022-07-20T20:22:53.676Z",
				"dateDebt": "2020-01-01T00:00:00.000Z",
				"debtStatus": true
			},
			{
				"id": 2,
				"ipoc": "166445711",
				"debtValue": "2000.00",
				"debtOrigin": "1100.00",
				"debtType": "credito",
				"registration": "2022-07-20T20:28:30.621Z",
				"dateDebt": "2021-01-01T00:00:00.000Z",
				"debtStatus": true
			}
		]
	}
]

Agreement

Post /agreement

{
	"agreedValue": 2000,
	"dateAgree": "20-3-21",
  "status": true,
	"bank": 2,
	"client": "334556232147",
	"user": 8,
	"formOfPayment": 2
}

Resposta: Status

{}

Get /agreement

Resposta: Status

[
	{
		"id": 1,
		"agreedvalue": "2000.00",
		"dateagree": "2022-01-01T00:00:00.000Z",
		"status": true,
		"formOfPayment": "a vista",
		"valueEntry": "2000",
		"installments": "1x"
	}
]

Get /agreement/:debtsId

Resposta: Status 200

{
	"id": 1,
	"agreedvalue": "2000.00",
	"dateagree": "2022-01-01T00:00:00.000Z",
	"status": true,
	"formOfPayment": "a vista",
	"valueEntry": "2000",
	"installments": "1x"
}

Resposta: Status 404 Not Found

{
	"message": "Agreement not found!"
}

Patch /agreement/:id

agreedvalue,dateagree:string status:boolean

{
  "agreedvalue":"1800.00",
  "dateagree":"2022-01-10",
  "status":false
}

Resposta: Status 200

{
	"message": "Updated Agreement!"
}

Resposta: Status 200

{
	"message": "Agreement not found!"
}

Delete /agreement/:id

Resposta: Status 200 Ok

{
	"message": "Agreement deleted with sucess!"
}

Inicio API


User

Obs: CRUD de usuario só pode ser realizado com usuario ADM ou HR

Post /user

Regras:

  • name,email,document,address,position : string
{
 		"telephone": 21331233,
   	"address":"Rua 1",
    "email": "[email protected]", 
   	"name": "Pedro Paulo",
		"password": "testE123-",
		"position": "HR"
}

Resposta: Status 201 Created

{
	"id": 4,
	"name": "Pedro Paulo",
	"position": "HR",
	"infos": {
		"email": "[email protected]",
		"telephone": "21331233",
		"address": "Rua 1"
	}
}

Resposta: Status 400 Bad Request

{
	"message": "User already exists!"
}

Resposta: Status 400 Bad Request

{
	"error": "ValidationError",
	"message": "The password must contain an uppercase letter, a number and a special character."
}

Get all users/user

Resposta: Status 200

[
	{
		"id": 1,
		"name": "Ana",
		"position": "ADM"
	},
	{
		"id": 2,
		"name": "Julio",
		"position": "user"
	},
	{
		"id": 3,
		"name": "Paula",
		"position": "HR"
	},
	{
		"id": 4,
		"name": "Pedro Paulo",
		"position": "HR"
	}
]

GET /user/:id

Resposta: Status 200 Update

{
	"id": 2,
	"name": "Julio",
	"position": "user",
	"infos": {
		"email": "[email protected]",
		"telephone": 21331233,
		"address": "Rua 45"
	}
}

Resposta: Status 404 Not Found

{
  "message": "User not found!"
}

GET /user/debts/me ( dividas alocadas ao usuario)

Resposta: Status 200 Update

[
	{
		"id": 1,
		"name": "teste",
		"position": "ADM",
		"debts": []
	}
]

Resposta: Status 404 Not Found

{
  "message": "User not found!"
}

Patch /user/:id

Regras:

Obritorio - name : string

{
    "telephone": 21331233,
   	"address":"Rua 1",
    "email": "[email protected]", 
   	"name": "Pedro Paulo",
		"position": "HR"
}

Resposta: Status 200

{
  "message": "User updated!"
}

Resposta: Status 400 Bad Request

{
  "message": "User does not exists!"
}

Delete /user/:id

Resposta: Status 200

{
  "message": "User deleted with sucess!"
}

Resposta: Status 404 Not Found

{
  "message": "User not found!"
}



Inicio API

ContactHistory


Post /history

  • date_contact,note: string
  • debtId,userId:number
  • agreement: boolean
{
	"date_contact":"2022-01-01",
	"agreement":false,
	"note":"faltou ligar",
	"debtId":5,
	"userId":2
}

Resposta: Status 201 Created

{
	"date": "2022-01-01",
	"agreement": false,
	"note": "faltou ligar",
	"debts": 5,
	"user_entry_contact": "Maicel"
}

Get /history

Resposta: Status

{
		"id": 7,
		"agreement": false,
		"date_contact": "2022-01-01T00:00:00.000Z",
		"note": "faltou ligar"
}

Patch /history/:id

  • note,date_contact: string
  • agreement: boolean
{
	"note":"cliente atendeu mas não quis negociar",
	"date_contact":"2022-07-19"
}

Resposta: Status 200 Ok

{
	"message": "Update contact History"
}

Resposta: Status 400 Not Found

{
	"message": "Contact history not found!"
}

Delete /history/:id

Resposta: Status 200

{
	"message": "Contact history not found!"
}

Resposta: Status 404 Not Found

{
	"message": "Contact history not found!"
}

Inicio API


Tecnologias

As seguintes ferramentas foram usadas na construção do projeto:

Devs


Danilo Valerio

🚀

Letícia Leal

🚀

Bráulio Silveira

🚀

Maciel A. Junior

🚀

Vinícius Martins

🚀

Vitor Schmidt

🚀

Inicio

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages