1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
package WebService::ILS::RecordedBooks::Patron;
use Modern::Perl;
=encoding utf-8
=head1 NAME
WebService::ILS::RecordedBooks::Patron - RecordedBooks patron API
=head1 SYNOPSIS
use WebService::ILS::RecordedBooks::Patron;
=cut
=head1 DESCRIPTION
L<WebService::ILS::RecordedBooks::Patron> - services
that require patron credentials
See L<WebService::ILS::RecordedBooks>
=cut
use Carp;
use parent qw(WebService::ILS::RecordedBooks);
=head1 CONSTRUCTOR
=head2 new (%params_hash or $params_hashref)
=head3 Additional constructor params:
=over 16
=item C<user_id>
=item C<password>
=back
=cut
use Class::Tiny qw(
user_id password
);
__PACKAGE__->_set_param_spec({
user_id => { required => 1 },
password => { required => 1 },
});
sub _access_auth_string {
my $self = shift;
return $self->client_secret;
}
sub _extract_token_from_response {
my $self = shift;
my $data = shift;
return ($data->{bearer}, "bearer");
}
sub make_access_token_request {
my $self = shift;
my $url = $self->api_url("/tokens");
my %params = (
UserName => $self->user_id,
Password => $self->password,
LibraryId => $self->library_id,
);
my $req = HTTP::Request::Common::POST( $url );
return $self->_json_request_content($req, \%params);
}
sub title_url {
my $self = shift;
my $isbn = shift or croak "No isbn";
return $self->api_url("/titles/$isbn");
}
sub circulation_action_base_url {
my $self = shift;
return $self->api_url("/transactions");
}
1;
__END__
=head1 LICENSE
Copyright (C) Catalyst IT NZ Ltd
Copyright (C) Bywater Solutions
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR
Srdjan Janković E<lt>srdjan@catalyst.net.nzE<gt>
=cut
|