File Coverage

blib/lib/WebService/Slack/WebApi/Chat.pm
Criterion Covered Total %
statement 41 41 100.0
branch 5 10 50.0
condition n/a
subroutine 12 12 100.0
pod 0 5 0.0
total 58 68 85.2


line stmt bran cond sub pod time code
1             package WebService::Slack::WebApi::Chat;
2 3     3   3098 use strict;
  3         8  
  3         148  
3 3     3   17 use warnings;
  3         6  
  3         164  
4 3     3   21 use utf8;
  3         6  
  3         18  
5 3     3   112 use feature qw/state/;
  3         6  
  3         540  
6              
7 3     3   23 use parent 'WebService::Slack::WebApi::Base';
  3         6  
  3         20  
8              
9 3     3   309 use JSON;
  3         8  
  3         31  
10             use WebService::Slack::WebApi::Generator (
11 3         102 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   1082 );
  3         9  
29              
30             sub post_ephemeral {
31 1     1 0 723 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         2495 my ($self, $args, %extra) = $rule->validate(@_);
41              
42 1 50       272 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
43 1         13 return $self->request('postEphemeral', {%$args, %extra});
44             }
45              
46             sub post_message {
47 1     1 0 754 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         2909 my ($self, $args, %extra) = $rule->validate(@_);
63              
64 1 50       333 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
65 1         15 return $self->request('postMessage', {%$args, %extra});
66             }
67              
68             sub update {
69 1     1 0 725 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         2461 my ($self, $args, %extra) = $rule->validate(@_);
79              
80 1 50       227 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
81 1         12 return $self->request('update', {%$args, %extra});
82             }
83              
84             sub schedule_message {
85 1     1 0 60 state $rule = Data::Validator->new(
86             channel => 'Str',
87             post_at => 'Int',
88             text => { isa => 'Str', optional => 1 },
89             as_user => { isa => 'Bool', optional => 1 },
90             attachments => { isa => 'ArrayRef', optional => 1 },
91             blocks => { isa => 'ArrayRef', optional => 1 },
92             icon_emoji => { isa => 'Str', optional => 1 },
93             icon_url => { isa => 'Str', optional => 1 },
94             link_names => { isa => 'Bool', optional => 1 },
95             markdown_text => { isa => 'Str', optional => 1 },
96             metadata => { isa => 'Str', optional => 1 },
97             parse => { isa => 'Str', optional => 1 },
98             reply_broadcast => { isa => 'Bool', optional => 1 },
99             thread_ts => { isa => 'Str', optional => 1 },
100             unfurl_links => { isa => 'Bool', optional => 1 },
101             unfurl_media => { isa => 'Bool', optional => 1 },
102             )->with('Method', 'AllowExtra');
103 1         3000 my ($self, $args, %extra) = $rule->validate(@_);
104              
105 1 50       264 $args->{attachments} = encode_json $args->{attachments} if exists $args->{attachments};
106 1 50       6 $args->{blocks} = encode_json $args->{blocks} if exists $args->{blocks};
107 1         12 return $self->request('scheduleMessage', {%$args, %extra});
108             }
109              
110             sub delete_scheduled_message {
111 1     1 0 738 state $rule = Data::Validator->new(
112             channel => 'Str',
113             scheduled_message_id => 'Str',
114             as_user => { isa => 'Bool', optional => 1 },
115             )->with('Method', 'AllowExtra');
116 1         2347 my ($self, $args, %extra) = $rule->validate(@_);
117              
118 1         145 return $self->request('deleteScheduledMessage', {%$args, %extra});
119             }
120              
121             1;
122