SparkBot/SharedRole.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 2 / 2 totaltotal 95.1% 39 / 41 CC 1 SCAR 1.1
CC
1
Cov
97%
uuidv4
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« HTTP/Spark.pm ↑ Summary
1 package AnyEvent::SparkBot::SharedRole;
2  
3 =head1 NAME
4  
5 AnyEvent::SparkBot::SharedRole - Shared methods for SparkBot
6  
7 =head1 SYNOPSIS
8  
9 use Modern::Perl;
10 use Moo;
11 BEGIN { with 'AnyEvent::SparkBot::SharedRole' }
12  
13 =head1 DESCRIPTION
14  
15 Shared functions used between different sparkbot classes.
16  
17 =cut
18  
19 4 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use Digest::MD5 qw(md5_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use MooX::Types::MooseLike::Base qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use UUID::Tiny ':std';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 4 has token=>(
28 required=>1,
29 is=>'ro',
30 isa=>Str,
31 );
32  
33 =head1 Constructor Arguments added
34  
35 The following arguments are required when creating a new instance of a class that uses this role:
36  
37 token: This is the cisco authentication token for your app
38  
39 =head1 Role methods
40  
41 =over 4
42  
43 =item * my $uuid=$self->uuidv4()
44  
45 Returns the next uuid.v4 ( md5 sum base64 encoded, due to limitations of cisco spark )
46  
47 =cut
48  
49 0 ▶sub uuidv4 {
Subroutine uuidv4: not called CC=1 SCAR=6.9
Pod documented
50 0 return md5_base64(create_uuid(UUID_V4));
51 }
52  
53 =item * my $headers=$self->default_headers()
54  
55 Returns an HTTP::Headers Object that contains the default header values
56  
57 =cut
58  
59 9 ▶sub default_headers {
Subroutine default_headers: called CC=1 SCAR=0.0
Pod documented
60 9 my ($self)=@_;
61 9 my $h=new HTTP::Headers;
62 9 $h->header(Authorization=>'Bearer ' .$self->token);
63 9 $h->header('Content-Type', 'application/json; charset=UTF-8');
64 9 $h->header(Accept=>'application/json');
65 9 return $h;
66 }
67  
68 =back
69  
70 =head1 AUTHOR
71  
72 Michael Shipper <AKALINUX@CPAN.ORG>
73  
74 =cut
75  
76 4 1;
« HTTP/Spark.pm ↑ Summary