You are here

public function FormAssemblyRequest::__construct in FormAssembly 7

Initialize a new FormAssemblyRequest object.

Parameters

string $client_id: The client ID required for authentication.

string $client_secret: The client secret required for authentication.

string $endpoint: The url of the api endpoint.

File

includes/FormAssemblyRequest.php, line 35
Authorizes the current site and handles API requests to FormAssembly.

Class

FormAssemblyRequest
@file Authorizes the current site and handles API requests to FormAssembly.

Code

public function __construct($client_id, $client_secret = '', $endpoint = '') {
  global $base_url;
  $api_mode = variable_get('formassembly_endpoint', FALSE);
  if ($api_mode) {
    switch ($api_mode) {
      case 'dev':
        $this->apiHost = 'https://developer.formassembly.com';
        break;
      case 'pro':
        $this->apiHost = 'https://app.formassembly.com';
        break;
      case 'ent':
        $this->apiHost = 'https://' . variable_get('formassembly_instance') . '.tfaforms.net';
        break;
    }
    $this->clientId = $client_id;
    $this->clientSecret = $client_secret;
    $this->authCallback = 'admin/config/services/formassembly/authorize';
    $this->returnUrl = $base_url . '/' . $this->authCallback;
  }
  else {
    watchdog('FormAssembly', 'Connection Failure: API Endpoint must be configured', WATCHDOG_ERROR);
  }
}