1package OpenXPKI::Server::API2::Plugin::UI::send_notification;
2use OpenXPKI::Server::API2::EasyPlugin;
3
4=head1 NAME
5
6OpenXPKI::Server::API2::Plugin::UI::send_notification
7
8=cut
9
10# Project modules
11use OpenXPKI::Server::Context qw( CTX );
12use OpenXPKI::Server::API2::Types;
13
14
15
16=head1 COMMANDS
17
18=head2 send_notification
19
20Sends out a notification using the configured notification handlers.
21
22B<Parameters>
23
24=over
25
26=item * C<message> I<Str> - message or message ID to be sent (depends on the
27notification handlers)
28
29=item * C<params> I<HashRef> - additional parameters to pass to the handler.
30Optional.
31
32=back
33
34=cut
35command "send_notification" => {
36    message => { isa => 'AlphaPunct', required => 1, },
37    params  => { isa => 'HashRef', default => sub { {} }, },
38} => sub {
39    my ($self, $params) = @_;
40
41    return CTX('notification')->notify({
42        MESSAGE => $params->message,
43        DATA    => $params->params
44    });
45};
46
47__PACKAGE__->meta->make_immutable;
48