mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-26 06:46:08 +03:00
Adjusted the HTTP client
This commit is contained in:
parent
762bfde571
commit
b4b9f0ec40
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ composer.phar
|
|||||||
smoketest.php
|
smoketest.php
|
||||||
rackspace_logo.jpg
|
rackspace_logo.jpg
|
||||||
mailgun_icon.png
|
mailgun_icon.png
|
||||||
|
build
|
||||||
|
@ -28,20 +28,19 @@ class HttpBroker{
|
|||||||
$this->apiKey = $apiKey;
|
$this->apiKey = $apiKey;
|
||||||
$this->workingDomain = $domain;
|
$this->workingDomain = $domain;
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
}
|
|
||||||
|
|
||||||
public function postRequest($endpointUrl, $postData = array(), $files = array()){
|
|
||||||
if($this->debug){
|
if($this->debug){
|
||||||
$this->client = new Guzzle('https://api.ninomail.com/' . $this->apiVersion . '/', array('ssl.certificate_authority' => false));
|
$this->client = new Guzzle('https://api.ninomail.com/' . $this->apiVersion . '/', array('ssl.certificate_authority' => false));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->client = new Guzzle('https://' . $this->apiEndpoint . '/' . $this->apiVersion . '/');
|
$this->client = new Guzzle('https://' . $this->apiEndpoint . '/' . $this->apiVersion . '/');
|
||||||
}
|
}
|
||||||
|
$this->client->setDefaultOption('curl.options', array('CURLOPT_FORBID_REUSE' => true));
|
||||||
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
||||||
$this->client->setDefaultOption('exceptions', true);
|
$this->client->setDefaultOption('exceptions', true);
|
||||||
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function postRequest($endpointUrl, $postData = array(), $files = array()){
|
||||||
$request = $this->client->post($endpointUrl, array(), $postData);
|
$request = $this->client->post($endpointUrl, array(), $postData);
|
||||||
|
|
||||||
if(isset($files["attachment"])){
|
if(isset($files["attachment"])){
|
||||||
@ -74,17 +73,6 @@ class HttpBroker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest($endpointUrl, $queryString = array()){
|
public function getRequest($endpointUrl, $queryString = array()){
|
||||||
if($this->debug){
|
|
||||||
$this->client = new Guzzle('https://api.ninomail.com/' . $this->apiVersion . '/', array('ssl.certificate_authority' => false));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$this->client = new Guzzle('https://' . $this->apiEndpoint . '/' . $this->apiVersion . '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
|
||||||
$this->client->setDefaultOption('exceptions', true);
|
|
||||||
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
|
||||||
|
|
||||||
$request = $this->client->get($endpointUrl, $queryString);
|
$request = $this->client->get($endpointUrl, $queryString);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
$httpResponeCode = $response->getStatusCode();
|
$httpResponeCode = $response->getStatusCode();
|
||||||
@ -106,17 +94,6 @@ class HttpBroker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function deleteRequest($endpointUrl){
|
public function deleteRequest($endpointUrl){
|
||||||
if($this->debug){
|
|
||||||
$this->client = new Guzzle('https://api.ninomail.com/' . $this->apiVersion . '/', array('ssl.certificate_authority' => false));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$this->client = new Guzzle('https://' . $this->apiEndpoint . '/' . $this->apiVersion . '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
|
||||||
$this->client->setDefaultOption('exceptions', true);
|
|
||||||
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
|
||||||
|
|
||||||
$request = $this->client->delete($endpointUrl);
|
$request = $this->client->delete($endpointUrl);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
$httpResponeCode = $response->getStatusCode();
|
$httpResponeCode = $response->getStatusCode();
|
||||||
@ -138,16 +115,6 @@ class HttpBroker{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function putRequest($endpointUrl, $queryString){
|
public function putRequest($endpointUrl, $queryString){
|
||||||
if($this->debug){
|
|
||||||
$this->client = new Guzzle('https://api.ninomail.com/' . $this->apiVersion . '/', array('ssl.certificate_authority' => false));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$this->client = new Guzzle('https://' . $this->apiEndpoint . '/' . $this->apiVersion . '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
|
||||||
$this->client->setDefaultOption('exceptions', true);
|
|
||||||
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
|
||||||
$request = $this->client->put($endpointUrl, $queryString);
|
$request = $this->client->put($endpointUrl, $queryString);
|
||||||
$response = $request->send();
|
$response = $request->send();
|
||||||
$httpResponeCode = $response->getStatusCode();
|
$httpResponeCode = $response->getStatusCode();
|
||||||
|
@ -40,6 +40,11 @@ class Messages{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMessage($message = array(), $files = array()){
|
||||||
|
$this->message = $message;
|
||||||
|
$this->files = $files;
|
||||||
|
}
|
||||||
|
|
||||||
public function MessageBuilder(){
|
public function MessageBuilder(){
|
||||||
return new MessageBuilder($this->httpBroker);
|
return new MessageBuilder($this->httpBroker);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user