protected function request($url, array $body = array()){
        $baseUrl = self::BASE_URL;
        if(isset($this->baseUrl)){
            $baseUrl = $this->baseUrl;
        }
        $client = new Client($baseUrl);
        $body['key'] = $this->apiKey;
        $section = explode('\\', get_called_class());
        $section = strtolower(end($section));
        $request = $client->post($section.'/'.$url.'.json', NULL, $body);
        try{
            $response = $request->send();
            $response = $response->getBody();
        }
        catch(ServerErrorResponseException $e){
            $response = json_decode($e->getResponse()->getBody(), true);
            throw new APIException($response['message'], $response['code'], $response['status'], $response['name'], $e);
        }
        return json_decode($response, true);
    }
protected function request($url, array $body = array()){
        $baseUrl = self::BASE_URL;
        if(isset($this->baseUrl)){
            $baseUrl = $this->baseUrl;
        }
        $client = new Client($baseUrl);
        $body['key'] = $this->apiKey;
        $section = explode('\\', get_called_class());
        $section = strtolower(end($section));
        $request = $client->post($section.'/'.$url.'.json', NULL, $body);
        try{
            $response = $request->send();
            $response = $response->getBody();
        }
        catch(ServerErrorResponseException $e){
            $response = json_decode($e->getResponse()->getBody(), true);
            throw new APIException($response['message'], $response['code'], $response['status'], $response['name'], $e);
        }
        return json_decode($response, true);
    }
protected function request ( $ url , array $ body = array ( ) ) { $ baseUrl = self :: BASE_URL ; if ( isset ( $ this -> baseUrl ) ) { $ baseUrl = $ this -> baseUrl ; } $ client = new Client ( $ baseUrl ) ; $ body [ 'key' ] = $ this -> apiKey ; $ section = explode ( '\\' , get_called_class ( ) ) ; $ section = strtolower ( end ( $ section ) ) ; $ request = $ client -> post ( $ section . '/' . $ url . '.json' , NULL , $ body ) ; try { $ response = $ request -> send ( ) ; $ response = $ response -> getBody ( ) ; } catch ( ServerErrorResponseException $ e ) { $ response = json_decode ( $ e -> getResponse ( ) -> getBody ( ) , true ) ; throw new APIException ( $ response [ 'message' ] , $ response [ 'code' ] , $ response [ 'status' ] , $ response [ 'name' ] , $ e ) ; } return json_decode ( $ response , true ) ; }
Send a request to Mandrill. All requests are sent via HTTP POST.
@param string $url
@param array $body
@throws Exception\APIException
@return array
Send a request to Mandrill . All requests are sent via HTTP POST .