line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
4
|
|
148759
|
use Modern::Perl; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
31
|
|
20
|
4
|
|
|
4
|
|
1293
|
use Moo::Role; |
|
4
|
|
|
|
|
16851
|
|
|
4
|
|
|
|
|
24
|
|
21
|
4
|
|
|
4
|
|
2014
|
use HTTP::Headers; |
|
4
|
|
|
|
|
6493
|
|
|
4
|
|
|
|
|
179
|
|
22
|
4
|
|
|
4
|
|
27
|
use Digest::MD5 qw(md5_base64); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
282
|
|
23
|
4
|
|
|
4
|
|
533
|
use MooX::Types::MooseLike::Base qw(:all); |
|
4
|
|
|
|
|
6753
|
|
|
4
|
|
|
|
|
1438
|
|
24
|
4
|
|
|
4
|
|
2113
|
use UUID::Tiny ':std'; |
|
4
|
|
|
|
|
41113
|
|
|
4
|
|
|
|
|
769
|
|
25
|
4
|
|
|
4
|
|
508
|
use namespace::clean; |
|
4
|
|
|
|
|
11206
|
|
|
4
|
|
|
|
|
37
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub uuidv4 { |
50
|
0
|
|
|
0
|
1
|
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
|
|
|
|
|
|
|
sub default_headers { |
60
|
9
|
|
|
9
|
1
|
23
|
my ($self)=@_; |
61
|
9
|
|
|
|
|
38
|
my $h=new HTTP::Headers; |
62
|
9
|
|
|
|
|
108
|
$h->header(Authorization=>'Bearer ' .$self->token); |
63
|
9
|
|
|
|
|
434
|
$h->header('Content-Type', 'application/json; charset=UTF-8'); |
64
|
9
|
|
|
|
|
352
|
return $h; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=back |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Michael Shipper <AKALINUX@CPAN.ORG> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |