File Coverage

blib/lib/Catmandu/Store/Resolver.pm
Criterion Covered Total %
statement 15 17 88.2
branch n/a
condition n/a
subroutine 5 6 83.3
pod n/a
total 20 23 86.9


line stmt bran cond sub pod time code
1             package Catmandu::Store::Resolver;
2              
3             our $VERSION = '0.05';
4              
5 1     1   952 use Catmandu::Sane;
  1         107279  
  1         6  
6              
7 1     1   206 use Moo;
  1         2  
  1         4  
8 1     1   599 use Catmandu::Store::Resolver::Bag;
  1         3  
  1         26  
9 1     1   6 use Catmandu::Store::Resolver::API;
  1         2  
  1         16  
10              
11 1     1   4 use LWP::UserAgent;
  1         2  
  1         97  
12              
13             with 'Catmandu::Store';
14              
15             has url => (is => 'ro', required => 1);
16             has username => (is => 'ro', required => 1);
17             has password => (is => 'ro', required => 1);
18              
19             has client => (is => 'lazy');
20              
21             sub _build_client {
22 0     0     my $self = shift;
23 0           return LWP::UserAgent->new();
24             }
25              
26              
27             1;
28              
29             __END__
30              
31             =head1 NAME
32              
33             =for html <a href="https://travis-ci.org/PACKED-vzw/Catmandu-Store-Resolver"><img src="https://travis-ci.org/PACKED-vzw/Catmandu-Store-Resolver.svg?branch=master"></a>
34              
35             Catmandu::Store::Resolver - Store/retrieve items from the Resolver
36              
37             =head1 SYNOPSIS
38              
39             A module that can be used to retrieve or store PIDS for records in the L<Resolver|https://github.com/PACKED-vzw/resolver>.
40              
41             lookup_in_store(
42             objectNumber,
43             Resolver,
44             username: username,
45             password: password,
46             url: http://www.resolver.be
47             )
48              
49             =head1 DESCRIPTION
50              
51             Configure the L<Resolver|https://github.com/PACKED-vzw/resolver> as a L<store|http://librecat.org/Catmandu/#stores> for L<Catmandu|http://librecat.org/>.
52              
53             Museum objects and records require a PID to be uniquely identifiable. The Resolver tool
54             generates and resolves these PIDs. By using this store, PIDs can be queried (based on
55             the object number of the record as stored in the resolver), created, updated and deleted
56             from Catmandu.
57              
58              
59              
60             Data is returned as JSON.
61              
62             {
63             "data": {
64             "documents": [],
65             "domain": "",
66             "id": "",
67             "persistentURIs": [
68             dataPid
69             ],
70             "title": "",
71             "type": ""
72             }
73             }
74              
75             The C<_id> attribute of the data after a L<add_to_store|Catmandu::Fix::add_to_store>
76             is set to the I<workPid>, which is the first item of the I<presistenURIs> array.
77              
78             =head1 CONFIGURATION
79              
80             The Resolver API requires a username and password. These must be provided.
81              
82             =over
83              
84             =item C<url>
85              
86             base url of the Resolver (e.g. I<http://www.resolver.be>).
87              
88             =item C<username>
89              
90             username for the Resolver.
91              
92             =item C<password>
93              
94             password for the Resolver.
95              
96             =back
97              
98             =head1 USAGE
99              
100             See L<the Catmandu documentation|http://librecat.org/Catmandu/#stores> for more information on how to use Stores.
101              
102             =head1 SEE ALSO
103              
104             L<Catmandu>
105              
106             =head1 AUTHORS
107              
108             Pieter De Praetere, C<< pieter at packed.be >>
109              
110             =head1 CONTRIBUTORS
111              
112             Pieter De Praetere, C<< pieter at packed.be >>
113              
114             =head1 COPYRIGHT AND LICENSE
115              
116             This package is copyright (c) 2016 by PACKED vzw.
117             This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
118              
119             =cut