A Project Skeleton to build Kotlin apps with Gradle and Ktor
-
Un usuario se puede registrar para gestionar sus reservas online
- El usuario necesita dni, nombre, apellidos, fecha de nacimiento, email y numero de telefono para registrarse
- No se puede repetir ni dni, email ni numero de telefono
-
Listar todos los libros de la biblioteca
- Un usuario deberia poder visualizar todos los libros de la biblioteca, con informacion sobre que libros estan disponibles y cuales no
-
Añadir libros a la biblioteca
- Un administrador podra añadir libros nuevos a la biblioteca
- Un libro debe tener informacion sobre su ISBN, titulo, autor, numero de paginas, editorial y año de publicacion
- La biblioteca puede tener varias copias del mismo libro
-
Retirar un libro
- Un usuario deberia poder retirar un libro si esta disponible (no prestado a otros usuarios)
- Un usuario solo puede tener prestados un maximo de 5 libros a la vez
-
Devolver un libro
- Un usuario ha de poder devolver un libro prestado.
GET /account
Retrieves all accounts
?filter[phoneNumber]
Filter accounts where phone number contains {phoneNumber}
?filter[email]
Filter accounts where email contains {email}
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": [
{
"id": "00000000-0000-0000-0000-000000000000",
"type": "account"
"attributes": {
"name": "John",
"surname": "Doe",
"email": "john.doe@email.example",
"identityNumber": "B01234567",
"phonePrefix": "+44",
"phoneNumber": "600123456",
"birthdate": "1970-01-01",
"registerDate": "2020-01-01T00:00:00Z",
"currentLoans": 2,
"totalLoans": 4
}
}
],
"meta": {
"total": 1
}
}
GET /account/{accountId}
Retrieves account with id {accountId}
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "account"
"attributes": {
"name": "John",
"surname": "Doe",
"email": "john.doe@email.example",
"identityNumber": "B01234567",
"phonePrefix": "+44",
"phoneNumber": "600123456",
"birthdate": "1970-01-01",
"registerDate": "2020-01-01T00:00:00Z",
"currentLoans": 2,
"totalLoans": 4
}
}
}
POST /account
Creates a new account
Content-Type: application/vnd.api+json
{
"data": {
"type": "account"
"attributes": {
"name": "John",
"surname": "Doe",
"email": "john.doe@email.example",
"identityNumber": "B01234567",
"phonePrefix": "+44",
"phoneNumber": "600123456",
"birthdate": "1970-01-01"
}
}
}
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"type": "account"
"attributes": {
"name": "John",
"surname": "Doe",
"email": "john.doe@email.example",
"identityNumber": "B01234567",
"phonePrefix": "+44",
"phoneNumber": "600123456",
"birthdate": "1970-01-01",
"registerDate": "2020-01-01T00:00:00Z",
"currentLoans": 0,
"totalLoans": 0
}
}
}
GET /book
Retrieves all books
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"data": [
{
"id": "00000000-0000-0000-0000-000000000000",
"type": "book",
"attributes": {
"isbn": "10000000-0000-0000-0000-000000000000",
"title": "Life of John Doe",
"author": "John Doe",
"pages": 90,
"publisher": "John Doe Publishing Inc.",
"copies": 2,
"availableCopies": 0
}
},
{
"id": "00000000-0000-0000-0000-000000000001",
"type": "book",
"attributes": {
"isbn": "10000000-0000-0000-0000-000000000001",
"title": "Life of John Doe (Volume II)",
"author": "John Doe",
"pages": 166,
"publisher": "John Doe Publishing Inc.",
"copies": 3,
"availableCopies": 2
}
}
],
"meta": {
"total": 2
}
}
GET /book/{bookId}
Retrieves book with id {bookId}
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"id": "00000000-0000-0000-0000-000000000000",
"type": "book"
"data": {
"attributes": {
"author": "John Doe",
"isbn": "00000000-0000-0000-0000-000000000000",
"pages": 90,
"publisher": "John Doe Publishing Inc.",
"title": "Life of John Doe"
}
}
}
POST /account
Creates a new book
Content-Type: application/vnd.api+json
{
"data": {
"type": "book"
"attributes": {
"author": "John Doe",
"isbn": "00000000-0000-0000-0000-000000000000",
"pages": 90,
"publisher": "John Doe Publishing Inc.",
"title": "Life of John Doe"
}
}
}
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
{
"id": "00000000-0000-0000-0000-000000000000",
"type": "book"
"data": {
"attributes": {
"author": "John Doe",
"isbn": "00000000-0000-0000-0000-000000000000",
"pages": 90,
"publisher": "John Doe Publishing Inc.",
"title": "Life of John Doe"
}
}
}
GET /loan
Retrieves all loans
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
XXX
GET /loan/{loanId}
Retrieves loan with id {loanId}
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
xxx
POST /loan
Creates a new loan
Content-Type: application/vnd.api+json
xxxx
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
xxxx
DELETE /loan/{bookId}
Finishes the loan for the book with id {bookId}
HTTP/1.1 202 Accepted
Content-Type: application/vnd.api+json
xxxx