You are here

public function FedExRequest::__call in Commerce FedEx 8

File

src/FedExRequest.php, line 25

Class

FedExRequest
Manage FedEx API services.

Namespace

Drupal\commerce_fedex

Code

public function __call($name, $arguments) {
  if (strpos($name, "get") !== 0) {
    throw new \Exception("Method {$name} not found");
  }
  $name = substr($name, 3);
  $configuration = $arguments[0];
  if (strpos($name, "Service") !== FALSE) {
    if (!class_exists("\\NicholasCreativeMedia\\FedExPHP\\Services\\{$name}")) {
      throw new \Exception("FedEx service {$name} not found");
    }
    $wsdl_options = $arguments[1] ?: [];
    $reset_soap_client = isset($arguments[2]) ? $arguments[2] : TRUE;
    return new $name($wsdl_options, $reset_soap_client, $this
      ->getMode($configuration));
  }
  if (strpos($name, "Request") !== FALSE) {
    if (!class_exists("\\NicholasCreativeMedia\\FedExPHP\\Services\\{$name}")) {
      throw new \Exception("Request Type {$name} not found");
    }
    return new $name($this
      ->getWebAuthenticationDetail($configuration), $this
      ->getClientDetail($configuration));
  }
  throw new \Exception("Method {$name} not found");
}