From 5c36bfdf7e52fb8c8a885eb18fd38b9a2f8314b0 Mon Sep 17 00:00:00 2001 From: Michelle <mis306@lehigh.edu> Date: Mon, 17 Feb 2020 16:32:37 -0500 Subject: [PATCH] Improve FOLIO's getMyHolds() method. - Simplify querying - Improve date processing --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 76d73a30c86..109af97c85f 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -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; -- GitLab