AgentPushKit-Client

 view release on metacpan or  search on metacpan

lib/AgentPushKit/Client/Object/User.pm  view on Meta::CPAN

            $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 => 'User',
                                  required => [], # TODO
}                                 );

__PACKAGE__->method_documentation({
    'id' => {
        datatype => 'string',
        base_name => 'id',
        description => '',
        format => '',
        read_only => '',
            },
    'email' => {
        datatype => 'string',
        base_name => 'email',
        description => '',
        format => '',
        read_only => '',
            },
    'display_name' => {
        datatype => 'string',
        base_name => 'displayName',
        description => '',
        format => '',
        read_only => '',
            },
    'has_password' => {
        datatype => 'boolean',
        base_name => 'hasPassword',
        description => '',
        format => '',
        read_only => '',
            },
    'has_google' => {
        datatype => 'boolean',
        base_name => 'hasGoogle',
        description => '',
        format => '',
        read_only => '',
            },
    'has_apple' => {
        datatype => 'boolean',
        base_name => 'hasApple',
        description => '',
        format => '',
        read_only => '',
            },
});

__PACKAGE__->openapi_types( {
    'id' => 'string',
    'email' => 'string',
    'display_name' => 'string',
    'has_password' => 'boolean',
    'has_google' => 'boolean',
    'has_apple' => 'boolean'
} );

__PACKAGE__->attribute_map( {
    'id' => 'id',
    'email' => 'email',
    'display_name' => 'displayName',
    'has_password' => 'hasPassword',
    'has_google' => 'hasGoogle',
    'has_apple' => 'hasApple'
} );

__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});


1;



( run in 1.379 second using v1.01-cache-2.11-cpan-4ef0a570458 )