#!/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{
	Sets specific User. User id, user Id of owner and type of specific user are required.
	--------------------------------------
	Available options:
	--userId       | -u user id
	--specUserType | -t type of specific user (SERVICE/SPONSORED)
	--owner        | -o user Id of owner
	--batch        | -b batch
	--help         | -h prints this help

	};
}

my ($userId, $ownerId, $specUsrType, $batch);
GetOptions ("help|h"  => sub {
		print help();
		exit 0;
	}, "batch|b"        => \$batch,
	"userId|u=i"        => \$userId, 
	"owner|o=i"         => \$ownerId,
	"specUserType|t=s"  => \$specUsrType ) || die help();

# Check options
unless (defined($userId)) { die "ERROR: userId is required \n";}
unless (defined($specUsrType)) { die "ERROR: Type of specific user is required \n";}
unless (defined($ownerId)) { die "ERROR:  owner Id is required \n";}

my $agent = Perun::Agent->new();
my $usersAgent = $agent->getUsersAgent;

$usersAgent->setSpecificUser( specificUser => $userId, owner => $ownerId, specificUserType => $specUsrType );

printMessage("Specific user Id:$userId successfully set", $batch);
