NAME

Circle::User - the user module for Circle::Chain SDK

VERSION

Version 0.05

SYNOPSIS

# 1. first register and login or login with verify code
## option1: register and login
my $response = send_register_verify_code({
  email => 'circle-node@gmail.com'
});
if ($response->{status} != 200) {
  croak 'cannot send register verify code:' . $response->{status};
}
# receive you verify code in email or your mobile phone.
$response = register({
  email => 'circle-node@gmail.com',
  passwordInput1 => '<password>',
  passwordInput2 => '<password>',
  verifyCode => '<verify_code>'
});
if ($response->{status} != 200) {
  croak 'cannot register status' . $response->{status};
}

# 2. then login
$response = login({
  email => 'circle-node@gmail.com',
  password => '<password>'
});
if ($response->{status} != 200) {
  croak 'cannot login status' . $response->{status};
}
## option2: login with verify code without register
$response = send_verify_code({
  email => 'circle-node@gmail.com'
});
if ($response->{status} != 200) {
  croak 'cannot send login verify code:' . $response->{status};
}
# receive you verify code in email or your mobile phone.
# then login
$response = login({
  email => 'circle-node@gmail.com',
  verifyCode => '<verifyCode>'
});
if ($response->{status} != 200) {
  croak 'cannot login status' . $response->{status};
}
## for you login, option1 and option2 are ok, you just select one.
# now your login in.

# 3. set pay password.
$response = send_pay_verify_code({
  email => 'circle-node@gmail.com'
});
if ($response->{status} != 200) {
  croak 'cannot send pay password verify code:' . $response->{status};
}
# receive you payVerifyCode from your email.
$response = set_pay_password({
  account => {
  	email => 'circle-node@gmail.com'
  },
  verifyCode => '<verify_code>',
  password => '<password>'
});
if ($response->{status} != 200) {
  croak 'cannot set pay password status:' . $response->{status};
}
# now the pay password is set success.

DESCRIPTION

The module provides user functions such as register, login and reset password etc.

EXPORT

Export the following methods in default:

our @EXPORT = qw(
  send_register_verify_code
  register
  send_verify_code
  login
  logout
  send_pay_verify_code
  set_pay_password
  have_pay_password
  send_reset_password_verify_code
  reset_password
  add_contacts
  list_contacts
  save_or_update_user_info
  get_user_info
);

So you just use the module:

use Circle::User;

METHODS

send_register_verify_code

my $response = send_register_verify_code(
    {
        email => 'circle-node@gmail.com'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot send register verify code:' . $response->{status};
}

If you want send register verify code to your phone, you can use the following code:

$response = send_register_verify_code({ phone => '<your mobile phone>'});

Note: the phone register is only supported in China mainland.

register

# receive you verify code in email or your mobile phone.
$response = register(
    {
        email          => 'circle-node@gmail.com',
        passwordInput1 => '<password>',
        passwordInput2 => '<password>',
        verifyCode     => '<verify_code>'
    }
);

send_verify_code

$response = send_verify_code(
    {
        email => 'circle-node@gmail.com'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot send login verify code:' . $response->{status};
}

login

# receive you verify code in email or your mobile phone.
$response = login(
    {
        email      => 'circle-node@gmail.com',
        verifyCode => '<verify_code>',
        password   => '<password>'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot login status' . $response->{status};
}

logout

$response = logout();
if ( $response->{status} == 200 ) {
    # you success log out.
}

send_pay_verify_code

$response = send_pay_verify_code(
    {
        email => 'circle-node@gmail.com'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot send pay password verify code:' . $response->{status};
}

set_pay_password

# receive you payVerifyCode from your email.
$response = set_pay_password(
    {
        account => {
            email => 'circle-node@gmail.com'
        },
        verifyCode => '<verify_code>',
        password   => '<password>'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot set pay password status:' . $response->{status};
}

send_reset_password_verify_code

$response = send_reset_password_verify_code(
    {
        email => 'circle-node@gmail.com'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot send reset password verify code:' . $response->{status};
}

reset_password

# receive you payVerifyCode from your email.
$response = reset_password(
    {
        account => {
            email => 'circle-node@gmail.com'
        },
        verifyCode => '<verify_code>',
        password1  => '<password>'
        password2  => '<password'
    }
);
if ( $response->{status} != 200 ) {
    croak 'cannot set reset password status:' . $response->{status};
}

add_contacts

my $response = add_contacts({
    phone => '<phone>',
    name  => 'tony',
    sex   => 1,  # 0 woman, 1 man
    icon  => '',
    address => 'Beijing China',
    description => 'this is my friend: tony'
});
if ($response->{status} == 200) {
   # add contacts success here.
}

list_contacts

my $response = list_contacts();
if ($response->{status} == 200) {
    my $data = $response->{data};
    # process contacts here.
}

save_or_update_user_info

my $response = save_or_update_user_info({
    "name" => "test",
    "phone" => "<your phone>",
    "email" => "test@gmail.com",
    "sex" => 1,
    "address" => "beijing",
    "motherLang" => 1,
    "wechat" => "lidh04"
});
if ($response->{status} == 200) {
  # your data is save success here.
}

get_user_info

my $response = get_user_info();
if ($response->{status} == 200) {
    my $data = $response->{data};
    # process user info data here.
}

SEE ALSO

See Circle::Common for circle common module.

See Circle::Wallet for circle wallet module.

See Circle::Block for circle block module.

COPYRIGHT AND LICENSE

Copyright 2024-2030 Charles li

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