/**
  * @param Transaction|null $transaction
  * @param TransactionListItem $transactionListItem
  * @param string $apiUrl
  * @param string $explorerUrl
  * @return $this
  */
 public static function from($transaction, TransactionListItem $transactionListItem, $apiUrl, $explorerUrl)
 {
     $transactionListItemDto = new self();
     // From local app transaction
     if ($transaction !== null) {
         $transactionListItemDto->setDescription($transaction->getDescription());
     } else {
         $transactionListItemDto->setDescription($transactionListItem->getTxHash());
     }
     // From BlockCypher TXRef
     $transactionListItemDto->setTxHash($transactionListItem->getTxHash());
     //$transactionListItemDto->setTxInputN($transactionListItem->getTxInputN());
     //$transactionListItemDto->setValue($transactionListItem->getValue());
     $transactionListItemDto->setConfirmations($transactionListItem->getConfirmations());
     if ($transactionListItem->getReceived() !== null) {
         $transactionListItemDto->setReceived($transactionListItem->getReceived());
     }
     if ($transactionListItem->getConfirmed() !== null) {
         $transactionListItemDto->setConfirmed($transactionListItem->getConfirmed());
     }
     $transactionListItemDto->setBlockHeight($transactionListItem->getBlockHeight());
     $transactionListItemDto->setTotal($transactionListItem->getFinalTotal());
     $transactionListItemDto->setApiUrl($apiUrl);
     $transactionListItemDto->setExplorerUrl($explorerUrl);
     return $transactionListItemDto;
 }
Example #2
0
 /**
  * Factory method to create a new TogglClient
  *
  * The following array keys and values are available options:
  * - base_url: Base URL of web service
  * - username: username or API key
  * - password: password (if empty, then username is a API key)
  *
  * See https://www.toggl.com/public/api#api_token for more information on the api token
  *
  * @param array|Collection $config Configuration data
  *
  * @return self
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://www.toggl.com/api/{apiVersion}', 'debug' => false, 'apiVersion' => 'v8', 'api_key' => '', 'username' => '', 'password' => '');
     $required = array('api_key', 'username', 'password', 'base_url', 'apiVersion');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     // Attach a service description to the client
     if ($config->get('apiVersion') == 'v8') {
         $description = ServiceDescription::factory(__DIR__ . '/services_v8.json');
     } else {
         die('Only v8 is supported at this time');
     }
     $client->setDescription($description);
     $client->setDefaultHeaders(array("Content-type" => "application/json"));
     if (!empty($config->get('api_key'))) {
         $config->set('username', $config->get('api_key'));
         $config->set('password', 'api_token');
     }
     if (empty($config->get('password'))) {
         $config->set('password', 'api_token');
     }
     $authPlugin = new CurlAuthPlugin($config->get('username'), $config->get('password'));
     $client->addSubscriber($authPlugin);
     if ($config->get('debug')) {
         $client->addSubscriber(LogPlugin::getDebugPlugin());
     }
     return $client;
 }
 /**
  * Import relevant properties from given test
  *
  * @param ilObjTest $a_test
  * @return object
  */
 public static function createFromTest(ilObjTest $a_test, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("wsp");
     $newObj = new self();
     $newObj->setTitle($lng->txt("wsp_type_tstv") . " \"" . $a_test->getTitle() . "\"");
     $newObj->setDescription($a_test->getDescription());
     $active_id = $a_test->getActiveIdOfUser($a_user_id);
     $pass = ilObjTest::_getResultPass($active_id);
     $date = $a_test->getPassFinishDate($active_id, $pass);
     $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $certificate = new ilCertificate(new ilTestCertificateAdapter($a_test));
     $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
 }
 /**
  * @param array $config
  * @return \Guzzle\Service\Client|ImageRelayClient
  * @throws \Guzzle\Common\Exception\InvalidArgumentException
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://{imagerelay_url}/api/v2/', 'imagerelay_url' => 'subdomain.imagerelay.com');
     $config = Collection::fromConfig($config, $default);
     $client = new self($config->get('base_url'), $config);
     if ($config['auth'] === 'http') {
         if (!isset($config['username'], $config['password'])) {
             throw new InvalidArgumentException("Username and password required when using http auth.");
         }
         $authorization = 'Basic ' . base64_encode($config['username'] . ':' . $config['password']);
     }
     if ($config['auth'] === 'oauth') {
         if (!isset($config['token'])) {
             throw new InvalidArgumentException("Access token required when using oauth.");
         }
         $authorization = sprintf('Bearer %s', $config['token']);
     }
     if (!isset($authorization)) {
         throw new InvalidArgumentException("Must use either http or oauth authentication method.");
     }
     // Attach a service description to the client
     $description = ServiceDescription::factory(__DIR__ . '/Resources/api.php');
     $client->setDescription($description);
     // Set required User-Agent
     $client->setUserAgent(sprintf('%s (%s)', $config['app_name'], $config['app_contact']));
     $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
         $event['request']->addHeader('Authorization', $authorization);
     });
     return $client;
 }
 public static function factory($config = array())
 {
     if (isset($config['developer_mode']) && is_bool($config['developer_mode'])) {
         $developerMode = $config['developer_mode'];
     } else {
         $developerMode = false;
     }
     $baseUrl = array('https://api.auspost.com.au', 'https://devcentre.auspost.com.au/myapi');
     // Ignore unnecessary user-specified configuration values
     if ($developerMode) {
         unset($config['email_address']);
         unset($config['password']);
     }
     unset($config['base_url']);
     $default = array('developer_mode' => $developerMode, 'base_url' => $baseUrl[$developerMode], 'email_address' => '*****@*****.**', 'password' => 'password');
     $required = array('developer_mode', 'base_url', 'email_address', "password");
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->getConfig()->setPath('request.options/headers/Authorization', 'Basic ' . base64_encode($config->get('email_address') . ':' . $config->get('password')));
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/service.json'));
     $client->setSslVerification(false);
     $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) {
         $request = $event['request'];
         $request->addCookie('OBBasicAuth', 'fromDialog');
     });
     return $client;
 }
Example #6
0
 public static function factory($config = array())
 {
     // The following values are required when creating the client
     $required = array('base_url', 'username', 'password');
     // Merge in default settings and validate the config
     $config = Collection::fromConfig($config, array(), $required);
     // Create a new sData client
     $client = new self($config->get('base_url'), $config);
     // JSON by default
     $client->setDefaultOption('query/format', 'json');
     // Authentication
     $client->setDefaultOption('auth', array($config->get('username'), $config->get('password'), 'Basic'));
     // Strip the BOM from results
     $client->addSubscriber(new StripBomPlugin());
     // Optional logging
     if ($config->get('log')) {
         $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) {
             $req = $event['request'];
             \Log::info('sData', ['request' => $req->getMethod() . ' ' . $req->getResource()]);
         });
     }
     // Set the service description
     $services = \Config::get('sdata::services');
     if (!empty($services)) {
         $client->setDescription(ServiceDescription::factory($services));
     }
     // Done
     return $client;
 }
 /**
  * Import relevant properties from given exercise
  *
  * @param ilObjExercise $a_test
  * @return object
  */
 public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id)
 {
     global $lng;
     $lng->loadLanguageModule("exercise");
     $newObj = new self();
     $newObj->setTitle($a_exercise->getTitle());
     $newObj->setDescription($a_exercise->getDescription());
     include_once "Services/Tracking/classes/class.ilLPMarks.php";
     $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
     $newObj->setProperty("issued_on", new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
     // create certificate
     include_once "Services/Certificate/classes/class.ilCertificate.php";
     include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
     $certificate = new ilCertificate(new ilExerciseCertificateAdapter($a_exercise));
     $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
     // save pdf file
     if ($certificate) {
         // we need the object id for storing the certificate file
         $newObj->create();
         $path = self::initStorage($newObj->getId(), "certificate");
         $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf";
         if (file_put_contents($path . $file_name, $certificate)) {
             $newObj->setProperty("file", $file_name);
             $newObj->update();
             return $newObj;
         }
         // file creation failed, so remove to object, too
         $newObj->delete();
     }
     // remove if certificate works
     $newObj->create();
     return $newObj;
 }
Example #8
0
 /**
  * @param string $serviceDescription
  * @param array $config
  * @return \Guzzle\Service\Client
  */
 public static function factory($config = array())
 {
     if (!isset($config['serviceDescription'])) {
         throw new \Exception("Cannot create a twuzzle client without a service description");
     }
     $oauthConfig = array();
     if (!isset($config['consumerKey'])) {
         throw new \Exception("Cannot create an twuzzle client without a consumer key");
     } else {
         $oauthConfig['consumer_key'] = $config['consumerKey'];
     }
     if (!isset($config['consumerSecret'])) {
         throw new \Exception("Cannot create an twuzzle client without a consumer secret");
     } else {
         $oauthConfig['consumer_secret'] = $config['consumerSecret'];
     }
     if (isset($config['token']) && !empty($config['token'])) {
         $oauthConfig['token'] = $config['token'];
     }
     if (isset($config['tokenSecret']) && !empty($config['tokenSecret'])) {
         $oauthConfig['token_secret'] = $config['tokenSecret'];
     }
     $client = new self();
     $client->setDescription(ServiceDescription::factory($config['serviceDescription']));
     $oauth = new OauthPlugin($oauthConfig);
     $client->addSubscriber($oauth);
     return $client;
 }
 /**
  * {@inheritdoc}
  */
 public static function factory($config = array())
 {
     $default = array('url' => false, 'munchkin_id' => false, 'version' => 1, 'bulk' => false);
     $required = array('client_id', 'client_secret', 'version');
     $config = Collection::fromConfig($config, $default, $required);
     $url = $config->get('url');
     if (!$url) {
         $munchkin = $config->get('munchkin_id');
         if (!$munchkin) {
             throw new \Exception('Must provide either a URL or Munchkin code.');
         }
         $url = sprintf('https://%s.mktorest.com', $munchkin);
     }
     $grantType = new Credentials($url, $config->get('client_id'), $config->get('client_secret'));
     $auth = new Oauth2Plugin($grantType);
     if ($config->get('bulk') === true) {
         $restUrl = sprintf('%s/bulk/v%d', rtrim($url, '/'), $config->get('version'));
     } else {
         $restUrl = sprintf('%s/rest/v%d', rtrim($url, '/'), $config->get('version'));
     }
     $client = new self($restUrl, $config);
     $client->addSubscriber($auth);
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/service.json'));
     $client->setDefaultOption('headers/Content-Type', 'application/json');
     return $client;
 }
Example #10
0
 /**
  * @param array $config
  * @return \Guzzle\Service\Client|BasecampClient
  * @throws \Guzzle\Common\Exception\InvalidArgumentException
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://basecamp.com/{user_id}/api/{version}/', 'version' => 'v1', 'auth' => 'http', 'token' => null, 'username' => null, 'password' => null);
     $required = array('user_id', 'app_name', 'app_contact');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     if ($config['auth'] === 'http') {
         if (!isset($config['username'], $config['password'])) {
             throw new InvalidArgumentException("Config must contain username and password when using http auth");
         }
         $authorization = 'Basic ' . base64_encode($config['username'] . ':' . $config['password']);
     }
     if ($config['auth'] === 'oauth') {
         if (!isset($config['token'])) {
             throw new InvalidArgumentException("Config must contain token when using oauth");
         }
         $authorization = sprintf('Bearer %s', $config['token']);
     }
     if (!isset($authorization)) {
         throw new InvalidArgumentException("Config must contain valid authentication method");
     }
     // Attach a service description to the client
     $description = ServiceDescription::factory(__DIR__ . '/Resources/service.php');
     $client->setDescription($description);
     // Set required User-Agent
     $client->setUserAgent(sprintf('%s (%s)', $config['app_name'], $config['app_contact']));
     $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
         $event['request']->addHeader('Authorization', $authorization);
     });
     return $client;
 }
Example #11
0
 /**
  * @param array $config
  * @return \Guzzle\Service\Client|BasecampClient
  * @throws \Guzzle\Common\Exception\InvalidArgumentException
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://basecamp.com/', 'version' => 'v1', 'token' => null, 'user_agent' => null, 'auth_method' => 'oauth');
     $required = [];
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     if (empty($config['token'])) {
         throw new InvalidArgumentException("Config must contain token when using oath");
     }
     $authorization = sprintf('Bearer %s', $config['token']);
     if (!isset($authorization)) {
         throw new InvalidArgumentException("Config must contain valid authentication method");
     }
     // Attach a service description to the client
     $description = ServiceDescription::factory(__DIR__ . '/Resources/service.php');
     $client->setDescription($description);
     // Set required User-Agent
     $client->setUserAgent($config['user_agent']);
     $client->getEventDispatcher()->addListener('request.before_send', function (Event $event) use($authorization) {
         $event['request']->addHeader('Authorization', $authorization);
     });
     // Add cache plugin
     $cachePlugin = new CachePlugin(['storage' => new DefaultCacheStorage(new DoctrineCacheAdapter(new ApcCache()))]);
     $client->addSubscriber($cachePlugin);
     return $client;
 }
 public static function import($string, $plugin)
 {
     $name = strstr($string, "\$", true);
     $members = explode(",", substr(strstr(strstr($string, "\$"), "#", true), 1));
     $desc = str_replace("|", " ", strstr(strstr($string, "#"), "%", true));
     $leaderID = 0;
     foreach ($members as $num => $text) {
         if (strpos($text, ":Leader")) {
             $leaderID = $num;
         }
     }
     $leader = strstr($members[$leaderID], ":", true);
     $faction = new self($plugin, $name, $leader);
     if (strcmp(substr(strstr($string, "%"), 1), "null") != 0) {
         $home_raw = str_replace("%", "", strstr($string, "%"));
         $home_array = explode("_", $home_raw);
         $x = $home_array[0];
         $y = $home_array[1];
         $z = $home_array[2];
         $levelName = $home_array[3];
         $level = $plugin->getServer()->getLevelByName($levelName);
         $faction->sethome(new Position($x, $y, $z, $level));
     }
     unset($members[$leaderID]);
     foreach ($members as $num => $text) {
         $player = strstr($text, ":", true);
         $rank = substr(strstr($text, ":"), 1);
         $faction->addPlayer($player, $rank);
     }
     $faction->setDescription($desc);
     if ($plugin->prefs->get("Developer Mode")) {
         $plugin->getServer()->getLogger()->info($plugin->formatMessage("[X] {$name}", true));
     }
 }
Example #13
0
    public static function factory($config = array()) {
        $client = new self(null, $config);

        $description = ServiceDescription::factory(__DIR__ . '/descriptor.php');
        $client->setDescription($description);

        return $client;
    }
Example #14
0
 /**
  * fromReflection()
  *
  * @param Zend_Reflection_Docblock_Tag $reflectionTagReturn
  * @return Zend_CodeGenerator_Php_Docblock_Tag_License
  */
 public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagLicense)
 {
     $returnTag = new self();
     $returnTag->setName('license');
     $returnTag->setUrl($reflectionTagLicense->getUrl());
     $returnTag->setDescription($reflectionTagLicense->getDescription());
     return $returnTag;
 }
Example #15
0
 /**
  * Factory method to create the client, add the service description, and set
  * the user again
  *
  * @param array $config
  *
  * @return Client
  */
 public static function factory($config = array())
 {
     $client = new self();
     $description = ServiceDescription::factory(__DIR__ . '/Config/endpoints.json');
     $client->setDescription($description);
     $client->setUserAgent('Shelf/' . Version::VERSION, true);
     return $client;
 }
 /**
  * Factory method to create a new GoogleBooksApiClient
  *
  * @param array|Collection $config Configuration data. Array keys:
  *    base_url - Base URL of web service
  *
  * @return GoogleBooksApiClient
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://www.googleapis.com', 'scheme' => 'https');
     $required = array('base_url');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
     return $client;
 }
 public static function factory($config = array())
 {
     $config = Collection::fromConfig($config, array(), array());
     $client = new self($config->get('base_url'), $config);
     // Attach a service description to the client
     $description = ServiceDescription::factory(__DIR__ . '/client.json');
     $client->setDescription($description);
     return $client;
 }
Example #18
0
 /**
  * fromReflection()
  *
  * @param Zend_Reflection_Docblock_Tag $reflectionTagReturn
  * @return Zend_CodeGenerator_Php_Docblock_Tag_Return
  */
 public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagReturn)
 {
     $returnTag = new self();
     $returnTag->setName('return');
     $returnTag->setDatatype($reflectionTagReturn->getType());
     // @todo rename
     $returnTag->setDescription($reflectionTagReturn->getDescription());
     return $returnTag;
 }
Example #19
0
 /**
  * fromReflection()
  *
  * @param \Zend\Code\Reflection\ReflectionDocblockTag $reflectionTagReturn
  * @return \Zend\Code\Generator\DocBlock\Tag\ReturnTag
  */
 public static function fromReflection(\Zend\Code\Reflection\DocBlock\TagInterface $reflectionTagReturn)
 {
     $returnTag = new self();
     $returnTag->setName('return');
     $returnTag->setDatatype($reflectionTagReturn->getType());
     // @todo rename
     $returnTag->setDescription($reflectionTagReturn->getDescription());
     return $returnTag;
 }
 public static function createFromInterface(InvoicePainterItemInterface $invoicePainterItemInterface)
 {
     $obj = new self();
     $obj->setAmountEx($invoicePainterItemInterface->getInvoicePainterAmountEx());
     $obj->setTaxRate($invoicePainterItemInterface->getInvoicePainterTaxRate());
     $obj->setDescription($invoicePainterItemInterface->getInvoicePainterDescription());
     $obj->setDate($invoicePainterItemInterface->getInvoicePainterDate());
     return $obj;
 }
Example #21
0
 /**
  * @param string $name
  * @param string $condition
  * @param string $action
  * @param int    $priority
  * @param string $description
  *
  * @return Rule
  */
 public static function factory($name, $condition, $action, $priority = 0, $description = '')
 {
     $rule = new self();
     $rule->setName($name);
     $rule->setCondition($condition);
     $rule->setAction($action);
     $rule->setPriority($priority);
     $rule->setDescription($description);
     return $rule;
 }
 /**
  * fromReflection()
  *
  * @param Zend_Reflection_Docblock_Tag $reflectionTagParam
  * @return Zend_CodeGenerator_Php_Docblock_Tag
  */
 public static function fromReflection(Zend_Reflection_Docblock_Tag $reflectionTagParam)
 {
     $paramTag = new self();
     $paramTag->setName('param');
     $paramTag->setDatatype($reflectionTagParam->getType());
     // @todo rename
     $paramTag->setParamName($reflectionTagParam->getVariableName());
     $paramTag->setDescription($reflectionTagParam->getDescription());
     return $paramTag;
 }
Example #23
0
 public static function factory($config = array())
 {
     $config = Collection::fromConfig($config, self::getDefaultConfig(), ['api_token', 'service_description']);
     $client = new self($config->get('base_url'), $config);
     $client->setDescription($client->getServiceDescriptionFromFile($config->get('service_description')));
     $client->setDefaultOption('auth', [$config->get('api_token'), null, 'basic']);
     $client->addSubscriber($client);
     $client->setErrorHandler();
     return $client;
 }
Example #24
0
 public static function factory($config = array())
 {
     $resolver = new OptionsResolver();
     static::setDefaultOptions($resolver);
     $config = $resolver->resolve($config);
     $client = new self($config['base_url'], array('request.options' => array('headers' => array('Content-Type' => 'application/json'))));
     $client->addSubscriber(new Plugin($config['application_key'], $config['application_secret'], $config['consumer_key']));
     $client->setDescription(ServiceDescription::factory(realpath(__DIR__ . '/../../../config/description.json')));
     return $client;
 }
Example #25
0
 public static function factory($config = array())
 {
     $default = array();
     $required = array('base_url', 'consumer_key', 'consumer_secret', 'token', 'token_secret');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->addSubscriber(new OauthPlugin($config->toArray()));
     $client->setDescription(ServiceDescription::factory(__DIR__ . '/../service/basekit.json'));
     return $client;
 }
Example #26
0
 public static function factory($config = array())
 {
     $default = array('base_url' => '{scheme}://{region}.battle.net/api/wow/', 'scheme' => 'http', 'region' => 'eu', self::CURL_OPTIONS => array(CURLOPT_ENCODING => 'gzip'));
     $required = array();
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $description = ServiceDescription::factory(__DIR__ . '/description.json');
     $client->setDescription($description);
     return $client;
 }
 /**
  * @param array $config
  *
  * @return TemplateClient
  *
  * @codeCoverageIgnore Test is not need because the command tests only work if this method works.
  */
 public static function factory($config = array())
 {
     // Merge in default settings and validate the config
     $config = Collection::fromConfig($config);
     // Create a new Cinderella Template client
     $client = new self('', $config);
     $description = ServiceDescription::factory(__DIR__ . '/Resources/template-1.0.json');
     $client->setDescription($description);
     return $client;
 }
Example #28
0
 public static function createFromArray(array $data)
 {
     $movement = new self();
     $movement->setId(isset($data['id']) ? $data['id'] : null);
     $movement->setDate(new \DateTime($data['date']));
     $movement->setAmount(new \InFog\SimpleFinance\Types\Money($data['amount']));
     $movement->setName(new \InFog\SimpleFinance\Types\SmallString($data['name']));
     $movement->setDescription(new \InFog\SimpleFinance\Types\Text($data['description']));
     return $movement;
 }
 /**                                                                          
  * Factory method to create a new ClickatellClient 
  *                                                                           
  * The following array keys and values are available options:                
  * - base_url:  Base URL of web service                                       
  * - api_id:    Clickatell API ID
  * - user:      Clickatell username
  * - password:  Clickatell password
  *                                                                           
  * @param array|Collection $config Configuration data                        
  *                                                                           
  * @return self                                                              
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'http://api.clickatell.com/');
     $required = array('api_id', 'user', 'password', 'base_url');
     $config = Collection::fromConfig($config, $default, $required);
     $description = ServiceDescription::factory(__DIR__ . '/service.json');
     $client = new self($config->get('base_url'), $config);
     $client->setDescription($description);
     return $client;
 }
Example #30
0
 /**
  * Factory method to create a new Bitpay client
  *
  * @param array $config
  *
  * @return BitpayClient
  */
 public static function factory($config = array())
 {
     $default = array('base_url' => 'https://bitpay.com/api');
     $required = array('apiKey');
     $config = Collection::fromConfig($config, $default, $required);
     $client = new self($config->get('base_url'), $config);
     $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json'));
     $client->setDefaultOption('auth', array($config['apiKey'], '', 'Basic'));
     return $client;
 }