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