wallet

command module
v0.0.0-...-8f95268 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 9 Imported by: 0

README

Cypto.com assignment

Contents

  • Quick start
  • Decisions
    • use RDBMS to make trade data consistency
    • use repository pattern to encapsulate DB access
  • how long you spent on the test
    • around 6-8 hours

Quick start

There are two methods that can launch the application.

  1. via the Makefile to setup the application (recommend)
make run
  1. through the docker-compose to buildup the application manually
docker-compose up --build

How to use

  • The server is listening to 8080 port, you can change it in the docker-compose.yaml

authorization

  • add header {"Authorization", {token}} in your HTTP.Header
  • for simplicity, we have some hardcode tokens to handle it
['Tim', 'Alex', 'Arthur', 'Ray', 'HD', 'peko', 'miko', 'rushia', 'gura', 'Ame']
withdraw
POST: localhost:8080/api/v1/wallet/withdraw

Header: {
    "Authorization": {{token}},
    "Content-Type": "application/json"
}

RequestBody: {
	"amount": integer (required)
}

Response:
	200: OK
	400: BadRequest
	401: Unauthorized
	500: serverError 

Deposit
POST: localhost:8080/api/v1/wallet/deposit

Header: {
    "Authorization": {{token}},
    "Content-Type": "application/json"
}

RequestBody: {
	"amount": integer (required)
}

Response:
	200: OK
	400: BadRequest
	401: Unauthorized
	500: serverError 

Transfer
POST: localhost:8080/api/v1/wallet/transfer

Header: {
    "Authorization": {{token}},
    "Content-Type": "application/json"
}

RequestBody: {
	"toAccount": string (required)
	"amount": integer (required)
}

Response:
	200: OK
	400: BadRequest
	401: Unauthorized
	500: serverError 
GetAccount
GET: localhost:8080/api/v1/wallet/account

Header: {
    "Authorization": {{token}}
}

Response:
	200: OK
	401: Unauthorized
	500: serverError 

Others

  1. build images
make build
  1. clean up the environment
make clean

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL