Giter VIP home page Giter VIP logo

hike-api's Introduction

Hike API

Application meant for getting hike recommendations.

Built with Java 17, Spring Boot & H2.

Initial data is loaded from src/main/resources/data.sql.

Hike recommendation overview

๐Ÿ“ฅ Information that will be provided:

  • Kilometers (long lengthInKilometers)
  • Season (String season)

๐Ÿ“ค Information that will be returned:

  • Sleepover count (int sleepoverCount)
    • Based on kilometers
  • Food calories (int foodCalories)
    • Based on base daily calories, kilometers & season, which applies multipliers
  • Liters of water (double litersOfWater)
    • Based on kilometers & season, which applies multipliers
  • Items (List<String> items)
    • Based on season

๐Ÿ”ง Calculation modification:

In the Constants file, you can modify:

  • after how many kilometers you should sleep (with the KILOMETERS_BEFORE_SLEEP property)
  • base daily calories (with the BASE_DAILY_CALORIES property)
  • amount of calories burned per kilometer (with the CALORIES_BURNED_PER_KILOMETER property)
  • for how many kilometers 1 litre of water should be sufficient (with the KILOMETERS_PER_WATER_LITRE property)

Hikes endpoints

POST http://localhost:8080/api/v1/hikes

๐ŸŽฏ Purpose: get hike recommendations.

Success request body example:

{
    "lengthInKilometers": 200,
    "season": "winter"
}

Success response status code: 200

Success response body example:

{
  "sleepoverCount": 4,
  "foodCalories": 23000,
  "litersOfWater": 20.0,
  "items": [
    "scarf",
    "gloves",
    "earmuffs"
  ]
}

Exception request body example:

{
    "lengthInKilometers": 200,
    "season": "abc"
}

Exception response status code: 400

Exception response body example:

{
  "message": "Invalid season 'abc' provided"
}

Items endpoints

GET http://localhost:8080/api/v1/items/{id}

๐ŸŽฏ Purpose: get item.

Success response status code: 200

Success response body example:

{
    "id": 13,
    "name": "sunglasses",
    "season": "summer"
}

Exception response status code: 400

Exception response body example:

{
  "message": "Item with provided ID not found"
}

GET http://localhost:8080/api/v1/items

๐ŸŽฏ Purpose: get all items.

Success response status code: 200

Success response body example:

[
  {
    "id": 1,
    "name": "cap",
    "season": "summer"
  },
  {
    "id": 2,
    "name": "insect repellent",
    "season": "summer"
  }
]

POST http://localhost:8080/api/v1/items

๐ŸŽฏ Purpose: create item.

Request body example:

{
  "name": "Sunglasses",
  "season": "Summer"
}

Success response status code: 201

Success response body example:

{
    "id": 13,
    "name": "sunglasses",
    "season": "summer"
}

Exception request body example:

{
  "name": "Sunglasses",
  "season": "abc"
}

Exception response status code: 400

Exception response body example:

{
  "message": "Invalid season 'abc' provided"
}

DELETE http://localhost:8080/api/v1/items/{id}

๐ŸŽฏ Purpose: delete item.

Success response status code: 204

hike-api's People

Contributors

xonism avatar

Watchers

 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.