/** * Create and configure a http curl client. * * @param array $settings additional settings * * @return Client */ public function create(array $settings = []) { $stack = null; $settings = $this->platform->toArray() + $settings; if ($this->getLogger() instanceof LoggerInterface) { $stack = HandlerStack::create(); $stack->push(Middleware::log($this->getLogger(), new MessageFormatter('{request} - {response}'))); } return new Client(['base_url' => (string) $settings['url'], 'handler' => $stack, 'exceptions' => false, 'timeout' => (double) $settings['responseTimeout'], 'connection_timeout' => (double) $settings['connectionTimeout']]); }
/** * Return a Soap configuration for given platformConfig. * * @param PlatformConfigInterface $platform * * @return SoapConfig * @throws InputException */ public static function config(PlatformConfigInterface $platform) { $platformName = $platform->getPlatformName(); if (self::hasConfig($platformName) === false) { throw new InputException("Could not find a platform config for '{$platformName}'"); } /** @var SoapConfig $soapConfig */ $soapConfig = sprintf(self::FQCN, ucfirst($platformName)); // return instance of config class with settings in place return $soapConfig::configure($platform); }
/** * Return config as an array. * * @return array */ public function toArray() { return ['converter' => $this->getConverter(), 'endpoints' => static::$endPoints, 'platformConfig' => $this->platformConfig->toArray(), 'retry_minutes' => static::DEFAULT_RESPONSE_TIMEOUT, 'soap_headers' => (array) $this->getSoapHeaders()]; }
/** * Build the connector with given client and platform config. * * @param ClientInterface $client * @param PlatformConfigInterface $config * * @return ConnectorInterface * @throws \WebservicesNl\Common\Exception\Client\InputException */ private function buildConnector(ClientInterface $client, PlatformConfigInterface $config) { $adapter = $this->buildAdapter($client); $connectorName = $config->getConnectorName(); return new $connectorName($adapter); }