# Loan history

3 of 3 supported
Source: https://plasapi.com/features/patron/loan-history/

Let patrons look back at what they have borrowed, and decide what their history contains.

## 2.8.1 View loan history — Supported

Show the material the patron has borrowed before.

### What you can build

A history the patron can use to find a title again or remember what they have read. It is only kept when the patron has consented to it.

### Typical flow

1. The client checks with `GetPatronConsents` whether the patron has given the `loan_history` consent.
2. Without the consent, the client can ask the patron to give it (2.11.5).
3. The client fetches the history page by page with `GetPatronLoanHistory`.
4. Each entry is shown with its publication and the date it was borrowed or returned.

### What the API provides

- `before`, `offset` and `size` are required. `size` is between 1 and 50.
- Sort by `addedToHistoryTime` (the default) or `dueDate`, in the order `desc` (the default) or `asc`.
- `addedToHistoryTime` is always set. `checkoutTime` and `checkinTime` are only set when known.
- `manuallyAdded` tells whether the patron added the entry themselves (2.8.2).

### Calls in the API

Requires: 2.2.1

In this order

1. [GET /patron/{patronId}/consent](https://plasapi.com/provider/v0.6.7/patron/#GetPatronConsents) — Get patron consents
2. [GET /patron/{patronId}/loan-history](https://plasapi.com/provider/v0.6.7/patron-loan-history/#GetPatronLoanHistory) — Get patron loan history

## 2.8.2 Add to loan history — Supported

Let the patron add material to their loan history themselves.

### Typical flow

1. The patron chooses a publication, for example on the work page.
2. The client calls `AddLoanToPatronLoanHistory` with the `publicationId` and `manuallyAdded` set to true.

### What the API provides

- When `patron.loanHistory.blockManuallyAddingLoans` in `GetConfiguration` is true, patrons are expected not to be allowed to add loans manually. The default is false.
- `checkoutTime`, `checkinTime`, `dueDate` and `acquiredFrom` are optional.

### Calls in the API

Requires: 2.2.1

Enabled in the configuration: `GetConfiguration`

- [POST /patron/{patronId}/loan-history](https://plasapi.com/provider/v0.6.7/patron-loan-history/#AddLoanToPatronLoanHistory) — Adds a loan to the patron's loan history

## 2.8.3 Remove from loan history — Supported

Remove an entry the patron does not want in their loan history.

### Typical flow

1. The patron chooses an entry.
2. The client calls `DeleteLoanFromPatronLoanHistory` with the entry's `id`.

### What the API provides

- The ID is the loan history ID from `GetPatronLoanHistory`, not the loan ID.

### Calls in the API

Requires: 2.2.1

- [DELETE /patron/{patronId}/loan-history/{loanHistoryId}](https://plasapi.com/provider/v0.6.7/patron-loan-history/#DeleteLoanFromPatronLoanHistory) — Delete loan from patron loan history
