AgentPushKit-Client
view release on metacpan or search on metacpan
lib/AgentPushKit/Client/Object/RegisterInput.pm view on Meta::CPAN
my $_subclass = $1;
my @_array = ();
foreach my $_element (@{$hash->{$_json_attribute}}) {
push @_array, $self->_deserialize($_subclass, $_element);
}
$self->{$_key} = \@_array;
} elsif ($_type =~ /^hash\[string,(.+)\]$/i) { # hash
my $_subclass = $1;
my %_hash = ();
while (my($_key, $_element) = each %{$hash->{$_json_attribute}}) {
$_hash{$_key} = $self->_deserialize($_subclass, $_element);
}
$self->{$_key} = \%_hash;
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
} else {
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
}
}
return $self;
}
# deserialize non-array data
sub _deserialize {
my ($self, $type, $data) = @_;
$log->debugf("deserializing %s with %s",Dumper($data), $type);
if (grep( /^$type$/ , ('DATE_TIME', 'DATE'))) {
return DateTime->from_epoch(epoch => str2time($data));
} elsif ( grep( /^$type$/, ('int', 'double'))) {
return undef unless defined $data;
return $data + 0;
} elsif ($type eq 'string') {
return undef unless defined $data;
return $data . q();
} elsif ($type eq 'boolean') {
return !!$data;
} elsif ($type eq 'object') {
return $data;
} else { # hash(model)
my $_instance = eval "AgentPushKit::Client::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
class => 'RegisterInput',
required => [], # TODO
} );
__PACKAGE__->method_documentation({
'email' => {
datatype => 'string',
base_name => 'email',
description => '',
format => '',
read_only => '',
},
'password' => {
datatype => 'string',
base_name => 'password',
description => '',
format => '',
read_only => '',
},
'display_name' => {
datatype => 'string',
base_name => 'displayName',
description => '',
format => '',
read_only => '',
},
});
__PACKAGE__->openapi_types( {
'email' => 'string',
'password' => 'string',
'display_name' => 'string'
} );
__PACKAGE__->attribute_map( {
'email' => 'email',
'password' => 'password',
'display_name' => 'displayName'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
1;
( run in 0.335 second using v1.01-cache-2.11-cpan-4ef0a570458 )