View | Details | Raw Unified | Return to bug 37640
Collapse All | Expand All

(-)a/Koha/REST/V1/Patrons.pm (-1 / +8 lines)
Lines 77-83 sub get { Link Here
77
77
78
    return try {
78
    return try {
79
        my $patron_id = $c->param('patron_id');
79
        my $patron_id = $c->param('patron_id');
80
        my $patron    = $c->objects->find( Koha::Patrons->search_limited, $patron_id );
80
        my $patron;
81
82
        if ( C4::Context->preference('RESTPatronIDField') eq 'cardnumber' ) {
83
            my $patron_obj = Koha::Patrons->search_limited({ cardnumber => $patron_id })->next;
84
            $patron = $c->objects->find( Koha::Patrons->search_limited, $patron_obj->id ) if $patron_obj;
85
        } else {
86
            $patron = $c->objects->find( Koha::Patrons->search_limited, $patron_id );
87
        }
81
88
82
        return $c->render_resource_not_found("Patron")
89
        return $c->render_resource_not_found("Patron")
83
            unless $patron;
90
            unless $patron;
(-)a/api/v1/swagger/paths/patrons.yaml (-1 / +1 lines)
Lines 487-493 Link Here
487
      - name: x-koha-embed
487
      - name: x-koha-embed
488
        in: header
488
        in: header
489
        required: false
489
        required: false
490
        description: Embed list sent as a request header
490
        description: Embed list sent as a request header hello
491
        type: array
491
        type: array
492
        items:
492
        items:
493
          type: string
493
          type: string
(-)a/api/v1/swagger/swagger.yaml (-2 / +2 lines)
Lines 829-839 parameters: Link Here
829
    required: false
829
    required: false
830
    type: integer
830
    type: integer
831
  patron_id_pp:
831
  patron_id_pp:
832
    description: Internal patron identifier
832
    description: Internal patron identifier. May be borrowernumber or cardnumber.
833
    in: path
833
    in: path
834
    name: patron_id
834
    name: patron_id
835
    required: true
835
    required: true
836
    type: integer
836
    type: string
837
  patron_id_qp:
837
  patron_id_qp:
838
    description: Internal patron identifier
838
    description: Internal patron identifier
839
    in: query
839
    in: query
(-)a/installer/data/mysql/atomicupdate/bug_37640_-_add_RESTPatronIDField_syspref.pl (+16 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "37640",
5
    description => "Allow patron REST API endpoint to accept cardnumber",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{ INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('RESTPatronIDField', 'borrowernumber', 'borrowernumber|cardnumber', 'Allow patrons to be identified by cardnumber instead of borrowernumber', 'Choice') }
12
        );
13
14
        say $out "Added system preference 'RESTPatronIDField'";
15
    },
16
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 666-671 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
666
('RESTBasicAuth','0',NULL,'If enabled, Basic authentication is enabled for the REST API.','YesNo'),
666
('RESTBasicAuth','0',NULL,'If enabled, Basic authentication is enabled for the REST API.','YesNo'),
667
('RESTdefaultPageSize','20','','Default page size for endpoints listing objects','Integer'),
667
('RESTdefaultPageSize','20','','Default page size for endpoints listing objects','Integer'),
668
('RESTOAuth2ClientCredentials','0',NULL,'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo'),
668
('RESTOAuth2ClientCredentials','0',NULL,'If enabled, the OAuth2 client credentials flow is enabled for the REST API.','YesNo'),
669
('RESTPatronIDField', 'borrowernumber', 'borrowernumber|cardnumber', 'Allow patrons to be identified by cardnumber instead of borrowernumber', 'Choice'),
669
('RESTPublicAnonymousRequests','1',NULL,'If enabled, the API will allow anonymous access to public routes that don\'t require authenticated access.','YesNo'),
670
('RESTPublicAnonymousRequests','1',NULL,'If enabled, the API will allow anonymous access to public routes that don\'t require authenticated access.','YesNo'),
670
('RESTPublicAPI','1',NULL,'If enabled, the REST API will expose the /public endpoints.','YesNo'),
671
('RESTPublicAPI','1',NULL,'If enabled, the REST API will expose the /public endpoints.','YesNo'),
671
('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
672
('RestrictedPageContent','',NULL,'HTML content of the restricted page','TextArea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref (-1 / +7 lines)
Lines 46-51 Web services: Link Here
46
                  none: "NULL"
46
                  none: "NULL"
47
                  apirenew: "'APIRenew'"
47
                  apirenew: "'APIRenew'"
48
            - as branchcode to store in the statistics table.
48
            - as branchcode to store in the statistics table.
49
        -
50
            - Patrons will be identified using the
51
            - pref: RESTPatronIDFIeld
52
              choices:
53
                  borrowernumber: borrowernumber
54
                  cardnumber: cardnumber
55
            - field.
49
    OAI-PMH:
56
    OAI-PMH:
50
        -
57
        -
51
            - pref: OAI-PMH
58
            - pref: OAI-PMH
52
- 

Return to bug 37640