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