library-rpc
Get a user's profile, including their loans.
RPC
users.getProfileReturns the user matching the given id, together with their currently open loans (currentLoans) and their closed/returned loans (loanHistory).
Servers
•
mock: https://mock.api.selfdochub.com/rpcParameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | params | string | yes | The user's unique identifier. |
Responses
result The requested user profile.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| currentLoans | array of object | yes | The user's currently open loans (not yet returned). |
| 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. |
| loanHistory | array of object | yes | The user's closed (returned) loans. |
| 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. |
| user | object | yes | A library member who can borrow books. |
| string (email) | yes | The user's contact email address. | |
| id | string | yes | Unique identifier assigned by the server, prefixed with us_. |
| name | string | yes | The user's full name. |
| registeredAt | string (date-time) | yes | When the user joined the library. |
Errors
| Code | Message | Description |
|---|---|---|
| -32004 | Not found | |
| -32602 | Invalid params |
Request example
{
"id": 1,
"jsonrpc": "2.0",
"method": "users.getProfile",
"params": {
"id": "id_193"
}
}Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"currentLoans": [
{
"bookId": "bookId_220",
"borrowedAt": "borrowedAt_817",
"dueAt": "dueAt_885",
"id": "id_109",
"overdue": true,
"returnedAt": "returnedAt_954",
"userId": "userId_469"
}
],
"loanHistory": [
{
"bookId": "bookId_185",
"borrowedAt": "borrowedAt_502",
"dueAt": "dueAt_752",
"id": "id_981",
"overdue": true,
"returnedAt": "returnedAt_339",
"userId": "userId_321"
}
],
"user": {
"email": "email_846",
"id": "id_630",
"name": "name_527",
"registeredAt": "registeredAt_152"
}
}
}