line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Pixabay; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
51888
|
use Modern::Perl '2009'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
122
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
265
|
use Function::Parameters; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
837
|
use Data::Dumper 'Dumper'; |
|
1
|
|
|
|
|
4859
|
|
|
1
|
|
|
|
|
417
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'WebService::Client'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Perl 5 interface to Pixabay API. |
11
|
|
|
|
|
|
|
our $VERSION = '2.0.1'; our $VERSION = '2.0.1'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# token key |
14
|
|
|
|
|
|
|
has api_key => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
required => 1 |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '+base_url' => ( default => 'https://pixabay.com/api/' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# get image metadata from JSON |
22
|
|
|
|
|
|
|
method image_search( |
23
|
|
|
|
|
|
|
: $q = "yellow flower", |
24
|
|
|
|
|
|
|
: $lang = "en", |
25
|
|
|
|
|
|
|
: $id = "", |
26
|
|
|
|
|
|
|
: $response_group = "image_details", |
27
|
|
|
|
|
|
|
: $image_type = "all", |
28
|
|
|
|
|
|
|
: $orientation = "all", |
29
|
|
|
|
|
|
|
: $category = "", |
30
|
|
|
|
|
|
|
: $min_width = 0, |
31
|
|
|
|
|
|
|
: $min_height = 0, |
32
|
|
|
|
|
|
|
: $editors_choice = "false", |
33
|
|
|
|
|
|
|
: $safesearch = "false", |
34
|
|
|
|
|
|
|
: $order = "popular", |
35
|
|
|
|
|
|
|
: $page = 1, |
36
|
|
|
|
|
|
|
: $per_page = 20, |
37
|
|
|
|
|
|
|
: $callback = "", |
38
|
|
|
|
|
|
|
: $pretty = "false" |
39
|
|
|
|
|
|
|
) |
40
|
0
|
0
|
0
|
0
|
0
|
|
{ |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self->get( |
42
|
|
|
|
|
|
|
"?key=" |
43
|
|
|
|
|
|
|
. $self->api_key |
44
|
|
|
|
|
|
|
. "&q=$q&lang=$lang&id=$id&response_group=$response_group&image_type=$image_type" |
45
|
|
|
|
|
|
|
. "&orientation=$orientation&category=$category&min_width=$min_width&mind_height=$min_height" |
46
|
|
|
|
|
|
|
. "&editors_choice=$editors_choice&safesearch=$safesearch&order=$order&page=$page" |
47
|
|
|
|
|
|
|
. "&per_page=$per_page&callback=$callback&pretty=$pretty" |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# get image metadata from JSON |
52
|
|
|
|
|
|
|
method video_search( |
53
|
|
|
|
|
|
|
: $q = "yellow flower", |
54
|
|
|
|
|
|
|
: $lang = "en", |
55
|
|
|
|
|
|
|
: $id = "", |
56
|
|
|
|
|
|
|
: $video_type = "all", |
57
|
|
|
|
|
|
|
: $category = "", |
58
|
|
|
|
|
|
|
: $min_width = 0, |
59
|
|
|
|
|
|
|
: $min_height = 0, |
60
|
|
|
|
|
|
|
: $editors_choice = "false", |
61
|
|
|
|
|
|
|
: $safesearch = "false", |
62
|
|
|
|
|
|
|
: $order = "popular", |
63
|
|
|
|
|
|
|
: $page = 1, |
64
|
|
|
|
|
|
|
: $per_page = 20, |
65
|
|
|
|
|
|
|
: $callback = "", |
66
|
|
|
|
|
|
|
: $pretty = "false" |
67
|
|
|
|
|
|
|
) |
68
|
0
|
0
|
0
|
0
|
0
|
|
{ |
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $self->get( |
70
|
|
|
|
|
|
|
"videos/?key=" |
71
|
|
|
|
|
|
|
. $self->api_key |
72
|
|
|
|
|
|
|
. "&q=$q&lang=$lang&id=$id&video_type=$video_type" |
73
|
|
|
|
|
|
|
. "&category=$category&min_width=$min_width&mind_height=$min_height" |
74
|
|
|
|
|
|
|
. "&editors_choice=$editors_choice&safesearch=$safesearch&order=$order&page=$page" |
75
|
|
|
|
|
|
|
. "&per_page=$per_page&callback=$callback&pretty=$pretty" |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# pretty print the JSON data structure |
80
|
0
|
0
|
|
0
|
0
|
|
method show_data_structure($method_name) { |
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
print Dumper $method_name; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |