Viniciuscardozo20 / challenge-bravo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Desafio Challenge Bravo

Candidato: Vinicius da Silva Cardozo

LinkedIn: https://www.linkedin.com/in/vinicius-cardozo-669a15136/

Recrutadoras: Paloma Andrade e Beatriz Cristine

Requesitos

Setup

Após clonar o repositório, é necessário ir no caminho raiz e rodar o seguinte comando

docker-compose up

Isso subirá a API na porta 8082

Rotas

Adicionar uma nova moeda

METÓDO POSTv1/

/v1/addCurrency

Exemplo

No terminal execute

curl --location --request POST 'http://localhost:8082/v1/addCurrency' \
--header 'Content-Type: application/json' \
--data-raw '{
    "initials": "AUD", 
  }'

Ou em alguma outra interface tipo Postman ou Insomnia Body (application/json):

{
    "initials": "AUD"
}

Saída esperada

Status http: 200 OK

{
  "status": "Created",
  "data": {
    "initials": "AUD"
  }
}

Converter moedas

METÓDO GET

/v1/currencyConvert

Parametros:

  • From: Sigla da moeda base
  • To: Sigla da moeda para ser convertida
  • Amount: Quantidade a ser convertida

Exemplo

No terminal execute

curl --location --request GET 'http://localhost:8082/v1/currencyConvert?from=USD&to=BRL&amount=70'

Ou em alguma outra interface preferência, tipo Postman ou Insomnia

Saída esperada

Status http: 200 OK

{
  "status": "success",
  "data": {
    "From": "USD",
    "To": "BRL",
    "Amount": 70,
    "Value": 383.074899284
  }
}

Deletar uma moeda

METÓDO DELETEv1/

/v1/deleteCurrency/:currency

Parametros:

  • currency: Sigla da moeda a ser deletada

Exemplo

No terminal execute

curl --location --request DELETE 'http://localhost:8082/v1/deleteCurrency/AUD' 

Ou em alguma outra interface de sua preferência, tipo Postman ou Insomnia

Saída esperada

Status http: 200 OK

{
  "status": "success"
}

Receber todas moedas

METÓDO GETv1/

/v1/getCurrencies

Parametros:

  • currency: Sigla da moeda a ser deletada

Exemplo

No terminal execute

curl --location --request GET 'http://localhost:8082/v1/getCurrencies' 

Ou em alguma outra interface de sua preferência, tipo Postman ou Insomnia

Saída esperada

Status http: 200 OK

{
  "AUD": 1.2976239415,
  "BRL": 5.4724985612,
  "BTC": 0.00002886,
  "ETH": 0.0009379,
  "EUR": 0.8221655841,
  "USD": 1
}

Executar os testes

Requesitos

  • GoLang 1:15

Para executar os testes feitos é necessario entrar na pasta ./api do projeto e rodar o comando:

make run-tests

A saída esperada será a seguinte:

  go test -race -coverpkg= ./... -coverprofile=./test/cover/cover.out
  ?       challenge-bravo/api     [no test files]
  ?       challenge-bravo/api/app [no test files]
  ok      challenge-bravo/api/controller  3.239s  coverage: 62.5% of statements
  ok      challenge-bravo/api/currency    3.212s  coverage: 62.2% of statements
  ok      challenge-bravo/api/currency/currency_updater   1.597s  coverage: 75.0% of statements
  ?       challenge-bravo/api/handlers/addCurrency        [no test files]
  ?       challenge-bravo/api/handlers/convert    [no test files]
  ?       challenge-bravo/api/handlers/deleteCurrency     [no test files]
  ?       challenge-bravo/api/handlers/getCurrencies      [no test files] 

About


Languages

Language:Go 97.3%Language:Makefile 1.5%Language:Dockerfile 1.2%