Bug 11879 added borrowers.primary_contact_method but not the REST API spec changes.
+1
Created attachment 136124 [details] [review] Bug 28701 - Adding primary_contact_method to the REST API spec
I tried to test this patch but my master cannot access the API because of modules dependencies. I test this patch in 21.05 and it works. If anyone wants to try, you just need to be connected in the OPAC and to call a endpoint involving patron. Like `/api/v1/patrons`. You may need to check your permissions.
Created attachment 143972 [details] [review] Bug 28701 - Adding primary_contact_method to the REST API spec This patch adds the primary_contact_method field to the api response for patrons To test: 1 - GET http://localhost:8081/api/v1/patrons/51 2 - Look for primary_contact_method, it's not there 3 - Apply patch 4 - GET http://localhost:8081/api/v1/patrons/51 5 - Look for primary_contact_method, it's not there Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
I think it should be an enum
(In reply to Tomás Cohen Arazi from comment #5) > I think it should be an enum `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for reporting purposes', Scope creep ?
> This patch adds the primary_contact_method field to the api response for patrons Please look at step 5 of your test plan. Contradiction :) > To test: > 4 - GET http://localhost:8081/api/v1/patrons/51 > 5 - Look for primary_contact_method, it's not there It was not there indeed. But it should be! Adding a follow-up.
Created attachment 145715 [details] [review] Bug 28701 - Adding primary_contact_method to the REST API spec This patch adds the primary_contact_method field to the api response for patrons To test: 1 - GET http://localhost:8081/api/v1/patrons/51 2 - Look for primary_contact_method, it's not there 3 - Apply patch 4 - GET http://localhost:8081/api/v1/patrons/51 5 - Look for primary_contact_method, it's not there Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 145716 [details] [review] Bug 28701: (QA follow-up) Make primary_contact_method visible Via to_api_mapping. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(In reply to Marcel de Rooy from comment #6) > (In reply to Tomás Cohen Arazi from comment #5) > > I think it should be an enum > > `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for > reporting purposes', > > Scope creep ? If you git grep primary_contact_method, you will notice that the possible values there are hardcoded: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: <select id="borrower_primary_contact_method" name ="borrower_primary_contact_method"> koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'phone' ) %] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'phonepro' ) %] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'mobile' ) %] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'email' ) %] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'emailpro' ) %] koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: [% IF ( borrower.primary_contact_method = = 'fax' ) %] when we write endpoint specs, we want them to be future proof (as much as possible). So I'm not expecting this bug to update the DB structure, but either: (a) make the type of the 'new API object attribute' be an enum with those values (b) choose better names for those hardcoded values, and list them as an enum IN THE SPEC and make to_api() handle the name mapping. I'd prefer (b). Regarding the follow-up, it does the job, but we've better only map things that need mapping (i.e. mapping to null removes it from the response, mapping to a value makes the API translate the name, not mapping makes the API return it as-is.
(In reply to Tomás Cohen Arazi from comment #10) > (In reply to Marcel de Rooy from comment #6) > > (In reply to Tomás Cohen Arazi from comment #5) > > > I think it should be an enum > > > > `primary_contact_method` varchar(45) DEFAULT NULL COMMENT 'useful for > > reporting purposes', > > > > Scope creep ? > > If you git grep primary_contact_method, you will notice that the possible > values there are hardcoded: > > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > <select id="borrower_primary_contact_method" name > ="borrower_primary_contact_method"> > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'phone' ) %] > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'phonepro' ) %] > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'mobile' ) %] > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'email' ) %] > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'emailpro' ) %] > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt: > [% IF ( borrower.primary_contact_method = > = 'fax' ) %] > > when we write endpoint specs, we want them to be future proof (as much as > possible). So I'm not expecting this bug to update the DB structure, but > either: > > (a) make the type of the 'new API object attribute' be an enum with those > values > (b) choose better names for those hardcoded values, and list them as an enum > IN THE SPEC and make to_api() handle the name mapping. > > I'd prefer (b). > > Regarding the follow-up, it does the job, but we've better only map things > that need mapping (i.e. mapping to null removes it from the response, > mapping to a value makes the API translate the name, not mapping makes the > API return it as-is. I'd like to point out that many librarians don't like the fact that these are hard coded values. I've written an enhancement to make them customizable via authorized values in Bug 31498.
Looking forward to the API being updated to include the contact method. :)