NAME

Net::Async::Webservice::UPS::Response::Utils - utility functions to parse hashrefs into response objects

VERSION

version 1.1.4

DESCRIPTION

The functions in this module are mostly for internal use, they may change or be removed without prior notice.

FUNCTIONS

set_implied_argument

Sets the ref that most other functions read from. It localises the assignment to the calling frame, so you don't have to remember to unset it.

out_if

out_if($key,$attr)

If $implied_arg->$attr is true, returns $key => $implied_arg->$attr, otherwise returns an empty list.

in_if

in_if($attr,$key)

If $implied_arg->{$key} is true, returns $attr => $implied_arg->{$key}, otherwise returns an empty list.

in_object_if

in_object_if($attr,$key,$class)

If $implied_arg->{$key} is true, returns $attr => $class->new($implied_arg->{$key}), otherwise returns an empty list. It also loads $class if necessary.

in_object_array_if

in_object_array_if($attr,$key,$class)

If $implied_arg->{$key} is true, maps each of its elements via $class->new($_), and returns $attr => \@mapped_elements, otherwise returns an empty list. It also loads $class if necessary.

If $implied_arg->{$key} is not an array, this function will map [ $implied_arg->{$key} ].

in_datetime_if

in_datetime_if($attr,$key)

If $implied_arg->{$key} is a hashref that contains a Date key, parses the values corresponding to the Date and Time keys, and returns $attr => $parsed_date, otherwise returns an empty list.

The DateTime object in the returned list will have a floating time zone.

pair_if

pair_if($key,$value);

If $value is true, returns the arguments, otherwise returns an empty list.

This function does not use the implied argument.

img_if

img_if($key,$hash);

If $hash is a non-empty hashref, coverts it into a Net::Async::Webservice::UPS::Response::Image and returns $key => $image, otherwise returns an empty list.

This function does not use the implied argument.

base64_if

base64_if($key,$string);

If $string is true, decodes its contents from Base64 and returns $key => $decoded_string, otherwise returns an empty list.

This function does not use the implied argument.

AUTHORS

  • Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>

  • Sherzod B. Ruzmetov <sherzodr@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.