line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::CA::API; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
522
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
380
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
107963
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
214
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
192
|
use JSON; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
515
|
use Catmandu::CA::API::QueryBuilder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
11
|
1
|
|
|
1
|
|
420
|
use Catmandu::CA::API::Request; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
455
|
|
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
|
|
|
|
|
|
|
has model => (is => 'ro', default => 'ca_objects'); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub id { |
20
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $field_list) = @_; |
21
|
0
|
|
|
|
|
|
my $q = Catmandu::CA::API::QueryBuilder->new(field_list => $field_list); |
22
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
23
|
|
|
|
|
|
|
url => $self->url, |
24
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/%s/id/%s', $self->model, $id), |
25
|
|
|
|
|
|
|
username => $self->username, |
26
|
|
|
|
|
|
|
password => $self->password, |
27
|
|
|
|
|
|
|
lang => $self->lang |
28
|
|
|
|
|
|
|
); |
29
|
0
|
|
|
|
|
|
return $r->get($q->query); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub simple { |
33
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
34
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
35
|
|
|
|
|
|
|
url => $self->url, |
36
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/%s/id/%s', $self->model, $id), |
37
|
|
|
|
|
|
|
username => $self->username, |
38
|
|
|
|
|
|
|
password => $self->password, |
39
|
|
|
|
|
|
|
lang => $self->lang |
40
|
|
|
|
|
|
|
); |
41
|
0
|
|
|
|
|
|
return $r->get('{}'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub add { |
45
|
0
|
|
|
0
|
0
|
|
my ($self, $data) = @_; |
46
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
47
|
|
|
|
|
|
|
url => $self->url, |
48
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/%s', $self->model), |
49
|
|
|
|
|
|
|
username => $self->username, |
50
|
|
|
|
|
|
|
password => $self->password, |
51
|
|
|
|
|
|
|
lang => $self->lang |
52
|
|
|
|
|
|
|
); |
53
|
0
|
|
|
|
|
|
return $r->put(encode_json($data)); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub update { |
57
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $data) = @_; |
58
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
59
|
|
|
|
|
|
|
url => $self->url, |
60
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/%s/id/%s', $self->model, $id), |
61
|
|
|
|
|
|
|
username => $self->username, |
62
|
|
|
|
|
|
|
password => $self->password, |
63
|
|
|
|
|
|
|
lang => $self->lang |
64
|
|
|
|
|
|
|
); |
65
|
0
|
|
|
|
|
|
return $r->put(encode_json($data)); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub delete { |
69
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
70
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
71
|
|
|
|
|
|
|
url => $self->url, |
72
|
|
|
|
|
|
|
url_query => sprintf('service.php/item/%s/id/%s', $self->model, $id), |
73
|
|
|
|
|
|
|
username => $self->username, |
74
|
|
|
|
|
|
|
password => $self->password, |
75
|
|
|
|
|
|
|
lang => $self->lang |
76
|
|
|
|
|
|
|
); |
77
|
0
|
|
|
|
|
|
return $r->delete(); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub list { |
81
|
0
|
|
|
0
|
0
|
|
my ($self, $field_list) = @_; |
82
|
0
|
|
|
|
|
|
my $q = Catmandu::CA::API::QueryBuilder->new(field_list => $field_list); |
83
|
0
|
|
|
|
|
|
my $r = Catmandu::CA::API::Request->new( |
84
|
|
|
|
|
|
|
url => $self->url, |
85
|
|
|
|
|
|
|
url_query => sprintf('service.php/find/%s?q=*', $self->model), |
86
|
|
|
|
|
|
|
username => $self->username, |
87
|
|
|
|
|
|
|
password => $self->password, |
88
|
|
|
|
|
|
|
lang => $self->lang |
89
|
|
|
|
|
|
|
); |
90
|
0
|
|
|
|
|
|
return $r->get($q->query); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
__END__ |