Example #1
0
File: Api.php Project: ivodvb/sdk
 public function doRequest($endpoint, $version = null)
 {
     if (is_null($version)) {
         $version = $this->version;
     }
     $data = $this->getData();
     $uri = Config::getApiUrl($endpoint, $version);
     $curl = Config::getCurl();
     if (Config::getCAInfoLocation()) {
         // set a custom CAInfo file
         $curl->setOpt(CURLOPT_CAINFO, Config::getCAInfoLocation());
     }
     $result = $curl->post($uri, $data);
     if ($curl->error) {
         // todo handle 400 errors properly, the SDK user needs to know what
         // went wrong
         $error = new Error\Error($curl->errorMessage);
         $error->setAdditionalData($result)->setServiceId(Config::getServiceId())->setApiToken(Config::getApiToken())->setApiEndpoint($endpoint)->setApiEndpointVersion($version);
         throw $error;
     }
     $output = static::processResult($result);
     return $output;
 }
Example #2
0
File: Api.php Project: paynl/sdk
 public function doRequest($endpoint, $version = null)
 {
     if (is_null($version)) {
         $version = $this->version;
     }
     $data = $this->getData();
     $uri = Config::getApiUrl($endpoint, $version);
     $curl = Config::getCurl();
     if (Config::getCAInfoLocation()) {
         // set a custom CAInfo file
         $curl->setOpt(CURLOPT_CAINFO, Config::getCAInfoLocation());
     }
     $result = $curl->post($uri, $data);
     if ($curl->error) {
         if (!empty($result)) {
             if ($result->status == "FALSE") {
                 throw new Error\Api($result->error);
             }
         }
         throw new Error\Error($curl->errorMessage);
     }
     $output = static::processResult($result);
     return $output;
 }
Example #3
0
 public function testGetCurlCustomString()
 {
     \Paynl\Config::setCurl('\\Paynl\\Curl\\Dummy');
     $this->assertInstanceOf('\\Paynl\\Curl\\Dummy', \Paynl\Config::getCurl());
 }