/** * OpenstackClient constructor * * @param string $auth_url URL of the Identity Service */ public function __construct($auth_url, $username, $password, $tenantName = '') { parent::__construct($auth_url); $this->auth_url = $auth_url; $this->serviceCatalog = array(); $this->identityClient = IdentityClient::factory(array('base_url' => $this->auth_url)); }
/** * Class constructor * * Call parent constructor and attach an event listener that in turn will attach listeners to * the request based on the command being called. * * @param string $baseUrl The base URL to Imbo * @param array|Collection $config Client configuration */ public function __construct($baseUrl, $config) { parent::__construct($baseUrl, $config); if (empty($config['serverUrls'])) { $config['serverUrls'] = array($baseUrl); } $this->setServerUrls($config['serverUrls']); $this->setDescription(ServiceDescription::factory(__DIR__ . '/service.php')); $this->setUserAgent('ImboClient/' . Version::VERSION, true); // Attach event listeners that handles the signing of write operations and the appending of // access tokens to requests that require this $dispatcher = $this->getEventDispatcher(); $dispatcher->addSubscriber(new EventSubscriber\AccessToken()); $dispatcher->addSubscriber(new EventSubscriber\Authenticate()); $dispatcher->addSubscriber(new EventSubscriber\PublicKey()); $client = $this; $dispatcher->addListener('command.before_send', function ($event) use($client) { $client->currentCommand = $event['command']->getName(); }); $dispatcher->addListener('request.error', function ($event) use($client) { if ($client->currentCommand === 'GetServerStatus') { // Stop propagation of the event when there is an error with the server status $event->stopPropagation(); $client->currentCommand = null; } }); }
/** * @param CredentialsInterface $credentials AWS credentials * @param SignatureInterface $signature Signature implementation * @param Collection $config Configuration options * * @throws InvalidArgumentException if an endpoint provider isn't provided */ public function __construct(CredentialsInterface $credentials, SignatureInterface $signature, Collection $config) { // Use the system's CACert if running as a phar if (defined('AWS_PHAR')) { $config->set(self::SSL_CERT_AUTHORITY, 'system'); } // Bootstrap with Guzzle parent::__construct($config->get(Options::BASE_URL), $config); $this->credentials = $credentials; $this->signature = $signature; $this->endpointProvider = $config->get(Options::ENDPOINT_PROVIDER); // Make sure an endpoint provider was provided in the config if (!$this->endpointProvider instanceof EndpointProviderInterface) { throw new InvalidArgumentException('An endpoint provider must be provided to instantiate an AWS client'); } // Make sure the user agent is prefixed by the SDK version $this->setUserAgent('aws-sdk-php2/' . Aws::VERSION, true); // Set the service description on the client $this->addServiceDescriptionFromConfig(); // Add the event listener so that requests are signed before they are sent $this->getEventDispatcher()->addSubscriber(new SignatureListener($credentials, $signature)); // Resolve any config options on the client that require a client to be instantiated $this->resolveOptions(); // Add a resource iterator factory that uses the Iterator directory $this->addDefaultResourceIterator(); }
public function __construct($description_path, $baseUrl = '', $config = null) { parent::__construct($baseUrl, $config); $this->setDescription(ServiceDescription::factory($description_path)); $adapter = new DoctrineCacheAdapter(new ArrayCache()); $cache = new CachePlugin($adapter, true); $this->addSubscriber($cache); }
/** * Client constructor * * @param string $baseUrl Base URL of the web service * @param string $guid The merchant guid * @param string $apiSecret The merchant password */ public function __construct($baseUrl, $guid, $password) { parent::__construct($baseUrl, array('curl.CURLOPT_SSL_VERIFYPEER' => false)); $this->guid = $guid; $this->password = $password; $userAgent = 'Mozilla/4.0 (compatible; MtGox PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')'; $this->setUserAgent($userAgent); }
public function __construct(array $config = []) { $config = static::resolveAndValidateConfig($config); parent::__construct('{protocol}://{host}/api/v1/', $config); $this->setDefaultOption('headers/Authorization', sprintf('SSWS %s', $config['api_key'])); $this->addSubscriber(new ResponseErrorPlugin()); $this->setCommandFactory(new MapFactory(['CreateUser' => CreateUserCommand::class, 'GetUser' => GetUserCommand::class, 'UpdateUser' => UpdateUserCommand::class, 'UpdateUserStatus' => UpdateUserStatusCommand::class, 'ListUser' => ListUserCommand::class])); }
/** * Client constructor * * @param string $baseUrl Base URL of the web service * @param string $apiKey API access key * @param string $apiSecret API secret to sign the request */ public function __construct($baseUrl, $apiKey, $apiSecret) { parent::__construct($baseUrl, array('curl.CURLOPT_SSL_VERIFYPEER' => false)); $this->apiKey = $apiKey; $this->apiSecret = $apiSecret; $userAgent = 'Mozilla/4.0 (compatible; MtGox PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')'; $this->setUserAgent($userAgent); }
/** * Abstract AWS client constructor * * @param string $baseUrl AWS webservice URL * @param string $accessKey AWS access key ID * @param string $secretKey AWS secret access key * @param string $version (optional) AWS version */ public function __construct($baseUrl, $accessKey, $secretKey, $associateTag = '', $version = null) { parent::__construct($baseUrl); $this->accessKey = $accessKey; $this->secretKey = $secretKey; $this->associateTag = $associateTag; $this->version = $version; }
/** * Default AWS client constructor. Clients must be created using a factory * * @param string $baseUrl Service base URL * @param string $accessKey AWS access key ID * @param string $secretKey AWS secret key * @param string $version (optional) Service version * @param AbstractSignature $signature (optional) AWS signature */ public function __construct($baseUrl, $accessKey, $secretKey, $version = null, AbstractSignature $signature = null) { parent::__construct($baseUrl); $this->accessKey = $accessKey; $this->secretKey = $secretKey; $this->version = $version; $this->signature = $signature; }
/** * @param string $networkUri * @param string $networkId * @param string $networkKey * @param mixed $config */ public function __construct($networkUri, $networkId, $networkKey, $config = null) { $this->networkId = $networkId; $this->networkKey = $networkKey; $this->serverAddress = $config->get('server_address'); $this->httpHost = $config->get('http_host'); $this->https = $config->get('https'); parent::__construct($networkUri, $config); }
/** * @param string $authorizationToken */ public function __construct($authorizationToken) { $default = array('base_url' => '{scheme}://pushalot.com/api/', 'scheme' => 'https'); $required = ['base_url', 'scheme']; $config = Collection::fromConfig([], $default, $required); parent::__construct($config->get('base_url'), $config); $this->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); $this->authorizationToken = $authorizationToken; }
/** * {@inheritdoc} */ public function __construct($baseUrl = '', $config = null) { $default = array(); $required = array('username', 'password'); $config = Collection::fromConfig($config, $default, $required); parent::__construct($baseUrl, $config); $this->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); $this->addSubscriber(new CurlAuthPlugin($config->get('username'), $config->get('password'))); }
/** * Constructor * * @param string $storeId * @param string $key * @param \Namshi\Innovate\Payment\Transaction $transaction * @param string $baseUrl * @param array $config */ public function __construct($storeId, $merchantId, $key, $searchKey, $baseUrl = '', $config = null) { parent::__construct($baseUrl, $config); $this->setStoreId($storeId); $this->setMerchantId($merchantId); $this->setSearchKey($searchKey); $this->setKey($key); $this->setRequestFactory(RequestFactory::getInstance()); }
/** * Constructor. * * @param string $apiKey * @param string $endpointUrl * * @throws \RuntimeException */ public function __construct($apiKey, $endpointUrl) { parent::__construct($endpointUrl); $this->setUserAgent('helthe-monitor/' . self::VERSION, true); // Plugins $this->addSubscriber(new AuthenticationPlugin($apiKey)); $this->setDefaultOption('headers/Accept', 'application/json'); $this->setDefaultOption('headers/Content-type', 'application/json'); }
/** * @param Credentials $credentials * @param Signature $signature * @param array|Collection|null $config */ public function __construct($credentials, $signature, $config) { $this->credentials = $credentials; $this->signature = $signature; parent::__construct($config->get('base_url'), $config); $this->setUserAgent('hmb-sdk-php/' . self::VERSION); $dispatcher = $this->getEventDispatcher(); $dispatcher->addSubscriber(new SignatureListener($credentials, $signature)); }
public function __construct(Collection $config) { parent::__construct($config->get("base_url"), $config); // Make sure the user agent is prefixed by the SDK version $this->setUserAgent('behave-sdk-php2/v1', true); $description = ServiceDescription::factory(__DIR__ . '/Resources/operations.php'); $this->setDescription($description); return $this; }
public function __construct($access_token) { parent::__construct(); // Set the service description $this->setDescription(ServiceDescription::factory(__DIR__ . '/Resources/bitly.json')); $this->addSubscriber(new TokenAuthPlugin($access_token)); $this->addSubscriber(new ArrayAggregatorSubscriber()); $this->addSubscriber(new ResponseStandardizationSubscriber()); }
public function __construct($baseUrl = '', $config = null) { parent::__construct($baseUrl, $config); // Set the description for this Service. $filename = $config->get('service_description_path'); if (is_file($filename)) { $this->setDescription(ServiceDescription::factory($filename)); } }
/** * @param String $service_url Service URL * @param Array $config Configuration array containing these parameters: * - string 'private_key' The API private key from your account * - string 'public_key' The API public key from your account */ public function __construct($service_url = '', $config = array()) { $config = Collection::fromConfig($config, array('api_path' => '/api/v3'), array('private_key', 'public_key')); parent::__construct($service_url . $config['api_path'], $config); $description = ServiceDescription::factory(__DIR__ . '/client.json'); $this->setDescription($description); $ModerationSignature = new ModerationSignature(array('private_key' => $config['private_key'], 'public_key' => $config['public_key'])); $this->addSubscriber($ModerationSignature); }
/** * @param array $config */ public function __construct($config = []) { $config = Collection::fromConfig($config, [], ['token']); parent::__construct('', $config); $description = ServiceDescription::factory(__DIR__ . '/Resources/slack_api.json'); $this->setDescription($description); $this->getEventDispatcher()->addListener('command.before_prepare', function (Event $event) use($config) { $event['command']['token'] = $config['token']; }); }
/** * @param string $baseUrl * @param array|null $config */ public function __construct($baseUrl = LegacyUrlPlugin::BASE_URL, $config = null) { $legacyMode = $this->isLegacyUrl($baseUrl); $config = Collection::fromConfig($config ?: [], $this->defaultConfig, $legacyMode ? $this->legacyRequirements : []); if ($legacyMode) { $this->addSubscriber(new LegacyUrlPlugin($config['username'], $config['token'])); unset($config['username'], $config['token']); } parent::__construct($baseUrl, $config); $this->setDescription(ServiceDescription::factory(__DIR__ . '/Resources/slack.json')); }
public function __construct(array $config = array()) { $config = static::resolveAndValidateConfig($config); parent::__construct(sprintf('{protocol}://{host}%s{+path}api/{project_id}/', isset($config['port']) ? sprintf(':%d', $config['port']) : ''), $config); if (!$this->getDefaultOption('headers/User-Agent')) { $this->setDefaultOption('headers/User-Agent', sprintf('sentry-client/' . Client::VERSION)); } $this->setCommandFactory(new MapFactory(array('capture' => 'Hautelook\\SentryClient\\Command\\CaptureCommand'))); $this->addSubscriber(new SentryAuthPlugin($this->getConfig('public_key'), $this->getConfig('secret_key'), self::PROTOCOL_VERSION, $this->getDefaultOption('headers/User-Agent'))); $this->exceptionFactory = isset($config['exception_factory']) ? $config['exception_factory'] : new ExceptionFactory(); }
/** * Constructor * * @param string $host Base url of the api * @param string $token Security token * @param string $json_location Full path to service.json file */ public function __construct($host, $token, $json_location) { //fallback value $default = array(); $config = array('host' => $host, 'token' => $token); $required = array('host', 'token'); $config = Collection::fromConfig($config, $default, $required); parent::__construct($config['host']); $this->setDescription(ServiceDescription::factory($json_location)); $header = array('Authentication' => 'Token' . " " . $config->get('token')); $this->setDefaultOption("headers", $header); }
/** * Constructor * * @param Credentials $credentials */ public function __construct(Credentials $credentials) { // Make sure we always have the app_id parameter as default parent::__construct('', array('command.params' => array('app_id' => $credentials->getAppId()))); $this->credentials = $credentials; $this->setDescription(ServiceDescription::factory(sprintf(__DIR__ . '/ServiceDescription/Pusher-%s.php', self::LATEST_API_VERSION))); // Prefix the User-Agent by SDK version $this->setUserAgent('zfr-pusher-php/' . Version::VERSION, true); // Add a listener to sign each requests $this->signature = new PusherSignature(); $this->addSubscriber(new SignatureListener($credentials, $this->signature)); }
/** * Factory method to create a new MandrillClient * * @param string $key Mandrill api key */ public function __construct($key) { $default = ['base_url' => 'https://mandrillapp.com/api/1.0/']; $required = ['base_url']; $config = Collection::fromConfig([], $default, $required); parent::__construct($config->get('base_url'), $config); $this->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); $this->getEventDispatcher()->addListener('command.before_prepare', function (\Guzzle\Common\Event $e) use($key) { $e['command']->set('key', $key); }); $this->users = new Users($this); $this->messages = new Messages($this); }
/** * OpenstackClient constructor * * @param string $auth_url URL of the Identity Service */ public function __construct($auth_url, $username, $password, $tenantName = '', EventDispatcherInterface $eventDispatcher = null) { parent::__construct($auth_url); $this->auth_url = $auth_url; $this->serviceCatalog = array(); $this->identityClient = IdentityClient::factory(array('base_url' => $this->auth_url)); $this->setEventDispatcher($eventDispatcher); $this->getEventDispatcher()->addSubscriber(new AuthenticationObserver()); $this->identityClient->setEventDispatcher($eventDispatcher); $this->username = $username; $this->password = $password; $this->tenantName = $tenantName; }
/** * @param CredentialsInterface $credentials AWS credentials * @param SignatureInterface $signature Signature implementation * @param Collection $config Configuration options * * @throws InvalidArgumentException if an endpoint provider isn't provided */ public function __construct(CredentialsInterface $credentials, SignatureInterface $signature, Collection $config) { // Bootstrap with Guzzle parent::__construct($config->get(Options::BASE_URL), $config); $this->credentials = $credentials; $this->signature = $signature; // Make sure the user agent is prefixed by the SDK version $this->setUserAgent('aws-sdk-php2/' . Aws::VERSION, true); // Add the event listener so that requests are signed before they are sent $dispatcher = $this->getEventDispatcher(); $dispatcher->addSubscriber(new SignatureListener($credentials, $signature)); if ($backoff = $config->get(Options::BACKOFF)) { $dispatcher->addSubscriber($backoff, -255); } }
/** * @param CredentialsInterface $credentials AWS credentials * @param SignatureInterface $signature Signature implementation * @param Collection $config Configuration options * * @throws InvalidArgumentException if an endpoint provider isn't provided */ public function __construct(CredentialsInterface $credentials, SignatureInterface $signature, Collection $config) { // Bootstrap with Guzzle parent::__construct($config->get(Options::BASE_URL), $config); $this->credentials = $credentials; $this->signature = $signature; $this->endpointProvider = $config->get(Options::ENDPOINT_PROVIDER); // Make sure an endpoint provider was provided in the config if (!$this->endpointProvider instanceof EndpointProviderInterface) { throw new InvalidArgumentException('An endpoint provider must be provided to instantiate an AWS client'); } // Make sure the user agent is prefixed by the SDK version $this->setUserAgent('aws-sdk-php2/' . Aws::VERSION, true); // Add the event listener so that requests are signed before they are sent $this->getEventDispatcher()->addSubscriber(new SignatureListener($credentials, $signature)); // Resolve any config options on the client that require a client to be instantiated $this->resolveOptions(); }
public function __construct($baseUrl = '', $config = null) { parent::__construct($baseUrl, $config); $service = ServiceDescription::factory(__DIR__ . '/tika.json'); $this->setDescription($service); }
/** * Constructor * * @param string $apiKey * @param string $version */ public function __construct($apiKey, $version = self::LATEST_API_VERSION) { parent::__construct(); $this->setApiKey($apiKey); $this->setApiVersion($version); $this->setUserAgent('zfr-stripe-php', true); // Add an event to set the Authorization param before sending any request $dispatcher = $this->getEventDispatcher(); $dispatcher->addSubscriber(new ErrorResponsePlugin()); $dispatcher->addListener('command.after_prepare', [$this, 'afterPrepare']); $dispatcher->addListener('command.before_send', [$this, 'authorizeRequest']); }