Broadworks-OCIP
view release on metacpan or search on metacpan
lib/Broadworks/OCIP/Response.pm view on Meta::CPAN
package Broadworks::OCIP::Response;
# ABSTRACT: A Broadworks OCI-P Response Message
use strict;
use warnings;
use utf8;
use feature 'unicode_strings';
our $VERSION = '0.09'; # VERSION
our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY
use Broadworks::OCIP::Throwable;
use Moose;
use Function::Parameters;
use MooseX::StrictConstructor;
use Try::Tiny;
use XML::Fast;
# ------------------------------------------------------------------------
sub _list {
return () unless ( defined( $_[0] ) );
return @{ $_[0] } if ( ref( $_[0] ) eq 'ARRAY' );
return $_[0];
}
# ------------------------------------------------------------------------
has xml => (
is => 'ro',
isa => 'Str',
required => 1,
);
# ------------------------------------------------------------------------
has expected => (
is => 'ro',
isa => 'Str',
required => 1,
);
# ------------------------------------------------------------------------
has die_on_error => (
is => 'ro',
isa => 'Bool',
required => 1,
default => 1,
);
# ------------------------------------------------------------------------
has hash => (
is => 'ro',
isa => 'HashRef',
lazy => 1,
builder => '_build_hash'
);
method _build_hash () {
my $hash;
try { $hash = XML::Fast::xml2hash( $self->xml ); }
catch {
Broadworks::OCIP::Throwable->throw(
message => sprintf( "Error on XML unpack %s with %s", $_, $self->xml ),
execution_phase => 'response',
error_code => 'xml_unpack'
);
};
Broadworks::OCIP::Throwable->throw(
( run in 1.579 second using v1.01-cache-2.11-cpan-97f6503c9c8 )