foliolib.folio.api.circulationStorage.LoanStorage
- class foliolib.folio.api.circulationStorage.LoanStorage(tenant: str, okapi: Optional[foliolib.okapi.okapiClient.OkapiClient] = None)
Bases:
foliolib.folio.FolioApiLoan Storage API
Storage for loans
- Parameters
tenant (str) – Tenant id
okapi (OkapiClient, optional) – Instance of OkapiClient. Defaults to None.
Methods
delete_loan(loanId)Delete loan item with given {loanId}
DELETE /loan-storage/loansget_loan(loanId)Retrieve loan item with given {loanId}
get_loanHistories(**kwargs)Retrieve a list of loanHistory items.
get_loans(**kwargs)Retrieve a list of loan items.
modify_loan(loanId, loan)Update loan item with given {loanId}
set_anonymize(userId)POST /loan-storage/loans/anonymize/{userId}set_loan(loan)Create a new loan item.
- delete_loan(loanId: str)
Delete loan item with given {loanId}
DELETE /loan-storage/loans/{loanId}- Parameters
loanId (str) –
- Raises
OkapiRequestNotFound – Not Found
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
OkapiFatalError – Server Error
- delete_loans()
DELETE /loan-storage/loans
- get_loan(loanId: str)
Retrieve loan item with given {loanId}
GET /loan-storage/loans/{loanId}- Parameters
loanId (str) –
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestNotFound – Not Found
OkapiFatalError – Server Error
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "Loan", "description": "Links the item with the patron and applies certain conditions based on policies", "properties": { "id": { "description": "Unique ID (generated UUID) of the loan", "type": "string" }, "userId": { "description": "ID of the patron the item was lent to. Required for open loans, not required for closed loans (for anonymization).", "type": "string" }, "proxyUserId": { "description": "ID of the user representing a proxy for the patron", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "itemId": { "description": "ID of the item lent to the patron", "type": "string" }, "itemEffectiveLocationIdAtCheckOut": { "description": "The effective location, at the time of checkout, of the item loaned to the patron.", "type": "string", "$ref": "raml-util/schemas/uuid.schema" }, "status": { "description": "Overall status of the loan", "type": "object", "properties": { "name": { "description": "Name of the status (currently can be any value, values commonly used are Open and Closed)", "type": "string" } }, "additionalProperties": false }, "loanDate": { "description": "Date time when the loan began (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "dueDate": { "description": "Date time when the item is due to be returned", "type": "string", "format": "date-time" }, "returnDate": { "description": "Date time when the item is returned and the loan ends (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "systemReturnDate": { "description": "Date time when the returned item is actually processed", "type": "string", "format": "date-time" }, "action": { "description": "Last action performed on a loan (currently can be any value, values commonly used are checkedout and checkedin)", "type": "string" }, "actionComment": { "description": "Comment to last action performed on a loan", "type": "string" }, "itemStatus": { "description": "Last item status used in relation to this loan (currently can be any value, values commonly used are Checked out and Available)", "type": "string" }, "renewalCount": { "description": "Count of how many times a loan has been renewed (incremented by the client)", "type": "integer" }, "loanPolicyId": { "description": "ID of last policy used in relation to this loan", "type": "string" }, "checkoutServicePointId": { "description": "ID of the Service Point where the last checkout occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "checkinServicePointId": { "description": "ID of the Service Point where the last checkin occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "patronGroupIdAtCheckout": { "description": "Patron Group Id at checkout", "type": "string" }, "dueDateChangedByRecall": { "description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item", "type": "boolean" }, "declaredLostDate": { "description": "Date and time the item was declared lost during this loan", "type": "string", "format": "date-time" }, "claimedReturnedDate": { "description": "Date and time the item was claimed returned for this loan", "type": "string", "format": "date-time" }, "overdueFinePolicyId": { "description": "ID of overdue fines policy at the time the item is check-in or renewed", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "lostItemPolicyId": { "description": "ID of lost item policy which determines when the item ages to lost and the associated fees or the associated fees if the patron declares the item lost.", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "metadata": { "description": "Metadata about creation and changes to loan, provided by the server (client should not provide)", "type": "object", "$ref": "raml-util/schemas/metadata.schema" }, "agedToLostDelayedBilling": { "description": "Aged to Lost Delayed Billing processing", "type": "object", "properties": { "lostItemHasBeenBilled": { "description": "Indicates if the aged to lost fee has been billed (for use where delayed billing is set up)", "type": "boolean" }, "dateLostItemShouldBeBilled": { "description": "Indicates when the aged to lost fee should be billed (for use where delayed billing is set up)", "type": "string", "format": "date-time" }, "agedToLostDate": { "description": "Date and time the item was aged to lost for this loan", "type": "string", "format": "date-time" } } }, "reminders": { "description": "Information about reminders for overdue loan", "type": "object", "properties": { "lastFeeBilled": { "description": "Information about the most recent reminder fee billing", "type": "object", "properties": { "number": { "description": "Last reminder fee billed, sequence number", "type": "integer" }, "date": { "description": "Last reminder fee billed, date", "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "additionalProperties": false } }, "additionalProperties": false, "required": [ "itemId", "loanDate", "action" ] }
- get_loanHistories(**kwargs)
Retrieve a list of loanHistory items.
GET /loan-storage/loan-history- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
offset (int) –
(default=0) Skip over a number of elements by specifying an offset value for the query
Example
0
limit (int) –
(default=10) Limit the number of elements returned in the response
Example
10
query (str) –
A query expressed as a CQL string (see [dev.folio.org/reference/glossary#cql](https://dev.folio.org/reference/glossary#cql)) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.
using CQL
Example
(username==”ab*” or personal.firstName==”ab*” or personal.lastName==”ab*”) and active==”true” sortby personal.lastName personal.firstName barcode
loan.status.name==Closed
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of loan history items", "type": "object", "properties": { "loansHistory": { "description": "List of loan history items", "id": "loansHistory", "type": "array", "items": { "type": "object", "$ref": "loans-history-item.json" } }, "totalRecords": { "type": "integer" } }, "required": [ "loansHistory", "totalRecords" ] }
- get_loans(**kwargs)
Retrieve a list of loan items.
GET /loan-storage/loans- Parameters
**kwargs (properties) – Keyword Arguments
- Keyword Arguments
offset (int) –
(default=0) Skip over a number of elements by specifying an offset value for the query
Example
0
limit (int) –
(default=10) Limit the number of elements returned in the response
Example
10
query (str) –
A query expressed as a CQL string (see [dev.folio.org/reference/glossary#cql](https://dev.folio.org/reference/glossary#cql)) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.
searchable using CQL
Example
(username==”ab*” or personal.firstName==”ab*” or personal.lastName==”ab*”) and active==”true” sortby personal.lastName personal.firstName barcode
requesterId=”cf23adf0-61ba-4887-bf82-956c4aae2260”
- Returns
See Schema below
- Return type
dict
- Raises
OkapiRequestError – Bad Request
OkapiRequestUnauthorized – Authentication is required
OkapiFatalError – Server Error
OkapiFatalError – Server Error
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Collection of loans", "type": "object", "properties": { "loans": { "description": "List of loan items", "id": "loans", "type": "array", "items": { "type": "object", "$ref": "loan.json" } }, "totalRecords": { "type": "integer" } }, "required": [ "loans", "totalRecords" ] }
- modify_loan(loanId: str, loan: dict)
Update loan item with given {loanId}
PUT /loan-storage/loans/{loanId}- Parameters
loanId (str) –
loan (dict) – See Schema below
- Raises
OkapiRequestNotFound – Not Found
OkapiRequestError – Bad Request
OkapiRequestConflict – Conflict
OkapiFatalError – Server Error
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "Loan", "description": "Links the item with the patron and applies certain conditions based on policies", "properties": { "id": { "description": "Unique ID (generated UUID) of the loan", "type": "string" }, "userId": { "description": "ID of the patron the item was lent to. Required for open loans, not required for closed loans (for anonymization).", "type": "string" }, "proxyUserId": { "description": "ID of the user representing a proxy for the patron", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "itemId": { "description": "ID of the item lent to the patron", "type": "string" }, "itemEffectiveLocationIdAtCheckOut": { "description": "The effective location, at the time of checkout, of the item loaned to the patron.", "type": "string", "$ref": "raml-util/schemas/uuid.schema" }, "status": { "description": "Overall status of the loan", "type": "object", "properties": { "name": { "description": "Name of the status (currently can be any value, values commonly used are Open and Closed)", "type": "string" } }, "additionalProperties": false }, "loanDate": { "description": "Date time when the loan began (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "dueDate": { "description": "Date time when the item is due to be returned", "type": "string", "format": "date-time" }, "returnDate": { "description": "Date time when the item is returned and the loan ends (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "systemReturnDate": { "description": "Date time when the returned item is actually processed", "type": "string", "format": "date-time" }, "action": { "description": "Last action performed on a loan (currently can be any value, values commonly used are checkedout and checkedin)", "type": "string" }, "actionComment": { "description": "Comment to last action performed on a loan", "type": "string" }, "itemStatus": { "description": "Last item status used in relation to this loan (currently can be any value, values commonly used are Checked out and Available)", "type": "string" }, "renewalCount": { "description": "Count of how many times a loan has been renewed (incremented by the client)", "type": "integer" }, "loanPolicyId": { "description": "ID of last policy used in relation to this loan", "type": "string" }, "checkoutServicePointId": { "description": "ID of the Service Point where the last checkout occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "checkinServicePointId": { "description": "ID of the Service Point where the last checkin occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "patronGroupIdAtCheckout": { "description": "Patron Group Id at checkout", "type": "string" }, "dueDateChangedByRecall": { "description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item", "type": "boolean" }, "declaredLostDate": { "description": "Date and time the item was declared lost during this loan", "type": "string", "format": "date-time" }, "claimedReturnedDate": { "description": "Date and time the item was claimed returned for this loan", "type": "string", "format": "date-time" }, "overdueFinePolicyId": { "description": "ID of overdue fines policy at the time the item is check-in or renewed", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "lostItemPolicyId": { "description": "ID of lost item policy which determines when the item ages to lost and the associated fees or the associated fees if the patron declares the item lost.", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "metadata": { "description": "Metadata about creation and changes to loan, provided by the server (client should not provide)", "type": "object", "$ref": "raml-util/schemas/metadata.schema" }, "agedToLostDelayedBilling": { "description": "Aged to Lost Delayed Billing processing", "type": "object", "properties": { "lostItemHasBeenBilled": { "description": "Indicates if the aged to lost fee has been billed (for use where delayed billing is set up)", "type": "boolean" }, "dateLostItemShouldBeBilled": { "description": "Indicates when the aged to lost fee should be billed (for use where delayed billing is set up)", "type": "string", "format": "date-time" }, "agedToLostDate": { "description": "Date and time the item was aged to lost for this loan", "type": "string", "format": "date-time" } } }, "reminders": { "description": "Information about reminders for overdue loan", "type": "object", "properties": { "lastFeeBilled": { "description": "Information about the most recent reminder fee billing", "type": "object", "properties": { "number": { "description": "Last reminder fee billed, sequence number", "type": "integer" }, "date": { "description": "Last reminder fee billed, date", "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "additionalProperties": false } }, "additionalProperties": false, "required": [ "itemId", "loanDate", "action" ] }
- set_anonymize(userId: str)
POST /loan-storage/loans/anonymize/{userId}- Parameters
userId (str) –
- Raises
OkapiFatalError – Server Error
OkapiRequestError – Bad Request
OkapiRequestUnprocessableEntity – Unprocessable Entity
- set_loan(loan: dict)
Create a new loan item.
POST /loan-storage/loans- Parameters
loan (dict) – See Schema below
- Raises
OkapiRequestError – Bad Request
OkapiRequestUnauthorized – Authentication is required
OkapiFatalError – Server Error
OkapiRequestUnprocessableEntity – Unprocessable Entity
Headers
Location - URI to the created loan item
Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "Loan", "description": "Links the item with the patron and applies certain conditions based on policies", "properties": { "id": { "description": "Unique ID (generated UUID) of the loan", "type": "string" }, "userId": { "description": "ID of the patron the item was lent to. Required for open loans, not required for closed loans (for anonymization).", "type": "string" }, "proxyUserId": { "description": "ID of the user representing a proxy for the patron", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "itemId": { "description": "ID of the item lent to the patron", "type": "string" }, "itemEffectiveLocationIdAtCheckOut": { "description": "The effective location, at the time of checkout, of the item loaned to the patron.", "type": "string", "$ref": "raml-util/schemas/uuid.schema" }, "status": { "description": "Overall status of the loan", "type": "object", "properties": { "name": { "description": "Name of the status (currently can be any value, values commonly used are Open and Closed)", "type": "string" } }, "additionalProperties": false }, "loanDate": { "description": "Date time when the loan began (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "dueDate": { "description": "Date time when the item is due to be returned", "type": "string", "format": "date-time" }, "returnDate": { "description": "Date time when the item is returned and the loan ends (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", "type": "string" }, "systemReturnDate": { "description": "Date time when the returned item is actually processed", "type": "string", "format": "date-time" }, "action": { "description": "Last action performed on a loan (currently can be any value, values commonly used are checkedout and checkedin)", "type": "string" }, "actionComment": { "description": "Comment to last action performed on a loan", "type": "string" }, "itemStatus": { "description": "Last item status used in relation to this loan (currently can be any value, values commonly used are Checked out and Available)", "type": "string" }, "renewalCount": { "description": "Count of how many times a loan has been renewed (incremented by the client)", "type": "integer" }, "loanPolicyId": { "description": "ID of last policy used in relation to this loan", "type": "string" }, "checkoutServicePointId": { "description": "ID of the Service Point where the last checkout occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "checkinServicePointId": { "description": "ID of the Service Point where the last checkin occured", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "patronGroupIdAtCheckout": { "description": "Patron Group Id at checkout", "type": "string" }, "dueDateChangedByRecall": { "description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item", "type": "boolean" }, "declaredLostDate": { "description": "Date and time the item was declared lost during this loan", "type": "string", "format": "date-time" }, "claimedReturnedDate": { "description": "Date and time the item was claimed returned for this loan", "type": "string", "format": "date-time" }, "overdueFinePolicyId": { "description": "ID of overdue fines policy at the time the item is check-in or renewed", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "lostItemPolicyId": { "description": "ID of lost item policy which determines when the item ages to lost and the associated fees or the associated fees if the patron declares the item lost.", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "metadata": { "description": "Metadata about creation and changes to loan, provided by the server (client should not provide)", "type": "object", "$ref": "raml-util/schemas/metadata.schema" }, "agedToLostDelayedBilling": { "description": "Aged to Lost Delayed Billing processing", "type": "object", "properties": { "lostItemHasBeenBilled": { "description": "Indicates if the aged to lost fee has been billed (for use where delayed billing is set up)", "type": "boolean" }, "dateLostItemShouldBeBilled": { "description": "Indicates when the aged to lost fee should be billed (for use where delayed billing is set up)", "type": "string", "format": "date-time" }, "agedToLostDate": { "description": "Date and time the item was aged to lost for this loan", "type": "string", "format": "date-time" } } }, "reminders": { "description": "Information about reminders for overdue loan", "type": "object", "properties": { "lastFeeBilled": { "description": "Information about the most recent reminder fee billing", "type": "object", "properties": { "number": { "description": "Last reminder fee billed, sequence number", "type": "integer" }, "date": { "description": "Last reminder fee billed, date", "type": "string", "format": "date-time" } }, "additionalProperties": false } }, "additionalProperties": false } }, "additionalProperties": false, "required": [ "itemId", "loanDate", "action" ] }