From e852b5e3254865c01203546b9ded34a85c48ec2c Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 16 Aug 2016 13:37:29 +0300 Subject: [PATCH] Bug 17008: Fix current data types This patch changes current Swagger definitions for patrons and holds to have data types corresponding to column data types in their database tables. To test: 1. Run t/db_dependent/api/v1/swagger/definitions.t 2. Note that test has a lot of failures. 3. Apply this patch. 4. Run t/db_dependent/api/v1/swagger/definitions.t 5. Note that tests pass. 6. Run REST of the tests in t/db_dependent/api/v1/* --- Koha/REST/V1/Hold.pm | 12 ++++++------ Koha/REST/V1/Patron.pm | 4 ++-- api/v1/definitions/hold.json | 20 +++++++++++++++++--- api/v1/definitions/patron.json | 16 ++++++++-------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Koha/REST/V1/Hold.pm b/Koha/REST/V1/Hold.pm index 7f0b1ff..9410396 100644 --- a/Koha/REST/V1/Hold.pm +++ b/Koha/REST/V1/Hold.pm @@ -34,9 +34,9 @@ sub list { foreach my $key (keys %$params) { delete $params->{$key} unless grep { $key eq $_ } @valid_params; } - my $holds = Koha::Holds->search($params)->unblessed; + my $holds = Koha::Holds->search($params); - return $c->$cb($holds, 200); + return $c->$cb($holds->swaggerize, 200); } sub add { @@ -106,9 +106,9 @@ sub add { }, 500); } - my $reserve = C4::Reserves::GetReserve($reserve_id); + my $reserve = Koha::Holds->find($reserve_id); - return $c->$cb($reserve, 201); + return $c->$cb($reserve->swaggerize, 201); } sub edit { @@ -138,9 +138,9 @@ sub edit { suspend_until => $suspend_until, }; C4::Reserves::ModReserve($params); - $reserve = C4::Reserves::GetReserve($reserve_id); + $reserve = Koha::Holds->find($reserve_id); - return $c->$cb($reserve, 200); + return $c->$cb($reserve->swaggerize, 200); } sub delete { diff --git a/Koha/REST/V1/Patron.pm b/Koha/REST/V1/Patron.pm index 2851308..042a24b 100644 --- a/Koha/REST/V1/Patron.pm +++ b/Koha/REST/V1/Patron.pm @@ -32,7 +32,7 @@ sub list { my $patrons = Koha::Patrons->search; - $c->$cb($patrons->unblessed, 200); + $c->$cb($patrons->swaggerize, 200); } sub get { @@ -52,7 +52,7 @@ sub get { return $c->$cb({error => "Patron not found"}, 404); } - return $c->$cb($patron->unblessed, 200); + return $c->$cb($patron->swaggerize, 200); } 1; diff --git a/api/v1/definitions/hold.json b/api/v1/definitions/hold.json index 620187e..5fd8b7a 100644 --- a/api/v1/definitions/hold.json +++ b/api/v1/definitions/hold.json @@ -2,17 +2,19 @@ "type": "object", "properties": { "reserve_id": { + "type": "integer", "description": "Internal hold identifier" }, "borrowernumber": { - "type": "string", + "type": "integer", "description": "internally assigned user identifier" }, "reservedate": { + "type": ["string", "null"], "description": "the date the hold was placed" }, "biblionumber": { - "type": "string", + "type": "integer", "description": "internally assigned biblio identifier" }, "branchcode": { @@ -20,43 +22,55 @@ "description": "internally assigned branch identifier" }, "notificationdate": { + "type": ["string", "null"], "description": "currently unused" }, "reminderdate": { + "type": ["string", "null"], "description": "currently unused" }, "cancellationdate": { + "type": ["string", "null"], "description": "the date the hold was cancelled" }, "reservenotes": { + "type": ["string", "null"], "description": "notes related to this hold" }, "priority": { + "type": ["integer", "null"], "description": "where in the queue the patron sits" }, "found": { + "type": ["string", "null"], "description": "a one letter code defining what the status of the hold is after it has been confirmed" }, "timestamp": { + "type": "string", "description": "date and time the hold was last updated" }, "itemnumber": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "internally assigned item identifier" }, "waitingdate": { + "type": ["string", "null"], "description": "the date the item was marked as waiting for the patron at the library" }, "expirationdate": { + "type": ["string", "null"], "description": "the date the hold expires" }, "lowestPriority": { + "type": "integer", "description": "" }, "suspend": { + "type": "integer", "description": "" }, "suspend_until": { + "type": ["string", "null"], "description": "" }, "itemtype": { diff --git a/api/v1/definitions/patron.json b/api/v1/definitions/patron.json index 8e7d08b..fcf9008 100644 --- a/api/v1/definitions/patron.json +++ b/api/v1/definitions/patron.json @@ -2,7 +2,7 @@ "type": "object", "properties": { "borrowernumber": { - "type": "string", + "type": "integer", "description": "internally assigned user identifier" }, "cardnumber": { @@ -146,11 +146,11 @@ "description": "date the patron's card is set to expire" }, "gonenoaddress": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "set to 1 if library marked this patron as having an unconfirmed address" }, "lost": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "set to 1 if library marked this patron as having lost his card" }, "debarred": { @@ -174,7 +174,7 @@ "description": "used for children to include title of guarantor" }, "guarantorid": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "borrowernumber used for children or professionals to link them to guarantor or organizations" }, "borrowernotes": { @@ -194,7 +194,7 @@ "description": "patron's encrypted password" }, "flags": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "a number associated with the patron's permissions" }, "userid": { @@ -258,15 +258,15 @@ "description": "the mobile phone number where the patron would like to receive notices (if SMS turned on)" }, "sms_provider_id": { - "type": ["string", "null"], + "type": ["integer", "null"], "description": "the provider of the mobile phone number defined in smsalertnumber" }, "privacy": { - "type": "string", + "type": "integer", "description": "patron's privacy settings related to their reading history" }, "privacy_guarantor_checkouts": { - "type": "string", + "type": "integer", "description": "controls if relatives can see this patron's checkouts" }, "checkprevcheckout": { -- 1.9.1