| 1 | # Item | ||
| 2 | # -------- | ||
| 3 | # To be used with Shipment and ShippingOptions requests. | ||
| 4 | # | ||
| 5 | # This class is not meant to be created directly but thru | ||
| 6 | # the addItem functions of Shipment and ShippintOptions. | ||
| 7 | # | ||
| 8 | # Mandatory fields: | ||
| 9 | # weight, length, height, width | ||
| 10 | package Net::MBE::Item { | ||
| 11 | use Moo; | ||
| 12 | use namespace::clean; | ||
| 13 | use SOAP::Lite; | ||
| 14 | use Arthas::Defaults::520; | ||
| 15 | |||
| 16 | # Mandatory fields | ||
| 17 | has weight => ( is => 'rw' ); | ||
| 18 | has length => ( is => 'rw' ); | ||
| 19 | has width => ( is => 'rw' ); | ||
| 20 | has height => ( is => 'rw' ); | ||
| 21 | |||
| 22 | sub BUILD($class, $args) { | ||
| 23 | croak 'Provide-weight' if !$args->{weight}; | ||
| 24 | croak 'Provide-length' if !$args->{length}; | ||
| 25 | croak 'Provide-width' if !$args->{width}; | ||
| 26 | croak 'Provide-height' if !$args->{height}; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub getSoapParams($self) { | ||
| 30 | return \SOAP::Data->value( | ||
| 31 | SOAP::Data->name('Weight', $self->weight), | ||
| 32 | SOAP::Data->name('Dimensions' => \SOAP::Data->value( | ||
| 33 | SOAP::Data->name('Length', $self->length), | ||
| 34 | SOAP::Data->name('Height', $self->height), | ||
| 35 | SOAP::Data->name('Width', $self->width), | ||
| 36 | )), | ||
| 37 | ); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 41 | 1; |