| 1 | package WWW::FCM::HTTP::V1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = "0.01"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | use Class::Accessor::Lite ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | new => 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | rw => [qw/sender api_url/], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use JSON qw(encode_json); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use WWW::FCM::HTTP::V1::OAuth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | our $SCOPE_FIREBASE_MESSAGING = "https://www.googleapis.com/auth/firebase.messaging"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | my %args = $_[0] && ref $_[0] eq 'HASH' ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] and ref $_[0] eq "HASH"
MC/DC100%2/2
$_[0] and ref $_[0] eq "HASH"
$_[0]
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= $_[0]B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | croak 'Usage: WWW::FCM::HTTP::V1->new({ api_url => $api_url, api_key_json => $api_key_json })' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | ▶ | unless (exists $args{api_url} && defined $args{api_url} && exists $args{api_key_json} && defined $args{api_key_json}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"} and defined $args{"api_key_json"}
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"}
exists $args{"api_url"} and defined $args{"api_url"}
MC/DC75%3/4
exists $args{"api_url"} and defined $args{"api_url"} and exists $args{"api_key_json"} and defined $args{"api_key_json"}
exists $args{"api_url"}
defined $args{"api_url"}
exists $args{"api_key_json"}
defined $args{"api_key_json"}
Truth table80%4/5
A and B and C and D
A= exists $args{"api_url"}B= defined $args{"api_url"}C= exists $args{"api_key_json"}D= defined $args{"api_key_json"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | $args{sender} ||= WWW::FCM::HTTP::V1::OAuth->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | api_key_json => $args{api_key_json}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | scopes => [$SCOPE_FIREBASE_MESSAGING], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"sender"} ||= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
MC/DC0%0/2
$args{"sender"} ||= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
$args{"sender"}
"WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
Truth table66%2/3
A ||= B
A= $args{"sender"}B= "WWW::FCM::HTTP::V1::OAuth"->new("api_key_json", $args{"api_key_json"}, "scopes", [$WWW::FCM::HTTP::V1::SCOPE_FIREBASE_MESSAGING])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | bless { %args }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | sub send { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 8 | ▶ | my ($self, $content) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 8 | ▶ | croak 'Usage: $fcm->send(\%content)' unless ref $content eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | $self->sender->request( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | method => "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | uri => $self->api_url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | content => encode_json($content), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||