| 1 | package Net::Async::Webservice::UPS::Types; | ||||||||||||
| 2 | 6 | $Net::Async::Webservice::UPS::Types::VERSION = '1.1.4'; | |||||||||||
| 3 | { | ||||||||||||
| 4 | 6 | $Net::Async::Webservice::UPS::Types::DIST = 'Net-Async-Webservice-UPS'; | |||||||||||
| 5 | } | ||||||||||||
| 6 | 6 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 6 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | use Type::Library | ||||||||||||
| 9 | 6 | ▶ | -base, | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | -declare => qw( PickupType CustomerClassification | ||||||||||||
| 11 | Cache Cacheable | ||||||||||||
| 12 | Address Package PackageList | ||||||||||||
| 13 | Rate RateList | ||||||||||||
| 14 | RequestMode Service ReturnService | ||||||||||||
| 15 | ServiceCode ServiceLabel | ||||||||||||
| 16 | ReturnServiceCode ReturnServiceLabel | ||||||||||||
| 17 | CreditCardCode CreditCardType | ||||||||||||
| 18 | PackagingType MeasurementSystem | ||||||||||||
| 19 | Measure SizeMeasurementUnit WeightMeasurementUnit Currency | ||||||||||||
| 20 | Tolerance Payment ImageType Image | ||||||||||||
| 21 | Contact Shipper CreditCard Label | ||||||||||||
| 22 | ShipmentConfirm PackageResult | ||||||||||||
| 23 | QVSubscription QVEvent QVFile QVDelivery QVGeneric | ||||||||||||
| 24 | QVOrigin QVManifest QVPackage QVException QVReference | ||||||||||||
| 25 | 6 | ); | |||||||||||
| 26 | 6 | ▶ | use Type::Utils -all; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 6 | ▶ | use Types::Standard -types; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | 6 | ▶ | use Scalar::Util 'weaken'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 6 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | |||||||||||||
| 31 | # ABSTRACT: type library for UPS | ||||||||||||
| 32 | |||||||||||||
| 33 | |||||||||||||
| 34 | 6 | enum PickupType, | |||||||||||
| 35 | [qw( | ||||||||||||
| 36 | DAILY_PICKUP | ||||||||||||
| 37 | DAILY | ||||||||||||
| 38 | CUSTOMER_COUNTER | ||||||||||||
| 39 | ONE_TIME_PICKUP | ||||||||||||
| 40 | ONE_TIME | ||||||||||||
| 41 | ON_CALL_AIR | ||||||||||||
| 42 | SUGGESTED_RETAIL | ||||||||||||
| 43 | SUGGESTED_RETAIL_RATES | ||||||||||||
| 44 | LETTER_CENTER | ||||||||||||
| 45 | AIR_SERVICE_CENTER | ||||||||||||
| 46 | )]; | ||||||||||||
| 47 | |||||||||||||
| 48 | |||||||||||||
| 49 | 6 | enum CustomerClassification, | |||||||||||
| 50 | [qw( | ||||||||||||
| 51 | WHOLESALE | ||||||||||||
| 52 | OCCASIONAL | ||||||||||||
| 53 | RETAIL | ||||||||||||
| 54 | )]; | ||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | 6 | enum RequestMode, # there are probably more | |||||||||||
| 58 | [qw( | ||||||||||||
| 59 | rate | ||||||||||||
| 60 | shop | ||||||||||||
| 61 | )]; | ||||||||||||
| 62 | |||||||||||||
| 63 | |||||||||||||
| 64 | 6 | enum ServiceCode, | |||||||||||
| 65 | [qw( | ||||||||||||
| 66 | 01 | ||||||||||||
| 67 | 02 | ||||||||||||
| 68 | 03 | ||||||||||||
| 69 | 07 | ||||||||||||
| 70 | 08 | ||||||||||||
| 71 | 11 | ||||||||||||
| 72 | 12 | ||||||||||||
| 73 | 12 | ||||||||||||
| 74 | 13 | ||||||||||||
| 75 | 14 | ||||||||||||
| 76 | 54 | ||||||||||||
| 77 | 59 | ||||||||||||
| 78 | 65 | ||||||||||||
| 79 | 86 | ||||||||||||
| 80 | 85 | ||||||||||||
| 81 | 83 | ||||||||||||
| 82 | 82 | ||||||||||||
| 83 | )]; | ||||||||||||
| 84 | |||||||||||||
| 85 | |||||||||||||
| 86 | 6 | enum ServiceLabel, | |||||||||||
| 87 | [qw( | ||||||||||||
| 88 | NEXT_DAY_AIR | ||||||||||||
| 89 | 2ND_DAY_AIR | ||||||||||||
| 90 | GROUND | ||||||||||||
| 91 | WORLDWIDE_EXPRESS | ||||||||||||
| 92 | WORLDWIDE_EXPEDITED | ||||||||||||
| 93 | STANDARD | ||||||||||||
| 94 | 3_DAY_SELECT | ||||||||||||
| 95 | 3DAY_SELECT | ||||||||||||
| 96 | NEXT_DAY_AIR_SAVER | ||||||||||||
| 97 | NEXT_DAY_AIR_EARLY_AM | ||||||||||||
| 98 | WORLDWIDE_EXPRESS_PLUS | ||||||||||||
| 99 | 2ND_DAY_AIR_AM | ||||||||||||
| 100 | SAVER | ||||||||||||
| 101 | TODAY_EXPRESS_SAVER | ||||||||||||
| 102 | TODAY_EXPRESS | ||||||||||||
| 103 | TODAY_DEDICATED_COURIER | ||||||||||||
| 104 | TODAY_STANDARD | ||||||||||||
| 105 | )]; | ||||||||||||
| 106 | |||||||||||||
| 107 | |||||||||||||
| 108 | 6 | enum PackagingType, | |||||||||||
| 109 | [qw( | ||||||||||||
| 110 | LETTER | ||||||||||||
| 111 | PACKAGE | ||||||||||||
| 112 | TUBE | ||||||||||||
| 113 | UPS_PAK | ||||||||||||
| 114 | UPS_EXPRESS_BOX | ||||||||||||
| 115 | UPS_25KG_BOX | ||||||||||||
| 116 | UPS_10KG_BOX | ||||||||||||
| 117 | )]; | ||||||||||||
| 118 | |||||||||||||
| 119 | |||||||||||||
| 120 | 6 | enum CreditCardCode, | |||||||||||
| 121 | [qw( | ||||||||||||
| 122 | 01 | ||||||||||||
| 123 | 03 | ||||||||||||
| 124 | 04 | ||||||||||||
| 125 | 05 | ||||||||||||
| 126 | 06 | ||||||||||||
| 127 | 07 | ||||||||||||
| 128 | 08 | ||||||||||||
| 129 | )]; | ||||||||||||
| 130 | |||||||||||||
| 131 | |||||||||||||
| 132 | 6 | enum CreditCardType, | |||||||||||
| 133 | [qw( | ||||||||||||
| 134 | AMEX | ||||||||||||
| 135 | Discover | ||||||||||||
| 136 | MasterCard | ||||||||||||
| 137 | Optima | ||||||||||||
| 138 | VISA | ||||||||||||
| 139 | Bravo | ||||||||||||
| 140 | Diners | ||||||||||||
| 141 | )]; | ||||||||||||
| 142 | |||||||||||||
| 143 | |||||||||||||
| 144 | 6 | enum MeasurementSystem, | |||||||||||
| 145 | [qw( | ||||||||||||
| 146 | metric | ||||||||||||
| 147 | english | ||||||||||||
| 148 | )]; | ||||||||||||
| 149 | |||||||||||||
| 150 | |||||||||||||
| 151 | 6 | enum SizeMeasurementUnit, | |||||||||||
| 152 | [qw( | ||||||||||||
| 153 | IN | ||||||||||||
| 154 | CM | ||||||||||||
| 155 | )]; | ||||||||||||
| 156 | |||||||||||||
| 157 | |||||||||||||
| 158 | 6 | enum WeightMeasurementUnit, | |||||||||||
| 159 | [qw( | ||||||||||||
| 160 | LBS | ||||||||||||
| 161 | KGS | ||||||||||||
| 162 | )]; | ||||||||||||
| 163 | |||||||||||||
| 164 | |||||||||||||
| 165 | 6 | declare Currency, | |||||||||||
| 166 | as Str; | ||||||||||||
| 167 | |||||||||||||
| 168 | |||||||||||||
| 169 | declare Measure, | ||||||||||||
| 170 | as StrictNum, | ||||||||||||
| 171 | 0 | ▶ | where { $_ >= 0 }, | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 172 | 18 | ▶ | inline_as { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 173 | 18 | my ($constraint, $varname) = @_; | |||||||||||
| 174 | 18 | my $perlcode = | |||||||||||
| 175 | $constraint->parent->inline_check($varname) | ||||||||||||
| 176 | . "&& ($varname >= 0)"; | ||||||||||||
| 177 | 18 | return $perlcode; | |||||||||||
| 178 | }, | ||||||||||||
| 179 | 0 | ▶ | message { ($_//'<undef>').' is not a valid measure, it must be a non-negative number' }; | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Condition0%0/2
$_ // "<undef>"
MC/DC0%0/1
$_ // "<undef>"
$_
Truth table0%0/2
A
A= $_
| |||||||||||||
| 180 | |||||||||||||
| 181 | |||||||||||||
| 182 | declare Tolerance, | ||||||||||||
| 183 | as StrictNum, | ||||||||||||
| 184 | 0 | ▶ | where { $_ >= 0 && $_ <= 1 }, | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||
| 185 | 14 | ▶ | inline_as { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 186 | 14 | my ($constraint, $varname) = @_; | |||||||||||
| 187 | 14 | my $perlcode = | |||||||||||
| 188 | $constraint->parent->inline_check($varname) | ||||||||||||
| 189 | . "&& ($varname >= 0 && $varname <= 1)"; | ||||||||||||
| 190 | 14 | return $perlcode; | |||||||||||
| 191 | }, | ||||||||||||
| 192 | 0 | ▶ | message { ($_//'<undef>').' is not a valid tolerance, it must be a number between 0 and 1' }; | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Condition0%0/2
$_ // "<undef>"
MC/DC0%0/1
$_ // "<undef>"
$_
Truth table0%0/2
A
A= $_
| |||||||||||||
| 193 | |||||||||||||
| 194 | |||||||||||||
| 195 | 6 | class_type Address, { class => 'Net::Async::Webservice::UPS::Address' }; | |||||||||||
| 196 | 4 | ▶ | coerce Address, from Str, via { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 197 | 4 | require Net::Async::Webservice::UPS::Address; | |||||||||||
| 198 | 4 | Net::Async::Webservice::UPS::Address->new({postal_code => $_}); | |||||||||||
| 199 | 6 | }; | |||||||||||
| 200 | 6 | Address->coercion->freeze; | |||||||||||
| 201 | |||||||||||||
| 202 | |||||||||||||
| 203 | 6 | class_type Contact, { class => 'Net::Async::Webservice::UPS::Contact' }; | |||||||||||
| 204 | 0 | ▶ | coerce Contact, from Address, via { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 205 | 0 | require Net::Async::Webservice::UPS::Contact; | |||||||||||
| 206 | 0 | Net::Async::Webservice::UPS::Contact->new({address=>$_}); | |||||||||||
| 207 | 6 | }; | |||||||||||
| 208 | 6 | Contact->coercion->freeze; | |||||||||||
| 209 | |||||||||||||
| 210 | |||||||||||||
| 211 | 6 | class_type Shipper, { class => 'Net::Async::Webservice::UPS::Shipper' }; | |||||||||||
| 212 | |||||||||||||
| 213 | |||||||||||||
| 214 | 6 | class_type Payment, { class => 'Net::Async::Webservice::UPS::Payment' }; | |||||||||||
| 215 | |||||||||||||
| 216 | |||||||||||||
| 217 | 6 | class_type CreditCard, { class => 'Net::Async::Webservice::UPS::CreditCard' }; | |||||||||||
| 218 | |||||||||||||
| 219 | |||||||||||||
| 220 | 6 | enum ImageType, [qw(EPL ZPL SPL STARPL GIF HTML)]; | |||||||||||
| 221 | |||||||||||||
| 222 | |||||||||||||
| 223 | 6 | class_type Image, { class => 'Net::Async::Webservice::UPS::Response::Image' }; | |||||||||||
| 224 | 0 | ▶ | coerce Image, from HashRef, via { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 225 | 0 | require Net::Async::Webservice::UPS::Response::Image; | |||||||||||
| 226 | 0 | Net::Async::Webservice::UPS::Response::Image->from_hash($_); | |||||||||||
| 227 | 6 | }; | |||||||||||
| 228 | 6 | Image->coercion->freeze; | |||||||||||
| 229 | |||||||||||||
| 230 | |||||||||||||
| 231 | 6 | class_type Label, { class => 'Net::Async::Webservice::UPS::Label' }; | |||||||||||
| 232 | 3 | ▶ | coerce Label, from Str, via { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 233 | 3 | require Net::Async::Webservice::UPS::Label; | |||||||||||
| 234 | 3 | Net::Async::Webservice::UPS::Label->new({ code => $_ }); | |||||||||||
| 235 | 6 | }; | |||||||||||
| 236 | 6 | Label->coercion->freeze; | |||||||||||
| 237 | |||||||||||||
| 238 | |||||||||||||
| 239 | 6 | class_type Package, { class => 'Net::Async::Webservice::UPS::Package' }; | |||||||||||
| 240 | 6 | declare PackageList, as ArrayRef[Package]; | |||||||||||
| 241 | 5 | ▶ | coerce PackageList, from Package, via { [ $_ ] }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 242 | 6 | PackageList->coercion->freeze; | |||||||||||
| 243 | |||||||||||||
| 244 | |||||||||||||
| 245 | 6 | class_type PackageResult, { class => 'Net::Async::Webservice::UPS::Response::PackageResult' }; | |||||||||||
| 246 | |||||||||||||
| 247 | |||||||||||||
| 248 | 6 | class_type Service, { class => 'Net::Async::Webservice::UPS::Service' }; | |||||||||||
| 249 | 8 | ▶ | coerce Service, from Str, via { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 250 | 8 | require Net::Async::Webservice::UPS::Service; | |||||||||||
| 251 | 8 | Net::Async::Webservice::UPS::Service->new({label=>$_}); | |||||||||||
| 252 | 6 | }; | |||||||||||
| 253 | 6 | Service->coercion->freeze; | |||||||||||
| 254 | |||||||||||||
| 255 | |||||||||||||
| 256 | 6 | class_type ReturnService, { class => 'Net::Async::Webservice::UPS::ReturnService' }; | |||||||||||
| 257 | 1 | ▶ | coerce ReturnService, from Str, via { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 258 | 1 | require Net::Async::Webservice::UPS::ReturnService; | |||||||||||
| 259 | 1 | Net::Async::Webservice::UPS::ReturnService->new({label=>$_}); | |||||||||||
| 260 | 6 | }; | |||||||||||
| 261 | 6 | ReturnService->coercion->freeze; | |||||||||||
| 262 | |||||||||||||
| 263 | |||||||||||||
| 264 | 6 | enum ReturnServiceCode, | |||||||||||
| 265 | [qw( | ||||||||||||
| 266 | 2 | ||||||||||||
| 267 | 3 | ||||||||||||
| 268 | 5 | ||||||||||||
| 269 | 8 | ||||||||||||
| 270 | 9 | ||||||||||||
| 271 | )]; | ||||||||||||
| 272 | |||||||||||||
| 273 | |||||||||||||
| 274 | 6 | enum ReturnServiceLabel, | |||||||||||
| 275 | [qw( | ||||||||||||
| 276 | PNM | ||||||||||||
| 277 | RS1 | ||||||||||||
| 278 | RS3 | ||||||||||||
| 279 | ERL | ||||||||||||
| 280 | PRL | ||||||||||||
| 281 | )]; | ||||||||||||
| 282 | |||||||||||||
| 283 | |||||||||||||
| 284 | 6 | class_type Rate, { class => 'Net::Async::Webservice::UPS::Rate' }; | |||||||||||
| 285 | 6 | declare RateList, as ArrayRef[Rate]; | |||||||||||
| 286 | 0 | ▶ | coerce RateList, from Rate, via { [ $_ ] }; | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 287 | 6 | RateList->coercion->freeze; | |||||||||||
| 288 | |||||||||||||
| 289 | |||||||||||||
| 290 | 6 | class_type ShipmentConfirm, { class => 'Net::Async::Webservice::UPS::Response::ShipmentConfirm' }; | |||||||||||
| 291 | |||||||||||||
| 292 | 6 | class_type QVSubscription, { class => 'Net::Async::Webservice::UPS::QVSubscription' }; | |||||||||||
| 293 | |||||||||||||
| 294 | 6 | class_type QVEvent, { class => 'Net::Async::Webservice::UPS::Response::QV::Event' }; | |||||||||||
| 295 | 6 | class_type QVFile, { class => 'Net::Async::Webservice::UPS::Response::QV::File' }; | |||||||||||
| 296 | 6 | class_type QVDelivery, { class => 'Net::Async::Webservice::UPS::Response::QV::Delivery' }; | |||||||||||
| 297 | 6 | class_type QVGeneric, { class => 'Net::Async::Webservice::UPS::Response::QV::Generic' }; | |||||||||||
| 298 | 6 | class_type QVOrigin, { class => 'Net::Async::Webservice::UPS::Response::QV::Origin' }; | |||||||||||
| 299 | 6 | class_type QVManifest, { class => 'Net::Async::Webservice::UPS::Response::QV::Manifest' }; | |||||||||||
| 300 | 6 | class_type QVPackage, { class => 'Net::Async::Webservice::UPS::Response::QV::Package' }; | |||||||||||
| 301 | 6 | class_type QVException, { class => 'Net::Async::Webservice::UPS::Response::QV::Exception' }; | |||||||||||
| 302 | 6 | class_type QVReference, { class => 'Net::Async::Webservice::UPS::Response::QV::Reference' }; | |||||||||||
| 303 | |||||||||||||
| 304 | |||||||||||||
| 305 | 6 | duck_type Cache, [qw(get set)]; | |||||||||||
| 306 | 6 | duck_type Cacheable, [qw(cache_id)]; | |||||||||||
| 307 | |||||||||||||
| 308 | 6 | 1; | |||||||||||
| 309 | |||||||||||||
| 310 | __END__ | ||||||||||||