line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Box; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: manage your documents on Box.com |
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
162292
|
use strict; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
246
|
|
6
|
7
|
|
|
7
|
|
38
|
use warnings; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
185
|
|
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
38
|
use Carp; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
1202
|
|
9
|
7
|
|
|
7
|
|
17602
|
use Moo; |
|
7
|
|
|
|
|
135481
|
|
|
7
|
|
|
|
|
45
|
|
10
|
7
|
|
|
7
|
|
19801
|
use Types::Standard qw(Str Int); |
|
7
|
|
|
|
|
602490
|
|
|
7
|
|
|
|
|
104
|
|
11
|
|
|
|
|
|
|
|
12
|
7
|
|
|
7
|
|
12883
|
use WebService::Box::Session; |
|
7
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
3688
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.02; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has api_url => (is => 'ro', isa => Str, required => 1, default => sub{ "" } ); |
17
|
|
|
|
|
|
|
has upload_url => (is => 'ro', isa => Str, required => 1, default => sub{ "" } ); |
18
|
|
|
|
|
|
|
has on_error => (is => 'ro', isa => sub{ |
19
|
|
|
|
|
|
|
die "invalid value for 'on_error'" if ( |
20
|
|
|
|
|
|
|
( ref $_[0] and ref $_[0] ne 'CODE' ) || |
21
|
|
|
|
|
|
|
( !ref $_[0] and defined $_[0] and $_[0] ne 'die' and $_[0] ne 'warn' ) |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
}, default => sub{ \&_my_die } ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has on_warn => (is => 'ro', isa => sub{ |
26
|
|
|
|
|
|
|
die "invalid value for 'on_warn'" if ( |
27
|
|
|
|
|
|
|
( ref $_[0] and ref $_[0] ne 'CODE' ) || |
28
|
|
|
|
|
|
|
!ref $_[0] |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
}, default => sub{ \&_my_warn } ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub error { |
33
|
5
|
|
|
5
|
0
|
71
|
my ($self, $message) = @_; |
34
|
|
|
|
|
|
|
|
35
|
5
|
50
|
|
|
|
45
|
return if !$self->on_error; |
36
|
|
|
|
|
|
|
|
37
|
5
|
50
|
|
|
|
26
|
if ( !ref $self->on_error ) { |
38
|
0
|
0
|
|
|
|
0
|
if ( $self->on_error eq 'die' ) { |
39
|
0
|
|
|
|
|
0
|
_my_die( $message ); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
0
|
|
|
|
0
|
if ( $self->on_warn eq 'warn' ) { |
42
|
0
|
|
|
|
|
0
|
_my_warn( $message ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
5
|
|
|
|
|
26
|
$self->on_error->( $message ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub warn { |
51
|
2
|
|
|
2
|
0
|
989
|
my ($self, $message) = @_; |
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
8
|
return if !$self->on_warn; |
54
|
|
|
|
|
|
|
|
55
|
2
|
50
|
|
|
|
8
|
if ( !ref $self->on_warn ) { |
56
|
0
|
|
|
|
|
0
|
_my_warn( $message ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
2
|
|
|
|
|
7
|
$self->on_warn->( $message ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub create_session { |
64
|
0
|
|
|
0
|
1
|
0
|
my ($self) |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _my_die { |
68
|
1
|
|
|
1
|
|
26
|
croak $_[0]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _my_warn { |
72
|
1
|
|
|
1
|
|
12
|
carp $_[0]; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |