line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Webservice::Judobase::Country; |
5
|
|
|
|
|
|
|
$Webservice::Judobase::Country::VERSION = '0.10'; |
6
|
|
|
|
|
|
|
# ABSTRACT: This module wraps the www.judobase.org website API. |
7
|
|
|
|
|
|
|
# VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use HTTP::Request; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
10
|
1
|
|
|
1
|
|
13
|
use JSON::Tiny 'decode_json'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
48
|
|
11
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#extends 'Webservice::Judobase'; |
14
|
1
|
|
|
1
|
|
353
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
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 competitors_list { |
27
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
28
|
|
|
|
|
|
|
return { error => 'id_country parameter is required' } |
29
|
0
|
0
|
|
|
|
|
unless defined $args{id_country}; |
30
|
|
|
|
|
|
|
return { error => 'id_country parameter must be an integer' } |
31
|
0
|
0
|
|
|
|
|
unless ( $args{id_country} =~ /\d+/ ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $url |
34
|
|
|
|
|
|
|
= $self->url |
35
|
|
|
|
|
|
|
. '?params[action]=country.competitors_list' |
36
|
|
|
|
|
|
|
. '¶ms[id_country]=' |
37
|
0
|
|
|
|
|
|
. $args{id_country}; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
40
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( $response->code == 200 ) { |
43
|
0
|
|
|
|
|
|
my $data = decode_json $response->content; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return $data->{competitors}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return { error => 'Error retreiving country info' }; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_list { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my $url = $self->url . '?params[action]=country.get_list'; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new( GET => $url ); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $response = $self->ua->request($request); |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
if ( $response->code == 200 ) { |
61
|
0
|
|
|
|
|
|
my $data = decode_json $response->content; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $data; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return { error => 'Error retreiving country info' }; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |