line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$Webservice::Judobase::Competitor::VERSION = '0.08'; |
5
|
|
|
|
|
|
|
# ABSTRACT: This module wraps the www.judobase.org website API. |
6
|
|
|
|
|
|
|
# VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use HTTP::Request; |
9
|
1
|
|
|
1
|
|
353
|
use JSON::Tiny 'decode_json'; |
|
1
|
|
|
|
|
16273
|
|
|
1
|
|
|
|
|
29
|
|
10
|
1
|
|
|
1
|
|
374
|
use Moo; |
|
1
|
|
|
|
|
2116
|
|
|
1
|
|
|
|
|
44
|
|
11
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
#extends 'Webservice::Judobase'; |
13
|
|
|
|
|
|
|
use namespace::clean; |
14
|
1
|
|
|
1
|
|
642
|
|
|
1
|
|
|
|
|
11750
|
|
|
1
|
|
|
|
|
9
|
|
15
|
|
|
|
|
|
|
has 'ua' => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'url' => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
26
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
27
|
0
|
|
|
0
|
1
|
|
|
28
|
0
|
0
|
|
|
|
|
my $url |
29
|
|
|
|
|
|
|
= $self->url |
30
|
|
|
|
|
|
|
. '?params[action]=competitor.best_results¶ms[id_person]=' |
31
|
|
|
|
|
|
|
. $args{id}; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return decode_json $response->content |
38
|
|
|
|
|
|
|
if $response->code == 200; |
39
|
0
|
0
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return { error => 'min_age parameter is required' } |
46
|
0
|
|
|
0
|
1
|
|
unless defined $args{min_age}; |
47
|
|
|
|
|
|
|
my $url |
48
|
|
|
|
|
|
|
= $self->url |
49
|
0
|
0
|
|
|
|
|
. '?params[action]=competitor.birthday_competitors¶ms[min_age]=' |
50
|
|
|
|
|
|
|
. $args{min_age}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
53
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $response = $self->ua->request($request); |
55
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return decode_json $response->content |
57
|
0
|
|
|
|
|
|
if $response->code == 200; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my ( $self, %args ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
65
|
|
|
|
|
|
|
my $url |
66
|
0
|
|
|
0
|
1
|
|
= $self->url |
67
|
|
|
|
|
|
|
. '?params[action]=competitor.contests¶ms[id_person]=' |
68
|
0
|
0
|
|
|
|
|
. $args{id}; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return decode_json $response->content |
75
|
|
|
|
|
|
|
if $response->code == 200; |
76
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
78
|
0
|
0
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my ( $self, %args ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
84
|
|
|
|
|
|
|
my $url |
85
|
|
|
|
|
|
|
= $self->url |
86
|
0
|
|
|
0
|
1
|
|
. '?params[action]=competitor.contests_statistics¶ms[id_person]=' |
87
|
|
|
|
|
|
|
. $args{id}; |
88
|
0
|
0
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $response = $self->ua->request($request); |
92
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return decode_json $response->content |
94
|
0
|
|
|
|
|
|
if $response->code == 200; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitor contests statistics' }; |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
101
|
0
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $url |
105
|
|
|
|
|
|
|
= $self->url |
106
|
0
|
|
|
0
|
1
|
|
. '?params[action]=competitor.fights_statistics¶ms[id_person]=' |
107
|
|
|
|
|
|
|
. $args{id}; |
108
|
0
|
0
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $response = $self->ua->request($request); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
if ( $response->code == 200 ) { |
114
|
|
|
|
|
|
|
my $data = decode_json $response->content; |
115
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
return $data->[0] if ref $data eq 'ARRAY'; |
117
|
0
|
|
|
|
|
|
return $data; |
118
|
|
|
|
|
|
|
} |
119
|
0
|
0
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
121
|
|
|
|
|
|
|
} |
122
|
0
|
0
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my ( $self, %args ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
126
|
0
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $url |
128
|
|
|
|
|
|
|
= $self->url |
129
|
|
|
|
|
|
|
. '?params[action]=competitor.info¶ms[id_person]=' |
130
|
0
|
|
|
0
|
1
|
|
. $args{id}; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $response = $self->ua->request($request); |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
return decode_json $response->content |
137
|
0
|
|
|
|
|
|
if $response->code == 200; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
140
|
|
|
|
|
|
|
} |
141
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
143
|
0
|
0
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return { error => 'id parameter is required' } unless defined $args{id}; |
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
my $url |
147
|
|
|
|
|
|
|
= $self->url |
148
|
|
|
|
|
|
|
. '?params[action]=competitor.wrl_current¶ms[id_person]=' |
149
|
|
|
|
|
|
|
. $args{id}; |
150
|
0
|
|
|
0
|
1
|
|
|
151
|
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
152
|
0
|
0
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $response = $self->ua->request($request); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
if ( $response->code == 200 ) { |
156
|
|
|
|
|
|
|
my $data = decode_json $response->content; |
157
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
return $data->[0] if ref $data eq 'ARRAY'; |
159
|
0
|
|
|
|
|
|
return $data; |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return { error => 'Error retreiving competitor info' }; |
163
|
0
|
0
|
|
|
|
|
} |
164
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |