Adjusted the HTTP client

This commit is contained in:
Travis Swientek 2013-07-24 23:56:18 -07:00
parent 762bfde571
commit b4b9f0ec40
3 changed files with 11 additions and 38 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ composer.phar
smoketest.php
rackspace_logo.jpg
mailgun_icon.png
build

View File

@ -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();

View File

@ -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);