private function createFixture($addTearDown = true, $forceCreate = false) { $category = new Category(); $category->setName($this->getRandomName())->setDataProviderId(SANDBOX_DATA_PROVIDER_ID); $category = $this->client->categories()->create($category); if ($addTearDown) { $this->fixtures[] = $category; } return $category; }
/** * Delete a category * * @param Category $category * * @throws Exception\ApiException if the API call fails * * @return Category */ public function delete(Category $category) { // Endpoint URI $uri = sprintf('v1/categories/%d', $category->getId()); try { $response = $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); } }