line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Webservice::Judobase::General; |
5
|
|
|
|
|
|
|
$Webservice::Judobase::General::VERSION = '0.10'; |
6
|
|
|
|
|
|
|
# VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
350
|
use HTTP::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
10
|
1
|
|
|
1
|
|
6
|
use JSON::Tiny 'decode_json'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
11
|
1
|
|
|
1
|
|
5
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'ua' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'url' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub competition { |
26
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
27
|
0
|
0
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $url |
30
|
|
|
|
|
|
|
= $self->url |
31
|
|
|
|
|
|
|
. '?params[action]=general.get_one' |
32
|
|
|
|
|
|
|
. '¶ms[module]=competition' |
33
|
|
|
|
|
|
|
. '¶ms[id]=' |
34
|
0
|
|
|
|
|
|
. $args{id}; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
return decode_json $response->content |
41
|
|
|
|
|
|
|
if $response->code == 200; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub competitions { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $url |
50
|
|
|
|
|
|
|
= $self->url |
51
|
|
|
|
|
|
|
. '?params[action]=competition.get_list' |
52
|
|
|
|
|
|
|
. '¶ms[limit]=9999' |
53
|
|
|
|
|
|
|
. '¶ms[sort]=-1'; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
return decode_json $response->content |
60
|
|
|
|
|
|
|
if $response->code == 200; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitions info' }; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub competitors { |
66
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
67
|
|
|
|
|
|
|
return { error => 'event_id parameter is required' } |
68
|
0
|
0
|
|
|
|
|
unless defined $args{event_id}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $url |
71
|
|
|
|
|
|
|
= $self->url |
72
|
|
|
|
|
|
|
. '?params[action]=competition.competitors' |
73
|
|
|
|
|
|
|
. '¶ms[id_competition]=' |
74
|
0
|
|
|
|
|
|
. $args{event_id}; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my @competitors = (); |
81
|
0
|
0
|
|
|
|
|
if ( $response->code == 200 ) { |
82
|
0
|
|
|
|
|
|
my $info = decode_json $response->content; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
for my $gender ( values %{ $info->{categories} } ) { |
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
for my $cat ( values %$gender ) { |
86
|
0
|
|
|
|
|
|
for my $person ( values %{ $cat->{persons} } ) { |
|
0
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
push @competitors, $person; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return \@competitors; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
else { |
95
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitors info' }; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |