From c1df58064ba82cee93f85044b83c62760b4b6585 Mon Sep 17 00:00:00 2001 From: Ian Hardy <ian.c.hardy@gmail.com> Date: Mon, 14 Oct 2019 07:23:46 -0400 Subject: [PATCH] update FOLIO driver getMyTransactions (#1461) --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 11 ++++++----- .../src/VuFindTest/ILS/Driver/FolioTest.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 997211fc80d..72d1911b8b2 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -514,7 +514,7 @@ class Folio extends AbstractAPI implements */ public function getMyTransactions($patron) { - $query = ['query' => 'userId==' . $patron['username']]; + $query = ['query' => 'userId==' . $patron['id']]; $response = $this->makeRequest("GET", '/circulation/loans', $query); $json = json_decode($response->getBody()); if (count($json->loans) == 0) { @@ -522,15 +522,16 @@ class Folio extends AbstractAPI implements } $transactions = []; foreach ($json->loans as $trans) { - $dueDate = date_create($trans['dueDate']); + $date = date_create($trans->dueDate); $transactions[] = [ 'duedate' => date_format($date, "j M Y"), 'dueTime' => date_format($date, "g:i:s a"), // TODO: Due Status // 'dueStatus' => $trans['itemId'], - 'id' => $trans['itemId'], - 'barcode' => $trans['item']['barcode'], - 'title' => $trans['item']['title'], + 'id' => $trans->item->instanceId, + 'item_id' => $trans->item->id, + 'barcode' => $trans->item->barcode, + 'title' => $trans->item->title, ]; } return $transactions; diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php index 8242d4da2e9..fc7f4d9dc93 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php @@ -158,7 +158,7 @@ class FolioTest extends \VuFindTest\Unit\TestCase public function testCheckValidToken() { $this->createConnector('check-valid-token'); - $profile = $this->driver->getMyTransactions(['username' => 'whatever']); + $profile = $this->driver->getMyTransactions(['id' => 'whatever']); // Check token $this->assertEquals('/users', $this->testRequestLog[0]['path']); // Move to method call -- GitLab