Giter VIP home page Giter VIP logo

unnatended-test's Introduction

Unnatended test

API to provide the functionalities to create a deck that provides three endpoints:


  • GET /deck/:deckId

Open a deck by your id. Example:

$ curl localhost:3000/deck/6ab9cd50-24b3-45d2-93df-76b627a27c5e

  {
    "deck_id": "6ab9cd50-24b3-45d2-93df-76b627a27c5e",
    "shuffled": false,
    "remaining": 3,
    "cards": [
      {
        "value": "ACE",
        "suit": "SPADES",
        "code": "AS",
      },
      {
        "value": "KING",
        "suit": "HEARTS",
        "code": "KH",
      },
      {
        "value": "8",
        "suit": "CLUBS",
        "code": "8C",
      },
    ]
  }

  • POST /deck or POST /deck?cards=AS,KD,AC,2C,KH or POST /deck?cards=AS,KD&shuffle=true

Create a deck passing or not the cards you would like in the deck and if the deck is shuffled or not, by default the deck is not shuffled. Example:

Create a standard deck with 52 playing cards:

$ curl -X POST localhost:3000/deck

 {
    "deck_id": "6ab9cd50-24b3-45d2-93df-76b627a27c5e",
    "shuffled": false,
    "remaining": 52
 }

Create a custom deck:

$ curl -X POST --url "localhost:3000/deck?cards=AS,KD,QH"

 {
    "deck_id": "db940885-274c-4d63-a1db-17088d4f73d4",
    "shuffled": false,
    "remaining": 3
 }

Create a shuffled custom deck:

$ curl -X POST --url "localhost:3000/deck?cards=AS,KD,QH&shuffle=true"

 {
    "deck_id": "e7cb2982-6e76-49c0-a87c-1f95dffb5e2c",
    "shuffled": true,
    "remaining": 3
 }

  • POST /deck/:deckId/:count

Draw card(s) from a deck. Example:

$ curl -X POST --url "localhost:3000/deck/e7cb2982-6e76-49c0-a87c-1f95dffb5e2c/1"

 {
    "cards": [
      {
        "value": "ACE",
        "suit": "SPADES",
        "code": "AS",
      },
 }

Dependencies

  • Go 1.17.9

How to run the project

Start the server

$ make start

The API will start in the port 3000


If you would like to run the tests

Run tests

$ make test

If you would like to build the project

Build project

$ make build

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.