Fixed HTTPBroker Response and README for Stats endpoint

This commit is contained in:
Travis Swientek 2013-08-03 14:20:31 -07:00
parent a3e2324d2a
commit ee2a9aece8
2 changed files with 8 additions and 4 deletions

View File

@ -52,9 +52,11 @@ class HttpBroker{
public function getRequest($endpointUrl, $queryString = array()){ public function getRequest($endpointUrl, $queryString = array()){
$request = $this->mgClient->get($endpointUrl); $request = $this->mgClient->get($endpointUrl);
if(isset($queryString)){
foreach($queryString as $key=>$value){ foreach($queryString as $key=>$value){
$request->getQuery()->set($key, $value); $request->getQuery()->set($key, $value);
} }
}
$response = $request->send(); $response = $request->send();
return $this->responseHandler($response); return $this->responseHandler($response);
} }
@ -75,6 +77,8 @@ class HttpBroker{
$httpResponeCode = $responseObj->getStatusCode(); $httpResponeCode = $responseObj->getStatusCode();
if($httpResponeCode === 200){ if($httpResponeCode === 200){
$jsonResponseData = $responseObj->json(); $jsonResponseData = $responseObj->json();
$result = new \stdClass();
$result->http_response_body = new \stdClass();
foreach ($jsonResponseData as $key => $value){ foreach ($jsonResponseData as $key => $value){
$result->http_response_body->$key = $value; $result->http_response_body->$key = $value;
} }

View File

@ -17,7 +17,7 @@ $mgClient = new MailgunClient("key-3ax6xnjp29jd6fds4gc373sgvjxteol0", "samples.m
$stats = $mgClient->Stats(); $stats = $mgClient->Stats();
# Next, get the last 50 stats. # Next, get the last 50 stats.
$stats->getStats(50, 0); $stats->getStats(array('limit' => 50, 'skip' => 0, 'event' => 'sent'));
``` ```
Available Functions Available Functions
@ -25,7 +25,7 @@ Available Functions
`deleteTag(string $tag)` `deleteTag(string $tag)`
`getStats(int $limit, int $skip)` `getStats(array $filterParams)`
More Documentation More Documentation
------------------ ------------------