Overview

Namespaces

  • LoginRadiusSDK
    • Advance
    • Clients
    • CustomerRegistration
      • Account
      • Authentication
      • Social
    • Utility

Classes

  • LoginRadiusSDK\Advance\ConfigAPI
  • LoginRadiusSDK\Advance\WebHooksAPI
  • LoginRadiusSDK\Clients\DefaultHttpClient
  • LoginRadiusSDK\CustomerRegistration\Account\AccountAPI
  • LoginRadiusSDK\CustomerRegistration\Account\CustomObjectAPI
  • LoginRadiusSDK\CustomerRegistration\Account\CustomRegistrationDataAPI
  • LoginRadiusSDK\CustomerRegistration\Account\RoleAPI
  • LoginRadiusSDK\CustomerRegistration\Authentication\AuthCustomObjectAPI
  • LoginRadiusSDK\CustomerRegistration\Authentication\UserAPI
  • LoginRadiusSDK\CustomerRegistration\Social\AdvanceSocialLoginAPI
  • LoginRadiusSDK\CustomerRegistration\Social\SocialLoginAPI
  • LoginRadiusSDK\Utility\Functions

Interfaces

  • LoginRadiusSDK\Clients\IHttpClient

Exceptions

  • LoginRadiusSDK\LoginRadiusException
  • Overview
  • Namespace
  • Class
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 
<?php

/**
 * @link                : http://www.loginradius.com
 * @category            : CustomerRegistration
 * @package             : AccountAPI
 * @author              : LoginRadius Team
 * @license             : https://opensource.org/licenses/MIT
 */

namespace LoginRadiusSDK\CustomerRegistration\Account;

use LoginRadiusSDK\Utility\Functions;

/**
 * Account API
 *
 * This is the main class to communicate with LoginRadius Customer Registration Account API.
 */
class AccountAPI {

    /**
     *
     * @param type $apikey
     * @param type $apisecret
     * @param type $options
     */
    public function __construct($apikey = '', $apisecret = '', $options = array()) {
        new Functions($apikey, $apisecret, $options);
    }

    /**
     * This API is create account.
     *
     * @param $payload = '{
      "FirstName":"",
      "LastName":"",
      "Password" : "*********",
      "Email":[
      {
      "Type":"Primary",
      "Value":"[email protected]"
      }
      ]}';
     * @return type Object
     */
    public function create($payload, $fields = '*') {
        return $this->apiClientHandler("", array('fields' => $fields), array('method' => 'POST', 'post_data' => $payload, 'content_type' => 'json'));
    }

    /**
     * This API Returns an Email Verification token.
     * 
     * @param $email
     *
     * @return 
     */
    public function getEmailVerificationToken($email, $fields = '*') {
        return $this->apiClientHandler('/verify/token', array('fields' => $fields), array('method' => 'POST', 'post_data' => array('Email' => $email), 'content_type' => 'json'));
    }

    /**
     * This API Returns a forgot password token.
     * 
     * @param $email
     *
     * @return 
     */
    public function getForgotPasswordToken($email, $fields = '*') {
        return $this->apiClientHandler('/forgot/token', array('fields' => $fields), array('method' => 'POST', 'post_data' => array('Email' => $email), 'content_type' => 'json'));
    }

    /**
     * This API is used to Get Identities by Email Id.
     * 
     * @param $email
     * @return array
     */
    public function getIdentitiesByEmail($email, $fields = '*') {
        return $this->apiClientHandler('/identities', array('email' => $email, 'fields' => $fields));
    }

    /**
     * This API is used to retrieve Access Token based on UID or user impersonation API.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     *
     * return Array of user profile
     */
    public function getAccessTokenByUid($uid, $fields = '*') {
        return $this->apiClientHandler("/access_token", array('uid' => $uid, 'fields' => $fields));
    }

    /**
     * This API is used to get the password field of an account.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     *
     * return {passwordHash : passwordhash}
     */
    public function getHashPassword($uid, $fields = '*') {
        return $this->apiClientHandler("/" . $uid . "/password", array('fields' => $fields));
    }

    /**
     * This API retrieves the profile data associated with the specific user using the passing in email address.
     *
     * @param $email = '[email protected]';
     *
     * return all user profile
     */
    public function getProfileByEmail($email, $fields = '*') {
        return $this->apiClientHandler('', array('email' => $email, 'fields' => $fields));
    }

    /**
     * This API retrieves the profile data associated with the specific user using the passing in username.
     *
     * @param $username = 'example';
     *
     * return all user profile
     */
    public function getProfileByUsername($username, $fields = '*') {
        return $this->apiClientHandler('', array('username' => $username, 'fields' => $fields));
    }

    /**
     * This API retrieves the profile data associated with the specific user using the passing in phone number.
     *
     * @param $phone = 'example';
     *
     * return all user profile
     */
    public function getProfileByPhone($phone, $fields = '*') {
        return $this->apiClientHandler('', array('phone' => $phone, 'fields' => $fields));
    }

    /**
     * This API is used to retrieve all of the profile data from each of the linked social provider accounts associated with the account. For ex: A user has linked facebook and google account then this api will retrieve both profile data.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     *
     * return Array of user profile
     */
    public function getProfileByUid($uid, $fields = '*') {
        return $this->apiClientHandler("/" . $uid, array('fields' => $fields));
    }

    /**
     * This API is used to set a password for an account. It does not require to know the previous(old) password.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     * @param $password = 'xxxxxxxxxx';
     *
     * return {PasswordHash : passwordhash}
     */
    public function setPassword($uid, $password, $fields = '*') {
        return $this->apiClientHandler("/" . $uid . "/password", array('fields' => $fields), array('method' => 'PUT', 'post_data' => array('password' => $password), 'content_type' => 'json'));
    }

    /**
     * This API is used to Modify/Update details of an existing user.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     * @param $payload = '{
      "Prefix":"",
      "FirstName":"",
      "MiddleName":null,
      "LastName":"",
      "Suffix":null,
      "FullName":"",
      "NickName":null,
      "ProfileName":null,
      "BirthDate":"10-12-1985",
      "Gender":"M",
      "Website":null
      }';
     * @return type Object
     */
    public function update($uid, $payload, $is_null_support = 'false', $fields = '*') {
        return $this->apiClientHandler('/' . $uid, array('nullsupport' => $is_null_support, 'fields' => $fields), array('method' => 'PUT', 'post_data' => $payload, 'content_type' => 'json'));
    }

    /**
     * This API is used to update security questions configuration using uid.
     * 
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     * @param $payload =
      {
      "securityquestionanswer": {
      "MiddleName": "value1",
      "PetName": "value1"
      }
      }
     * @return type object
     */
    public function updateSecurityQuestionByUid($uid, $payload, $fields = '*') {
        return $this->apiClientHandler("/" . $uid, array('fields' => $fields), array('method' => 'PUT', 'post_data' => $payload, 'content_type' => 'json'));
    }

    /**
     * This API is used to invalidate the account.
     * 
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     * @param $data = true(boolean type) if have you no body parameters
     * 
     * @return array
     */
    public function invalidateEmail($uid, $data, $fields = '*') {
        return $this->apiClientHandler("/" . $uid . '/invalidateemail', array('fields' => $fields), array('method' => 'PUT', 'post_data' => $data, 'content_type' => 'json'));
    }

    /**
     * This API is used to remove email using uid.
     * 
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     * @param $email = '[email protected]'
     * @return type object
     */
    public function removeEmailByUidAndEmail($uid, $email, $fields = '*') {
        return $this->apiClientHandler('/' . $uid . '/email', array('fields' => $fields), array('method' => 'DELETE', 'post_data' => array('Email' => $email), 'content_type' => 'json'));
    }

    /**
     * Delete an account from your LoginRadius app.
     *
     * @param $uid = 'xxxxxxxxxx' //UID, the unified identifier for each user account.
     *
     * return {"IsDeleted": "true"}
     */
    public function delete($uid, $fields = '*') {
        return $this->apiClientHandler('/' . $uid, array('fields' => $fields), array('method' => 'DELETE', 'post_data' => true));
    }

    /**
     * This API is used to update or insert email using uid.
     * 
     * @param $uid
     * @param $payload =
      '{
      "Email" : [
      {
      "Type" : "Primary",
      "Value" : "[email protected]"
      }
      ]
      }';
     * @return type object
     */
    public function updateOrInsertEmailByUid($uid, $payload, $fields = '*') {
        return $this->apiClientHandler('/' . $uid . '/email', array('fields' => $fields), array('method' => 'PUT', 'post_data' => $payload, 'content_type' => 'json'));
    }

    /**
     * This API is used to receive a backup code to login via the UID.
     *
     * @param $uid
     * @return type object
     */
    public function mfaGetBackupCodeByUid($uid, $fields = '*') {
        return $this->apiClientHandler("/2fa/backupcode", array('uid' => $uid, 'fields' => $fields));
    }

    /**
     * This API is used to get backup codes for login by the UID.
     *
     * @param $uid
     * @return type object
     */
    public function mfaResetBackupCodeByUid($uid, $fields = '*') {
        return $this->apiClientHandler("/2fa/backupcode/reset", array('uid' => $uid, 'fields' => $fields));
    }

    /**
     * MFA Reset Google Authenticator By UID
     * 
     * @param $uid
     * @param $googleauthenticator
     * @return {"IsDeleted": "true"}
     */
    public function mfaResetGoogleAuthenticatorByUid($uid, $googleauthenticator) {
        return $this->apiClientHandler("/2fa/authenticator", array('uid' => $uid), array('method' => 'DELETE', 'post_data' => array('googleauthenticator' => $googleauthenticator), 'content_type' => 'json'));
    }

    /**
     * MFA Reset SMS Authenticator By UID
     * 
     * @param $uid
     * @param $otpauthenticator
     * @return {"IsDeleted": "true"}
     */
    public function mfaResetSMSAuthenticatorByUid($uid, $otpauthenticator) {
        return $this->apiClientHandler("/2fa/authenticator", array('uid' => $uid), array('method' => 'DELETE', 'post_data' => array('otpauthenticator' => $otpauthenticator), 'content_type' => 'json'));
    }

    /**
     * This API is used to reset phone id verification by the UID.
     *
     * @param $uid
     * @param $data = true(boolean type) if have you no body parameters
     * @return type object
     */
    public function resetPhoneIdVerification($uid, $data, $fields = '*') {
        return $this->apiClientHandler('/' . $uid . '/invalidatephone', array('fields' => $fields), array('method' => 'PUT', 'post_data' => $data, 'content_type' => 'json'));
    }

    /**
     * This API allows you to generate SOTT with a given expiration time.
     * 
     * @param $time_difference
     * @return type object
     */
    public function generateSOTT($time_difference = '10', $fields = '*') {
        return $this->apiClientHandler("/sott", array('timedifference' => $time_difference, 'fields' => $fields));
    }

    /**
     * Handle account APIs
     *
     * @param type $path
     * @param type $query_array
     * @param type $options
     * @return type
     */
    private function apiClientHandler($path, $query_array = array(), $options = array()) {
        return Functions::apiClient("/identity/v2/manage/account" . $path, $query_array, array_merge(array('authentication' => 'secret'), $options));
    }

}
API documentation generated by ApiGen