# Patron Registration

Provider API v0.6.4 · 3 operasjoner
Kilde: https://plasapi.com/no/provider/v0.6.4/patron-registration/

Ingen beskrivelse i spesifikasjonen.

## This will create a new patron, by the given identifier.

`POST` `/patron/registration/identifier` · `RegisterPatronByIdentifier`

### Eksempel på kall

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/registration/identifier?version=0.6.4" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "identifier": {
    "type": "local",
    "value": "N00012345"
  },
  "password": "correct-horse-battery",
  "pickupLocation": {
    "branchId": "nordby-main",
    "sections": [
      {
        "id": "nordby-main-children",
        "type": "department"
      }
    ]
  },
  "registry": "national"
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/registration/identifier?version=0.6.4`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "identifier": {
      "type": "local",
      "value": "N00012345"
    },
    "password": "correct-horse-battery",
    "pickupLocation": {
      "branchId": "nordby-main",
      "sections": [
        {
          "id": "nordby-main-children",
          "type": "department"
        }
      ]
    },
    "registry": "national"
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/registration/identifier",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "identifier": {
            "type": "local",
            "value": "N00012345",
        },
        "password": "correct-horse-battery",
        "pickupLocation": {
            "branchId": "nordby-main",
            "sections": [
                {
                    "id": "nordby-main-children",
                    "type": "department",
                },
            ],
        },
        "registry": "national",
    },
)
data = response.json()
```

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

### Parametere

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

### Request body

`application/json` · påkrevd

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

### Svar

#### `200` Success

`PatronRegistrationIdentifierResponseBody`

Eksempel (Generert fra skjemaet):

```json
{
  "message": "I accept the library’s terms of use.",
  "patronId": "40218873",
  "status": "done"
}
```

#### `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.4/)

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.4/)

## This will redirect the user to the chosen identity provider, for signup.

`GET` `/patron/registration/identity-provider` · `RegisterPatronByIdentityProvider`

This will redirect the user to the chosen identity provider, and create the user in the LMS.
[See a sequence flow diagram](https://storage.googleapis.com/open-library-api-files/images/idp.png).


### Eksempel på kall

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/patron/registration/identity-provider?type=bankid&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/registration/identity-provider?type=bankid&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/registration/identity-provider",
    params={
        "type": "bankid",
        "version": "0.6.4",
    },
    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

- `type` (i `query`, `string`, påkrevd) — Identity provider type. The different types are defined in the /configuration endpoint.

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

### Svar

#### `200` Success

`PatronRegistrationIdentityProviderResponseBody`

Eksempel (Generert fra skjemaet):

```json
{
  "message": "I accept the library’s terms of use.",
  "patronId": "40218873",
  "status": "done"
}
```

#### `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.4/)

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.4/)

## This will tell if it is possible to register a new patron, using the given identifier.

`POST` `/patron/registration/possible` · `IsPatronRegistrationPossible`

This will tell if it is possible to register a new patron, using the given identifier.  
The patron can then be registered through `POST /patron/registration/identifier`.


### Eksempel på kall

**cURL**

```bash
curl -X POST "$PLAS_BASE_URL/patron/registration/possible?version=0.6.4" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN" \
  -d '{
  "identifier": {
    "type": "local",
    "value": "N00012345"
  },
  "password": "correct-horse-battery"
}'
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/patron/registration/possible?version=0.6.4`, {
  method: "POST",
  headers: {
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.PLAS_TOKEN}`,
  },
  body: JSON.stringify({
    "identifier": {
      "type": "local",
      "value": "N00012345"
    },
    "password": "correct-horse-battery"
  }),
});
const data = await response.json();
```

**Python**

```python
import os
import requests

response = requests.post(
    f"{os.environ['PLAS_BASE_URL']}/patron/registration/possible",
    params={
        "version": "0.6.4",
    },
    headers={
        "Accept": "application/json",
        "Content-Type": "application/json",
        "Authorization": f"Bearer {os.environ['PLAS_TOKEN']}",
    },
    json={
        "identifier": {
            "type": "local",
            "value": "N00012345",
        },
        "password": "correct-horse-battery",
    },
)
data = response.json()
```

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

### Parametere

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

### Request body

`application/json` · påkrevd

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

### Svar

#### `200` Success

`IsPatronRegistrationPossibleResponseBody`

Eksempel (Generert fra skjemaet):

```json
{
  "registries": [
    {
      "type": "norway_national_library_card"
    }
  ]
}
```

#### `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.4/)

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.4/)
