#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Perun::Agent;
use Perun::Common qw(printMessage);

sub help {
	return qq{
	Unsets sponsorship for member. Member ID is required.
	--------------------------------------
	Available options:
	--memberId       | -m member id
	--batch          | -b batch
	--help           | -h prints this help
	};
}

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

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

my $agent = Perun::Agent->new();
my $membersAgent = $agent->getMembersAgent;

$membersAgent->unsetSponsorshipForMember( sponsoredMember => $memberId );

printMessage("Member Id:$memberId was successfully unset from sponsorship.", $batch);
