| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Business::MollieAPI; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 4 |  |  | 4 |  | 174802 | use strict; | 
|  | 4 |  |  |  |  | 12 |  | 
|  | 4 |  |  |  |  | 154 |  | 
| 4 | 4 |  |  | 4 |  | 104 | use 5.008_005; | 
|  | 4 |  |  |  |  | 16 |  | 
|  | 4 |  |  |  |  | 218 |  | 
| 5 |  |  |  |  |  |  | our $VERSION = '0.10'; | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 4 |  |  | 4 |  | 17578 | use Moo; | 
|  | 4 |  |  |  |  | 117244 |  | 
|  | 4 |  |  |  |  | 30 |  | 
| 8 | 4 |  |  | 4 |  | 12646 | use URI; | 
|  | 4 |  |  |  |  | 34978 |  | 
|  | 4 |  |  |  |  | 157 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 4 |  |  | 4 |  | 31670 | use LWP::UserAgent; | 
|  | 4 |  |  |  |  | 278249 |  | 
|  | 4 |  |  |  |  | 146 |  | 
| 11 | 4 |  |  | 4 |  | 4819 | use JSON::XS; | 
|  | 4 |  |  |  |  | 83191 |  | 
|  | 4 |  |  |  |  | 377 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 4 |  |  | 4 |  | 2497 | use Business::MollieAPI::Payments; | 
|  | 4 |  |  |  |  | 18 |  | 
|  | 4 |  |  |  |  | 160 |  | 
| 14 | 4 |  |  | 4 |  | 2438 | use Business::MollieAPI::Methods; | 
|  | 4 |  |  |  |  | 14 |  | 
|  | 4 |  |  |  |  | 131 |  | 
| 15 | 4 |  |  | 4 |  | 2795 | use Business::MollieAPI::Issuers; | 
|  | 4 |  |  |  |  | 13 |  | 
|  | 4 |  |  |  |  | 2390 |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | has endpoint => ( | 
| 18 |  |  |  |  |  |  | is      => 'rw', | 
| 19 |  |  |  |  |  |  | builder => 1, | 
| 20 |  |  |  |  |  |  | ); | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | sub _build_endpoint { | 
| 23 | 2 |  |  | 2 |  | 4397 | my $self = shift; | 
| 24 | 2 |  |  |  |  | 23 | return URI->new('https://api.mollie.nl'); | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | has version => ( | 
| 28 |  |  |  |  |  |  | is      => 'rw', | 
| 29 |  |  |  |  |  |  | default => 'v1', | 
| 30 |  |  |  |  |  |  | ); | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | has client_version => ( | 
| 33 |  |  |  |  |  |  | is      => 'rw', | 
| 34 |  |  |  |  |  |  | default => $VERSION, | 
| 35 |  |  |  |  |  |  | ); | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | has payments => ( | 
| 39 |  |  |  |  |  |  | is => 'lazy', | 
| 40 |  |  |  |  |  |  | ); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | sub _build_payments { | 
| 43 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 44 | 0 |  |  |  |  |  | return Business::MollieAPI::Payments->new(client => $self); | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | has methods => ( | 
| 48 |  |  |  |  |  |  | is => 'lazy', | 
| 49 |  |  |  |  |  |  | ); | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub _build_methods { | 
| 52 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 53 | 0 |  |  |  |  |  | return Business::MollieAPI::Methods->new(client => $self); | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | has issuers => ( | 
| 57 |  |  |  |  |  |  | is => 'lazy', | 
| 58 |  |  |  |  |  |  | ); | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | sub _build_issuers { | 
| 61 | 0 |  |  | 0 |  |  | my $self = shift; | 
| 62 | 0 |  |  |  |  |  | return Business::MollieAPI::Issuers->new(client => $self); | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | has api_key => ( | 
| 66 |  |  |  |  |  |  | is  => 'rw', | 
| 67 |  |  |  |  |  |  | isa => sub { | 
| 68 |  |  |  |  |  |  | my $value = shift; | 
| 69 |  |  |  |  |  |  | die "API KEY is not valid" unless $value =~ m/^(live_|test_)\w+/; | 
| 70 |  |  |  |  |  |  | }, | 
| 71 |  |  |  |  |  |  | ); | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | sub log_response { | 
| 74 | 0 |  |  | 0 | 0 |  | return; | 
| 75 |  |  |  |  |  |  | } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | sub perform { | 
| 78 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 79 | 0 |  |  |  |  |  | my $req = shift; | 
| 80 | 0 |  |  |  |  |  | $req->header('Authorization', 'Bearer ' . $self->api_key); | 
| 81 | 0 |  |  |  |  |  | my $ua = LWP::UserAgent->new(); | 
| 82 | 0 |  |  |  |  |  | my $res = $ua->request($req); | 
| 83 | 0 |  |  |  |  |  | my $data = decode_json($res->decoded_content); | 
| 84 | 0 |  |  |  |  |  | $self->log_response({ request => $req, response => $res }); | 
| 85 | 0 |  |  |  |  |  | return $data; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | 1; | 
| 89 |  |  |  |  |  |  | __END__ |