Skip to content

Commit

Permalink
Fixes #15, adds an option to override cURL library defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-chargeover committed Nov 20, 2021
1 parent 7293f2d commit c801853
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions ChargeOverAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ protected function _request($http_method, $uri, $data = null)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $http_method);

// Override cURL options
if ($this->_http)
{
foreach ($this->_http as $k => $v)
{
curl_setopt($ch, $k, $v);
}
}

// Build last request string
$this->_last_request = $http_method . ' ' . $endpoint . "\r\n\r\n";
if ($post_data)
Expand Down Expand Up @@ -263,9 +272,15 @@ protected function _error($err, $code = 400, $details = null)
)));
}

/**
* Override HTTP (cURL) options
*
* @param string $opt The cURL option (php.net/curl)
* @param string $value The cURL value
*/
public function http($opt, $value)
{

$this->_http[$opt] = $value;
}

public function debug($debug)
Expand Down Expand Up @@ -532,7 +547,7 @@ public function modify($id, $Object)
*
* @param string $type The type of object
* @param array $where An optional array of fields to filter by
* @return object A response object where $resp->response is the # of object that matched
* @return object A response object where $resp->response is the # of object that matched
*/
public function count($type, $where = array())
{
Expand Down

0 comments on commit c801853

Please sign in to comment.