/** * @param $id * * @return bool * * @throws Exceptions\RequestException * @throws Exceptions\ServerException */ public function delete($id) { $ResourceName = $this->resourceName . '/' . $id; list($status, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_DELETE, $ResourceName); if ($status === Common\HttpClient::HTTP_NO_CONTENT) { return true; } else { return $this->processRequest($body); } }
/** * @param $object * @param $id * * @return $this ->Object * * @internal param array $parameters */ public function update($object, $id) { $objVars = get_object_vars($object); $body = array(); foreach ($objVars as $key => $value) { if (null !== $value) { $body[$key] = $value; } } $ResourceName = $this->resourceName . ($id ? '/' . $id : null); $body = json_encode($body); list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_PUT, $ResourceName, false, $body); return $this->processRequest($body); }
/** * Test that requests can only be made when there is an Authentication set * * @test * @expectedException \MessageBird\Exceptions\AuthenticateException * @expectedExceptionMessageRegExp #Can not perform API Request without Authentication# */ public function testHttpClientWithoutAuthenticationException() { $client = new HttpClient(Client::ENDPOINT); $client->performHttpRequest('foo', 'bar'); }