Skip to content

vadim-hleif/ktor-simple-rest-service

Repository files navigation

Ktor-simple-rest-service

Unit tests

What is it

A simple example of rest api service, without db and authentication. Data will be generated at the runtime.

Domain is flat viewing schedule. It allows reserving slots from tenant side, and rejected or approve reservation from landlord side. Once rejected slot can't be used anymore.

Viewing slots will be generated for 7 upcoming days, the first slot will be available in 24h after application start. Time window of each slot is 20 minutes.

Each action (reservation, cancellation, approving, rejection) will be logged in the console.

REST API

Get all flats (with slots inside and references to landlords)

curl --location --request GET 'http://127.0.0.1:8080/flats'

Get all tenants

curl --location --request GET 'http://127.0.0.1:8080/tenants'

Reserve the slot by the tenant

curl --location --request PATCH 'http://localhost:8080/flats/214/slots/1' \
--header 'Content-Type: application/json' \
--data-raw '{"tenantId": 639}'

Approve reservation

curl --location --request PATCH 'http://localhost:8080/flats/214/slots/1' \
--header 'Content-Type: application/json' \
--data-raw '{"state": "APPROVED"}'

Reject reservation

curl --location --request PATCH 'http://localhost:8080/flats/214/slots/1' \
--header 'Content-Type: application/json' \
--data-raw '{"state": "REJECTED"}'

Release the reservation

curl --location --request DELETE 'http://localhost:8080/flats/214/slots/1'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages