Skip to content

Commit a708150

Browse files
Endpoint\Application: Add support for deleting images (#528)
Adds support for deleting application images. Api docs: https://gotify.net/api-docs#/application/removeAppImage
1 parent 417d627 commit a708150

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

docs/endpoints.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ Upload image for an application
5757
uploadImage(int $id, string $image): stdClass
5858
```
5959

60+
Delete the image for an application
61+
62+
```PHP
63+
deleteImage(int $id): stdClass
64+
```
65+
6066
## ApplicationMessage
6167

6268
```PHP

src/Endpoint/Application.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,19 @@ public function uploadImage(int $id, string $image): stdClass
117117

118118
return (object) $application;
119119
}
120+
121+
/**
122+
* Delete the image of an application
123+
*
124+
* @param int $id Application Id
125+
*
126+
* @return boolean
127+
*
128+
* @see https://gotify.net/api-docs#/application/removeAppImage API docs for deleting an application image
129+
*/
130+
public function deleteImage(int $id): bool
131+
{
132+
$response = $this->guzzle->delete($this->endpoint . '/' . $id . '/image');
133+
return $response->getStatusCode() === 200 ? true : false;
134+
}
120135
}

tests/Endpoints/ApplicationTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ public function testUploadImage(): void
113113
$this->assertObjectHasProperty('image', $uploaded);
114114
}
115115

116+
/**
117+
* Test deleting an image for the application
118+
*/
119+
#[Depends('testUploadImage')]
120+
public function testDeleteImage(): void
121+
{
122+
$deleted = self::$application->deleteImage(self::$appId);
123+
$this->assertTrue($deleted);
124+
}
125+
116126
/**
117127
* Test deleting an application
118128
*/

0 commit comments

Comments
 (0)