예제 #1
0
파일: Api.php 프로젝트: 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;
 }
예제 #2
0
파일: Api.php 프로젝트: 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;
 }
예제 #3
0
파일: ConfigTest.php 프로젝트: ivodvb/sdk
 public function testGetCurlCustomString()
 {
     \Paynl\Config::setCurl('\\Paynl\\Curl\\Dummy');
     $this->assertInstanceOf('\\Paynl\\Curl\\Dummy', \Paynl\Config::getCurl());
 }