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
|
|
161561
|
use strict; |
|
17
|
|
|
|
|
46
|
|
|
17
|
|
|
|
|
572
|
|
14
|
17
|
|
|
17
|
|
98
|
use warnings; |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
464
|
|
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
17
|
|
563
|
use Moo::Role; |
|
17
|
|
|
|
|
9323
|
|
|
17
|
|
|
|
|
122
|
|
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
|
17500
|
my ( $self,$params ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
7
|
100
|
100
|
|
|
79
|
return '' if ( ! $params || ! keys( %{ $params } ) ); |
|
5
|
|
|
|
|
31
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return join( '&', |
36
|
9
|
|
|
|
|
47
|
map { $_->[0] . '=' . $_->[1] } |
37
|
9
|
|
|
|
|
23
|
map { [ _rfc5849_encode( $_ ),_rfc5849_encode( $params->{$_} ) ] } |
38
|
5
|
|
|
|
|
21
|
sort { $a cmp $b } |
39
|
4
|
|
|
|
|
12
|
keys( %{ $params } ) |
|
4
|
|
|
|
|
21
|
|
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _rfc5849_encode { |
44
|
18
|
|
|
18
|
|
33
|
my ( $str ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
18
|
50
|
|
|
|
41
|
if ( ref( $str ) eq 'DateTime' ) { |
47
|
0
|
|
|
|
|
0
|
$str = $str->iso8601; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
18
|
|
|
|
|
74
|
$str =~ s#([^-.~_a-z0-9])#sprintf('%%%02X', ord($1))#gei; |
|
4
|
|
|
|
|
74
|
|
51
|
18
|
|
|
|
|
75
|
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 |