#!/usr/bin/perl
#------------------------------------------------------------
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
use strict;

use Getopt::Std;

use lib '/app/tools/common/lib';
use lib '/app/tools/rps/lib';
use RPS::Portal::SendNotification;

use Common::Log;
use Common::RSApp;

# Allow tuning of the verbosity of our output.
#
my $gVerbosityLevel = 1;

Common::Log::Print(" - running with args '@ARGV'");

my %opt;
getopts( 'c:r:t:p:', \%opt );

my $clientID  = $opt{c};
my $runID     = $opt{r};
my $payeeType = $opt{t};
my $payeeList = $opt{p};

usage("missing client ID")   unless ( defined $clientID );
usage("missing run ID")      unless ( defined $runID );
usage("missing payee ID(s)") unless ( defined $payeeList );

# Creating the app singleton.  This set ups some useful environmental variables and shortcuts.
my $appSingleton = Common::RSApp->new( clientID => $clientID );

my $notifier = RPS::Portal::SendNotification->new( runID => $runID, payeeType => $payeeType, payeeList => $payeeList );

$notifier->run();

sub usage {
    my $err = shift;

    print "$err\n\n" if ($err);

    print <<EOF;
usage: $0 [-re] -c CLIENT_ID

-c CLIENT_ID : is the client ID
-r RUN_ID : is the run ID
-t PAYEE_TYPE: is the type ID
-p PAYEE_LIST : is the payee ID list
EOF

    exit;
}

