Net-Async-Slack

 view release on metacpan or  search on metacpan

lib/Net/Async/Slack/Commands.pm  view on Meta::CPAN

    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'auth_test',
    );
    my ($res) = await $self->http_post(
        $uri,
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 bots_info

Gets information about a bot user.

L<API method documentation|https://api.slack.com/methods/bots.info>

Takes the following named parameters:

=over 4

=item * C<bot> - Bot user to get info on (string, optional)

=back

Resolves to a structure representing the response.

=cut

async sub bots_info {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'bots_info',
        %args{grep { exists $args{$_} } qw(bot)}
    );
    my ($res) = await $self->http_get(
        $uri,
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 calls_add

Registers a new Call.

L<API method documentation|https://api.slack.com/methods/calls.add>

Takes the following named parameters:

=over 4

=item * C<external_unique_id> - An ID supplied by the 3rd-party Call provider. It must be unique across all Calls from that service. (string, required)

=item * C<external_display_id> - An optional, human-readable ID supplied by the 3rd-party Call provider. If supplied, this ID will be displayed in the Call object. (string, optional)

=item * C<join_url> - The URL required for a client to join the Call. (string, required)

=item * C<desktop_app_join_url> - When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL. (string, optional)

=item * C<date_start> - Call start time in UTC UNIX timestamp format (integer, optional)

=item * C<title> - The name of the Call. (string, optional)

=item * C<created_by> - The valid Slack user ID of the user who created this Call. When this method is called with a user token, the `created_by` field is optional and defaults to the authed user of the token. Otherwise, the field is required. (strin...

=item * C<users> - The list of users to register as participants in the Call. [Read more on how to specify users here](/apis/calls#users). (string, optional)

=back

Resolves to a structure representing the response.

=cut

async sub calls_add {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'calls_add',
    );
    my $content = encode_json_utf8({
        %args{grep { exists $args{$_} } qw(external_unique_id external_display_id join_url desktop_app_join_url date_start title created_by users)}
    });
    my ($res) = await $self->http_post(
        $uri,
        $content,
        content_type => 'application/json; charset=utf-8',
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 calls_end

Ends a Call.

L<API method documentation|https://api.slack.com/methods/calls.end>

Takes the following named parameters:

=over 4

=item * C<id> - `id` returned when registering the call using the [`calls.add`](/methods/calls.add) method. (string, required)

=item * C<duration> - Call duration in seconds (integer, optional)

=back

Resolves to a structure representing the response.

=cut

async sub calls_end {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'calls_end',
    );
    my $content = encode_json_utf8({
        %args{grep { exists $args{$_} } qw(id duration)}
    });
    my ($res) = await $self->http_post(
        $uri,
        $content,
        content_type => 'application/json; charset=utf-8',
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 calls_info

Returns information about a Call.

L<API method documentation|https://api.slack.com/methods/calls.info>

Takes the following named parameters:

=over 4

=item * C<id> - `id` of the Call returned by the [`calls.add`](/methods/calls.add) method. (string, required)

lib/Net/Async/Slack/Commands.pm  view on Meta::CPAN

    );
    die $res unless $res->{ok};
    return $res;
}


=head2 calls_participants_remove

Registers participants removed from a Call.

L<API method documentation|https://api.slack.com/methods/calls.participants.remove>

Takes the following named parameters:

=over 4

=item * C<id> - `id` returned by the [`calls.add`](/methods/calls.add) method. (string, required)

=item * C<users> - The list of users to remove as participants in the Call. [Read more on how to specify users here](/apis/calls#users). (string, required)

=back

Resolves to a structure representing the response.

=cut

async sub calls_participants_remove {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'calls_participants_remove',
    );
    my $content = encode_json_utf8({
        %args{grep { exists $args{$_} } qw(id users)}
    });
    my ($res) = await $self->http_post(
        $uri,
        $content,
        content_type => 'application/json; charset=utf-8',
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 calls_update

Updates information about a Call.

L<API method documentation|https://api.slack.com/methods/calls.update>

Takes the following named parameters:

=over 4

=item * C<id> - `id` returned by the [`calls.add`](/methods/calls.add) method. (string, required)

=item * C<title> - The name of the Call. (string, optional)

=item * C<join_url> - The URL required for a client to join the Call. (string, optional)

=item * C<desktop_app_join_url> - When supplied, available Slack clients will attempt to directly launch the 3rd-party Call with this URL. (string, optional)

=back

Resolves to a structure representing the response.

=cut

async sub calls_update {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'calls_update',
    );
    my $content = encode_json_utf8({
        %args{grep { exists $args{$_} } qw(id title join_url desktop_app_join_url)}
    });
    my ($res) = await $self->http_post(
        $uri,
        $content,
        content_type => 'application/json; charset=utf-8',
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 chat_delete

Deletes a message.

L<API method documentation|https://api.slack.com/methods/chat.delete>

Takes the following named parameters:

=over 4

=item * C<ts> - Timestamp of the message to be deleted. (number, optional)

=item * C<channel> - Channel containing the message to be deleted. (string, optional)

=item * C<as_user> - Pass true to delete the message as the authed user with `chat:write:user` scope. [Bot users](/bot-users) in this context are considered authed users. If unused or false, the message will be deleted with `chat:write:bot` scope. (b...

=back

Resolves to a structure representing the response.

=cut

async sub chat_delete {
    my ($self, %args) = @_;
    my $uri = $self->endpoint(
        'chat_delete',
    );
    my $content = encode_json_utf8({
        %args{grep { exists $args{$_} } qw(ts channel as_user)}
    });
    my ($res) = await $self->http_post(
        $uri,
        $content,
        content_type => 'application/json; charset=utf-8',
    );
    die $res unless $res->{ok};
    return $res;
}


=head2 chat_delete_scheduled_message

Deletes a pending scheduled message from the queue.

L<API method documentation|https://api.slack.com/methods/chat.deleteScheduledMessage>

Takes the following named parameters:

=over 4



( run in 2.255 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )