Resources
Library REST Service
Retrieve user books
Path parameters
Parameter | Description |
---|---|
|
User id |
Example request
GET /users/johndoe/books HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
UUID used to identify a book |
|
|
10 digits ISBN (optional) |
|
|
13 digits ISBN (optional) |
|
|
Book title |
|
|
Book authors (optional) |
|
|
First name |
|
|
Last name |
|
|
Number of pages |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 213
[{"uuid":"1e4014b1-a551-4310-9f30-590c3140b695","isbn10":"1-61729-310-5","isbn13":"978-1-61729-310-8","title":"Get Programming with JavaScript","authors":[{"firstName":"John R.","lastName":"Larsen"}],"pages":406}]
Add a new book for a user
Path parameters
Parameter | Description |
---|---|
|
User id |
Request fields
Path | Type | Description |
---|---|---|
|
|
10 digits ISBN (optional) |
|
|
13 digits ISBN (optional) |
|
|
Book title |
|
|
Book authors (optional) |
|
|
First name |
|
|
Last name |
|
|
Number of pages |
Example request
POST /users/johndoe/books HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 215
{
"isbn10": "1-61729-310-5",
"isbn13": "978-1-61729-310-8",
"title": "Get Programming with JavaScript",
"authors": [
{
"firstName": "John R.",
"lastName": "Larsen"
}
],
"pages": 406
}
Response headers
Name | Description |
---|---|
|
New added book resource |
Example response
HTTP/1.1 201 Created
Location: /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695
Add an existing book
Example request
POST /users/johndoe/books HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 215
{
"isbn10": "1-61729-310-5",
"isbn13": "978-1-61729-310-8",
"title": "Get Programming with JavaScript",
"authors": [
{
"firstName": "John R.",
"lastName": "Larsen"
}
],
"pages": 406
}
Response fields
Path | Type | Description |
---|---|---|
|
|
Error type |
|
|
Error causes |
|
|
Error causes (OPTIONAL). If present, it contains the name of the fields related with this error. |
|
|
Error key. This should be used to locate the right translation for the error |
Example response
HTTP/1.1 403 Forbidden
Content-Type: application/json;charset=UTF-8
Content-Length: 93
{"type":"DATA_VALIDATION","causes":[{"causes":["isbn10","isbn13"],"key":"book.isbn.exists"}]}
Retrieve a user book
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Book uuid |
Example request
GET /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
UUID used to identify a book |
|
|
10 digits ISBN (optional) |
|
|
13 digits ISBN (optional) |
|
|
Book title |
|
|
Book authors (optional) |
|
|
First name |
|
|
Last name |
|
|
Number of pages |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 211
{"uuid":"1e4014b1-a551-4310-9f30-590c3140b695","isbn10":"1-61729-310-5","isbn13":"978-1-61729-310-8","title":"Get Programming with JavaScript","authors":[{"firstName":"John R.","lastName":"Larsen"}],"pages":406}
Retrieve a missing user book
Example request
GET /users/johndoe/books/missing-uuid-1 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found
Update a user book
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Book uuid |
Request fields
Path | Type | Description |
---|---|---|
|
|
10 digits ISBN (optional) |
|
|
13 digits ISBN (optional) |
|
|
Book title |
|
|
Book authors (optional) |
|
|
First name |
|
|
Last name |
|
|
Number of pages |
Example request
PUT /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 207
{
"isbn10": "1-61729-310-5",
"isbn13": "978-1-61729-310-8",
"title": "Get Programming with JS",
"authors": [
{
"firstName": "John R.",
"lastName": "Larsen"
}
],
"pages": 406
}
Example response
HTTP/1.1 200 OK
Update a missing user book
Example request
PUT /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 207
{
"isbn10": "1-61729-310-5",
"isbn13": "978-1-61729-310-8",
"title": "Get Programming with JS",
"authors": [
{
"firstName": "John R.",
"lastName": "Larsen"
}
],
"pages": 406
}
Example response
HTTP/1.1 404 Not Found
Delete a user book
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Book uuid |
Example request
DELETE /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 200 OK
Delete a missing user book
Example request
DELETE /users/johndoe/books/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found
Retrieve user reading sessions
Path parameters
Parameter | Description |
---|---|
|
User id |
Example request
GET /users/johndoe/reading-sessions HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
UUID used to identify a reading session |
|
|
UUID used to identify a book |
|
|
Reading sessions (optional) |
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 188
[{"uuid":"1e4014b1-a551-4310-9f30-590c3140b695","bookUuid":"1e4014b1-a551-4310-9f30-590c3140b695","dateReadingSessions":[{"date":"2017-01-01","lastReadPage":32,"bookmark":"Section 3.3"}]}]
Add a new reading session for a user
Path parameters
Parameter | Description |
---|---|
|
User id |
Request fields
Path | Type | Description |
---|---|---|
|
|
UUID used to identify a book |
|
|
Reading sessions (optional) |
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example request
POST /users/johndoe/reading-sessions HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 186
{
"bookUuid": "1e4014b1-a551-4310-9f30-590c3140b695",
"dateReadingSessions": [
{
"date": "2017-01-01",
"lastReadPage": 32,
"bookmark": "Section 3.3"
}
]
}
Response headers
Name | Description |
---|---|
|
New added reading session resource |
Example response
HTTP/1.1 201 Created
Location: /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695
Retrieve a user reading session
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
Example request
GET /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
UUID used to identify a reading session |
|
|
UUID used to identify a book |
|
|
Reading sessions (optional) |
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 186
{"uuid":"1e4014b1-a551-4310-9f30-590c3140b695","bookUuid":"1e4014b1-a551-4310-9f30-590c3140b695","dateReadingSessions":[{"date":"2017-01-01","lastReadPage":32,"bookmark":"Section 3.3"}]}
Retrieve a missing user reading session
Example request
GET /users/johndoe/reading-sessions/missing-uuid-1 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found
Delete a user reading session
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
Example request
DELETE /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 200 OK
Delete a missing user reading session
Example request
DELETE /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found
Retrieve a user date reading sessions
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
Example request
GET /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 66
[{"date":"2017-01-01","lastReadPage":32,"bookmark":"Section 3.3"}]
Add a new date reading session for a user
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
Request fields
Path | Type | Description |
---|---|---|
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example request
POST /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 75
{
"date": "2017-01-02",
"lastReadPage": 56,
"bookmark": "Chapter 5"
}
Response headers
Name | Description |
---|---|
|
New added reading session resource |
Example response
HTTP/1.1 201 Created
Location: /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-02
Add existing date reading session for a user
Example request
POST /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 75
{
"date": "2017-01-01",
"lastReadPage": 56,
"bookmark": "Chapter 5"
}
Example response
HTTP/1.1 403 Forbidden
Retrieve a date reading session
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
|
Reading session date in the format yyyy-MM-dd |
Example request
GET /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-01 HTTP/1.1
Host: localhost:8080
Response fields
Path | Type | Description |
---|---|---|
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example response
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 64
{"date":"2017-01-01","lastReadPage":32,"bookmark":"Section 3.3"}
Retrieve a missing date reading session
Example request
GET /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-02 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found
Update a date reading session
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
|
Reading session date in the format yyyy-MM-dd |
Request fields
Path | Type | Description |
---|---|---|
|
|
Date of a reading session in the format yyyy-MM-dd |
|
|
Last page that was read |
|
|
Where to start next (optional) |
Example request
PUT /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-01 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 75
{
"date": "2017-01-01",
"lastReadPage": 56,
"bookmark": "Chapter 5"
}
Example response
HTTP/1.1 200 OK
Update a missing date reading session
Example request
PUT /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-02 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Host: localhost:8080
Content-Length: 75
{
"date": "2017-01-01",
"lastReadPage": 56,
"bookmark": "Chapter 5"
}
Example response
HTTP/1.1 404 Not Found
Delete a date reading session
Path parameters
Parameter | Description |
---|---|
|
User id |
|
Reading session uuid |
|
Reading session date in the format yyyy-MM-dd |
Example request
DELETE /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-01 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 200 OK
Delete a missing date reading session
Example request
DELETE /users/johndoe/reading-sessions/1e4014b1-a551-4310-9f30-590c3140b695/date-reading-sessions/2017-01-02 HTTP/1.1
Host: localhost:8080
Example response
HTTP/1.1 404 Not Found