| 1 | package Business::MollieAPI::Resource; | ||
| 2 | 4 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 4 | ▶ | use HTTP::Request; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use HTTP::Request::Common; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use JSON::XS; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 4 | has client => ( | |
| 8 | is => 'ro', | ||
| 9 | ); | ||
| 10 | |||
| 11 | 4 | requires 'name'; | |
| 12 | |||
| 13 | 0 | ▶ | sub _create_request { |
|
Subroutine
_create_request: not called CC=1 SCAR=6.9
| |||
| 14 | 0 | my $self = shift; | |
| 15 | 0 | my %args = @_; | |
| 16 | |||
| 17 | 0 | my $url = URI->new_abs( | |
| 18 | '/' . $self->client->version . '/' . $self->name, | ||
| 19 | $self->client->endpoint); | ||
| 20 | |||
| 21 | 0 | my $body = encode_json(\%args); | |
| 22 | |||
| 23 | 0 | my $req = POST $url->as_string, | |
| 24 | Content_Type => 'application/json', | ||
| 25 | Content => $body; | ||
| 26 | |||
| 27 | 0 | return $req; | |
| 28 | } | ||
| 29 | |||
| 30 | 0 | ▶ | sub create { |
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 31 | 0 | my $self = shift; | |
| 32 | 0 | my $req = $self->_create_request(@_); | |
| 33 | 0 | my $res = $self->client->perform($req); | |
| 34 | 0 | return $res; | |
| 35 | } | ||
| 36 | |||
| 37 | 0 | ▶ | sub _get_request { |
|
Subroutine
_get_request: not called CC=1 SCAR=6.9
| |||
| 38 | 0 | my $self = shift; | |
| 39 | 0 | my ($id) = @_; | |
| 40 | |||
| 41 | 0 | my $url = URI->new_abs( | |
| 42 | '/' . $self->client->version . '/' . $self->name . '/' . $id, | ||
| 43 | $self->client->endpoint); | ||
| 44 | |||
| 45 | 0 | return GET $url->as_string; | |
| 46 | } | ||
| 47 | |||
| 48 | 0 | ▶ | sub get { |
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 49 | 0 | my $self = shift; | |
| 50 | 0 | my $req = $self->_get_request(@_); | |
| 51 | 0 | my $res = $self->client->perform($req); | |
| 52 | 0 | return $res; | |
| 53 | } | ||
| 54 | |||
| 55 | 0 | ▶ | sub _all_request { |
|
Subroutine
_all_request: not called CC=1 SCAR=6.9
| |||
| 56 | 0 | my $self = shift; | |
| 57 | |||
| 58 | 0 | my $url = URI->new_abs( | |
| 59 | '/' . $self->client->version . '/' . $self->name, | ||
| 60 | $self->client->endpoint); | ||
| 61 | |||
| 62 | 0 | return GET $url->as_string; | |
| 63 | } | ||
| 64 | |||
| 65 | 0 | ▶ | sub all { |
|
Subroutine
all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 66 | 0 | my $self = shift; | |
| 67 | 0 | my $req = $self->_all_request(@_); | |
| 68 | 0 | my $res = $self->client->perform($req); | |
| 69 | 0 | return $res; | |
| 70 | } | ||
| 71 | |||
| 72 | 4 | 1; | |
| 73 | |||