You are here

class UsersAPIHandler in Google Authenticator / 2 Factor Authentication - 2FA 8

Same name and namespace in other branches
  1. 8.2 src/UsersAPIHandler.php \Drupal\miniorange_2fa\UsersAPIHandler

Hierarchy

Expanded class hierarchy of UsersAPIHandler

10 files declare their use of UsersAPIHandler
configure_google_authenticator.php in src/Form/configure_google_authenticator.php
configure_kba.php in src/Form/configure_kba.php
configure_otp_over_email.php in src/Form/configure_otp_over_email.php
configure_otp_over_phone.php in src/Form/configure_otp_over_phone.php
configure_otp_over_sms.php in src/Form/configure_otp_over_sms.php

... See full list

File

src/UsersAPIHandler.php, line 5

Namespace

Drupal\miniorange_2fa
View source
class UsersAPIHandler {
  private $customerId;
  private $apiKey;
  public function __construct($customerId, $apiKey) {
    $this->apiKey = $apiKey;
    $this->customerId = $customerId;
  }
  public function update(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
      'phone' => $user
        ->getPhone(),
      'authType' => $user
        ->getAuthType(),
      'transactionName' => MoAuthConstants::$PLUGIN_NAME,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$USERS_UPDATE_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function get(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$USERS_GET_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }

  /*
   *
   * This function is used to check no. of users in customer account is full or not. Executes when check license is clicked in Register/Login tab.
   *
   * */
  public function getall($tot_users) {
    $fields = array(
      'customerKey' => $this->customerId,
      'batchNo' => $tot_users,
      'batchSize' => 1,
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$AUTH_GET_ALL_USER_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function create(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $this->customerId,
      'username' => $user
        ->getUsername(),
      'firstName' => $user
        ->getName(),
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$USERS_CREATE_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function search(MiniorangeUser $user) {
    $fields = array(
      'customerKey' => $user
        ->getCustomerId(),
      'username' => $user
        ->getUsername(),
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$USERS_SEARCH_API;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }
  public function fetchLicense() {
    $fields = array(
      'customerId' => $this->customerId,
      'applicationName' => 'drupal8_2fa',
    );
    $json = json_encode($fields);
    $url = MoAuthConstants::$CUSTOMER_CHECK_LICENSE;
    return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
  }

}

Members