API/Resource/Products.pm

filter: Statementstmt 52.3% 11 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 50.0% 3 / 6 Podpod 100% 3 / 3 totaltotal 41.4% 17 / 41 CC 5 SCAR 20.4
CC
5
Cov
38%
get_product
12.0
get_products
12.0
new
2.0
CRAP 7.7
« API/Client.pm ↑ Summary API/Token.pm »
1 # Copyright 2013 Digital River, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 package Net::MyCommerce::API::Resource::Products;
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 2 ▶use base qw( Net::MyCommerce::API::Resource );
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 =head1 NAME
23
24 Net::MyCommerce::API::Resource::Products
25
26 =head1 VERSION
27
28 version 1.0.1
29
30 =cut
31
32 2 our $VERSION = '1.0.1';
33
34 =head1 SCHEMA
35  
36 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/15-schemas-product
37  
38 =head1 METHODS
39  
40 =head2 new
41  
42 Subclass Net::MyCommerce::API::Resource
43  
44 =cut
45  
46 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
47 0 my ($pkg, %args) = @_;
48 0 return $pkg->SUPER::new( %args, scope=>'products' );
49 }
50  
51 =head2 _vendorID ( $product_id )
52  
53 Extract vendor_id from product_id
54  
55 =cut
56  
57 =head2 get_product
58  
59 Get a single product
60  
61 Examples:
62  
63 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/6-example-get-products-one-product
64  
65 =cut
66  
67 0 ▶sub get_product {
Subroutine get_product: not called CC=3 SCAR=24.8
Pod documented
68 0 my ($self, %opts) = @_;
69 0 ▶ my $params = { language => $opts{language} || 'en_US' };
Condition0%0/2
$opts{'language'} || 'en_US'
l!l
00
MC/DC0%0/1
$opts{'language'} || 'en_US'
$opts{'language'}
Truth table0%0/2
A
A= $opts{'language'}
Aresult
11
00
70 0 ▶ if ($opts{offer_id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts{"offer_id"}) 0 0 0
71 0 $params->{offer_id} = $opts{offer_id};
72 }
73 return $self->request(
74 0 path => [ '/vendors', $opts{vendor_id}, 'products', $opts{product_id} ],
75 params => $params,
76 );
77 }
78  
79 =head2 get_products
80  
81 Get full product catalog
82  
83 Filter options:
84  
85 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/11-parameters-product
86  
87 Examples:
88  
89 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/5-example-get-products-base
90 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/31-example-get-products-expand-and-fields
91 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/30-example-get-products-limit-and-offset
92 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/29-example-get-products-status
93 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/32-example-get-products-affiliate
94 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/39-example-get-products-custom-fields
95 http://help.mycommerce.com/index.php/mycommerce-apis/product-resource/40-example-get-products-language
96  
97 =cut
98  
99 0 ▶sub get_products {
Subroutine get_products: not called CC=3 SCAR=24.8
Pod documented
100 0 my ($self, %opts) = @_;
101 my $params = {
102 limit => $opts{limit} || 50,
103 status => 'approved',
104 expand => 'product',
105 fields => 'id,name',
106 0 ▶ language => $opts{language} || 'en_US',
Condition0%0/4
$opts{'limit'} || 50
l!l
00
$opts{'language'} || 'en_US'
l!l
00
MC/DC0%0/1
$opts{'limit'} || 50
$opts{'limit'}
MC/DC0%0/1
$opts{'language'} || 'en_US'
$opts{'language'}
Truth table0%0/2
A
A= $opts{'limit'}
Aresult
11
00
Truth table0%0/2
A
A= $opts{'language'}
Aresult
11
00
107 };
108 return $self->request(
109 0 path => [ '/vendors', $opts{vendor_id}, 'products' ],
110 params => $params,
111 );
112 }
113  
114 2 1;
« API/Client.pm ↑ Summary API/Token.pm »