You are here

class MiniorangeSAMLCustomer in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

Hierarchy

Expanded class hierarchy of MiniorangeSAMLCustomer

1 file declares its use of MiniorangeSAMLCustomer
MiniorangeSAMLRemoveLicense.php in src/Form/MiniorangeSAMLRemoveLicense.php

File

src/MiniorangeSAMLCustomer.php, line 14
Contains miniOrange Customer class.

Namespace

Drupal\miniorange_saml
View source
class MiniorangeSAMLCustomer {
  public $email;
  public $phone;
  public $password;
  public $otpToken;

  /**
   * Constructor.
   */
  public function __construct($email, $phone, $password, $otp_token) {
    $this->email = $email;
    $this->phone = $phone;
    $this->password = $password;
    $this->otpToken = $otp_token;
  }

  /**
   * Check if customer exists.
   */
  public function checkCustomer() {
    $url = MiniorangeSAMLConstants::CUSTOMER_CHECK_API;
    $fields = array(
      'email' => $this->email,
    );
    $api = new MoAuthApi();
    return $api
      ->makeCurlCall($url, $fields);
  }

  /**
   * Create Customer.
   */
  public function createCustomer() {
    $url = MiniorangeSAMLConstants::CUSTOMER_CREATE_API;
    $fields = array(
      'companyName' => $_SERVER['SERVER_NAME'],
      'areaOfInterest' => MiniorangeSAMLConstants::AREA_OF_INTEREST,
      'email' => $this->email,
      'phone' => $this->phone,
      'password' => $this->password,
    );
    $api = new MoAuthApi();
    $header = $api
      ->getHttpHeaderArray();
    return $api
      ->makeCurlCall($url, $fields, $header);
  }

  /**
   * Get Customer Keys.
   */
  public function getCustomerKeys() {
    $url = MiniorangeSAMLConstants::CUSTOMER_GET_KEYS;
    $fields = array(
      'email' => $this->email,
      'password' => $this->password,
    );
    $api = new MoAuthApi();
    return $api
      ->makeCurlCall($url, $fields);
  }

  /**
   * Send OTP.
   */
  public function sendOtp() {
    $url = MiniorangeSAMLConstants::AUTH_CHALLENGE_API;
    $username = \Drupal::config('miniorange_saml.settings')
      ->get('miniorange_saml_customer_admin_email');
    $fields = array(
      'customerKey' => MiniorangeSAMLConstants::DEFAULT_CUSTOMER_ID,
      'email' => $username,
      'authType' => 'EMAIL',
    );
    $api = new MoAuthApi();
    $header = $api
      ->getHttpHeaderArray();
    return $api
      ->makeCurlCall($url, $fields, $header);
  }

  /**
   * Validate OTP.
   */
  public function validateOtp($transaction_id) {
    $url = MiniorangeSAMLConstants::AUTH_VALIDATE_API;
    $fields = array(
      'txId' => $transaction_id,
      'token' => $this->otpToken,
    );
    $api = new MoAuthApi();
    $header = $api
      ->getHttpHeaderArray();
    return $api
      ->makeCurlCall($url, $fields, $header);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MiniorangeSAMLCustomer::$email public property
MiniorangeSAMLCustomer::$otpToken public property
MiniorangeSAMLCustomer::$password public property
MiniorangeSAMLCustomer::$phone public property
MiniorangeSAMLCustomer::checkCustomer public function Check if customer exists.
MiniorangeSAMLCustomer::createCustomer public function Create Customer.
MiniorangeSAMLCustomer::getCustomerKeys public function Get Customer Keys.
MiniorangeSAMLCustomer::sendOtp public function Send OTP.
MiniorangeSAMLCustomer::validateOtp public function Validate OTP.
MiniorangeSAMLCustomer::__construct public function Constructor.