File Coverage

blib/lib/WebService/ValidSign/API/Constructor.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 0 1 0.0
total 39 40 97.5


line stmt bran cond sub pod time code
1             package WebService::ValidSign::API::Constructor;
2              
3             our $VERSION = '0.002';
4 3     3   27820 use Moo::Role;
  3         8  
  3         17  
5 3     3   1158 use namespace::autoclean;
  3         6  
  3         22  
6              
7             # ABSTRACT: A REST API client for ValidSign
8              
9 3     3   260 use Carp qw(croak);
  3         8  
  3         173  
10 3     3   1358 use HTTP::Request;
  3         60207  
  3         100  
11 3     3   1862 use JSON qw(decode_json);
  3         29210  
  3         17  
12 3     3   395 use URI;
  3         7  
  3         84  
13 3     3   1495 use Types::Standard qw(Str);
  3         245925  
  3         38  
14 3         33 use WebService::ValidSign::Types qw(
15             WebServiceValidSignURI
16 3     3   3650 );
  3         30  
17              
18             has lwp => (
19             is => 'ro',
20             builder => 1,
21             lazy => 1,
22             );
23              
24             has endpoint => (
25             is => 'ro',
26             isa => WebServiceValidSignURI,
27             default => sub { 'https://try.validsign.nl/api' },
28             coerce => 1
29             );
30              
31             has secret => (
32             is => 'ro',
33             isa => Str,
34             required => 1,
35             );
36              
37             sub args_builder {
38 3     3 0 8 my $self = shift;
39 3         8 return map { $_ => $self->$_ } qw(secret endpoint lwp);
  9         111  
40             }
41              
42             sub _build_lwp {
43 3     3   10814 require LWP::UserAgent;
44 3         37371 return LWP::UserAgent->new(
45             agent => join('/', "WebService::ValidSign", "$VERSION"),
46             protocols_allowed => [qw(https)],
47             ssl_opts => { verify_hostname => 1 },
48             requests_redirectable => [qw(HEAD GET)],
49             );
50             }
51              
52              
53             1;
54              
55             __END__
56              
57             =pod
58              
59             =encoding UTF-8
60              
61             =head1 NAME
62              
63             WebService::ValidSign::API::Constructor - A REST API client for ValidSign
64              
65             =head1 VERSION
66              
67             version 0.002
68              
69             =head1 SYNOPSIS
70              
71             use WebService::ValidSign;
72              
73             my $client = WebService::ValidSign->new(
74             secret => "Your API key",
75             endpoint => 'https://hostname.validsign.nl/api'
76             );
77              
78             $client->
79              
80             =head1 ATTRIBUTES
81              
82             =over
83              
84             =item api_uri
85              
86             The API URI endpoint as described in the Acceplication Integrator's Guide
87              
88             =item lwp
89              
90             An LWP::UserAgent object. If you extend this module you can use your own
91             builder or just inject something that respects the LWP::UserAgent API.
92              
93             =back
94              
95             =head1 METHODS
96              
97             =head1 AUTHOR
98              
99             Wesley Schwengle <waterkip@cpan.org>
100              
101             =head1 COPYRIGHT AND LICENSE
102              
103             This software is Copyright (c) 2019 by Wesley Schwengle.
104              
105             This is free software, licensed under:
106              
107             The (three-clause) BSD License
108              
109             =cut