# Patron

Provider API v0.6.4 · 6 operationer
Kilde: https://plasapi.com/da/provider/v0.6.4/patron/

Ingen beskrivelse i specifikationen.

## Get patron consents

`GET` `/patron/{patronId}/consent` · `GetPatronConsents`

This includes all the consents that are available for the patron, even if the patron has made a decision on them or not.  
This also includes all the consents the patron has made a decision on, i.e. accepted or rejected.


### Eksempel på kald

**cURL**

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

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/consent?version=0.6.4`, {
  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/consent",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

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

### Parametre

- `patronId` (i `path`, `string`, påkrævet) — Patron ID from authentication.

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Svar

#### `200` Success

`PatronConsentResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "available": [
    {
      "type": "loan_history",
      "version": "2025-01"
    }
  ],
  "evaluated": [
    {
      "given": true,
      "type": "loan_history",
      "version": "2025-01"
    }
  ]
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

## Update one or more patron consent(s)

`PATCH` `/patron/{patronId}/consent` · `UpdatePatronConsent`

Update patron consents.

Only the consents that are present in the body will be updated.  
Other consents will not be updated.

The update is an atomic operation. If one consent fails to update, all consent updates in the request will be rolled back.

All consents are returned in the response, not only the updated consents.


### Eksempel på kald

**cURL**

```bash
curl -X PATCH "$PLAS_BASE_URL/patron/40218873/consent?version=0.6.4" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "consents": [
    {
      "given": true,
      "type": "loan_history",
      "version": "2025-01"
    }
  ]
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/consent?version=0.6.4`, {
  method: "PATCH",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "consents": [
      {
        "given": true,
        "type": "loan_history",
        "version": "2025-01"
      }
    ]
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.patch(
    f"{os.environ['PLAS_BASE_URL']}/patron/40218873/consent",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "consents": [
            {
                "given": True,
                "type": "loan_history",
                "version": "2025-01",
            },
        ],
    },
)
data = response.json()
```

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

### Parametre

- `patronId` (i `path`, `string`, påkrævet) — Patron ID from authentication.

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Request body

`application/json` · påkrævet

[`UpdatePatronConsentRequestBody`](https://plasapi.com/da/provider/v0.6.4/schemas/#UpdatePatronConsentRequestBody)

### Svar

#### `200` Success

`UpdatePatronConsentResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "available": [
    {
      "type": "loan_history",
      "version": "2025-01"
    }
  ],
  "evaluated": [
    {
      "given": true,
      "type": "loan_history",
      "version": "2025-01"
    }
  ]
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

## Get patron information

`GET` `/patron/{patronId}/information` · `GetPatronInformation`

Retrieve patron information

### Eksempel på kald

**cURL**

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

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/information?version=0.6.4`, {
  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/information",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

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

### Parametre

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

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Svar

#### `200` Success

`PatronInformationResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "patron": {
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no",
        "verified": "yes"
      }
    ],
    "fullName": "Kari Nordmann",
    "givenName": "Kari",
    "identifiers": [
      {
        "type": "local",
        "value": "N00012345"
      }
    ],
    "patronId": "40218873",
    "permissions": [
      {
        "reason": "The patron has unpaid fees above the library’s limit.",
        "status": "allowed",
        "type": "off_hours"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile",
        "verified": "yes"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    },
    "surname": "Nordmann"
  }
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

## Update patron information

`PATCH` `/patron/{patronId}/information` · `UpdatePatronInformation`

Update patron information.

Important: If a field is missing on the outermost level of the json body (like `pickupLocation`, `emails`, `phoneNumbers`, etc.), the field value is not updated in the LMS.


### Eksempel på kald

**cURL**

```bash
curl -X PATCH "$PLAS_BASE_URL/patron/40218873/information?version=0.6.4" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "address": {
    "city": "Nordby",
    "country": "Norway",
    "postalCode": "0182",
    "street": "Storgata 12"
  },
  "emails": [
    {
      "default": true,
      "email": "kari.nordmann@example.no"
    }
  ],
  "phoneNumbers": [
    {
      "default": true,
      "number": "+4791234567",
      "type": "mobile"
    }
  ],
  "pickupLocation": {
    "branchId": "nordby-main",
    "sections": [
      {
        "id": "nordby-main-children",
        "type": "department"
      }
    ]
  },
  "reservation": {
    "postpone": {
      "fromDate": "2025-03-01",
      "toDate": "2025-03-31"
    }
  }
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/information?version=0.6.4`, {
  method: "PATCH",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "sections": [
        {
          "id": "nordby-main-children",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    }
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.patch(
    f"{os.environ['PLAS_BASE_URL']}/patron/40218873/information",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "address": {
            "city": "Nordby",
            "country": "Norway",
            "postalCode": "0182",
            "street": "Storgata 12",
        },
        "emails": [
            {
                "default": True,
                "email": "kari.nordmann@example.no",
            },
        ],
        "phoneNumbers": [
            {
                "default": True,
                "number": "+4791234567",
                "type": "mobile",
            },
        ],
        "pickupLocation": {
            "branchId": "nordby-main",
            "sections": [
                {
                    "id": "nordby-main-children",
                    "type": "department",
                },
            ],
        },
        "reservation": {
            "postpone": {
                "fromDate": "2025-03-01",
                "toDate": "2025-03-31",
            },
        },
    },
)
data = response.json()
```

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

### Parametre

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

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Request body

`application/json` · påkrævet

[`UpdatePatronInformationRequestBody`](https://plasapi.com/da/provider/v0.6.4/schemas/#UpdatePatronInformationRequestBody)

### Svar

#### `200` Success

`UpdatePatronInformationResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "patron": {
    "address": {
      "city": "Nordby",
      "country": "Norway",
      "postalCode": "0182",
      "street": "Storgata 12"
    },
    "emails": [
      {
        "default": true,
        "email": "kari.nordmann@example.no",
        "verified": "yes"
      }
    ],
    "fullName": "Kari Nordmann",
    "givenName": "Kari",
    "identifiers": [
      {
        "type": "local",
        "value": "N00012345"
      }
    ],
    "patronId": "40218873",
    "permissions": [
      {
        "reason": "The patron has unpaid fees above the library’s limit.",
        "status": "allowed",
        "type": "off_hours"
      }
    ],
    "phoneNumbers": [
      {
        "default": true,
        "number": "+4791234567",
        "type": "mobile",
        "verified": "yes"
      }
    ],
    "pickupLocation": {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    },
    "reservation": {
      "postpone": {
        "fromDate": "2025-03-01",
        "toDate": "2025-03-31"
      }
    },
    "surname": "Nordmann"
  }
}
```

#### `202` Accepted, meaning that the request of a patron update was received, but processing will be done (or completed) later.

`UpdatePatronInformationRequestAcceptedResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "ticket": "4f1c2e9a"
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

## Get patron notifications settings

`GET` `/patron/{patronId}/notification-settings` · `GetPatronNotificationSettings`

Retrieve the patron's notification settings

### Eksempel på kald

**cURL**

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

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/notification-settings?version=0.6.4`, {
  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/notification-settings",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
)
data = response.json()
```

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

### Parametre

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

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Svar

#### `200` Success

`PatronNotificationSettingsResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "notificationSettings": [
    {
      "category": "reservations",
      "delivery": {
        "chosen": [
          {
            "method": "sms"
          }
        ],
        "methods": [
          {
            "method": "sms"
          }
        ]
      },
      "name": "Kari Nordmann",
      "type": "reservation_ready"
    }
  ]
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

## Update one or more patron notification settings

`PATCH` `/patron/{patronId}/notification-settings` · `UpdatePatronNotificationSettings`

Update patron notification settings.

Only the notification settings that are present in the body will be updated.  
Other notification settings will not be updated.

The update is an atomic operation. If one notification setting fails to update, all notification settings updates in the request will be rolled back.

All notification settings are returned in the response, not only the updated notification settings.


### Eksempel på kald

**cURL**

```bash
curl -X PATCH "$PLAS_BASE_URL/patron/40218873/notification-settings?version=0.6.4" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "notificationSettings": [
    {
      "chosen": [
        {
          "method": "sms"
        }
      ],
      "type": "reservation_ready"
    }
  ]
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/40218873/notification-settings?version=0.6.4`, {
  method: "PATCH",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "notificationSettings": [
      {
        "chosen": [
          {
            "method": "sms"
          }
        ],
        "type": "reservation_ready"
      }
    ]
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.patch(
    f"{os.environ['PLAS_BASE_URL']}/patron/40218873/notification-settings",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "notificationSettings": [
            {
                "chosen": [
                    {
                        "method": "sms",
                    },
                ],
                "type": "reservation_ready",
            },
        ],
    },
)
data = response.json()
```

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

### Parametre

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

Fælles for operationerne: `version`. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

### Request body

`application/json` · påkrævet

[`UpdatePatronNotificationSettingsRequestBody`](https://plasapi.com/da/provider/v0.6.4/schemas/#UpdatePatronNotificationSettingsRequestBody)

### Svar

#### `200` Success

`UpdatePatronNotificationSettingsResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "notificationSettings": [
    {
      "category": "reservations",
      "delivery": {
        "chosen": [
          {
            "method": "sms"
          }
        ],
        "methods": [
          {
            "method": "sms"
          }
        ]
      },
      "name": "Kari Nordmann",
      "type": "reservation_ready"
    }
  ]
}
```

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

`Errors`

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

Eksempel (Genereret ud fra skemaet):

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

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

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)

#### `404` Resource not found.

Intet indhold i svaret.

Fælles svar, defineret én gang for hele API’et. [Se den fælles kontrakt på versionssiden.](https://plasapi.com/da/provider/v0.6.4/)
