#!/usr/bin/perl
#-*-cperl-*-

use strict;

use lib '/app/tools/data_classes/lib';
use User::User;
use Getopt::Std;

my %arg;
getopts( 'e:i:p:', \%arg );

my %hash;
if ( $arg{i} && $arg{p} ) {
    $hash{user_id} = $arg{i};
} elsif ( $arg{e} && $arg{p} ) {
    $hash{email} = $arg{e};
} else {
    die <<"EOT";
Incomplete Input!

 Usage:

  $0 -i <user_id> -e <email> # user_id OR email (user_id overrides email)

EOT
}

my $user = new User::User(%hash);

unless ( defined $user->UserID ) {
    die $user->Error;
}

my $IsPassword = defined $user->IsPassword( $arg{p} ) ? 'YES' : 'NO';

print "User Data:\n";
print "--------------------------\n";
printf "User ID: %d\n",          $user->UserID;
printf "Email: %s\n",            $user->Email;
printf "Valid Password: %s\n",   $IsPassword;
printf "FirstName: %s\n",        $user->FirstName;
printf "LastName: %s\n",         $user->LastName;
printf "PrimaryAddressID: %d\n", $user->Address;
printf "PrimaryPhoneID: %d\n",   $user->Phone;
printf "DateCreated: %s\n",      $user->DateCreated;
printf "DateModified: %s\n",     $user->DateModified;

