File Coverage

blib/lib/WebService/Slack/WebApi/Chat.pm
Criterion Covered Total %
statement 33 33 100.0
branch 3 6 50.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 46 52 88.4


line stmt bran cond sub pod time code
1             package WebService::Slack::WebApi::Chat;
2 3     3   2244 use strict;
  3         7  
  3         95  
3 3     3   15 use warnings;
  3         7  
  3         71  
4 3     3   16 use utf8;
  3         5  
  3         14  
5 3     3   86 use feature qw/state/;
  3         7  
  3         222  
6              
7 3     3   19 use parent 'WebService::Slack::WebApi::Base';
  3         15  
  3         28  
8              
9 3     3   206 use JSON;
  3         8  
  3         22  
10             use WebService::Slack::WebApi::Generator (
11 3         61 delete => {
12             channel => 'Str',
13             ts => 'Str',
14             as_user => { isa => 'Bool', optional => 1 },
15             },
16             me_message => {
17             channel => 'Str',
18             text => 'Str',
19             },
20             unfurl => {
21             channel => 'Str',
22             ts => 'Str',
23             unfurls => 'Str',
24             user_auth_message => { isa => 'Str', optional => 1 },
25             user_auth_required => { isa => 'Bool', optional => 1 },
26             user_auth_url => { isa => 'Str', optional => 1 },
27             },
28 3     3   671 );
  3         7  
29              
30             sub post_ephemeral {
31 1     1 0 457 state $rule = Data::Validator->new(
32             channel => 'Str',
33             text => { isa => 'Str', optional => 1 },
34             user => 'Str',
35             as_user => { isa => 'Bool', optional => 1 },
36             attachments => { isa => 'ArrayRef', optional => 1 },
37             link_names => { isa => 'Bool', optional => 1 },
38             parse => { isa => 'Str', optional => 1 },
39             )->with('Method', 'AllowExtra');
40 1         1925 my ($self, $args, %extra) = $rule->validate(@_);
41              
42 1 50       172 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
43 1         8 return $self->request('postEphemeral', {%$args, %extra});
44             }
45              
46             sub post_message {
47 1     1 0 476 state $rule = Data::Validator->new(
48             channel => 'Str',
49             text => { isa => 'Str', optional => 1 },
50             as_user => { isa => 'Bool', optional => 1 },
51             attachments => { isa => 'ArrayRef', optional => 1 },
52             icon_emoji => { isa => 'Str', optional => 1 },
53             icon_url => { isa => 'Str', optional => 1 },
54             link_names => { isa => 'Bool', optional => 1 },
55             parse => { isa => 'Str', optional => 1 },
56             reply_broadcast => { isa => 'Bool', optional => 1 },
57             thread_ts => { isa => 'Str', optional => 1 },
58             unfurl_links => { isa => 'Bool', optional => 1 },
59             unfurl_media => { isa => 'Bool', optional => 1 },
60             username => { isa => 'Str', optional => 1 },
61             )->with('Method', 'AllowExtra');
62 1         2187 my ($self, $args, %extra) = $rule->validate(@_);
63              
64 1 50       258 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
65 1         21 return $self->request('postMessage', {%$args, %extra});
66             }
67              
68             sub update {
69 1     1 0 38 state $rule = Data::Validator->new(
70             channel => 'Str',
71             text => { isa => 'Str', optional => 1 },
72             ts => 'Str',
73             as_user => { isa => 'Bool', optional => 1 },
74             attachments => { isa => 'ArrayRef', optional => 1 },
75             link_names => { isa => 'Bool', optional => 1 },
76             parse => { isa => 'Str', optional => 1 },
77             )->with('Method', 'AllowExtra');
78 1         1887 my ($self, $args, %extra) = $rule->validate(@_);
79              
80 1 50       188 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
81 1         11 return $self->request('update', {%$args, %extra});
82             }
83              
84             1;
85