WebService-ValidSign
view release on metacpan or search on metacpan
bin/vs-download.pl view on Meta::CPAN
#!/usr/bin/perl
use warnings;
use strict;
# ABSTRACT: Download ValidSign documents from the command line
# PODNAME: vs-download.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-id=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-id);
my $nok = 0;
foreach (@required) {
if (!defined $opts{$_}) {
$nok++;
warn "$_ is missing!"
}
}
pod2usage(1) if $nok;
my $id = delete $opts{'document-package-id'};
my $client = WebService::ValidSign->new(%opts);
my $documentpackage = $client->package->find($id);
use Data::Dumper;
print Dumper $documentpackage;
my $fh = $client->package->download_document($documentpackage);
#$client->package->download_documents($documentpackage);
__END__
=pod
( run in 1.085 second using v1.01-cache-2.11-cpan-71847e10f99 )