File: PartnerPatron.pm

package info (click to toggle)
libwebservice-ils-perl 0.18-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 348 kB
  • sloc: perl: 2,645; makefile: 2; sh: 2
file content (103 lines) | stat: -rw-r--r-- 1,804 bytes parent folder | download | duplicates (3)
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
package WebService::ILS::RecordedBooks::PartnerPatron;

use Modern::Perl;

=encoding utf-8

=head1 NAME

WebService::ILS::RecordedBooks::PartnerPatron - RecordedBooks patner API
for an individual patron

=head1 SYNOPSIS

    use WebService::ILS::RecordedBooks::PartnerPatron;

=head1 DESCRIPTION

L<WebService::ILS::RecordedBooks::PartnerPatron> - services
that use trusted partner credentials to operat on behalf of a specified patron

See L<WebService::ILS::RecordedBooks::Partner>

=cut

use Carp;

use parent qw(WebService::ILS::RecordedBooks::PartnerBase);

=head1 CONSTRUCTOR

=head2 new (%params_hash or $params_hashref)

=head3 Additional constructor params:

=over 12

=item C<user_id>        => RecordedBooks user id (barcode), or email

=back

C<client_id> is either RecordedBooks id (barcode) or email

=cut

use Class::Tiny qw(
    user_id
);

__PACKAGE__->_set_param_spec({
    user_id => { required => 1 },
});

sub BUILD {
    my $self = shift;
    my $params = shift;

    local $@;
    my $patron_id = eval { $self->SUPER::patron_id($self->user_id) }
      or croak "Invalid user_id ".$self->user_id.($@ ? "\n$@" : "");
    $self->user_id($patron_id);
}

sub circulation_action_base_url {
    my $self = shift;

    return $self->library_action_base_url."/patrons/".$self->user_id;
}

sub patron_id {
    my $self = shift;
    return $self->user_id;
}

sub patron {
    my $self = shift;
    return {id => $self->user_id};
}

=head1 NATIVE METHODS

=head2 native_patron ()

This method cannot be called

=cut

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