Skip to content

GeorgiiVoyakin/travel-agency-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

travel-agency-api

REST API for travel agency

Run

Using docker:

docker compose up

API endpoints

Cities

Get all cities

GET /cities

Response

[
  {
    "id" : 1,
    "name" : "Moscow"
  },
  {
    "id" : 2,
    "name" : "Tambov"
  }
]

Get city by id

GET /cities/{id}

Response

{
  "id" : 1,
  "name" : "Moscow"
}

Add new city

POST /cities

Request params

Param Type Description
name String City name

Response

{
  "id": 3,
  "name": "Tomsk"
}

Update city

PATCH /cities/{id}

To make tours from city to country pass country id in request.

Request params

Param Type Description
optionalName String City name
optionalCountryId Long Country id

Response

{
  "id": 3,
  "name": "Omsk"
}

Delete city by id

DELETE /cities/{id}

Countries

Get all countries

GET /countries

Response

[
  {
    "id" : 1,
    "name" : "Russia"
  },
  {
    "id" : 2,
    "name" : "Turkey"
  }
]

Get country by id

GET /countries/{id}

Response

{
  "id" : 1,
  "name" : "Russia"
}

Add new country

POST /countries

Request params

Param Type Description
name String Country name

Response

{
  "id": 3,
  "name": "Italy"
}

Update country

PATCH /countries/{id}

Request params

Param Type Description
optionalName String City name
optionalCityId Long City id
optionalTourId Long Tour id

Response

{
  "id": 3,
  "name": "Omsk"
}

Delete country by id

DELETE /countries/{id}

Tours

Get all tours

GET /tours

Response

[
  {
    "id" : 1,
    "name" : "tour-name-1",
    "description" : "Description",
    "price" : 3000,
    "distance" : 500,
    "seaResort" : true,
    "beach" : "Sand",
    "wirelessInternet" : true,
    "meal" : true
  },
  {
    "id" : 2,
    "name" : "tour-name-2",
    "description" : "Description",
    "price" : 5000,
    "distance" : null,
    "seaResort" : false,
    "beach" : null,
    "wirelessInternet" : false,
    "meal" : true
  }
]

Get tour by id

GET /tours/{id}

Response

{
  "id" : 1,
  "name" : "tour-name-1",
  "description" : "Description",
  "price" : 3000,
  "distance" : 500,
  "seaResort" : true,
  "beach" : "Sand",
  "wirelessInternet" : true,
  "meal" : true
}

Add new tour

POST /tours/countries/{country_id}

County id - id of country where tour is located.

Request params

Param Type Description
name String City name
description String Description of the tour
price Long Tour price per one day for one person
optionalDistance Short Distance to the sea
seaResort boolean Shows the tour is next to the sea or not
optionalBeach String Type of the beach
wirelessInternet boolean Tour has wireless internet
meal boolean Tour provides meal

Response

{
  "id" : 3,
  "name" : "tour-name-3",
  "description" : "Description",
  "price" : 3000,
  "distance" : 300,
  "seaResort" : true,
  "beach" : "Pebble",
  "wirelessInternet" : true,
  "meal" : true
}

Delete tour by id

DELETE /tours/{id}

Find tours in country by parameters

GET /tours/find/{country_id}

Returns list of available tours from city to country with calculated prices.

Request params

Param Type Description
cityId Long City id
days int Amount of days
people int Amount of people

Response

[
  {
    "id" : 1,
    "name" : "tour-name-1",
    "description" : "Description",
    "calculatedPrice" : 6000,
    "distance" : 500,
    "seaResort" : true,
    "beach" : "Sand",
    "wirelessInternet" : true,
    "meal" : true
  },
  {
    "id" : 2,
    "name" : "tour-name-2",
    "description" : "Description",
    "calculatedPrice" : 10000,
    "distance" : null,
    "seaResort" : false,
    "beach" : null,
    "wirelessInternet" : false,
    "meal" : true
  }
]