From f9fdcbd5163b416ae54c1d5053f7069d9ac53355 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 8 Dec 2017 09:35:45 -0300 Subject: [PATCH] Bug 19784: Adapt /v1/patrons to new naming guidelines This patch introduces two functions to the patrons endpoint: - _to_api - _to_model This are in charge of field mappings in order to comply with the guidelines. Koha::REST::V1:Auth is adjusted to handle 'patron_id' as well. 'borrowernumber' handling is kept until the existing endpoints get updated. To test: - Apply the patches - Run: $ kshell k$ prove t/db_dependent/api/v1/*.t => SUCCESS: Tests pass! - Sign off :-D --- Koha/REST/V1/Auth.pm | 9 +- Koha/REST/V1/Patrons.pm | 263 +++++++++++++++++++++++++++++---- api/v1/swagger/definitions/patron.json | 130 +++++++--------- api/v1/swagger/parameters.json | 8 +- api/v1/swagger/parameters/patron.json | 10 +- api/v1/swagger/paths.json | 4 +- api/v1/swagger/paths/patrons.json | 232 ++++++++++++----------------- api/v1/swagger/x-primitives.json | 4 +- 8 files changed, 402 insertions(+), 258 deletions(-) diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm index 77864eb26d..c76d26fe36 100644 --- a/Koha/REST/V1/Auth.pm +++ b/Koha/REST/V1/Auth.pm @@ -254,7 +254,8 @@ sub check_object_ownership { my $parameters = { accountlines_id => \&_object_ownership_by_accountlines_id, - borrowernumber => \&_object_ownership_by_borrowernumber, + borrowernumber => \&_object_ownership_by_patron_id, + patron_id => \&_object_ownership_by_patron_id, checkout_id => \&_object_ownership_by_checkout_id, reserve_id => \&_object_ownership_by_reserve_id, }; @@ -296,10 +297,10 @@ Compares C<$borrowernumber> to currently logged in C<$user>. =cut -sub _object_ownership_by_borrowernumber { - my ($c, $user, $borrowernumber) = @_; +sub _object_ownership_by_patron_id { + my ($c, $user, $patron_id) = @_; - return $user->borrowernumber == $borrowernumber; + return $user->borrowernumber == $patron_id; } =head3 _object_ownership_by_checkout_id diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm index 42a2b15adf..2c1934ab0a 100644 --- a/Koha/REST/V1/Patrons.pm +++ b/Koha/REST/V1/Patrons.pm @@ -43,14 +43,46 @@ sub list { my $c = shift->openapi->valid_input or return; return try { - my $patrons_set = Koha::Patrons->new; - my $patrons = $c->objects->search( $patrons_set ); - return $c->render( status => 200, openapi => $patrons ); + my $attributes = {}; + my $args = $c->validation->output; + my ( $params, $reserved_params ) = $c->extract_reserved_params( $args ); + + # Merge sorting into query attributes + $c->dbic_merge_sorting({ attributes => $attributes, params => $reserved_params }); + + # Merge pagination into query attributes + $c->dbic_merge_pagination({ filter => $attributes, params => $reserved_params }); + + my $restricted = $args->{restricted}; + + $params = _to_model($params) + if defined $params; + # deal with string params + $params = $c->build_query_params( $params, $reserved_params ); + + # translate 'restricted' => 'debarred' + $params->{debarred} = { '!=' => undef } + if $restricted; + + my $patrons = Koha::Patrons->search( $params, $attributes ); + if ( $patrons->is_paged ) { + $c->add_pagination_headers( + { + total => $patrons->pager->total_entries, + params => $args, + } + ); + } + my @patrons = $patrons->as_list; + @patrons = map { _to_api( $_->TO_JSON ) } @patrons; + return $c->render( status => 200, openapi => \@patrons ); } catch { if ( $_->isa('DBIx::Class::Exception') ) { - return $c->render( status => 500, - openapi => { error => $_->{msg} } ); + return $c->render( + status => 500, + openapi => { error => $_->{msg} } + ); } else { return $c->render( @@ -61,6 +93,7 @@ sub list { }; } + =head3 get Controller function that handles retrieving a single Koha::Patron object @@ -70,14 +103,14 @@ Controller function that handles retrieving a single Koha::Patron object sub get { my $c = shift->openapi->valid_input or return; - my $borrowernumber = $c->validation->param('borrowernumber'); - my $patron = Koha::Patrons->find($borrowernumber); + my $patron_id = $c->validation->param('patron_id'); + my $patron = Koha::Patrons->find($patron_id); unless ($patron) { - return $c->render(status => 404, openapi => { error => "Patron not found." }); + return $c->render( status => 404, openapi => { error => "Patron not found." } ); } - return $c->render(status => 200, openapi => $patron); + return $c->render( status => 200, openapi => _to_api( $patron->TO_JSON ) ); } =head3 add @@ -91,11 +124,11 @@ sub add { return try { - my $body = _to_model($c->validation->param('body')); + my $body = _to_model( $c->validation->param('body') ); # TODO: Use AddMember until it has been moved to Koha-namespace - my $borrowernumber = AddMember(%$body); - my $patron = Koha::Patrons->find($borrowernumber); + my $patron_id = AddMember( %{ _to_model($body) } ); + my $patron = _to_api( Koha::Patrons->find($patron_id)->TO_JSON ); return $c->render( status => 201, openapi => $patron ); } @@ -103,9 +136,7 @@ sub add { unless ( blessed $_ && $_->can('rethrow') ) { return $c->render( status => 500, - openapi => { - error => "Something went wrong, check Koha logs for details." - } + openapi => { error => "Something went wrong, check Koha logs for details." } ); } if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) { @@ -117,26 +148,33 @@ sub add { elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { return $c->render( status => 400, - openapi => { error => "Given " . $_->broken_fk . " does not exist" } + openapi => { + error => "Given " + . $Koha::REST::V1::Patrons::to_api_mapping->{ $_->broken_fk } + . " does not exist" + } ); } elsif ( $_->isa('Koha::Exceptions::BadParameter') ) { return $c->render( status => 400, - openapi => { error => "Given " . $_->parameter . " does not exist" } + openapi => { + error => "Given " + . $Koha::REST::V1::Patrons::to_api_mapping->{ $_->parameter } + . " does not exist" + } ); } else { return $c->render( status => 500, - openapi => { - error => "Something went wrong, check Koha logs for details." - } + openapi => { error => "Something went wrong, check Koha logs for details." } ); } }; } + =head3 update Controller function that handles updating a Koha::Patron object @@ -146,7 +184,7 @@ Controller function that handles updating a Koha::Patron object sub update { my $c = shift->openapi->valid_input or return; - my $patron_id = $c->validation->param('borrowernumber'); + my $patron_id = $c->validation->param('patron_id'); my $patron = Koha::Patrons->find( $patron_id ); unless ($patron) { @@ -195,7 +233,9 @@ sub update { elsif ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) { return $c->render( status => 400, - openapi => { error => "Given " . $_->broken_fk . " does not exist" } + openapi => { error => "Given " . + $Koha::REST::V1::Patrons::to_api_mapping->{$_->broken_fk} + . " does not exist" } ); } elsif ( $_->isa('Koha::Exceptions::MissingParameter') ) { @@ -246,7 +286,7 @@ sub delete { my $patron; return try { - $patron = Koha::Patrons->find( $c->validation->param('borrowernumber') ); + $patron = Koha::Patrons->find( $c->validation->param('patron_id') ); # check if loans, reservations, debarrment, etc. before deletion! my $res = $patron->delete; @@ -271,6 +311,41 @@ sub delete { }; } +=head3 _to_api + +Helper function that maps unblessed Koha::Patron objects into REST api +attribute names. + +=cut + +sub _to_api { + my $patron = shift; + my $patron_id = $patron->{ borrowernumber }; + + # Rename attributes + foreach my $column ( keys %{ $Koha::REST::V1::Patrons::to_api_mapping } ) { + my $mapped_column = $Koha::REST::V1::Patrons::to_api_mapping->{$column}; + if ( exists $patron->{ $column } + && defined $mapped_column ) + { + # key != undef + $patron->{ $mapped_column } = delete $patron->{ $column }; + } + elsif ( exists $patron->{ $column } + && !defined $mapped_column ) + { + # key == undef + delete $patron->{ $column }; + } + } + + # Calculate the 'restricted' field + my $patron_obj = Koha::Patrons->find( $patron_id ); + $patron->{ restricted } = ($patron_obj->is_debarred) ? Mojo::JSON->true : Mojo::JSON->false; + + return $patron; +} + =head3 _to_model Helper function that maps REST api objects into Koha::Patron @@ -279,12 +354,146 @@ attribute names. =cut sub _to_model { - my $params = shift; + my $patron = shift; + + foreach my $attribute ( keys %{ $Koha::REST::V1::Patrons::to_model_mapping } ) { + my $mapped_attribute = $Koha::REST::V1::Patrons::to_model_mapping->{$attribute}; + if ( exists $patron->{ $attribute } + && defined $mapped_attribute ) + { + # key => !undef + $patron->{ $mapped_attribute } = delete $patron->{ $attribute }; + } + elsif ( exists $patron->{ $attribute } + && !defined $mapped_attribute ) + { + # key => undef / to be deleted + delete $patron->{ $attribute }; + } + } + + # TODO: Get rid of this once write operations are based on Koha::Patron + if ( exists $patron->{lost} ) { + $patron->{lost} = ($patron->{lost}) ? 1 : 0; + } - $params->{lost} = ($params->{lost}) ? 1 : 0; - $params->{gonenoaddress} = ($params->{gonenoaddress}) ? 1 : 0; + if ( exists $patron->{ gonenoaddress} ) { + $patron->{gonenoaddress} = ($patron->{gonenoaddress}) ? 1 : 0; + } - return $params; + return $patron; } +=head2 Global variables + +=head3 $to_api_mapping + +=cut + +our $to_api_mapping = { + borrowernotes => 'staff_notes', + borrowernumber => 'patron_id', + branchcode => 'library_id', + categorycode => 'category_id', + checkprevcheckout => 'check_previous_checkout', + contactfirstname => undef, # Unused + contactname => undef, # Unused + contactnote => 'altaddress_notes', + contacttitle => undef, # Unused + dateenrolled => 'date_enrolled', + dateexpiry => 'expiry_date', + dateofbirth => 'date_of_birth', + debarred => undef, # replaced by 'restricted' + debarredcomment => undef, # calculated, API consumers will use /restrictions instead + emailpro => 'secondary_email', + flags => undef, # permissions manipulation handled in /permissions + gonenoaddress => 'incorrect_address', + guarantorid => 'guarantor_id', + lastseen => 'last_seen', + lost => 'patron_card_lost', + opacnote => 'opac_notes', + othernames => 'other_name', + password => undef, # password manipulation handled in /password + phonepro => 'secondary_phone', + relationship => 'relationship_type', + sex => 'gender', + smsalertnumber => 'sms_number', + sort1 => 'statistics_1', + sort2 => 'statistics_2', + streetnumber => 'street_number', + streettype => 'street_type', + zipcode => 'postal_code', + B_address => 'altaddress_address', + B_address2 => 'altaddress_address2', + B_city => 'altaddress_city', + B_country => 'altaddress_country', + B_email => 'altaddress_email', + B_phone => 'altaddress_phone', + B_state => 'altaddress_state', + B_streetnumber => 'altaddress_street_number', + B_streettype => 'altaddress_street_type', + B_zipcode => 'altaddress_postal_code', + altcontactaddress1 => 'altcontact_address', + altcontactaddress2 => 'altcontact_address2', + altcontactaddress3 => 'altcontact_city', + altcontactcountry => 'altcontact_country', + altcontactfirstname => 'altcontact_firstname', + altcontactphone => 'altcontact_phone', + altcontactsurname => 'altcontact_surname', + altcontactstate => 'altcontact_state', + altcontactzipcode => 'altcontact_postal_code' +}; + +=head3 $to_model_mapping + +=cut + +our $to_model_mapping = { + altaddress_notes => 'contactnote', + category_id => 'categorycode', + check_previous_checkout => 'checkprevcheckout', + date_enrolled => 'dateenrolled', + date_of_birth => 'dateofbirth', + expiry_date => 'dateexpiry', + gender => 'sex', + guarantor_id => 'guarantorid', + incorrect_address => 'gonenoaddress', + last_seen => 'lastseen', + library_id => 'branchcode', + opac_notes => 'opacnote', + other_name => 'othernames', + patron_card_lost => 'lost', + patron_id => 'borrowernumber', + postal_code => 'zipcode', + relationship_type => 'relationship', + restricted => undef, + secondary_email => 'emailpro', + secondary_phone => 'phonepro', + sms_number => 'smsalertnumber', + staff_notes => 'borrowernotes', + statistics_1 => 'sort1', + statistics_2 => 'sort2', + street_number => 'streetnumber', + street_type => 'streettype', + altaddress_address => 'B_address', + altaddress_address2 => 'B_address2', + altaddress_city => 'B_city', + altaddress_country => 'B_country', + altaddress_email => 'B_email', + altaddress_phone => 'B_phone', + altaddress_state => 'B_state', + altaddress_street_number => 'B_streetnumber', + altaddress_street_type => 'B_streettype', + altaddress_postal_code => 'B_zipcode', + altcontact_firstname => 'altcontactfirstname', + altcontact_surname => 'altcontactsurname', + altcontact_address => 'altcontactaddress1', + altcontact_address2 => 'altcontactaddress2', + altcontact_city => 'altcontactaddress3', + altcontact_state => 'altcontactstate', + altcontact_postal_code => 'altcontactzipcode', + altcontact_country => 'altcontactcountry', + altcontact_phone => 'altcontactphone' +}; + 1; diff --git a/api/v1/swagger/definitions/patron.json b/api/v1/swagger/definitions/patron.json index 948b9569db..5d6ccd82c0 100644 --- a/api/v1/swagger/definitions/patron.json +++ b/api/v1/swagger/definitions/patron.json @@ -1,8 +1,8 @@ { "type": "object", "properties": { - "borrowernumber": { - "$ref": "../x-primitives.json#/borrowernumber" + "patron_id": { + "$ref": "../x-primitives.json#/patron_id" }, "cardnumber": { "$ref": "../x-primitives.json#/cardnumber" @@ -17,7 +17,7 @@ "type": ["string", "null"], "description": "patron's title" }, - "othernames": { + "other_name": { "type": ["string", "null"], "description": "any other names associated with the patron" }, @@ -25,11 +25,11 @@ "type": ["string", "null"], "description": "initials of the patron" }, - "streetnumber": { + "street_number": { "type": ["string", "null"], "description": "street number of patron's primary address" }, - "streettype": { + "street_type": { "type": ["string", "null"], "description": "street type of patron's primary address" }, @@ -49,7 +49,7 @@ "type": ["string", "null"], "description": "state or province of patron's primary address" }, - "zipcode": { + "postal_code": { "type": ["string", "null"], "description": "zip or postal code of patron's primary address" }, @@ -71,73 +71,73 @@ "type": ["string", "null"], "description": "fax number for patron's primary address" }, - "emailpro": { + "secondary_email": { "type": ["string", "null"], "description": "secondary email address for patron's primary address" }, - "phonepro": { + "secondary_phone": { "type": ["string", "null"], "description": "secondary phone number for patron's primary address" }, - "B_streetnumber": { + "altaddress_street_number": { "type": ["string", "null"], "description": "street number of patron's alternate address" }, - "B_streettype": { + "altaddress_street_type": { "type": ["string", "null"], "description": "street type of patron's alternate address" }, - "B_address": { + "altaddress_address": { "type": ["string", "null"], "description": "first address line of patron's alternate address" }, - "B_address2": { + "altaddress_address2": { "type": ["string", "null"], "description": "second address line of patron's alternate address" }, - "B_city": { + "altaddress_city": { "type": ["string", "null"], "description": "city or town of patron's alternate address" }, - "B_state": { + "altaddress_state": { "type": ["string", "null"], "description": "state or province of patron's alternate address" }, - "B_zipcode": { + "altaddress_postal_code": { "type": ["string", "null"], "description": "zip or postal code of patron's alternate address" }, - "B_country": { + "altaddress_country": { "type": ["string", "null"], "description": "country of patron's alternate address" }, - "B_email": { + "altaddress_email": { "type": ["string", "null"], "description": "email address for patron's alternate address" }, - "B_phone": { + "altaddress_phone": { "type": ["string", "null"], "description": "phone number for patron's alternate address" }, - "dateofbirth": { + "date_of_birth": { "type": ["string", "null"], "format": "date", "description": "patron's date of birth" }, - "branchcode": { + "library_id": { "type": "string", - "description": "code of patron's home branch" + "description": "Internal identifier for the patron's home library" }, - "categorycode": { + "category_id": { "type": "string", - "description": "code of patron's category" + "description": "Internal identifier for the patron's category" }, - "dateenrolled": { + "date_enrolled": { "type": ["string", "null"], "format": "date", "description": "date the patron was added to Koha" }, - "dateexpiry": { + "expiry_date": { "type": ["string", "null"], "format": "date", "description": "date the patron's card is set to expire" @@ -146,116 +146,92 @@ "type": ["string", "null"], "description": "date the patron's card was last renewed" }, - "gonenoaddress": { + "incorrect_address": { "type": ["boolean", "null"], "description": "set to 1 if library marked this patron as having an unconfirmed address" }, - "lost": { + "patron_card_lost": { "type": ["boolean", "null"], "description": "set to 1 if library marked this patron as having lost his card" }, - "debarred": { - "type": ["string", "null"], - "format": "date", - "description": "until this date the patron can only check-in" - }, - "debarredcomment": { - "type": ["string", "null"], - "description": "comment on the stop of the patron" - }, - "contactname": { - "type": ["string", "null"], - "description": "used for children and professionals to include surname or last name of guarantor or organization name" - }, - "contactfirstname": { - "type": ["string", "null"], - "description": "used for children to include first name of guarantor" - }, - "contacttitle": { - "type": ["string", "null"], - "description": "used for children to include title of guarantor" + "restricted": { + "type": "boolean", + "readOnly": true, + "description": "If any restriction applies to the patron" }, - "guarantorid": { + "guarantor_id": { "type": ["integer", "null"], - "description": "borrowernumber used for children or professionals to link them to guarantor or organizations" + "description": "patron_id used for children or professionals to link them to guarantor or organizations" }, - "borrowernotes": { + "staff_notes": { "type": ["string", "null"], "description": "a note on the patron's account" }, - "relationship": { + "relationship_type": { "type": ["string", "null"], "description": "used for children to include the relationship to their guarantor" }, - "sex": { + "gender": { "type": ["string", "null"], "description": "patron's gender" }, - "password": { - "type": ["string", "null"], - "description": "patron's encrypted password" - }, - "flags": { - "type": ["integer", "null"], - "description": "a number associated with the patron's permissions" - }, "userid": { "type": ["string", "null"], "description": "patron's login" }, - "opacnote": { + "opac_notes": { "type": ["string", "null"], "description": "a note on the patron's account visible in OPAC and staff client" }, - "contactnote": { + "altaddress_notes": { "type": ["string", "null"], "description": "a note related to patron's alternate address" }, - "sort1": { + "statistics_1": { "type": ["string", "null"], "description": "a field that can be used for any information unique to the library" }, - "sort2": { + "statistics_2": { "type": ["string", "null"], "description": "a field that can be used for any information unique to the library" }, - "altcontactfirstname": { + "altcontact_firstname": { "type": ["string", "null"], "description": "first name of alternate contact for the patron" }, - "altcontactsurname": { + "altcontact_surname": { "type": ["string", "null"], "description": "surname or last name of the alternate contact for the patron" }, - "altcontactaddress1": { + "altcontact_address": { "type": ["string", "null"], "description": "the first address line for the alternate contact for the patron" }, - "altcontactaddress2": { + "altcontact_address2": { "type": ["string", "null"], "description": "the second address line for the alternate contact for the patron" }, - "altcontactaddress3": { + "altcontact_city": { "type": ["string", "null"], "description": "the city for the alternate contact for the patron" }, - "altcontactstate": { + "altcontact_state": { "type": ["string", "null"], "description": "the state for the alternate contact for the patron" }, - "altcontactzipcode": { + "altcontact_postal_code": { "type": ["string", "null"], "description": "the zipcode for the alternate contact for the patron" }, - "altcontactcountry": { + "altcontact_country": { "type": ["string", "null"], "description": "the country for the alternate contact for the patron" }, - "altcontactphone": { + "altcontact_phone": { "type": ["string", "null"], "description": "the phone number for the alternate contact for the patron" }, - "smsalertnumber": { + "sms_number": { "type": ["string", "null"], "description": "the mobile phone number where the patron would like to receive notices (if SMS turned on)" }, @@ -271,7 +247,7 @@ "type": "integer", "description": "controls if relatives can see this patron's checkouts" }, - "checkprevcheckout": { + "check_previous_checkout": { "type": "string", "description": "produce a warning for this patron if this item has previously been checked out to this patron if 'yes', not if 'no', defer to category setting if 'inherit'" }, @@ -280,7 +256,7 @@ "format": "date-time", "description": "time of last change could be useful for synchronization with external systems (among others)" }, - "lastseen": { + "last_seen": { "type": ["string", "null"], "format": "date-time", "description": "last time a patron has been seen (connected at the OPAC or staff interface)" @@ -299,5 +275,5 @@ } }, "additionalProperties": false, - "required": ["surname", "address", "city", "branchcode", "categorycode"] + "required": ["surname", "address", "city", "library_id", "category_id"] } diff --git a/api/v1/swagger/parameters.json b/api/v1/swagger/parameters.json index 584a0c2112..d951cf7d99 100644 --- a/api/v1/swagger/parameters.json +++ b/api/v1/swagger/parameters.json @@ -1,9 +1,9 @@ { - "borrowernumberPathParam": { - "$ref": "parameters/patron.json#/borrowernumberPathParam" + "patron_id_pp": { + "$ref": "parameters/patron.json#/patron_id_pp" }, - "borrowernumberQueryParam": { - "$ref": "parameters/patron.json#/borrowernumberQueryParam" + "patron_id_qp": { + "$ref": "parameters/patron.json#/patron_id_qp" }, "city_id_pp": { "$ref": "parameters/city.json#/city_id_pp" diff --git a/api/v1/swagger/parameters/patron.json b/api/v1/swagger/parameters/patron.json index 409d0b2c35..d2114ba36f 100644 --- a/api/v1/swagger/parameters/patron.json +++ b/api/v1/swagger/parameters/patron.json @@ -1,15 +1,15 @@ { - "borrowernumberPathParam": { - "name": "borrowernumber", + "patron_id_pp": { + "name": "patron_id", "in": "path", "description": "Internal patron identifier", "required": true, "type": "integer" }, - "borrowernumberQueryParam": { - "name": "borrowernumber", + "patron_id_qp": { + "name": "patron_id", "in": "query", - "description": "Internal borrower identifier", + "description": "Internal patron identifier", "type": "integer" } } diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json index df4f55a999..f3e843e6c3 100644 --- a/api/v1/swagger/paths.json +++ b/api/v1/swagger/paths.json @@ -20,8 +20,8 @@ "/patrons": { "$ref": "paths/patrons.json#/~1patrons" }, - "/patrons/{borrowernumber}": { - "$ref": "paths/patrons.json#/~1patrons~1{borrowernumber}" + "/patrons/{patron_id}": { + "$ref": "paths/patrons.json#/~1patrons~1{patron_id}" }, "/illrequests": { "$ref": "paths/illrequests.json#/~1illrequests" diff --git a/api/v1/swagger/paths/patrons.json b/api/v1/swagger/paths/patrons.json index f4505a89d5..4a710d6924 100644 --- a/api/v1/swagger/paths/patrons.json +++ b/api/v1/swagger/paths/patrons.json @@ -8,9 +8,9 @@ "application/json" ], "parameters": [{ - "name": "borrowernumber", + "name": "patron_id", "in": "query", - "description": "Case insensitive search on borrowernumber", + "description": "Search on patron_id", "required": false, "type": "string" }, { @@ -38,7 +38,7 @@ "required": false, "type": "string" }, { - "name": "othernames", + "name": "other_name", "in": "query", "description": "Case insensitive search on othernames", "required": false, @@ -50,13 +50,13 @@ "required": false, "type": "string" }, { - "name": "streetnumber", + "name": "street_number", "in": "query", "description": "Case insensitive search on streetnumber", "required": false, "type": "string" }, { - "name": "streettype", + "name": "street_type", "in": "query", "description": "Case insensitive search on streettype", "required": false, @@ -86,7 +86,7 @@ "required": false, "type": "string" }, { - "name": "zipcode", + "name": "postal_code", "in": "query", "description": "Case insensitive search on zipcode", "required": false, @@ -122,183 +122,147 @@ "required": false, "type": "string" }, { - "name": "emailpro", + "name": "secondary_email", "in": "query", - "description": "Case insensitive search on emailpro", + "description": "Case insensitive search on secondary_email", "required": false, "type": "string" }, { - "name": "phonepro", + "name": "secondary_phone", "in": "query", - "description": "Case insensitive search on phonepro", + "description": "Case insensitive search on secondary_phone", "required": false, "type": "string" }, { - "name": "B_streetnumber", + "name": "altaddress_street_number", "in": "query", - "description": "Case insensitive search on B_streetnumber", + "description": "Case insensitive search on altaddress_street_number", "required": false, "type": "string" }, { - "name": "B_streettype", + "name": "altaddress_street_type", "in": "query", - "description": "Case insensitive search on B_streettype", + "description": "Case insensitive search on altaddress_street_type", "required": false, "type": "string" }, { - "name": "B_address", + "name": "altaddress_address", "in": "query", - "description": "Case insensitive search on B_address", + "description": "Case insensitive search on altaddress_address", "required": false, "type": "string" }, { - "name": "B_address2", + "name": "altaddress_address2", "in": "query", - "description": "Case insensitive search on B_address2", + "description": "Case insensitive search on altaddress_address2", "required": false, "type": "string" }, { - "name": "B_city", + "name": "altaddress_city", "in": "query", - "description": "Case insensitive search on B_city", + "description": "Case insensitive search on altaddress_city", "required": false, "type": "string" }, { - "name": "B_state", + "name": "altaddress_state", "in": "query", - "description": "Case insensitive search on B_state", + "description": "Case insensitive search on altaddress_state", "required": false, "type": "string" }, { - "name": "B_zipcode", + "name": "altaddress_postal_code", "in": "query", - "description": "Case insensitive search on B_zipcode", + "description": "Case insensitive search on altaddress_postal_code", "required": false, "type": "string" }, { - "name": "B_country", + "name": "altaddress_country", "in": "query", - "description": "Case insensitive search on B_country", + "description": "Case insensitive search on altaddress_country", "required": false, "type": "string" }, { - "name": "B_email", + "name": "altaddress_email", "in": "query", - "description": "Case insensitive search on B_email", + "description": "Case insensitive search on altaddress_email", "required": false, "type": "string" }, { - "name": "B_phone", + "name": "altaddress_phone", "in": "query", - "description": "Case insensitive search on B_phone", + "description": "Case insensitive search on altaddress_phone", "required": false, "type": "string" }, { - "name": "dateofbirth", + "name": "date_of_birth", "in": "query", - "description": "Case insensitive search on dateofbirth", + "description": "Case insensitive search on date_of_birth", "required": false, "type": "string" }, { - "name": "branchcode", + "name": "library_id", "in": "query", - "description": "Case insensitive search on branchcode", + "description": "Case insensitive search on library_id", "required": false, "type": "string" }, { - "name": "categorycode", + "name": "category_id", "in": "query", - "description": "Case insensitive search on categorycode", + "description": "Case insensitive search on category_id", "required": false, "type": "string" }, { - "name": "dateenrolled", + "name": "date_enrolled", "in": "query", - "description": "Case insensitive search on dateenrolled", + "description": "Case insensitive search on date_enrolled", "required": false, "type": "string" }, { - "name": "dateexpiry", + "name": "expiry_date", "in": "query", - "description": "Case insensitive search on dateexpiry", + "description": "Case insensitive search on expiry_date", "required": false, "type": "string" }, { - "name": "gonenoaddress", + "name": "incorrect_address", "in": "query", - "description": "Search on gonenoaddress", + "description": "Search on incorrect_address", "required": false, "type": "boolean" }, { - "name": "lost", + "name": "patron_card_lost", "in": "query", - "description": "Search on lost", + "description": "Search on patron_card_lost", "required": false, "type": "boolean" }, { - "name": "debarred", + "name": "restricted", "in": "query", - "description": "Case insensitive search on debarred", + "description": "Filter search by restricted", "required": false, - "type": "string" - }, { - "name": "debarredcomment", - "in": "query", - "description": "Case insensitive search on debarredcomment", - "required": false, - "type": "string" - }, { - "name": "contactname", - "in": "query", - "description": "Case insensitive search on contactname", - "required": false, - "type": "string" - }, { - "name": "contactfirstname", - "in": "query", - "description": "Case insensitive search on contactfirstname", - "required": false, - "type": "string" - }, { - "name": "contacttitle", - "in": "query", - "description": "Case insensitive search on contacttitle", - "required": false, - "type": "string" - }, { - "name": "guarantorid", - "in": "query", - "description": "Case insensitive search on guarantorid", - "required": false, - "type": "string" - }, { - "name": "borrowernotes", - "in": "query", - "description": "Case insensitive search on borrowernotes", - "required": false, - "type": "string" + "type": "boolean" }, { - "name": "relationship", + "name": "guarantor_id", "in": "query", - "description": "Case insensitive search on relationship", + "description": "Search on guarantor_id", "required": false, "type": "string" }, { - "name": "sex", + "name": "staff_notes", "in": "query", - "description": "Case insensitive search on sex", + "description": "Case insensitive search on staff_notes", "required": false, "type": "string" }, { - "name": "password", + "name": "relationship_type", "in": "query", - "description": "Case insensitive search on password", + "description": "Case insensitive search on relationship_type", "required": false, "type": "string" }, { - "name": "flags", + "name": "gender", "in": "query", - "description": "Case insensitive search on flags", + "description": "Case insensitive search on gender", "required": false, "type": "string" }, { @@ -308,87 +272,87 @@ "required": false, "type": "string" }, { - "name": "opacnote", + "name": "opac_notes", "in": "query", - "description": "Case insensitive search on opacnote", + "description": "Case insensitive search on opac_notes", "required": false, "type": "string" }, { - "name": "contactnote", + "name": "altaddress_notes", "in": "query", - "description": "Case insensitive search on contactnote", + "description": "Case insensitive search on altaddress_notes", "required": false, "type": "string" }, { - "name": "sort1", + "name": "statistics_1", "in": "query", - "description": "Case insensitive search on sort1", + "description": "Case insensitive search on statistics_1", "required": false, "type": "string" }, { - "name": "sort2", + "name": "statistics_2", "in": "query", - "description": "Case insensitive search on sort2", + "description": "Case insensitive search on statistics_2", "required": false, "type": "string" }, { - "name": "altcontactfirstname", + "name": "altcontact_firstname", "in": "query", - "description": "Case insensitive search on altcontactfirstname", + "description": "Case insensitive search on altcontact_firstname", "required": false, "type": "string" }, { - "name": "altcontactsurname", + "name": "altcontact_surname", "in": "query", - "description": "Case insensitive search on altcontactsurname", + "description": "Case insensitive search on altcontact_surname", "required": false, "type": "string" }, { - "name": "altcontactaddress1", + "name": "altcontact_address", "in": "query", - "description": "Case insensitive search on altcontactaddress1", + "description": "Case insensitive search on altcontact_address", "required": false, "type": "string" }, { - "name": "altcontactaddress2", + "name": "altcontact_address2", "in": "query", - "description": "Case insensitive search on altcontactaddress2", + "description": "Case insensitive search on altcontact_address2", "required": false, "type": "string" }, { - "name": "altcontactaddress3", + "name": "altcontact_city", "in": "query", - "description": "Case insensitive search on altcontactaddress3", + "description": "Case insensitive search on altcontact_city", "required": false, "type": "string" }, { - "name": "altcontactstate", + "name": "altcontact_state", "in": "query", - "description": "Case insensitive search on altcontactstate", + "description": "Case insensitive search on altcontact_state", "required": false, "type": "string" }, { - "name": "altcontactzipcode", + "name": "altcontact_postal_code", "in": "query", - "description": "Case insensitive search on altcontactzipcode", + "description": "Case insensitive search on altcontact_postal_code", "required": false, "type": "string" }, { - "name": "altcontactcountry", + "name": "altcontact_country", "in": "query", - "description": "Case insensitive search on altcontactcountry", + "description": "Case insensitive search on altcontact_country", "required": false, "type": "string" }, { - "name": "altcontactphone", + "name": "altcontact_phone", "in": "query", - "description": "Case insensitive search on altcontactphone", + "description": "Case insensitive search on altcontact_phone", "required": false, "type": "string" }, { - "name": "smsalertnumber", + "name": "sms_number", "in": "query", - "description": "Case insensitive search on smsalertnumber", + "description": "Case insensitive search on sms_number", "required": false, "type": "string" }, { @@ -400,31 +364,31 @@ }, { "name": "privacy", "in": "query", - "description": "Case insensitive search on privacy", + "description": "Search on privacy", "required": false, "type": "string" }, { "name": "privacy_guarantor_checkouts", "in": "query", - "description": "Case insensitive search on privacy_guarantor_checkouts", + "description": "Search on privacy_guarantor_checkouts", "required": false, "type": "string" }, { - "name": "checkprevcheckout", + "name": "check_previous_checkout", "in": "query", - "description": "Case insensitive search on checkprevcheckout", + "description": "Case insensitive search on check_previous_checkout", "required": false, "type": "string" }, { "name": "updated_on", "in": "query", - "description": "Case insensitive search on updated_on", + "description": "Search on updated_on", "required": false, "type": "string" }, { - "name": "lastseen", + "name": "last_seen", "in": "query", - "description": "Case insensitive search on lastseen", + "description": "Case insensitive search on last_seen", "required": false, "type": "string" }, { @@ -436,13 +400,7 @@ }, { "name": "login_attempts", "in": "query", - "description": "Case insensitive search on login_attempts", - "required": false, - "type": "string" - }, { - "name": "overdrive_auth_token", - "in": "query", - "description": "Case insensitive search on overdrive_auth_token", + "description": "Search on login_attempts", "required": false, "type": "string" }, { @@ -563,13 +521,13 @@ } } }, - "/patrons/{borrowernumber}": { + "/patrons/{patron_id}": { "get": { "x-mojo-to": "Patrons#get", "operationId": "getPatron", "tags": ["patrons"], "parameters": [{ - "$ref": "../parameters.json#/borrowernumberPathParam" + "$ref": "../parameters.json#/patron_id_pp" }], "produces": [ "application/json" @@ -626,7 +584,7 @@ "tags": ["patrons"], "parameters": [ { - "$ref": "../parameters.json#/borrowernumberPathParam" + "$ref": "../parameters.json#/patron_id_pp" }, { "name": "body", @@ -703,7 +661,7 @@ "operationId": "deletePatron", "tags": ["patrons"], "parameters": [{ - "$ref": "../parameters.json#/borrowernumberPathParam" + "$ref": "../parameters.json#/patron_id_pp" }], "produces": ["application/json"], "responses": { diff --git a/api/v1/swagger/x-primitives.json b/api/v1/swagger/x-primitives.json index 5fa58badaa..0266297cee 100644 --- a/api/v1/swagger/x-primitives.json +++ b/api/v1/swagger/x-primitives.json @@ -3,9 +3,9 @@ "type": "integer", "description": "internally assigned biblio identifier" }, - "borrowernumber": { + "patron_id": { "type": "integer", - "description": "internally assigned user identifier" + "description": "Internal patron identifier" }, "cardnumber": { "type": ["string", "null"], -- 2.16.2