# Patron Loan

Provider API v0.6.6 · 2 operasjoner
Kilde: https://plasapi.com/no/provider/v0.6.6/patron-loan/

Ingen beskrivelse i spesifikasjonen.

## Get patron loans

`GET` `/patron/{patronId}/loan` · `GetPatronLoans`

### Eksempel på kall

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/patron/40218873/loan?version=0.6.6" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/loan?version=0.6.6`, {
  method: "GET",
  headers: {
    "Accept": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.get(
    f"{os.environ['PLAS_BASE_URL']}/patron/40218873/loan",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

Verten og tokenet er miljøvariabler: `PLAS_BASE_URL` providerens adresse · `PLAS_TOKEN` et access token.

### Parametere

- `patronId` (i `path`, `string`, påkrevd) — Patron ID from authentication

Felles for operasjonene: `version`. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

### Svar

#### `200` Success

`PatronLoanResponseBody`

Eksempel (Generert fra skjemaet):

```json
{
  "loans": [
    {
      "acquiredFrom": {
        "type": "local_circulation"
      },
      "createdTime": "2025-03-14T10:24:00+01:00",
      "dueDate": "2025-04-11",
      "id": "94549",
      "itemId": "03011042557129",
      "location": {
        "branchId": "nordby-main",
        "sections": [
          {
            "id": "nordby-main-children",
            "name": "Children’s department",
            "type": "department"
          }
        ]
      },
      "publicationId": "310552",
      "publicationMetadata": {
        "additionalIdentifiers": [
          {
            "digits": "10",
            "type": "isbn",
            "value": "9788203363344"
          }
        ],
        "binding": {
          "type": "literal",
          "value": "Hardback"
        },
        "contributors": [
          {
            "agent": {
              "description": "Norwegian novelist, awarded the Nobel Prize in Literature in 1928.",
              "fullName": "Sigrid Undset",
              "id": "agent-4102",
              "images": [
                {
                  "height": 1200,
                  "mime": "png",
                  "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
                  "width": 800,
                  "type": "agent"
                }
              ],
              "active": {
                "type": "literal",
                "value": "1882-1949"
              },
              "birthDate": {
                "type": "literal",
                "value": "1920"
              },
              "deathDate": {
                "type": "literal",
                "value": "1920"
              },
              "externals": {
                "identifiers": [
                  {
                    "type": "norwegianAuthorityFile",
                    "value": "4102"
                  }
                ]
              },
              "givenName": "Kari",
              "surname": "Nordmann",
              "type": "person"
            },
            "roles": [
              {
                "roleCode": "aut",
                "type": "marcRelator"
              }
            ]
          }
        ],
        "creators": [
          {
            "agent": {
              "description": "Norwegian novelist, awarded the Nobel Prize in Literature in 1928.",
              "fullName": "Sigrid Undset",
              "id": "agent-4102",
              "images": [
                {
                  "height": 1200,
                  "mime": "png",
                  "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
                  "width": 800,
                  "type": "agent"
                }
              ],
              "active": {
                "type": "literal",
                "value": "1882-1949"
              },
              "birthDate": {
                "type": "literal",
                "value": "1920"
              },
              "deathDate": {
                "type": "literal",
                "value": "1920"
              },
              "externals": {
                "identifiers": [
                  {
                    "type": "norwegianAuthorityFile",
                    "value": "4102"
                  }
                ]
              },
              "givenName": "Kari",
              "surname": "Nordmann",
              "type": "person"
            },
            "roles": [
              {
                "roleCode": "aut",
                "type": "marcRelator"
              }
            ]
          }
        ],
        "edition": {
          "type": "literal",
          "value": "2nd edition"
        },
        "extent": [
          {
            "type": "literal",
            "value": "312 pages"
          }
        ],
        "identifier": "310552",
        "images": [
          {
            "height": 1200,
            "mime": "png",
            "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
            "width": 800,
            "type": "frontCover"
          }
        ],
        "language": [
          {
            "code": "SplxlOBeZQQYbYS6WxSbIA",
            "name": "Kari Nordmann"
          }
        ],
        "mediaTypes": [
          {
            "code": "book",
            "name": "Kari Nordmann"
          }
        ],
        "publicationDate": {
          "type": "literal",
          "value": "1920"
        },
        "publishers": [
          {
            "places": [
              {
                "place": "Oslo"
              }
            ],
            "publisher": {
              "id": "94549",
              "name": "Kari Nordmann"
            }
          }
        ],
        "titles": [
          {
            "language": {
              "code": "SplxlOBeZQQYbYS6WxSbIA",
              "name": "Kari Nordmann"
            },
            "main": "Kristin Lavransdatter",
            "part": {
              "name": "Kari Nordmann",
              "number": "1"
            },
            "remainder": "The Wreath",
            "type": "preferred"
          }
        ],
        "works": [
          {
            "identifier": "882107",
            "relation": "contains"
          }
        ]
      },
      "renew": {
        "count": 2,
        "lastDate": "2025-03-14",
        "state": "renewable"
      }
    }
  ]
}
```

#### `400` The list of errors.

`Errors`

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

Eksempel (Generert fra skjemaet):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

Ikke noe innhold i svaret.

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

#### `404` Resource not found.

Ikke noe innhold i svaret.

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

## Renew loan

`PUT` `/patron/{patronId}/loan/{loanId}` · `RenewPatronLoan`

Renew a loan

### Eksempel på kall

**cURL**

```bash
curl -X PUT "$PLAS_BASE_URL/patron/40218873/loan/58210447?version=0.6.6" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/loan/58210447?version=0.6.6`, {
  method: "PUT",
  headers: {
    "Accept": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.put(
    f"{os.environ['PLAS_BASE_URL']}/patron/40218873/loan/58210447",
    params={
        "version": "0.6.6",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

Verten og tokenet er miljøvariabler: `PLAS_BASE_URL` providerens adresse · `PLAS_TOKEN` et access token.

### Parametere

- `patronId` (i `path`, `string`, påkrevd) — Patron ID from authentication
- `loanId` (i `path`, `string`, påkrevd) — ID of the loan that is to be renewed

Felles for operasjonene: `version`. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

### Svar

#### `200` It is important to check the returned `status` field, to distinguish between success and the different failure statuses.

`RenewPatronLoanResponseBody`

Eksempel (Generert fra skjemaet):

```json
{
  "loan": {
    "acquiredFrom": {
      "type": "local_circulation"
    },
    "createdTime": "2025-03-14T10:24:00+01:00",
    "dueDate": "2025-04-11",
    "id": "94549",
    "itemId": "03011042557129",
    "location": {
      "branchId": "nordby-main",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "publicationId": "310552",
    "publicationMetadata": {
      "additionalIdentifiers": [
        {
          "digits": "10",
          "type": "isbn",
          "value": "9788203363344"
        }
      ],
      "binding": {
        "type": "literal",
        "value": "Hardback"
      },
      "contributors": [
        {
          "agent": {
            "description": "Norwegian novelist, awarded the Nobel Prize in Literature in 1928.",
            "fullName": "Sigrid Undset",
            "id": "agent-4102",
            "images": [
              {
                "height": 1200,
                "mime": "png",
                "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
                "width": 800,
                "type": "agent"
              }
            ],
            "active": {
              "type": "literal",
              "value": "1882-1949"
            },
            "birthDate": {
              "type": "literal",
              "value": "1920"
            },
            "deathDate": {
              "type": "literal",
              "value": "1920"
            },
            "externals": {
              "identifiers": [
                {
                  "type": "norwegianAuthorityFile",
                  "value": "4102"
                }
              ]
            },
            "givenName": "Kari",
            "surname": "Nordmann",
            "type": "person"
          },
          "roles": [
            {
              "roleCode": "aut",
              "type": "marcRelator"
            }
          ]
        }
      ],
      "creators": [
        {
          "agent": {
            "description": "Norwegian novelist, awarded the Nobel Prize in Literature in 1928.",
            "fullName": "Sigrid Undset",
            "id": "agent-4102",
            "images": [
              {
                "height": 1200,
                "mime": "png",
                "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
                "width": 800,
                "type": "agent"
              }
            ],
            "active": {
              "type": "literal",
              "value": "1882-1949"
            },
            "birthDate": {
              "type": "literal",
              "value": "1920"
            },
            "deathDate": {
              "type": "literal",
              "value": "1920"
            },
            "externals": {
              "identifiers": [
                {
                  "type": "norwegianAuthorityFile",
                  "value": "4102"
                }
              ]
            },
            "givenName": "Kari",
            "surname": "Nordmann",
            "type": "person"
          },
          "roles": [
            {
              "roleCode": "aut",
              "type": "marcRelator"
            }
          ]
        }
      ],
      "edition": {
        "type": "literal",
        "value": "2nd edition"
      },
      "extent": [
        {
          "type": "literal",
          "value": "312 pages"
        }
      ],
      "identifier": "310552",
      "images": [
        {
          "height": 1200,
          "mime": "png",
          "url": "https://images.nordby.bibliotek.example/covers/310552.jpg",
          "width": 800,
          "type": "frontCover"
        }
      ],
      "language": [
        {
          "code": "SplxlOBeZQQYbYS6WxSbIA",
          "name": "Kari Nordmann"
        }
      ],
      "mediaTypes": [
        {
          "code": "book",
          "name": "Kari Nordmann"
        }
      ],
      "publicationDate": {
        "type": "literal",
        "value": "1920"
      },
      "publishers": [
        {
          "places": [
            {
              "place": "Oslo"
            }
          ],
          "publisher": {
            "id": "94549",
            "name": "Kari Nordmann"
          }
        }
      ],
      "titles": [
        {
          "language": {
            "code": "SplxlOBeZQQYbYS6WxSbIA",
            "name": "Kari Nordmann"
          },
          "main": "Kristin Lavransdatter",
          "part": {
            "name": "Kari Nordmann",
            "number": "1"
          },
          "remainder": "The Wreath",
          "type": "preferred"
        }
      ],
      "works": [
        {
          "identifier": "882107",
          "relation": "contains"
        }
      ]
    },
    "renew": {
      "count": 2,
      "lastDate": "2025-03-14",
      "state": "renewable"
    }
  },
  "status": "success"
}
```

#### `400` The list of errors.

`Errors`

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

Eksempel (Generert fra skjemaet):

```json
{
  "errors": [
    {
      "code": 200103,
      "info": "200103: invalid/unsupported query parameter value"
    }
  ]
}
```

#### `401` Bearer token invalid, missing, or expired.

Ikke noe innhold i svaret.

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)

#### `404` Resource not found.

Ikke noe innhold i svaret.

Felles svar, definert én gang for hele API-et. [Se den felles kontrakten på versjonssiden.](https://plasapi.com/no/provider/v0.6.6/)
