Example #1
0
 public function __construct($url, array $config = [])
 {
     $this->factories = [];
     $this->modules = [];
     $client = new HTTPClient(['base_url' => $url]);
     parent::__construct($client, $config);
 }
 /**
  * The client constructor accepts an associative array of configuration
  * options:
  *
  * - defaults: Associative array of default command parameters to add to
  *   each command created by the client.
  * - validate: Specify if command input is validated (defaults to true).
  *   Changing this setting after the client has been created will have no
  *   effect.
  * - process: Specify if HTTP responses are parsed (defaults to true).
  *   Changing this setting after the client has been created will have no
  *   effect.
  * - response_locations: Associative array of location types mapping to
  *   ResponseLocationInterface objects.
  * - serializer: Optional callable that accepts a CommandTransactions and
  *   returns a serialized request object.
  *
  * @param ClientInterface      $client      HTTP client to use.
  * @param DescriptionInterface $description Guzzle service description
  * @param array                $config      Configuration options
  */
 public function __construct(ClientInterface $client, DescriptionInterface $description, array $config = [])
 {
     parent::__construct($client, $config);
     $this->description = $description;
     $this->processConfig($config);
 }
 /**
  * Executes an Vws command.
  *
  * @param CommandInterface $command Command to execute
  *
  * @return mixed Returns the result of the command
  *
  * @throws VwsException when an error occurs during transfer
  */
 public function execute(CommandInterface $command)
 {
     try {
         return parent::execute($command);
     } catch (VwsException $e) {
         throw $e;
     } catch (\Exception $e) {
         // Wrap other uncaught exceptions for consistency
         $exceptionClass = $this->commandException;
         throw new $exceptionClass(sprintf('Uncaught exception while executing %s::%s - %s', get_class($this), $command->getName(), $e->getMessage()), new CommandTransaction($this, $command), $e);
     }
 }