Git Product home page Git Product logo

bowling_api's Introduction

Bowling API

Rules of scoring for ten-pin bowling:

https://en.wikipedia.org/wiki/Ten-pin_bowling

http://slocums.homestead.com/gamescore.html

To run the application:

  1. Clone this repo locally

    $ git clone [email protected]:svetlik/bowling_api.git

  2. Run the Rails server:

    $ rails s

  3. Call the JSON API. You can use Postman, in which case, there is a collection file Bowling_API.postman_collection.json added to the project, that you can import, and execute the calls from.

Alternatively, there is a Demo currently live at Heroku where you can address calls to the API directly.


API Documentation

Endpoints:

POST /api/games

Creates a new game, and returns its ID for easier initial reference.

{
  "id": 2354
}

GET /api/games/:id

Show details about a game by its id. Will return id, score, frames, current_frame, last_roll_score:

{
    "id": 2205,
    "score": 115,
    "frames": [
        [
            "3",
            "3",
            null
        ],
        [
            "10",
            "4",
            "5"
        ],
        [
            "4",
            "5",
            null
        ],
        [
            "6",
            "3",
            null
        ],
        [
            "10",
            "10",
            "10"
        ],
        [
            "10",
            "10",
            "4"
        ],
        [
            "10",
            "4",
            null
        ],
        [
            "4",
            null,
            null
        ],
        [
            null,
            null,
            null
        ],
        [
            null,
            null,
            null
        ]
    ],
    "last_frame": 7,
    "last_roll_score": 4
}

Response: HTTP OK 200

PUT/PATCH /api/games/:id?roll_score=:integer

Adds score to the frame, and updates the game score. The roll_score value must be an integer between 0 and 10.

Response: HTTP 204 No Content

In case of erratic input, the following errors should be displayed:

  • in case of input different than an integer:
"Throw score cannot be a non-integer symbol"
  • in case of second throw for a frame, if given input adds up to more than 10, a message about the maximum number that should the input be equal to:
"Pin number cannot exceed 2."
  • in case an integer bigger than 10 is given:
"Throw score cannot be more than 10."
  • in case an attempt to update the game has been made after the last frame:
"Game has already ended."

bowling_api's People

Contributors

svetlik avatar

Watchers

 avatar  avatar

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.