| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::Akeneo::Resource::Categories; |
|
2
|
|
|
|
|
|
|
$WebService::Akeneo::Resource::Categories::VERSION = '0.001'; |
|
3
|
3
|
|
|
3
|
|
38
|
use v5.38; |
|
|
3
|
|
|
|
|
12
|
|
|
4
|
3
|
|
|
3
|
|
17
|
use Object::Pad; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
22
|
|
|
5
|
3
|
|
|
3
|
|
418
|
use Mojo::JSON 'encode_json'; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
192
|
|
|
6
|
3
|
|
|
3
|
|
18
|
use Mojo::URL; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
class WebService::Akeneo::Resource::Categories 0.001; |
|
9
|
|
|
|
|
|
|
field $t :param; |
|
10
|
|
|
|
|
|
|
field $paginator; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BUILD { $paginator = WebService::Akeneo::Paginator->new( transport => $t ) } |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
0
|
|
method get ($code) { $t->request('GET', "/categories/$code") } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
0
|
|
method upsert ($code, $payload) { $t->request('PATCH', "/categories/$code", json => $payload) } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
0
|
|
method upsert_ndjson ($records) { $t->request('PATCH', "/categories", ndjson => $records) } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
|
method list (%params) { $paginator->collect('/categories', %params) } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
0
|
0
|
|
method list_under_root ($root_code, %opt) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
20
|
0
|
|
0
|
|
|
|
my $limit = delete($opt{limit}) // 100; |
|
21
|
0
|
|
|
|
|
|
my $query = { |
|
22
|
|
|
|
|
|
|
with_position => 'true', |
|
23
|
|
|
|
|
|
|
limit => $limit, |
|
24
|
|
|
|
|
|
|
search => encode_json({ parent => [ { operator => '=', value => $root_code } ] }), |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
0
|
|
|
|
|
|
my $acc = []; |
|
27
|
0
|
|
|
|
|
|
my $path = '/categories'; |
|
28
|
0
|
|
|
|
|
|
while (1) { |
|
29
|
0
|
|
|
|
|
|
my $page_res = $t->request('GET', $path, query => $query); |
|
30
|
0
|
|
0
|
|
|
|
my $items = ($page_res->{items}//($page_res->{_embedded} && $page_res->{_embedded}{items})) // []; |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
push @$acc, @$items if @$items; |
|
32
|
0
|
|
0
|
|
|
|
my $next = ($page_res->{_links}//{})->{next} && $page_res->{_links}{next}{href}; |
|
33
|
0
|
0
|
|
|
|
|
last unless $next; |
|
34
|
0
|
|
|
|
|
|
my $url = Mojo::URL->new($next); $path = $url->path->to_string; $query = $url->query->to_hash; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} |
|
36
|
0
|
|
|
|
|
|
my $root = $self->get($root_code); |
|
37
|
0
|
0
|
|
|
|
|
die sprintf('Category %s is not root.', $root_code) if defined $root->{parent}; |
|
38
|
0
|
|
|
|
|
|
push @$acc, $root; |
|
39
|
0
|
|
|
|
|
|
return $acc; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |