line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Magrathea::API::Status; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
13
|
use 5.10.0; |
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use version 0.77; our $VERSION = qv('v0.9.0'); |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
9
|
|
8
|
1
|
|
|
1
|
|
97
|
use experimental qw{ switch }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
143
|
use Phone::Number; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
11
|
1
|
|
|
1
|
|
433
|
use Attribute::Boolean; |
|
1
|
|
|
|
|
9135
|
|
|
1
|
|
|
|
|
5
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
148
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
102
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
7
|
use overload q("") => \&stringify; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Magrathea::API::Status - A status return for a number |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub get_type($) |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
26
|
0
|
|
|
|
|
|
given ($type) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
when (/^[Ss]:/) |
29
|
0
|
|
|
|
|
|
{ |
30
|
0
|
|
|
|
|
|
return 'sip'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
when (/^I:/) |
33
|
0
|
|
|
|
|
|
{ |
34
|
0
|
|
|
|
|
|
return 'iax2'; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
when (/^F:/) |
37
|
0
|
|
|
|
|
|
{ |
38
|
0
|
|
|
|
|
|
return 'fax2email'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
when (/^V:/) |
41
|
0
|
|
|
|
|
|
{ |
42
|
0
|
|
|
|
|
|
return 'voice2email'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
when (/^\d+$/) |
45
|
0
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
|
return 'divert'; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
default { |
49
|
0
|
|
|
|
|
|
return 'unallocated'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 CLASS FUNCTIONS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 new |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Usually only called by L. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $status = new Magrathea:API::Status($status); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub new |
65
|
|
|
|
|
|
|
{ |
66
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
67
|
0
|
|
|
|
|
|
my $string = shift; |
68
|
0
|
0
|
|
|
|
|
return undef if $string =~ /^\s*$/; |
69
|
0
|
|
|
|
|
|
my ($number, $status, $expiry, $target) = split /\s/, $string; |
70
|
0
|
|
|
|
|
|
my $type = get_type $target; |
71
|
0
|
|
|
|
|
|
$target =~ s/.:(.*)/$1/; |
72
|
0
|
0
|
|
|
|
|
$target = new Phone::Number($target) if $type eq 'divert'; |
73
|
0
|
|
|
|
|
|
my $active:Boolean = $status eq 'Y'; |
74
|
0
|
|
|
|
|
|
my $self = { |
75
|
|
|
|
|
|
|
number => new Phone::Number($number), |
76
|
|
|
|
|
|
|
active => $active, |
77
|
|
|
|
|
|
|
expiry => $expiry, |
78
|
|
|
|
|
|
|
type => $type, |
79
|
|
|
|
|
|
|
target => $target, |
80
|
|
|
|
|
|
|
entry => 1, |
81
|
|
|
|
|
|
|
}; |
82
|
0
|
|
|
|
|
|
bless $self, $class; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub AUTOLOAD |
86
|
|
|
|
|
|
|
{ |
87
|
0
|
|
|
0
|
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
my $value = shift; |
89
|
0
|
|
|
|
|
|
(my $name = our $AUTOLOAD) =~ s/.*://; |
90
|
0
|
0
|
|
|
|
|
croak "Unknown command: $name" unless defined $self->{$name}; |
91
|
0
|
0
|
|
|
|
|
$self->{$name} = $value if defined $value; |
92
|
0
|
|
|
|
|
|
return $self->{$name}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub stringify |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
return sprintf '%s %s', $self->type, $self->target; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
0
|
|
|
sub DESTROY { } |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |