Skip to content

Repository files navigation

Ramblings

See https://kambur.ie/tips/shuffled/

Tests

This is to be automated one day :)

Create Deck

curl -X POST http://localhost:8080/deck-api/deck/create -H 'Content-Type: application/json'  -d '{
"deckType": "standard52"
}'
curl -X POST http://localhost:8080/deck-api/deck/create -H 'Content-Type: application/json'  -d '{
"deckType": "uno"       
}'

Draw a card

curl -X PATCH http://localhost:8080/deck-api/deck/draw  -H 'Content-Type: application/json'  -d '{
"deckState":"rO0ABXcUAApzdGFuZGFyZDUyAAAANAAAAAB1cgACW0p4IAS1ErF1kwIAAHhwAAAAAHVxAH4AAAAAAAEAD////////w==","deckType":"standard52"
}'
curl -X PATCH http://localhost:8080/deck-api/deck/draw  -H 'Content-Type: application/json'  -d '{
"deckState":"rO0ABXcNAAN1bm8AAABsAAAAAHVyAAJbSnggBLUSsXWTAgAAeHAAAAAAdXEAfgAAAAAAAv//////////AAAP//////8=","deckType":"uno"
}'

Return a card

StandardCard format

curl -X PUT http://localhost:8080/deck-api/deck/return  -H 'Content-Type: application/json'  -d '{
"card":{"rank":"KING","suit":"CLUBS"},"deck":{"deckState":"rO0ABXcUAApzdGFuZGFyZDUyAAAAMwAAAAB1cgACW0p4IAS1ErF1kwIAAHhwAAAAAQAAAAACAAAAdXEAfgAAAAAAAQAP////////","deckType":"standard52"}
}'

UnoCard format

curl -X PUT http://localhost:8080/deck-api/deck/return  -H 'Content-Type: application/json'  -d '{
"card":{"colour":"RED","rank":"KING","ordinal":0},"deck":{"deckState":"<base64>","deckType":"uno"}
}'

Health monitoring

curl http://localhost:8080/deck-api/health

Adding new type of Deck

Core

Implement Card and OrderedDeck.

Modify src/main/resources/META-INF/services/ie.kambur.Cards.core.interfaces.OrderedDeck to include the class name.

Rest/Json

Serialisation of ShuffledDeck should suffice but one must implement CardJsonSerialiser like StandardCardJsonSerialiser.

Register the serialiser in src/main/resources/META-INF/services/ie.kambur.Cards.service.interfaces.CardJsonSerialiser.

Useful stuff

Tomcat manual deploy

bin/catalina.sh start
build/libs/deck-api.war ~/opt/tomcat/webapps 

Deploymnet with container

See docker/Dockerfile.

As simple as

COPY build/libs/deck-api.war /usr/local/tomcat/webapps/

K8s service peekaboo

wget http://ramblings-app.ramblings.svc.cluster.local:8080/deck-api/health
curl -X POST https://deck-api.api.kambur.ie/deck-api/deck/create -H 'Content-Type: application/json'  -d '{
"deckType": "standard52"
}'

curl -X PUT https://deck-api.api.kambur.ie/deck-api/deck/return  -H 'Content-Type: application/json'  -d '{
"card":{"rank":"KING","suit":"CLUBS"},"deck":{"deckState":"rO0ABXcUAApzdGFuZGFyZDUyAAAAMwAAAAB1cgACW0p4IAS1ErF1kwIAAHhwAAAAAQAAAAACAAAAdXEAfgAAAAAAAQAP////////","deckType":"standard52"}
}'

curl -X PATCH  https://deck-api.api.kambur.ie/deck-api/deck/draw  -H 'Content-Type: application/json'  -d '{
"deckState":"rO0ABXcUAApzdGFuZGFyZDUyAAAANAAAAAB1cgACW0p4IAS1ErF1kwIAAHhwAAAAAHVxAH4AAAAAAAEAD////////w==","deckType":"standard52"
}'

API Documentation

Interactive API documentation is available at:

https://deck-api.api.kambur.ie/api-docs/swagger-ui.html

The OpenAPI spec is served at:

https://deck-api.api.kambur.ie/api-docs/shuffledDeck.yaml

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages