REST API to create and interact with decks of playing cards.
- Go 1.16
- Either run directly using
go run .or build and run usinggo build - Run all unit tests using
go test ./...
All the params need to be provided in body as JSON
POST /deck Creates a new deck according to the provided params.
| param | type | default | description |
|---|---|---|---|
| shuffle | boolean, optional | false | If true, the deck will be created in shuffled order |
To create custom deck user need to provide cards in Query. ex. http://localhost:8000/deck?cards=AS,KD,AC,2C,KH
| param | type | description |
|---|---|---|
| deck_id | string | UUID of the created deck |
| shuffled | boolean | Indicates whether the deck was shuffled during creation |
| remaining | integer | The number of cards remaining in the deck |
GET /deck/{deck_uuid} Returns the deck corresponding to the provided deck UUID
| param | type | description |
|---|---|---|
| deck_id | string | UUID of the returned deck |
| shuffled | boolean | Indicates whether the deck was shuffled during creation |
| remaining | integer | remaining cards in the deck |
| cards | array of card objects {suit string, value string, code string} |
Deck of cards |
PUT /deck/{deck_uuid} Returns n cards from the top of the deck corresponding to the provided deck UUID
| param | type | default | description |
|---|---|---|---|
| numberofcards | integer | N/A | The number of cards to draw. Must be greater than 0. |
| param | type | description |
|---|---|---|
| cards | array of card objects {suit string, value string, code string} |
The drawn cards. |
- For testing api user has to provide the newely generated
UUIDwherever its required in the request url. - Start the server by building the package or execute command
go run .for testing - Command for running test is
go test ./...