diff --git a/docs/endpoints.md b/docs/endpoints.md index 1c4538e..d51c275 100644 --- a/docs/endpoints.md +++ b/docs/endpoints.md @@ -57,6 +57,12 @@ Upload image for an application uploadImage(int $id, string $image): stdClass ``` +Delete the image for an application + +```PHP +deleteImage(int $id): stdClass +``` + ## ApplicationMessage ```PHP diff --git a/src/Endpoint/Application.php b/src/Endpoint/Application.php index 32e383c..c560d11 100644 --- a/src/Endpoint/Application.php +++ b/src/Endpoint/Application.php @@ -117,4 +117,19 @@ public function uploadImage(int $id, string $image): stdClass return (object) $application; } + + /** + * Delete the image of an application + * + * @param int $id Application Id + * + * @return boolean + * + * @see https://gotify.net/api-docs#/application/removeAppImage API docs for deleting an application image + */ + public function deleteImage(int $id): bool + { + $response = $this->guzzle->delete($this->endpoint . '/' . $id . '/image'); + return $response->getStatusCode() === 200 ? true : false; + } } diff --git a/tests/Endpoints/ApplicationTest.php b/tests/Endpoints/ApplicationTest.php index 48fda2d..c039213 100644 --- a/tests/Endpoints/ApplicationTest.php +++ b/tests/Endpoints/ApplicationTest.php @@ -113,6 +113,16 @@ public function testUploadImage(): void $this->assertObjectHasProperty('image', $uploaded); } + /** + * Test deleting an image for the application + */ + #[Depends('testUploadImage')] + public function testDeleteImage(): void + { + $deleted = self::$application->deleteImage(self::$appId); + $this->assertTrue($deleted); + } + /** * Test deleting an application */