File Coverage

blib/lib/WebService/ILS/OverDrive/Library.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 6 0.0
condition n/a
subroutine 4 8 50.0
pod 1 4 25.0
total 17 45 37.7


line stmt bran cond sub pod time code
1             package WebService::ILS::OverDrive::Library;
2              
3 1     1   789 use Modern::Perl;
  1         2  
  1         8  
4              
5             =encoding utf-8
6              
7             =head1 NAME
8              
9             WebService::ILS::OverDrive::Library - WebService::ILS module for OverDrive
10             discovery only services
11              
12             =head1 SYNOPSIS
13              
14             use WebService::ILS::OverDrive::Library;
15              
16             =head1 DESCRIPTION
17              
18             See L
19              
20             =cut
21              
22 1     1   160 use Carp;
  1         2  
  1         58  
23 1     1   461 use HTTP::Request::Common;
  1         22646  
  1         85  
24              
25 1     1   469 use parent qw(WebService::ILS::OverDrive);
  1         275  
  1         7  
26              
27             __PACKAGE__->_set_param_spec({
28             library_id => { required => 1, defined => 1 },
29             });
30              
31             sub make_access_token_request {
32 0     0 0   my $self = shift;
33              
34 0           return HTTP::Request::Common::POST( 'https://oauth.overdrive.com/token', {
35             grant_type => 'client_credentials'
36             } );
37             }
38              
39             sub collection_token {
40 0     0 0   my $self = shift;
41              
42 0 0         if (my $collection_token = $self->SUPER::collection_token) {
43 0           return $collection_token;
44             }
45            
46 0           $self->native_library_account;
47 0 0         my $collection_token = $self->SUPER::collection_token
48             or die "Library has no collections\n";
49 0           return $collection_token;
50             }
51              
52             =head1 NATIVE METHODS
53              
54             =head2 native_library_account ()
55              
56             See L
57              
58             =cut
59              
60             sub native_library_account {
61 0     0 1   my $self = shift;
62              
63 0           my $library = $self->get_response($self->library_url);
64 0 0         if (my $collection_token = $library->{collectionToken}) {
65 0           $self->SUPER::collection_token( $collection_token);
66             }
67 0           return $library;
68             }
69              
70             # Discovery helpers
71              
72             sub library_url {
73 0     0 0   my $self = shift;
74 0           return $self->discovery_action_url("/libraries/".$self->library_id);
75             }
76              
77             1;
78              
79             __END__