| 1 | package Google::Voice::Feed; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Google::Voice::SMS::Message; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Mojo::Base -base; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use constant FEED_TYPE => { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 2 => 'voicemail', | ||||||||||||||||||||||||||||||||
| 12 | 10 => 'sms', | ||||||||||||||||||||||||||||||||
| 13 | 4 => 'recorded', | ||||||||||||||||||||||||||||||||
| 14 | 7 => 'placed', | ||||||||||||||||||||||||||||||||
| 15 | 1 => 'received', | ||||||||||||||||||||||||||||||||
| 16 | 0 => 'missed', | ||||||||||||||||||||||||||||||||
| 17 | 11 => 'trash', | ||||||||||||||||||||||||||||||||
| 18 | 10 => 'starred', | ||||||||||||||||||||||||||||||||
| 19 | 1 | }; | |||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 1 | __PACKAGE__->attr([qw/ xml id type name meta text rnr_se ua /]); | |||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 24 | 0 | my $self = bless {}, shift; | |||||||||||||||||||||||||||||||
| 25 | 0 | my $xml = shift; | |||||||||||||||||||||||||||||||
| 26 | 0 | my $meta = shift; | |||||||||||||||||||||||||||||||
| 27 | 0 | my $rnr_se = shift; | |||||||||||||||||||||||||||||||
| 28 | 0 | my $ua = shift; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 0 | $self->xml($xml); | |||||||||||||||||||||||||||||||
| 31 | 0 | $self->id($xml->attrs->{id}); | |||||||||||||||||||||||||||||||
| 32 | 0 | $self->name($self->_message_name($xml->at('.gc-message-name-link'))); | |||||||||||||||||||||||||||||||
| 33 | 0 | $self->meta($meta->{messages}->{$self->id}); | |||||||||||||||||||||||||||||||
| 34 | 0 | $self->type(FEED_TYPE->{$self->meta->{type}}); | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 0 | $self->text("@{[map $_->text, @{$xml->find('.gc-orig-trans > span')}]}"); | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 0 | $self->rnr_se($rnr_se); | |||||||||||||||||||||||||||||||
| 39 | 0 | $self->ua($ua); | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub _message_name { | ||||||||||||||||||||||||||||||
|
Subroutine
_message_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 46 | 0 | my $node = shift; | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return $node->text if $node; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | return ''; | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub messages { | ||||||||||||||||||||||||||||||
|
Subroutine
messages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | # Each text message is a span.gc-message-sms-row | ||||||||||||||||||||||||||||||||
| 57 | return | ||||||||||||||||||||||||||||||||
| 58 | map Google::Voice::SMS::Message->new($_, $self->meta, $self->rnr_se, | ||||||||||||||||||||||||||||||||
| 59 | $self->ua), | ||||||||||||||||||||||||||||||||
| 60 | 0 | @{$self->xml->find('.gc-message-sms-row')}; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub latest { return (shift->messages)[-1] } | ||||||||||||||||||||||||||||||
|
Subroutine
latest: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | my $json = $self->ua->post( | |||||||||||||||||||||||||||||||
| 70 | 'https://www.google.com/voice/inbox/deleteMessages' => form => { | ||||||||||||||||||||||||||||||||
| 71 | messages => $self->id, | ||||||||||||||||||||||||||||||||
| 72 | trash => 1, | ||||||||||||||||||||||||||||||||
| 73 | _rnr_se => $self->rnr_se | ||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | )->res->json; | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $@ = $json->{data}->{code} and return unless $json->{ok}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$json->{'ok'} || ($@ = $json->{'data'}{'code'}) && (return)
$@ = $json->{"data"}{"code"} and return
MC/DC0%0/2
$json->{'ok'} || ($@ = $json->{'data'}{'code'}) && (return)
$json->{'ok'}
$@ = $json->{"data"}{"code"}
Truth table0%0/3
A || B
A= $json->{'ok'}B= $@ = $json->{"data"}{"code"}
| |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | return $json->{ok}; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub download { | ||||||||||||||||||||||||||||||
|
Subroutine
download: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 84 | 0 | my ($from, $to) = @_; | |||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 0 | my $res = $self->ua->get( | |||||||||||||||||||||||||||||||
| 87 | 'https://www.google.com/voice/media/send_voicemail/' . $self->id)->res; | ||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $@ = $res->message and return if $res->code != 200; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$res->code != 200 && (($@ = $res->message) && (return))
$@ = $res->message and return
MC/DC0%0/2
$res->code != 200 && (($@ = $res->message) && (return))
$res->code != 200
$@ = $res->message
Truth table0%0/3
A && B
A= $res->code != 200B= $@ = $res->message
| |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 0 | return $res->content->asset; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 1 | 1; | |||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | Google::Voice::Feed | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | All feeds (voicemail, text, recorded, placed, received, missed, history | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | =head2 id | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | Unique id | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | =head2 name | ||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||
| 112 | Sender's name | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | =head2 meta | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | Metadata hashref | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | =head2 text (voicemail feed only) | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | Text transcription of voicemail | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | =head2 xml | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | Raw xml | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | =head1 METHODS | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | =head2 messages (sms feed only) | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | List of messages in sms conversation, Google::Voice::SMS::Message objects | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | =head2 latest (sms feed only) | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | Most recent sms message | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | =head2 delete | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | Remove conversation | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | =head2 download | ||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | Download associated audio (mp3 format) | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | =cut | ||||||||||||||||||||||||||||||||