#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Text::ASCIITable;
use Perun::Agent;
use Perun::Common qw(printTable getSortingFunction);

sub help {
	return qq{
Find NotifReceiver by id. Id is required field.
------------------------
Available options:
 --NotifReceiverId      | -i NotifReceiver id
 --batch                | -b batch
 --help                 | -h prints this help

};
}

our $batch;
my $receiverId;
GetOptions ("help|h"      => sub {
		print help();
		exit 0;
	}, "batch|b"          => \$batch,
	"NotifReceiverId|i=i" => \$receiverId) || die help();

# Check options
unless (defined($receiverId)) { die "ERROR: NotifReceiver: Id is required \n";}

my $agent = Perun::Agent->new();
my $notifAgent = $agent->getNotificationsAgent();

my $receiver = $notifAgent->getPerunNotifReceiverById( id => $receiverId );

#output
if (defined($receiver->getId)) {
	my $sortingFunction = getSortingFunction("getName", 1);
	printTable($sortingFunction, $receiver);
} else { die "NotifReceiver with id $receiverId does not exist \n" }
