| 1 | package WebService::ILS::RecordedBooks::PartnerBase; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Modern::Perl; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | =encoding utf-8 | ||||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | WebService::ILS::RecordedBooks::PartnerBase - RecordedBooks partner API | ||||||||||
| 10 | |||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||
| 12 | |||||||||||
| 13 | See L<WebService::ILS::RecordedBooks::Partner> | ||||||||||
| 14 | and L<WebService::ILS::RecordedBooks::PartnerPatron>; | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use URI::Escape; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | use parent qw(WebService::ILS::RecordedBooks); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub title_url { | ||||||||
|
Subroutine
title_url: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 24 | 0 | my $self = shift; | |||||||||
| 25 | 0 | ▶ | my $isbn = shift or croak "No isbn"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 0 | return $self->library_action_base_url."/titles/$isbn"; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub _request_with_token { | ||||||||
|
Subroutine
_request_with_token: not called CC=2 SCAR=17.9
| |||||||||||
| 30 | 0 | my $self = shift; | |||||||||
| 31 | 0 | ▶ | my $request = shift or croak "No request"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | $request->header( Authorization => "Basic ".$self->client_secret ); | |||||||||
| 34 | 0 | return $self->user_agent->request( $request ); | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | =head1 CIRCULATION METHOD SPECIFICS | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | 1 | ▶ | use constant NATIVE_PATRON_ID_KEY => "patronId"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 42 | 1 | my %PATRON_XLATE = ( | |||||||||
| 43 | NATIVE_PATRON_ID_KEY() => 'id', | ||||||||||
| 44 | ); | ||||||||||
| 45 | 0 | ▶ | sub patron { | ||||||||
|
Subroutine
patron: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | 0 | my $self = shift; | |||||||||
| 47 | 0 | return $self->_result_xlate($self->native_patron(@_), \%PATRON_XLATE); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | =head2 patron_id ($email_or_id) | ||||||||||
| 51 | |||||||||||
| 52 | =cut | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub patron_id { | ||||||||
|
Subroutine
patron_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 55 | 0 | my $self = shift; | |||||||||
| 56 | 0 | ▶ | my $patron = $self->native_patron(@_) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | return $patron->{NATIVE_PATRON_ID_KEY()}; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | =head1 NATIVE METHODS | ||||||||||
| 61 | |||||||||||
| 62 | =head2 native_patron ($email_or_id) | ||||||||||
| 63 | |||||||||||
| 64 | =cut | ||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | sub native_patron { | ||||||||
|
Subroutine
native_patron: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 67 | 0 | my $self = shift; | |||||||||
| 68 | 0 | ▶ | my $cardnum_or_email = shift or croak "No patron identification"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | |||||||||||
| 70 | 0 | my $url = $self->api_url("/rpc/libraries/".$self->library_id."/patrons/".uri_escape($cardnum_or_email)); | |||||||||
| 71 | 0 | return $self->get_response($url); | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 1 | 1; | |||||||||
| 75 | |||||||||||
| 76 | __END__ | ||||||||||