library-rpc

Return a borrowed book.

RPCloans.return

Closes the loan with the given id, stamping returnedAt with the current time, and flips the book's status back to "available".

Servers

•mock: https://mock.api.selfdochub.com/rpc

Parameters

NameInTypeRequiredDescription
idparamsstringyesThe loan's unique identifier.

Responses

result The closed loan; the book is now available again.

application/json

FieldTypeRequiredDescription
bookIdstringyesThe id of the borrowed Book.
borrowedAtstring (date-time)yesWhen the loan started.
dueAtstring (date-time)yesWhen the book is expected back.
idstringyesUnique identifier assigned by the server, prefixed with ln_.
overduebooleanyesComputed at response time: true if the loan is still open and past its dueAt. Never stored, so it never goes stale.
returnedAtstring (date-time)When the book was actually returned, or null while the loan is still open.
userIdstringyesThe id of the User who borrowed the book.

Errors

CodeMessageDescription
-32004Not found
-32001Conflict
-32602Invalid params

Request example

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "loans.return",
  "params": {
    "id": "id_657"
  }
}

Response example

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "bookId": "bookId_936",
    "borrowedAt": "borrowedAt_214",
    "dueAt": "dueAt_775",
    "id": "id_137",
    "overdue": true,
    "returnedAt": "returnedAt_893",
    "userId": "userId_870"
  }
}