public function __construct(uspsShipping $plugin, array $params) { $str = strtolower($params['service']); $service_name = ''; foreach ($this->token_to_services as $token => $name) { if (strpos($str, $token) !== false) { $service_name = $name; break; } } if (!isset($this->services[$service_name])) { throw new waException($plugin->_w("Unsupported service: ") . $params['service'] . $plugin->_w(". Supported services by this API are: ") . implode(", ", $this->getSupportedServices())); } $this->service = $this->services[$service_name]; if (empty($params['items'])) { throw new waException($plugin->_w("Empty items of order")); } $this->plugin = $plugin; $this->params = $params; $address = $this->getAddress(); foreach ($address as $name => $value) { $address[$name] = $this->correctAddress($value); } $this->setAddress($address); }
public function __construct(uspsShipping $plugin, array $params) { // tracking ID is obligatory if (!isset($params['tracking_id'])) { throw new waException($plugin->_w("Empty tracking ID")); } parent::__construct($plugin, $params); }
public function __construct(uspsShipping $plugin, array $params) { $service = uspsServices::getServiceByCode(!empty($params['service']) ? $params['service'] : ''); if (!$service) { throw new waException($plugin->_w("Unknown service")); } $supported = $this->getSupportedServices(); if (is_array($supported) && !in_array($service['code'], $supported)) { throw new waException($plugin->_w("Unsupported service: ") . $service['code'] . $plugin->_w(". Supported services by this API are: ") . implode(", ", $supported)); } $this->service = $service; parent::__construct($plugin, $params); }
/** * @return array */ protected function getCountryList() { return include $this->plugin->getPluginPath() . '/lib/config/countries.php'; }