line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=encoding utf-8 |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Webservice::OVH::Helper |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 DESCRIPTION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Some Helper Methods |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use strict; |
17
|
36
|
|
|
36
|
|
254
|
use warnings; |
|
36
|
|
|
|
|
70
|
|
|
36
|
|
|
|
|
1076
|
|
18
|
36
|
|
|
36
|
|
162
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
75
|
|
|
36
|
|
|
|
|
1095
|
|
19
|
36
|
|
|
36
|
|
187
|
|
|
36
|
|
|
|
|
69
|
|
|
36
|
|
|
|
|
2050
|
|
20
|
|
|
|
|
|
|
use DateTime::Format::Strptime; |
21
|
36
|
|
|
36
|
|
18879
|
|
|
36
|
|
|
|
|
6024629
|
|
|
36
|
|
|
|
|
186
|
|
22
|
|
|
|
|
|
|
=head2 construct_filter |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Helper method to construct uri parameter |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * Parameter: key => value |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item * Return: VALUE |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Helper->construct_filter(); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=back |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my ( $class, %params ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
1
|
|
my @params = keys %params; |
42
|
|
|
|
|
|
|
my @values = values %params; |
43
|
0
|
|
|
|
|
|
my $filter = scalar @values ? '?' : ""; |
44
|
0
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
my $pairs = []; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
foreach my $param (@params) { |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $value = $params{$param}; |
50
|
|
|
|
|
|
|
next unless $value; |
51
|
0
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
$value = $value eq '_empty_' ? "" : $value; |
53
|
|
|
|
|
|
|
push @$pairs, sprintf( "%s=%s", $param, $value ); |
54
|
0
|
0
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $str = join('&', @$pairs); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return $str ? "?" . $str : ""; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
0
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 construct_filter |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns a DateTime Object. |
65
|
|
|
|
|
|
|
Methods uses special pattern to match ovhs DT format. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * Parameter: $str_datetime - datetime string, $locale - locale like 'en_EN', $timezone - timezone |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * Return: DateTime |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Helper->parse_datetime("2016-05-15T19:30:23", 'de_DE', 'Europe/Berlin'); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my ( $class, $str_datetime, $locale, $timezone ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $strp = DateTime::Format::Strptime->new( |
83
|
0
|
|
|
0
|
1
|
|
pattern => '%FT%T', |
84
|
|
|
|
|
|
|
locale => ( $locale || 'de_DE' ), |
85
|
0
|
|
0
|
|
|
|
time_zone => ( $timezone || 'Europe/Berlin' ), |
|
|
|
0
|
|
|
|
|
86
|
|
|
|
|
|
|
on_error => 'croak', |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
return $strp->parse_datetime($str_datetime); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my ( $class, $str_datetime, $locale, $timezone ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $strp = DateTime::Format::Strptime->new( |
96
|
|
|
|
|
|
|
pattern => '%F', |
97
|
0
|
|
|
0
|
0
|
|
locale => ( $locale || 'de_DE' ), |
98
|
|
|
|
|
|
|
time_zone => ( $timezone || 'Europe/Berlin' ), |
99
|
0
|
|
0
|
|
|
|
on_error => 'croak', |
|
|
|
0
|
|
|
|
|
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
return $strp->parse_datetime($str_datetime); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 format_datetime |
106
|
0
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns a date time string fitting ovhs requirements |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * Parameter: $dt - DateTime object |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * Return: VALUE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * Synopsis: my $dt_str = Webservice::OVH::Helper->format_datetime(DateTime->today()); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my ( $class, $dt ) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return $dt->strftime('%FT%T%z'); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
0
|
1
|
|
|
128
|
|
|
|
|
|
|
my ( $class, $string ) = @_; |
129
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$string =~ s/^\s+|\s+$//g; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
return $string; |
133
|
|
|
|
|
|
|
} |
134
|
0
|
|
|
0
|
0
|
|
|
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my ( $class, $string ) = @_; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$string =~ s/\s+$//; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
return $string; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
0
|
0
|
|
|
144
|
|
|
|
|
|
|
my ( $class, $string ) = @_; |
145
|
0
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$string =~ s/^\s+//; |
147
|
0
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
return $string; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |