Skip to content
Snippets Groups Projects
Commit 5c36bfdf authored by Michelle's avatar Michelle Committed by Robert Lange
Browse files

Improve FOLIO's getMyHolds() method.

- Simplify querying
- Improve date processing
parent d4324fbf
Branches
Tags
No related merge requests found
......@@ -661,24 +661,24 @@ class Folio extends AbstractAPI implements
*/
public function getMyHolds($patron)
{
// Get user id
$query = ['query' => 'username == "' . $patron['username'] . '"'];
$response = $this->makeRequest('GET', '/users', $query);
$users = json_decode($response->getBody());
$query = [
'query' => 'requesterId == "' . $users->users[0]->id . '"' .
' and requestType == "Hold"'
'query' => 'requesterId == "' . $patron['id'] . '"'
];
// Request HOLDS
$response = $this->makeRequest('GET', '/request-storage/requests', $query);
$json = json_decode($response->getBody());
$holds = [];
foreach ($json->requests as $hold) {
$requestDate = date_create($hold->requestDate);
// Set expire date if it was included in the response
$expireDate = isset($hold->requestExpirationDate)
? date_create($hold->requestExpirationDate) : null;
$holds[] = [
'type' => 'Hold',
'create' => $hold->requestDate,
'expire' => $hold->requestExpirationDate,
'create' => date_format($requestDate, "j M Y"),
'expire' => isset($expireDate)
? date_format($expireDate, "j M Y") : "",
'id' => $this->getBibId(null, null, $hold->itemId),
'title' => $hold->item->title
];
}
return $holds;
......
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