# Location

Provider API v0.6.7 · 1 operation
Kilde: https://plasapi.com/da/provider/v0.6.7/location/

The library's branches and the sections inside them, with their names and IDs, and which branch is the main one. Other endpoints refer to these IDs, for example the pickup location on a reservation and the place where a checkout or checkin happened.

## Get locations

`GET` `/locations` · `GetLocations`

Get all branches (libraries) that exist, and all sections of the branches. Sections is a natural division of the branches into smaller and 
smaller locations (such as floor and/or department, etc.), and each section is part of the path that describes an item's location in a library.  
Each section object contains the actual location values (e.g. a section of type "department" could contain the location values "adult", "youngAdult" and "children").


### Eksempel på kald

**cURL**

```bash
curl -X GET "$PLAS_BASE_URL/locations?version=0.6.7" \
  -H 'Accept: application/json' \
  -H "Authorization: Bearer $PLAS_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch(`${process.env.PLAS_BASE_URL}/locations?version=0.6.7`, {
  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']}/locations",
    params={
        "version": "0.6.7",
    },
    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

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

### Svar

#### `200` Success

`LocationsResponseBody`

Eksempel (Genereret ud fra skemaet):

```json
{
  "branches": [
    {
      "coordinates": {
        "latitude": 59.9139,
        "longitude": 10.7522,
        "radius": 5000
      },
      "externals": {
        "identifiers": [
          {
            "type": "isil",
            "value": "0301"
          }
        ]
      },
      "id": "nordby-main",
      "name": "Nordby Main Library",
      "pickup": {
        "allow": true,
        "locations": [
          {
            "sections": [
              {
                "id": "nordby-main-children",
                "name": "Children’s department",
                "type": "department"
              }
            ]
          }
        ]
      },
      "tags": [
        "makerspace"
      ]
    }
  ],
  "mainBranch": {
    "branchId": "nordby-main",
    "branchName": "Nordby Main Library"
  },
  "pickupLocations": [
    {
      "branchId": "nordby-main",
      "branchName": "Nordby Main Library",
      "sections": [
        {
          "id": "nordby-main-children",
          "name": "Children’s department",
          "type": "department"
        }
      ]
    }
  ],
  "sections": [
    {
      "elements": [
        {
          "id": "nordby-main",
          "name": "Nordby Main Library",
          "parentId": "nordby-main"
        }
      ],
      "type": "department"
    }
  ]
}
```

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

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