abstract class UPSRequest in Commerce UPS 8.3
UPS API Service.
@package Drupal\commerce_ups
Hierarchy
- class \Drupal\commerce_ups\UPSRequest implements UPSRequestInterface
Expanded class hierarchy of UPSRequest
File
- src/
UPSRequest.php, line 10
Namespace
Drupal\commerce_upsView source
abstract class UPSRequest implements UPSRequestInterface {
/**
* The configuration array from a CommerceShippingMethod.
*
* @var array
*/
protected $configuration;
/**
* {@inheritdoc}
*/
public function setConfig(array $configuration) {
$this->configuration = $configuration;
}
/**
* Returns authentication array for a request.
*
* @return array
* An array of authentication parameters.
*
* @throws \Exception
*/
public function getAuth() {
// Verify necessary configuration is available.
if (empty($this->configuration['api_information']['access_key']) || empty($this->configuration['api_information']['user_id']) || empty($this->configuration['api_information']['password'])) {
throw new \Exception('Configuration is required.');
}
return [
'access_key' => $this->configuration['api_information']['access_key'],
'user_id' => $this->configuration['api_information']['user_id'],
'password' => $this->configuration['api_information']['password'],
];
}
/**
* Determine if integration mode (test or live) should be used.
*
* @return bool
* Integration mode (ie: test) is the default.
*/
public function useIntegrationMode() {
// If live mode is enabled, do not use integration mode.
if (!empty($this->configuration['api_information']['mode']) && $this->configuration['api_information']['mode'] == 'live') {
return FALSE;
}
// Use integration mode by default.
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UPSRequest:: |
protected | property | The configuration array from a CommerceShippingMethod. | 1 |
UPSRequest:: |
public | function | Returns authentication array for a request. | |
UPSRequest:: |
public | function |
Set the request configuration. Overrides UPSRequestInterface:: |
|
UPSRequest:: |
public | function | Determine if integration mode (test or live) should be used. |