library-rpc

Get a user's profile, including their loans.

RPCusers.getProfile

Returns 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/rpc

Parameters

NameInTypeRequiredDescription
idparamsstringyesThe user's unique identifier.

Responses

result The requested user profile.

application/json

FieldTypeRequiredDescription
currentLoansarray of objectyesThe user's currently open loans (not yet returned).
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.
loanHistoryarray of objectyesThe user's closed (returned) loans.
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.
userobjectyesA library member who can borrow books.
emailstring (email)yesThe user's contact email address.
idstringyesUnique identifier assigned by the server, prefixed with us_.
namestringyesThe user's full name.
registeredAtstring (date-time)yesWhen the user joined the library.

Errors

CodeMessageDescription
-32004Not found
-32602Invalid 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"
    }
  }
}