library-rpc
Return a borrowed book.
RPC
loans.returnCloses 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/rpcParameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | params | string | yes | The loan's unique identifier. |
Responses
result The closed loan; the book is now available again.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| bookId | string | yes | The id of the borrowed Book. |
| borrowedAt | string (date-time) | yes | When the loan started. |
| dueAt | string (date-time) | yes | When the book is expected back. |
| id | string | yes | Unique identifier assigned by the server, prefixed with ln_. |
| overdue | boolean | yes | Computed at response time: true if the loan is still open and past its dueAt. Never stored, so it never goes stale. |
| returnedAt | string (date-time) | When the book was actually returned, or null while the loan is still open. | |
| userId | string | yes | The id of the User who borrowed the book. |
Errors
| Code | Message | Description |
|---|---|---|
| -32004 | Not found | |
| -32001 | Conflict | |
| -32602 | Invalid 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"
}
}