line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Mattermost::Role::UserAgent; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
13713
|
use Moo::Role; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
53
|
|
6
|
8
|
|
|
8
|
|
4547
|
use Types::Standard 'InstanceOf'; |
|
8
|
|
|
|
|
77221
|
|
|
8
|
|
|
|
|
65
|
|
7
|
|
|
|
|
|
|
|
8
|
8
|
|
|
8
|
|
7616
|
use WebService::Mattermost::Util::UserAgent; |
|
8
|
|
|
|
|
34
|
|
|
8
|
|
|
|
|
303
|
|
9
|
8
|
|
|
8
|
|
563
|
use WebService::Mattermost::Helper::Alias 'util'; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
1438
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has ua => (is => 'ro', isa => InstanceOf['Mojo::UserAgent'], lazy => 1, builder => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub mmauthtoken { |
18
|
1
|
|
|
1
|
1
|
47
|
my $self = shift; |
19
|
1
|
|
|
|
|
2
|
my $token = shift; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
8
|
return sprintf 'MMAUTHTOKEN=%s', $token; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub bearer { |
25
|
11
|
|
|
11
|
1
|
148
|
my $self = shift; |
26
|
11
|
|
|
|
|
26
|
my $token = shift; |
27
|
|
|
|
|
|
|
|
28
|
11
|
|
|
|
|
69
|
return sprintf 'Bearer %s', $token; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_ua { |
34
|
14
|
|
|
14
|
|
8108
|
return util('UserAgent')->new->ua; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding UTF-8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
WebService::Mattermost::Role::UserAgent - Internal user agent role. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 VERSION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
version 0.26 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Bundles C<Mojo::UserAgent> and required parameters for HTTP headers. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 USAGE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use Moo; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
with 'WebService::Mattermost::Role::UserAgent'; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub something { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $bearer_header = $self->bearer; |
69
|
|
|
|
|
|
|
my $mmauthtoken = $self->mmauthtoken; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Methods from Mojo::UserAgent |
72
|
|
|
|
|
|
|
$self->ua->post( |
73
|
|
|
|
|
|
|
# ... |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 ATTRIBUTES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item C<ua> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
A C<Mojo::UserAgent> object. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item C<mmauthtoken()> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Formats the C<MMAUTHTOKEN> header. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item C<bearer> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Formats the C<Bearer> header. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Mike Jones <mike@netsplit.org.uk> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Mike Jones. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software, licensed under: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The MIT (X11) License |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|