foliolib.folio.api.patron.Patron

class foliolib.folio.api.patron.Patron(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)

Bases: foliolib.folio.FolioApi

Patron Services

This module allows 3rd party discovery services to perform patron

actions in FOLIO

Parameters
  • tenant (str) – Tenant id

  • okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.

Methods

get_account(accountId, **kwargs)

Return account details for the specified FOLIO user id

set_cancel(accountId, holdId, cancel)

cancels the request

set_hold(accountId, instanceId, hold)

Creates a hold request on an existing item by instance ID for the user

set_hold_for_account(accountId, itemId, hold)

Creates a hold request on an existing item for the user

set_renew(accountId, itemId)

Renews a loan on the item for the user

get_account(accountId: str, **kwargs)

Return account details for the specified FOLIO user id

GET /patron/account/{accountId}

Parameters
  • accountId (str) –

  • **kwargs (properties) – Keyword Arguments

Keyword Arguments
  • includeLoans (bool) – (default=False) Indicates whether or not to include the loans array in the response

  • includeCharges (bool) – (default=False) Indicates whether or not to include the charges array in the response

  • includeHolds (bool) – (default=False) Indicates whether or not to include the holds array in the response

  • sortBy (str) –

    Part of CQL query, indicates the order of records within the lists of holds, charges, loans

    Example

    • item.title/sort.ascending

  • offset (int) –

    (default=0) Skip over a number of elements by specifying an offset value for the query

    Example

    • 0

  • limit (int) –

    (default=2147483647) Limit the number of elements returned in the response

    Example

    • 10

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestNotFound – Not Found

  • OkapiRequestForbidden – Forbidden

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Patron Account Schema",
  "type": "object",
  "description": "Account schema for patron portal integration",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The FOLIO id of the patron"
    },
    "totalCharges": {
      "type": "object",
      "description": "A patron's total outstanding fines and charges",
      "$ref": "money.json"
    },
    "totalChargesCount": {
      "type": "integer",
      "description": "The total number of fines and charges for the patron",
      "example": 10
    },
    "totalLoans": {
      "type": "integer",
      "description": "The total number of items loaned to the patron",
      "example": 10
    },
    "totalHolds": {
      "type": "integer",
      "description": "The total number of requested items for the patron",
      "example": 10
    },
    "charges": {
      "type": "array",
      "description": "A list of the patron's charges and fines",
      "items": {
        "type": "object",
        "$ref": "charge.json"
      }
    },
    "holds": {
      "type": "array",
      "description": "A list of the patron's item holds",
      "items": {
        "type": "object",
        "$ref": "hold.json"
      }
    },
    "loans": {
      "type": "array",
      "description": "A list of the patron's item checked out items",
      "items": {
        "type": "object",
        "$ref": "loan.json"
      }
    }
  },
  "required": [
    "totalCharges",
    "totalChargesCount",
    "totalLoans",
    "totalHolds",
    "charges",
    "holds",
    "loans"
  ]
}
set_cancel(accountId: str, holdId: str, cancel: dict)

cancels the request

POST /patron/account/{accountId}/hold/{holdId}/cancel

Parameters
  • accountId (str) –

  • holdId (str) –

  • cancel (dict) – See Schema below

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestForbidden – Forbidden

  • OkapiRequestNotFound – Not Found

  • OkapiRequestConflict – Conflict

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

  • OkapiFatalError – Server Error

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Patron Hold Schema",
  "type": "object",
  "description": "Hold schema for patron portal integration",
  "additionalProperties": true,
  "properties": {
    "requestId": {
      "type": "string",
      "description": "The UUID of the request"
    },
    "item": {
      "type": "object",
      "description": "The item that is checked out",
      "$ref": "item.json"
    },
    "requestDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request was made"
    },
    "expirationDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request expires"
    },
    "status": {
      "type": "string",
      "description": "The status of the hold request",
      "enum": [
        "Open - Not yet filled",
        "Open - Awaiting pickup",
        "Open - Awaiting delivery",
        "Open - In transit",
        "Closed - Filled",
        "Closed - Cancelled",
        "Closed - Unfilled",
        "Closed - Pickup expired"
      ]
    },
    "pickupLocationId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The UUID of the pick up location"
    },
    "queuePosition": {
      "type": "integer",
      "description": "The position in the queue for this patron"
    },
    "cancellationReasonId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the request reason"
    },
    "canceledByUserId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the user that cancelled the request"
    },
    "cancellationAdditionalInformation": {
      "description": "Additional information about a cancellation",
      "type": "string"
    },
    "canceledDate": {
      "description": "Date the request was cancelled",
      "type": "string",
      "format": "date-time"
    },
    "patronComments": {
      "description": "Comments made by the patron",
      "type": "string"
    }
  },
  "required": [
    "requestDate",
    "pickupLocationId"
  ]
}
set_hold(accountId: str, instanceId: str, hold: dict)

Creates a hold request on an existing item by instance ID for the user

POST /patron/account/{accountId}/instance/{instanceId}/hold

Parameters
  • accountId (str) –

  • instanceId (str) –

  • hold (dict) – See Schema below

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestNotFound – Not Found

  • OkapiRequestForbidden – Forbidden

  • OkapiRequestConflict – Conflict

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Patron Hold Schema",
  "type": "object",
  "description": "Hold schema for patron portal integration",
  "additionalProperties": true,
  "properties": {
    "requestId": {
      "type": "string",
      "description": "The UUID of the request"
    },
    "item": {
      "type": "object",
      "description": "The item that is checked out",
      "$ref": "item.json"
    },
    "requestDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request was made"
    },
    "expirationDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request expires"
    },
    "status": {
      "type": "string",
      "description": "The status of the hold request",
      "enum": [
        "Open - Not yet filled",
        "Open - Awaiting pickup",
        "Open - Awaiting delivery",
        "Open - In transit",
        "Closed - Filled",
        "Closed - Cancelled",
        "Closed - Unfilled",
        "Closed - Pickup expired"
      ]
    },
    "pickupLocationId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The UUID of the pick up location"
    },
    "queuePosition": {
      "type": "integer",
      "description": "The position in the queue for this patron"
    },
    "cancellationReasonId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the request reason"
    },
    "canceledByUserId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the user that cancelled the request"
    },
    "cancellationAdditionalInformation": {
      "description": "Additional information about a cancellation",
      "type": "string"
    },
    "canceledDate": {
      "description": "Date the request was cancelled",
      "type": "string",
      "format": "date-time"
    },
    "patronComments": {
      "description": "Comments made by the patron",
      "type": "string"
    }
  },
  "required": [
    "requestDate",
    "pickupLocationId"
  ]
}
set_hold_for_account(accountId: str, itemId: str, hold: dict)

Creates a hold request on an existing item for the user

POST /patron/account/{accountId}/item/{itemId}/hold

Parameters
  • accountId (str) –

  • itemId (str) –

  • hold (dict) – See Schema below

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestNotFound – Not Found

  • OkapiRequestForbidden – Forbidden

  • OkapiRequestConflict – Conflict

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Patron Hold Schema",
  "type": "object",
  "description": "Hold schema for patron portal integration",
  "additionalProperties": true,
  "properties": {
    "requestId": {
      "type": "string",
      "description": "The UUID of the request"
    },
    "item": {
      "type": "object",
      "description": "The item that is checked out",
      "$ref": "item.json"
    },
    "requestDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request was made"
    },
    "expirationDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date when the request expires"
    },
    "status": {
      "type": "string",
      "description": "The status of the hold request",
      "enum": [
        "Open - Not yet filled",
        "Open - Awaiting pickup",
        "Open - Awaiting delivery",
        "Open - In transit",
        "Closed - Filled",
        "Closed - Cancelled",
        "Closed - Unfilled",
        "Closed - Pickup expired"
      ]
    },
    "pickupLocationId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The UUID of the pick up location"
    },
    "queuePosition": {
      "type": "integer",
      "description": "The position in the queue for this patron"
    },
    "cancellationReasonId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the request reason"
    },
    "canceledByUserId": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the user that cancelled the request"
    },
    "cancellationAdditionalInformation": {
      "description": "Additional information about a cancellation",
      "type": "string"
    },
    "canceledDate": {
      "description": "Date the request was cancelled",
      "type": "string",
      "format": "date-time"
    },
    "patronComments": {
      "description": "Comments made by the patron",
      "type": "string"
    }
  },
  "required": [
    "requestDate",
    "pickupLocationId"
  ]
}
set_renew(accountId: str, itemId: str)

Renews a loan on the item for the user

POST /patron/account/{accountId}/item/{itemId}/renew

Parameters
  • accountId (str) –

  • itemId (str) –

Returns

See Schema below

Return type

dict

Raises
  • OkapiRequestError – Bad Request

  • OkapiRequestUnauthorized – Authentication is required

  • OkapiRequestNotFound – Not Found

  • OkapiRequestForbidden – Forbidden

  • OkapiRequestConflict – Conflict

  • OkapiFatalError – Server Error

  • OkapiRequestUnprocessableEntity – Unprocessable Entity

Schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Patron Loan Schema",
  "type": "object",
  "description": "Loan schema for patron portal integration",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
      "description": "The id of the loan"
    },
    "item": {
      "type": "object",
      "description": "The item that is loaned out",
      "$ref": "item.json"
    },
    "loanDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date the item was loaned out"
    },
    "dueDate": {
      "type": "string",
      "format": "date-time",
      "description": "The date the item is due"
    },
    "overdue": {
      "type": "boolean",
      "description": "Indicates if the item is overdue"
    }
  },
  "required": [
    "item",
    "loanDate",
    "dueDate",
    "overdue"
  ]
}