mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-22 04:26:02 +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
|
||||
rackspace_logo.jpg
|
||||
mailgun_icon.png
|
||||
build
|
||||
|
@ -28,20 +28,19 @@ class HttpBroker{
|
||||
$this->apiKey = $apiKey;
|
||||
$this->workingDomain = $domain;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
public function postRequest($endpointUrl, $postData = array(), $files = 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('curl.options', array('CURLOPT_FORBID_REUSE' => true));
|
||||
$this->client->setDefaultOption('auth', array ($this->apiUser, $this->apiKey));
|
||||
$this->client->setDefaultOption('exceptions', true);
|
||||
$this->client->setUserAgent($this->sdkUserAgent . '/' . $this->sdkVersion);
|
||||
|
||||
}
|
||||
|
||||
public function postRequest($endpointUrl, $postData = array(), $files = array()){
|
||||
$request = $this->client->post($endpointUrl, array(), $postData);
|
||||
|
||||
if(isset($files["attachment"])){
|
||||
@ -74,17 +73,6 @@ class HttpBroker{
|
||||
}
|
||||
|
||||
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);
|
||||
$response = $request->send();
|
||||
$httpResponeCode = $response->getStatusCode();
|
||||
@ -106,17 +94,6 @@ class HttpBroker{
|
||||
}
|
||||
|
||||
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);
|
||||
$response = $request->send();
|
||||
$httpResponeCode = $response->getStatusCode();
|
||||
@ -138,16 +115,6 @@ class HttpBroker{
|
||||
}
|
||||
|
||||
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);
|
||||
$response = $request->send();
|
||||
$httpResponeCode = $response->getStatusCode();
|
||||
|
@ -38,7 +38,12 @@ class Messages{
|
||||
else{
|
||||
throw new MissingRequiredMIMEParameters("You are missing the minimum parameters to send a message.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setMessage($message = array(), $files = array()){
|
||||
$this->message = $message;
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
public function MessageBuilder(){
|
||||
return new MessageBuilder($this->httpBroker);
|
||||
|
Loading…
Reference in New Issue
Block a user