| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Money::Converter::WebserviceX; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Data::Money::Converter::WebserviceX::VERSION = '0.07'; |
|
4
|
|
|
|
|
|
|
$Data::Money::Converter::WebserviceX::AUTHORITY = 'gphat'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Data::Money::Converter::WebserviceX - WebserviceX currency conversion implementation. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version v0.07 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use strict; use warnings; |
|
17
|
|
|
|
|
|
|
use Data::Money; |
|
18
|
|
|
|
|
|
|
use Data::Money::Converter::WebserviceX; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $curr = Data::Money->new(value => 10, code => 'USD'); |
|
21
|
|
|
|
|
|
|
my $conv = Data::Money::Converter::WebserviceX->new; |
|
22
|
|
|
|
|
|
|
my $newc = $conv->convert($curr, 'GBP'); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
print $newc->value, "\n"; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
149031
|
use Moo; |
|
|
4
|
|
|
|
|
28322
|
|
|
|
4
|
|
|
|
|
41
|
|
|
29
|
4
|
|
|
4
|
|
4918
|
use namespace::clean; |
|
|
4
|
|
|
|
|
23267
|
|
|
|
4
|
|
|
|
|
15
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
4
|
|
|
4
|
|
2087
|
use Data::Dumper; |
|
|
4
|
|
|
|
|
21491
|
|
|
|
4
|
|
|
|
|
182
|
|
|
32
|
4
|
|
|
4
|
|
1357
|
use Locale::Currency; |
|
|
4
|
|
|
|
|
34671
|
|
|
|
4
|
|
|
|
|
239
|
|
|
33
|
4
|
|
|
4
|
|
1954
|
use Finance::Currency::Convert::WebserviceX; |
|
|
4
|
|
|
|
|
129914
|
|
|
|
4
|
|
|
|
|
746
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
with 'Data::Money::Converter'; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has '_converter' => (is => 'lazy'); |
|
38
|
|
|
|
|
|
|
has 'valid_currency_code' => (is => 'ro', default => sub { |
|
39
|
|
|
|
|
|
|
return { |
|
40
|
|
|
|
|
|
|
map { uc($_) => uc($_) } Locale::Currency::all_currency_codes() |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
}); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _build__converter { |
|
45
|
0
|
|
|
0
|
|
|
return Finance::Currency::Convert::WebserviceX->new; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 convert($money, $code) |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Convert C<$money>, which is an object of type L to currency C<$code> |
|
53
|
|
|
|
|
|
|
and returns an object of type L.The C<$code> has to be a valid three |
|
54
|
|
|
|
|
|
|
letter codes. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub convert { |
|
59
|
0
|
|
|
0
|
1
|
|
my ($self, $curr, $code) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#die "[$code]",Dumper($self->{valid_currency_code}); |
|
62
|
|
|
|
|
|
|
die "ERROR: $code is not a valid currency code.\n" |
|
63
|
0
|
0
|
|
|
|
|
unless ($self->{valid_currency_code}{uc($code)}); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $curr->clone( |
|
66
|
|
|
|
|
|
|
code => $code, |
|
67
|
|
|
|
|
|
|
value => $self->_converter->convert($curr->value, $curr->code, $code), |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Cory G Watson, C<< >> |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Currently maintained by Mohammad S Anwar (MANWAR) C<< >> |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
L |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 4 |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item L |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item L |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright 2010 Cory G Watson. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the |
|
96
|
|
|
|
|
|
|
terms of either: the GNU General Public License as published by the Free Software |
|
97
|
|
|
|
|
|
|
Foundation; or the Artistic License. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; # End of Data::Money::Converter::WebserviceX |