/** * Delete a category * * @param Segment $segment * * @throws Exception\ApiException if the API call fails * * @return Segment */ public function delete(Segment $segment) { // Endpoint URI $uri = sprintf('v1/segments/%d', $segment->getId()); try { $this->httpClient->delete($uri); if ($this->cache) { $this->cache->invalidate($this->cachePrefix); } return true; } catch (ClientException $e) { $response = $e->getResponse(); $responseBody = $response->getBody()->getContents(); $responseCode = $response->getStatusCode(); throw Exception\ApiException::translate($responseBody, $responseCode); } }