line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::LocalBitcoins::API::Request; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
28
|
use 5.014002; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
7
|
use constant URL => 'https://localbitcoins.com/api/'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
10
|
1
|
|
|
1
|
|
6
|
use constant REQUEST_TYPE => 'POST'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
11
|
1
|
|
|
1
|
|
11
|
use constant CONTENT_TYPE => 'application/x-www-form-urlencoded'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
12
|
1
|
|
|
1
|
|
5
|
use constant ATTRIBUTES => qw(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
13
|
1
|
|
|
1
|
|
7
|
use constant READY_TO_SEND => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
45
|
|
14
|
1
|
|
|
1
|
|
5
|
use constant IS_PRIVATE => 1; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
15
|
1
|
|
|
1
|
|
5
|
use constant DATA_KEY => undef; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
448
|
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub url { URL } |
18
|
4
|
|
|
4
|
0
|
18
|
sub request_type { REQUEST_TYPE } |
19
|
6
|
|
|
6
|
0
|
36
|
sub content_type { CONTENT_TYPE } |
20
|
14
|
|
|
14
|
0
|
74
|
sub attributes { ATTRIBUTES } |
21
|
0
|
|
|
0
|
0
|
0
|
sub is_ready_to_send { READY_TO_SEND } |
22
|
2
|
|
|
2
|
0
|
13
|
sub is_private { IS_PRIVATE } |
23
|
0
|
|
|
0
|
0
|
0
|
sub data_key { DATA_KEY } |
24
|
|
|
|
|
|
|
|
25
|
10
|
|
|
10
|
0
|
107
|
sub new { (bless {} => shift)->init(@_) } |
26
|
|
|
|
|
|
|
sub init { |
27
|
10
|
|
|
10
|
0
|
25
|
my $self = shift; |
28
|
10
|
|
|
|
|
35
|
my %args = @_; |
29
|
10
|
|
|
|
|
71
|
foreach my $attribute ($self->attributes) { |
30
|
6
|
100
|
|
|
|
32
|
$self->$attribute($args{$attribute}) if exists $args{$attribute}; |
31
|
|
|
|
|
|
|
} |
32
|
10
|
|
|
|
|
65
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# this method simply makes all the get/setter attribute methods below very tidy... |
36
|
|
|
|
|
|
|
sub get_set { |
37
|
15
|
|
|
15
|
0
|
26
|
my $self = shift; |
38
|
15
|
|
|
|
|
147
|
my $attribute = ((caller(1))[3] =~ /::(\w+)$/)[0]; |
39
|
15
|
100
|
|
|
|
75
|
$self->{$attribute} = shift if scalar @_; |
40
|
15
|
|
|
|
|
142
|
return $self->{$attribute}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# dump all the fields as a hashref... |
44
|
|
|
|
|
|
|
sub request_content { |
45
|
10
|
|
|
10
|
0
|
29
|
my $self = shift; |
46
|
10
|
|
|
|
|
25
|
my $content = {}; |
47
|
10
|
|
|
|
|
40
|
foreach my $field ($self->attributes) { |
48
|
6
|
100
|
|
|
|
28
|
$content->{$field} = $self->$field if defined $self->$field; |
49
|
|
|
|
|
|
|
} |
50
|
10
|
|
|
|
|
59
|
return $content; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |