line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Business::Fixflo::Utils; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Business::Fixflo::Utils |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
A role containing Fixflo utilities. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
17
|
|
132115
|
use strict; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
469
|
|
14
|
17
|
|
|
17
|
|
78
|
use warnings; |
|
17
|
|
|
|
|
30
|
|
|
17
|
|
|
|
|
388
|
|
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
17
|
|
500
|
use Moo::Role; |
|
17
|
|
|
|
|
8252
|
|
|
17
|
|
|
|
|
135
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 normalize_params |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Normalizes the passed params hash into a string for use in queries to the |
23
|
|
|
|
|
|
|
fixflo API. Includes RFC5849 encoding and will convert DateTime objects |
24
|
|
|
|
|
|
|
into the corresponding ISO8601 string |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $query_string = $self->normalize_params( \%params ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub normalize_params { |
31
|
7
|
|
|
7
|
1
|
13924
|
my ( $self,$params ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
7
|
100
|
100
|
|
|
35
|
return '' if ( ! $params || ! keys( %{ $params } ) ); |
|
5
|
|
|
|
|
27
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return join( '&', |
36
|
9
|
|
|
|
|
34
|
map { $_->[0] . '=' . $_->[1] } |
37
|
9
|
|
|
|
|
22
|
map { [ _rfc5849_encode( $_ ),_rfc5849_encode( $params->{$_} ) ] } |
38
|
6
|
|
|
|
|
18
|
sort { $a cmp $b } |
39
|
4
|
|
|
|
|
8
|
keys( %{ $params } ) |
|
4
|
|
|
|
|
20
|
|
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _rfc5849_encode { |
44
|
18
|
|
|
18
|
|
26
|
my ( $str ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
18
|
50
|
|
|
|
34
|
if ( ref( $str ) eq 'DateTime' ) { |
47
|
0
|
|
|
|
|
0
|
$str = $str->iso8601; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
18
|
|
|
|
|
63
|
$str =~ s#([^-.~_a-z0-9])#sprintf('%%%02X', ord($1))#gei; |
|
4
|
|
|
|
|
58
|
|
51
|
18
|
|
|
|
|
47
|
return $str; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 AUTHOR |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Lee Johnson - C |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
59
|
|
|
|
|
|
|
the same terms as Perl itself. If you would like to contribute documentation, |
60
|
|
|
|
|
|
|
features, bug fixes, or anything else then please raise an issue / pull request: |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
https://github.com/Humanstate/business-fixflo |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# vim: ts=4:sw=4:et |