Skip to content
Snippets Groups Projects
Commit 444569e3 authored by Brad Busenius's avatar Brad Busenius Committed by Robert Lange
Browse files

FOLIO: use location discoveryDisplayName instead of name (#1692)

parent 8f19036d
Branches
Tags
No related merge requests found
......@@ -416,6 +416,36 @@ class Folio extends AbstractAPI implements
);
}
/**
* Gets the location name from the /locations endpoint and sets
* the display name to discoveryDisplayName, name, or code
* based on whichever is available first in that order.
*
* @param string $locationId ID of a location from the
* /holdings-storage/holdings endpoint
*
* @return string
*/
protected function getLocationName($locationId)
{
$locationName = '';
if (!empty($locationId)) {
$locationResponse = $this->makeRequest(
'GET',
'/locations/' . $locationId
);
$location = json_decode($locationResponse->getBody());
if (!empty($location->discoveryDisplayName)) {
$locationName = $location->discoveryDisplayName;
} elseif (!empty($location->name)) {
$locationName = $location->name;
} elseif (!empty($location->code)) {
$locationName = $location->code;
}
}
return $locationName;
}
/**
* This method queries the ILS for holding information.
*
......@@ -442,15 +472,8 @@ class Folio extends AbstractAPI implements
$holdingBody = json_decode($holdingResponse->getBody());
$items = [];
foreach ($holdingBody->holdingsRecords as $holding) {
$locationName = '';
if (!empty($holding->permanentLocationId)) {
$locationResponse = $this->makeRequest(
'GET',
'/locations/' . $holding->permanentLocationId
);
$location = json_decode($locationResponse->getBody());
$locationName = $location->name;
}
$locationId = $holding->permanentLocationId;
$locationName = $this->getLocationName($locationId);
$query = [
'query' => '(holdingsRecordId=="' . $holding->id
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment