The goal is to write a JSON API in Golang to get the balance and manage credit/debit operations on the players wallets. For example, you might receive calls on your API to get the balance of the wallet with id 123, or to credit the wallet with id 456 by 10.00 €. The storage mechanism to use will be MySQL.
The following endpoints are exposed Baseurl = localhost Port = 8080
- GET
- /api/v1/wallets/{wallet_id}/balance
- POST
- /api/v1/wallets/{wallet_id}/credit
- POST
- /api/v1/wallets/{wallet_id}/debit
This endpoint is required in order to implement the authorization middleware and associate a specific player to a wallet
- POST
- /api/v1/players
- GET
- /api/v1/players/{id}
- PUT
- /api/v1/players/{id}
- DELETE
- /api/v1/players/{id}
- POST
- /api/v1/players/login
The API documentation can be visited on postman to interact with endpoints to display the JSON response and sample error codes https://www.postman.com/bold-desert-829444/workspace/quik
- cd /cmd/api
- go build Or use air a development tool to generate an executable file in tmp dir
This test coverage is focused on the business logic for crediting and debiting players wallet
- cd /wallet/service
- go test -v
- cd /wallet/service
- go test -cover
This result into a coverage of 76.3% covering all the edge cases of the business logic