| 1 | package WWW::PayPal::API::Products; | ||||||||||||
| 2 | |||||||||||||
| 3 | # ABSTRACT: PayPal Catalogs Products API (v1) | ||||||||||||
| 4 | |||||||||||||
| 5 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 3 | ▶ | use WWW::PayPal::Product; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 3 | our $VERSION = '0.003'; | |||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | 3 | has client => ( | |||||||||||
| 14 | is => 'ro', | ||||||||||||
| 15 | required => 1, | ||||||||||||
| 16 | weak_ref => 1, | ||||||||||||
| 17 | ); | ||||||||||||
| 18 | |||||||||||||
| 19 | has openapi_operations => ( | ||||||||||||
| 20 | is => 'lazy', | ||||||||||||
| 21 | 1 | ▶ | builder => sub { | ||||||||||
|
Subroutine
_build_openapi_operations: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | return { | ||||||||||||
| 23 | 1 | 'catalogs.products.create' => { method => 'POST', path => '/v1/catalogs/products' }, | |||||||||||
| 24 | 'catalogs.products.list' => { method => 'GET', path => '/v1/catalogs/products' }, | ||||||||||||
| 25 | 'catalogs.products.get' => { method => 'GET', path => '/v1/catalogs/products/{id}' }, | ||||||||||||
| 26 | 'catalogs.products.patch' => { method => 'PATCH', path => '/v1/catalogs/products/{id}' }, | ||||||||||||
| 27 | }; | ||||||||||||
| 28 | }, | ||||||||||||
| 29 | 3 | ); | |||||||||||
| 30 | |||||||||||||
| 31 | 3 | with 'WWW::PayPal::Role::OpenAPI'; | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | sub _wrap { | ||||||||||
|
Subroutine
_wrap: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | 0 | my ($self, $data) = @_; | |||||||||||
| 35 | 0 | return WWW::PayPal::Product->new(client => $self->client, data => $data); | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | sub create { | ||||||||||
|
Subroutine
create: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 39 | 0 | my ($self, %args) = @_; | |||||||||||
| 40 | 0 | ▶ | croak 'name required' unless $args{name}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | 0 | ▶ | croak 'type required' unless $args{type}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | |||||||||||||
| 43 | my %body = ( | ||||||||||||
| 44 | name => $args{name}, | ||||||||||||
| 45 | type => $args{type}, | ||||||||||||
| 46 | 0 | ); | |||||||||||
| 47 | 0 | for my $k (qw(description category image_url home_url id)) { | |||||||||||
| 48 | 0 | ▶ | $body{$k} = $args{$k} if defined $args{$k}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | } | ||||||||||||
| 50 | 0 | my $data = $self->call_operation('catalogs.products.create', body => \%body); | |||||||||||
| 51 | 0 | return $self->_wrap($data); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | |||||||||||||
| 55 | 0 | ▶ | sub get { | ||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 56 | 0 | my ($self, $id) = @_; | |||||||||||
| 57 | 0 | ▶ | croak 'product id required' unless $id; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 58 | 0 | return $self->_wrap($self->call_operation('catalogs.products.get', path => { id => $id })); | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | |||||||||||||
| 62 | 0 | ▶ | sub list { | ||||||||||
|
Subroutine
list: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 63 | 0 | my ($self, %args) = @_; | |||||||||||
| 64 | 0 | my %query; | |||||||||||
| 65 | 0 | for my $k (qw(page_size page total_required)) { | |||||||||||
| 66 | 0 | ▶ | $query{$k} = $args{$k} if defined $args{$k}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 67 | } | ||||||||||||
| 68 | 0 | ▶ | my $data = $self->call_operation('catalogs.products.list', | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 69 | (%query ? (query => \%query) : ())); | ||||||||||||
| 70 | 0 | ▶ | return [ map { $self->_wrap($_) } @{ $data->{products} || [] } ]; | ||||||||||
|
Condition0%0/2
$data->{'products'} || []
MC/DC0%0/1
$data->{'products'} || []
$data->{'products'}
Truth table0%0/2
A
A= $data->{'products'}
| |||||||||||||
| 71 | } | ||||||||||||
| 72 | |||||||||||||
| 73 | |||||||||||||
| 74 | 3 | 1; | |||||||||||
| 75 | |||||||||||||
| 76 | __END__ | ||||||||||||