File Coverage

blib/lib/Catmandu/Store/VKC.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::VKC;
2              
3 1     1   1189 use strict;
  1         1  
  1         27  
4 1     1   4 use warnings;
  1         1  
  1         25  
5              
6 1     1   3 use Moo;
  1         1  
  1         5  
7 1     1   206 use Catmandu::Sane;
  1         1  
  1         6  
8              
9 1     1   223 use Catmandu::Store::VKC::Bag;
  1         2  
  1         137  
10              
11             with 'Catmandu::Store';
12              
13             extends 'Catmandu::Store::CA';
14              
15             has username => (is => 'ro', required => 1);
16             has password => (is => 'ro', required => 1);
17             has model => (is => 'ro', default => 'ca_objects');
18             has lang => (is => 'ro', default => 'nl_NL');
19             has _field_list => (is => 'rw', default => sub { return []; });
20              
21              
22             has url => (is => 'lazy');
23              
24             sub _build_url {
25 0     0     my $self = shift;
26 0           return 'http://vkc-ca-prod.inuits.eu';
27             }
28              
29             1;
30             __END__
31             =encoding utf-8
32              
33             =head1 NAME
34              
35             Catmandu::Store::VKC - Retrieve items from the L<CollectiveAccess|http://collectiveaccess.org/> instance of the L<VKC|http://www.vlaamsekunstcollectie.be/>
36              
37             =head1 SYNOPSIS
38              
39             # From the command line
40             catmandu export VKC to YAML --id 1234 --username demo --password demo --model ca_objects --lang nl_NL --field_list 'ca_entities, preferred_labels'
41              
42             # From a Catmandu Fix
43             lookup_in_store(
44             object_id,
45             VKC,
46             username: demo,
47             password: demo,
48             lang: nl_NL,
49             model: ca_objects,
50             field_list: 'ca_entities, preferred_labels'
51             )
52              
53             # From Perl code
54             use Catmandu;
55              
56             my $store = Catmandu->store('CA',
57             username => 'demo',
58             password => 'demo',
59             lang => 'nl_NL',
60             model => ca_objects,
61             field_list =>'ca_entities, preferred_labels'
62             )->bag;
63              
64             my $item = $store->get('1234');
65              
66              
67             =head1 DESCRIPTION
68              
69             A Catmandu::Store::VKC is Perl package that can query the L<CollectiveAccess|http://collectiveaccess.org> instance of the L<VKC|http://www.vlaamsekunstcollectie.be/>.
70             It functions identically to L<Catmandu::Store::CA>, but does not require the C<url> parameter to be set.
71              
72             =head1 CONFIGURATION
73              
74             =head2 username
75              
76             Name of a user that can be used to query the API. If you want to store
77             items in the CA instance, it must have the necessary rights.
78              
79             =head2 password
80              
81             Password for the user.
82              
83             =head2 lang
84              
85             The language (locale) in which to return the data. Set to C<nl_NL> by default,
86             will automatically fall back to C<en_US> if the attribute does not exist in the
87             selected locale. Use the L<IETF language tag|https://en.wikipedia.org/wiki/IETF_language_tag>.
88              
89             =head2 field_list
90              
91             A comma-separated, quoted, (C<'foo, bar'>) list of fields that the CollectiveAccess
92             API should return. Is optional and can be left empty to return the default 'summary'.
93              
94             =head1 METHODS
95              
96             =head2 new(%configuration)
97              
98             Create a new Catmandu::Store::VKC
99              
100             =head2 get($id)
101              
102             Retrieve a CA record given an identifier. This returns whatever
103             the CA administrator designated as the "summary" of the record.
104              
105             =head2 add($data)
106              
107             Create a new CA record. See L<here|http://docs.collectiveaccess.org/wiki/Web_Service_API#Creating_new_records> to
108             see what data you must provide to create a record.
109              
110             =head2 update($id, $data)
111              
112             Update a new CA record. See L<here|http://docs.collectiveaccess.org/wiki/Web_Service_API#Creating_new_records> to
113             see what data you must provide to create a record.
114              
115             =head2 delete($id)
116              
117             Delete (I<soft delete>) a record.
118              
119             =head2 each()
120              
121             Not supported
122              
123             =head1 AUTHOR
124              
125             Pieter De Praetere E<lt>pieter at packed.beE<gt>
126              
127             =head1 COPYRIGHT
128              
129             Copyright 2017- PACKED vzw
130              
131             =head1 LICENSE
132              
133             This library is free software; you can redistribute it and/or modify
134             it under the same terms as Perl itself.
135              
136             =head1 SEE ALSO
137              
138             L<Catmandu>
139             L<Catmandu::Store::CA>
140             L<Catmandu::CA::API>
141              
142             =cut