line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::CA::API; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
514
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
24
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
388
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
142060
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
226
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
207
|
use JSON; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
595
|
use Catmandu::CA::API::QueryBuilder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
11
|
1
|
|
|
1
|
|
358
|
use Catmandu::CA::API::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
417
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has username => (is => 'ro', required => 1); |
14
|
|
|
|
|
|
|
has password => (is => 'ro', required => 1); |
15
|
|
|
|
|
|
|
has url => (is => 'ro', required => 1); |
16
|
|
|
|
|
|
|
has lang => (is => 'ro', default => 'nl_NL'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub id { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $field_list) = @_; |
20
|
0
|
|
|
|
|
|
my $q = Catmandu::CA::API::QueryBuilder->new(field_list => $field_list); |
21
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
22
|
|
|
|
|
|
|
url => $self->url, |
23
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/ca_objects/id/%s', $id), |
24
|
|
|
|
|
|
|
username => $self->username, |
25
|
|
|
|
|
|
|
password => $self->password, |
26
|
|
|
|
|
|
|
lagn => $self->lang |
27
|
|
|
|
|
|
|
); |
28
|
0
|
|
|
|
|
|
return $r->get($q->query); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub simple { |
32
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
33
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
34
|
|
|
|
|
|
|
url => $self->url, |
35
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/ca_objects/id/%s', $id), |
36
|
|
|
|
|
|
|
username => $self->username, |
37
|
|
|
|
|
|
|
password => $self->password, |
38
|
|
|
|
|
|
|
lagn => $self->lang |
39
|
|
|
|
|
|
|
); |
40
|
0
|
|
|
|
|
|
return $r->get('{}'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub add { |
44
|
0
|
|
|
0
|
0
|
|
my ($self, $data) = @_; |
45
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
46
|
|
|
|
|
|
|
url => $self->url, |
47
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/ca_objects'), |
48
|
|
|
|
|
|
|
username => $self->username, |
49
|
|
|
|
|
|
|
password => $self->password, |
50
|
|
|
|
|
|
|
lagn => $self->lang |
51
|
|
|
|
|
|
|
); |
52
|
0
|
|
|
|
|
|
return $r->put(encode_json($data)); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub update { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $data) = @_; |
57
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
58
|
|
|
|
|
|
|
url => $self->url, |
59
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/ca_objects/id/%s', $id), |
60
|
|
|
|
|
|
|
username => $self->username, |
61
|
|
|
|
|
|
|
password => $self->password, |
62
|
|
|
|
|
|
|
lagn => $self->lang |
63
|
|
|
|
|
|
|
); |
64
|
0
|
|
|
|
|
|
return $r->put(encode_json($data)); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub delete { |
68
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
69
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
70
|
|
|
|
|
|
|
url => $self->url, |
71
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/ca_objects/id/%s', $id), |
72
|
|
|
|
|
|
|
username => $self->username, |
73
|
|
|
|
|
|
|
password => $self->password, |
74
|
|
|
|
|
|
|
lagn => $self->lang |
75
|
|
|
|
|
|
|
); |
76
|
0
|
|
|
|
|
|
return $r->delete(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |