/** * Set the request body for the given request. * * @param RestRequest $request * @param $body */ public function setRequestBody(RestRequest &$request, $body) { $request->setBody(json_encode($body), 'application/json'); }
/** * Actually send the request specified. This has been separated out to allow subclasses to add in their own * methods as needed. * * @param \Trucker\Requests\RestRequest $request * @param string $requestType (GET/DELETE/PUT/PATCH/POST/etc) * @return bool|\Trucker\Responses\Response */ protected function sendRequest($request) { //add auth if it is needed if ($auth = AuthFactory::build()) { $request->authenticate($auth); } //actually send the request $response = $request->sendRequest(); //handle clean response with errors if (ResponseInterpreterFactory::build()->invalid($response)) { //get the errors and set them to our local collection $this->errors = ErrorHandlerFactory::build()->parseErrors($response); //do any needed cleanup $this->doPostRequestCleanUp(); return false; } //end if return $response; }