WebService-ValidSign

 view release on metacpan or  search on metacpan

bin/vs-upload.pl  view on Meta::CPAN

#!/usr/bin/perl
use warnings;
use strict;

# ABSTRACT: Create a ValidSign document package from the command line
# PODNAME: vs-upload.pl

use Config::Any;
use File::Temp;
use File::Spec::Functions qw(catfile);
use Getopt::Long;
use Pod::Usage;

use WebService::ValidSign;
use WebService::ValidSign::Object::DocumentPackage;
use WebService::ValidSign::Object::Document;

my %opts = (
    help      => 0,
    config    => catfile($ENV{HOME}, qw (.config validsign.conf)),
);

{
    local $SIG{__WARN__};
    my $ok = eval {
        GetOptions(
            \%opts, qw(help secret=s endpoint=s sender=s
                document-package-name=s file=s@ signer=s@ use-fh)
        );
    };
    if (!$ok) {
        die($@);
    }
}

pod2usage(0) if ($opts{help});

if (-f $opts{config}) {
    my $config = Config::Any->load_files({
            files => [$opts{config}],
            use_ext => 1,
            flatten_hash => 1,

        })->[0]{$opts{config}};

    foreach (keys %$config) {
        # If an option is set multiple times in the config file, take
        # the last value and work with that
        $opts{$_} ||= ref $config->{$_} eq 'ARRAY'
            ? $config->{$_}[-1]
            : $config->{$_};
    }
}

my @required = qw(secret document-package-name);
my $nok = 0;
foreach (@required) {
    if (!defined $opts{$_}) {
        $nok++;
        warn "$_ is missing!"
    }
}
pod2usage(1) if $nok;

my $sender  = delete $opts{sender};
my $files   = delete $opts{file};
my $signers = delete $opts{signer};
my $use_fh  = delete $opts{'use-fh'};

my $client = WebService::ValidSign->new(
    %opts
);

my $documentpackage = WebService::ValidSign::Object::DocumentPackage->new(
    name => $opts{'document-package-name'},
);

if ($sender) {
    my $senders = $client->account->senders(search => $sender);
    if (!@$senders) {



( run in 1.110 second using v1.01-cache-2.11-cpan-71847e10f99 )