Resources

Library REST Service

Retrieve user books

Path parameters

Table 1. /users/{user}/books
Parameter Description

user

User id

Example request

GET /users/johndoe/books HTTP/1.1
Host: localhost:8080

Response fields

Path Type Description

[].uuid

String

UUID used to identify a book

[].isbn10

String

10 digits ISBN (optional)

[].isbn13

String

13 digits ISBN (optional)

[].title

String

Book title

[].authors

Array

Book authors (optional)

[].authors[].firstName

String

First name

[].authors[].firstName

String

Last name

[].pages

Number

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

Table 2. /users/{user}/books
Parameter Description

user

User id

Request fields

Path Type Description

isbn10

String

10 digits ISBN (optional)

isbn13

String

13 digits ISBN (optional)

title

String

Book title

authors

Array

Book authors (optional)

authors[].firstName

String

First name

authors[].firstName

String

Last name

pages

Number

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

Location

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

type

String

Error type

causes

Array

Error causes

causes[].causes

Array

Error causes (OPTIONAL). If present, it contains the name of the fields related with this error.

causes[].key

String

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

Table 3. /users/{user}/books/{uuid}
Parameter Description

user

User id

uuid

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

String

UUID used to identify a book

isbn10

String

10 digits ISBN (optional)

isbn13

String

13 digits ISBN (optional)

title

String

Book title

authors

Array

Book authors (optional)

authors[].firstName

String

First name

authors[].firstName

String

Last name

pages

Number

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

Table 4. /users/{user}/books/{uuid}
Parameter Description

user

User id

uuid

Book uuid

Request fields

Path Type Description

isbn10

String

10 digits ISBN (optional)

isbn13

String

13 digits ISBN (optional)

title

String

Book title

authors

Array

Book authors (optional)

authors[].firstName

String

First name

authors[].firstName

String

Last name

pages

Number

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

Table 5. /users/{user}/books/{uuid}
Parameter Description

user

User id

uuid

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

Table 6. /users/{user}/reading-sessions
Parameter Description

user

User id

Example request

GET /users/johndoe/reading-sessions HTTP/1.1
Host: localhost:8080

Response fields

Path Type Description

[].uuid

String

UUID used to identify a reading session

[].bookUuid

String

UUID used to identify a book

[].dateReadingSessions

Array

Reading sessions (optional)

[].dateReadingSessions[].date

String

Date of a reading session in the format yyyy-MM-dd

[].dateReadingSessions[].lastReadPage

Number

Last page that was read

[].dateReadingSessions[].bookmark

String

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

Table 7. /users/{user}/reading-sessions
Parameter Description

user

User id

Request fields

Path Type Description

bookUuid

String

UUID used to identify a book

dateReadingSessions

Array

Reading sessions (optional)

dateReadingSessions[].date

String

Date of a reading session in the format yyyy-MM-dd

dateReadingSessions[].lastReadPage

Number

Last page that was read

dateReadingSessions[].bookmark

String

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

Location

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

Table 8. /users/{user}/reading-sessions/{uuid}
Parameter Description

user

User id

uuid

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

String

UUID used to identify a reading session

bookUuid

String

UUID used to identify a book

dateReadingSessions

Array

Reading sessions (optional)

dateReadingSessions[].date

String

Date of a reading session in the format yyyy-MM-dd

dateReadingSessions[].lastReadPage

Number

Last page that was read

dateReadingSessions[].bookmark

String

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

Table 9. /users/{user}/reading-sessions/{uuid}
Parameter Description

user

User id

uuid

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

Table 10. /users/{user}/reading-sessions/{uuid}/date-reading-sessions
Parameter Description

user

User id

uuid

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

String

Date of a reading session in the format yyyy-MM-dd

[].lastReadPage

Number

Last page that was read

[].bookmark

String

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

Table 11. /users/{user}/reading-sessions/{uuid}/date-reading-sessions
Parameter Description

user

User id

uuid

Reading session uuid

Request fields

Path Type Description

date

String

Date of a reading session in the format yyyy-MM-dd

lastReadPage

Number

Last page that was read

bookmark

String

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

Location

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

Table 12. /users/{user}/reading-sessions/{uuid}/date-reading-sessions/{date}
Parameter Description

user

User id

uuid

Reading session uuid

date

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

String

Date of a reading session in the format yyyy-MM-dd

lastReadPage

Number

Last page that was read

bookmark

String

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

Table 13. /users/{user}/reading-sessions/{uuid}/date-reading-sessions/{date}
Parameter Description

user

User id

uuid

Reading session uuid

date

Reading session date in the format yyyy-MM-dd

Request fields

Path Type Description

date

String

Date of a reading session in the format yyyy-MM-dd

lastReadPage

Number

Last page that was read

bookmark

String

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

Table 14. /users/{user}/reading-sessions/{uuid}/date-reading-sessions/{date}
Parameter Description

user

User id

uuid

Reading session uuid

date

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