blib/lib/P5kkelabels.pm

filter: Statementstmt 16.6% 12 / 72 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 9.5% 2 / 21 Podpod 0.0% 0 / 16 totaltotal 12.1% 14 / 115 CC 3 SCAR 9.6
CC
3
Cov
16%
_get
6.0
_post
6.0
__ANON__
2.0
CRAP 2.6
↑ Summary
1 package P5kkelabels;
2 1 $P5kkelabels::VERSION = '0.01';
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 with 'Role::REST::Client';
5  
6 1 ▶use constant API_ENDPOINT => 'https://app.pakkelabels.dk/api/public/v2/';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 1 has 'api_user' => (
10 is => 'ro',
11 );
12  
13 1 has 'api_key' => (
14 is => 'ro',
15 );
16  
17 has 'token' => (
18 is => 'ro',
19 default => sub {
20 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 $self->server(API_ENDPOINT);
22 0 my $result = $self->post('users/login', {api_user => $self->api_user, api_key => $self->api_key});
23 0 return $result->data->{'token'};
24 },
25 1 lazy => 1,
26 );
27  
28  
29  
30 sub _get {
31 0 ▶ my ( $self, $path, $data ) = @_;
Subroutine _get: not called CC=2 SCAR=17.9
32 0 ▶ $data //= {};
Condition0%0/2
$data //= {}
l!l
00
MC/DC0%0/1
$data //= {}
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
33 0 $data->{token} = $self->token;
34 0 $self->get($path, $data);
35 };
36  
37 sub _post {
38 0 ▶ my ( $self, $path, $data ) = @_;
Subroutine _post: not called CC=2 SCAR=17.9
39 0 ▶ $data //= {};
Condition0%0/2
$data //= {}
l!l
00
MC/DC0%0/1
$data //= {}
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
40 0 $data->{token} = $self->token;
41 0 $self->post($path, $data);
42 };
43  
44 sub balance {
45 0 ▶ my $self = shift;
Subroutine balance: not called CC=1 SCAR=6.9
Pod undocumented
46 0 my $result = $self->_get('users/balance');
47 0 return $result->data->{balance};
48 }
49  
50 sub pdf {
51 0 ▶ my ($self, $id) = @_;
Subroutine pdf: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my $result = $self->_get('shipments/pdf', {id => $id});
53 0 return $result->data->{base64};
54 }
55  
56 sub zpl {
57 0 ▶ my ($self, $id) = @_;
Subroutine zpl: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my $result = $self->_get('shipments/zpl', {id => $id});
59 0 return $result->data->{base64};
60 }
61  
62 sub shipments {
63 0 ▶ my ($self, $params) = @_;
Subroutine shipments: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my $result = $self->_get('shipments/shipments', $params);
65 0 return $result->data;
66 }
67  
68 sub imported_shipments {
69 0 ▶ my ($self, $params) = @_;
Subroutine imported_shipments: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my $result = $self->_get('shipments/imported_shipments', $params);
71 0 return $result->data;
72 }
73 sub create_imported_shipment {
74 0 ▶ my ($self, $params) = @_;
Subroutine create_imported_shipment: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $result = $self->_post('shipments/imported_shipment', $params);
76 0 return $result->data;
77 }
78  
79 sub create_shipment {
80 0 ▶ my ($self, $params) = @_;
Subroutine create_shipment: not called CC=1 SCAR=6.9
Pod undocumented
81 0 my $result = $self->_post('shipments/shipment', $params);
82 0 return $result->data;
83 }
84  
85 sub create_shipment_own_customer_number {
86 0 ▶ my ($self, $params) = @_;
Subroutine create_shipment_own_customer_number: not called CC=1 SCAR=6.9
Pod undocumented
87 0 my $result = $self->_post('shipments/shipment_own_customer_number', $params);
88 0 return $result->data;
89 }
90  
91 sub freight_rates {
92 0 ▶ my ($self, $params) = @_;
Subroutine freight_rates: not called CC=1 SCAR=6.9
Pod undocumented
93 0 my $result = $self->_get('shipments/freight_rates', $params);
94 0 return $result->data;
95 }
96  
97 sub payment_requests {
98 0 ▶ my $self = shift;
Subroutine payment_requests: not called CC=1 SCAR=6.9
Pod undocumented
99 0 my $result = $self->_get('users/payment_requests');
100 0 return $result->data;
101 }
102  
103 sub gls_droppoints {
104 0 ▶ my ($self, $params) = @_;
Subroutine gls_droppoints: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my $result = $self->_get('shipments/gls_droppoints', $params);
106 0 return $result->data;
107 }
108  
109 sub pdk_droppoints {
110 0 ▶ my ($self, $params) = @_;
Subroutine pdk_droppoints: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my $result = $self->_get('shipments/pdk_droppoints', $params);
112 0 return $result->data;
113 }
114  
115 sub dao_droppoints {
116 0 ▶ my ($self, $params) = @_;
Subroutine dao_droppoints: not called CC=1 SCAR=6.9
Pod undocumented
117 0 my $result = $self->_get('shipments/dao_droppoints', $params);
118 0 return $result->data;
119 }
120  
121 sub pickup_points {
122 0 ▶ my ($self, $params) = @_;
Subroutine pickup_points: not called CC=1 SCAR=6.9
Pod undocumented
123 0 my $result = $self->_get('pickup_points', $params);
124 0 return $result->data;
125 }
126  
127 sub add_to_print_queue {
128 0 ▶ my ($self, $shipments) = @_;
Subroutine add_to_print_queue: not called CC=1 SCAR=6.9
Pod undocumented
129 0 my $result = $self->_post('shipments/add_to_print_queue', {ids => join(',', @$shipments)});
130 0 return $result->data;
131 }
132  
133 sub pdf_multiple {
134 0 ▶ my ($self, $shipments) = @_;
Subroutine pdf_multiple: not called CC=1 SCAR=6.9
Pod undocumented
135 0 my $result = $self->_get('shipments/pdf_multiple', {ids => join(',', @$shipments)});
136 0 return $result->data;
137 }
138  
139 1 1;
140  
141 =pod
142  
143 =encoding UTF-8
144  
145 =head1 NAME
146  
147 P5kkelabels - API interface to pakkelabels.dk
148  
149 =head1 VERSION
150  
151 version 0.01
152  
153 =head1 SYNOPSIS
154  
155 =head1 DESCRIPTION
156  
157 =head1 ATTRIBUTES
158  
159 =head1 METHODS
160  
161 =head1 NAME
162  
163 P5kkelabels - REST API interface
164  
165 =head1 METHODS
166  
167 =head2 methods
168  
169 =head1 BUGS
170  
171 Please report any bugs or feature requests to bug-role-rest-client at rt.cpan.org, or through the
172 web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=P5kkelabels.
173  
174 =head1 AUTHOR
175  
176 Kaare Rasmussen <kaare at cpan dot org>
177  
178 =head1 COPYRIGHT AND LICENSE
179  
180 This software is copyright (c) 2017 by Kaare Rasmussen.
181  
182 This is free software; you can redistribute it and/or modify it under
183 the same terms as the Perl 5 programming language system itself.
184  
185 =cut
186  
187 __END__
188  
189 # ABSTRACT: API interface to pakkelabels.dk
190  
↑ Summary