Based in real coins with value 50, 10, 5, and 1, this api calculate how many coins will be used based on value.
- docker 19 or latest
- docker-compose 1.27 or latest
- make command
$ make test
$ make run-docker \\ Runs docker-compose with application image and its requirements
$ make run-docke-clean \\ Run a clean build image from docker application
Open API Docs at ./docs/swagger.yml
Analise the coins for amount
Name | Located in | Description | Required | Schema |
---|---|---|---|---|
amount | query | Pass the amount you want withdrawal | Yes | number |
Code | Description | Schema |
---|---|---|
200 | Complete analysis | AnalysisResponse |
400 | bad input parameter |
Name | Type | Description | Required |
---|---|---|---|
amount | number | Example: 1987 |
Yes |
coins | Coins | Yes |
Name | Type | Description | Required |
---|---|---|---|
1 | integer | Example: 2 |
No |
5 | integer | Example: 1 |
No |
10 | integer | Example: 3 |
No |
50 | integer | Example: 39 |
No |
[GET] http://0.0.0.0:8080/withdrawal?amount=1987
{
"amount": 1987,
"coins": {
"1": 2,
"5": 1,
"10": 3,
"50": 39
}
}
- github.com/go-redis/redis/v8 - Main redis package from golang community
- github.com/google/uuid - Main package for uses uuid
- github.com/sirupsen/logrus - Easy way to log the application
- github.com/stretchr/testify - Used for unit test assertions and mocks
The application will consult the redis before to analise the value.
├── build ##Docker configuration
│ └── docker
│ ├── Dockerfile
│ └── start.server.sh
├── config
│ ├── container ## Injection Container
│ │ ├── container.go
│ │ └── container_test.go
│ └── routes ## Routes
│ ├── routes.go
│ └── routes_test.go
├── docker-compose.yml
├── docs
│ ├── swagger.yml
│ └── withdrawal.get.v1.plantuml
├── go.mod
├── go.sum
├── internal
│ ├── httpserver ## net/http abstraction
│ │ ├── errors.go
│ │ ├── httpserver.go
│ │ ├── httpserver_test.go
│ │ └── responses.go
│ ├── primary ## Primari ports
│ │ └── v1.withdrawalhttp
│ │ ├── withdrawal.go
│ │ └── withdrawal_test.go
│ └── secondary ## Secondary ports
│ └── cache
│ ├── redis.go
│ └── redis_test.go
├── LICENSE
├── main.go
├── Makefile
├── pkg
│ └── domain ## main logic
│ └── v1.withdrawal
│ ├── enum.go
│ ├── service.go
│ ├── service_test.go
│ └── types.go
├── README.md
└── tools
└── logger
├── logger.go
└── logger_test.go