From 57f37f14c25157f893273f85180ce0b911fbb9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 04:52:15 +0200 Subject: [PATCH 01/29] Group List implementation #29 --- Example/GroupsExample.php | 3 ++ README.md | 1 + src/Api/Groups/Group.php | 18 +++++++++ src/Client/GroupsClient.php | 5 +++ src/Client/Response/ListGroupResponse.php | 49 +++++++++++++++++++++++ tests/Api/Groups/GroupTest.php | 14 +++++++ tests/Client/GroupsClientTest.php | 4 ++ 7 files changed, 94 insertions(+) create mode 100644 src/Client/Response/ListGroupResponse.php diff --git a/Example/GroupsExample.php b/Example/GroupsExample.php index b8f9789..6e941bf 100644 --- a/Example/GroupsExample.php +++ b/Example/GroupsExample.php @@ -41,6 +41,9 @@ public function groupsExample() $createGroupResponse = $group->create('Test'); $newGroupKey = $createGroupResponse->getGroupKey(); + // Obtain list of all groups + $currentGroups = $group->list(); + // Retrieve information about the group from the API and populate the object with it. /** @var RetrieveGroupResponse $retrieveGroupResponse */ $retrieveGroupResponse = $group->retrieveGroupInformation(); diff --git a/README.md b/README.md index 0ff061d..4aac34f 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Light, simple and fast, yet comprehensive wrapper for the [Pushover](https://pus - Cancel emergency priority retry - Groups API ([Example](Example/GroupsExample.php)) - Create a group + - List groups - Retrieve information about the group - Add / Remove users - Enable / Disable users diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index fa26a2c..0915a4c 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -17,6 +17,7 @@ use Serhiy\Pushover\Client\Request\Request; use Serhiy\Pushover\Client\Response\AddUserToGroupResponse; use Serhiy\Pushover\Client\Response\CreateGroupResponse; +use Serhiy\Pushover\Client\Response\ListGroupResponse; use Serhiy\Pushover\Client\Response\DisableUserInGroupResponse; use Serhiy\Pushover\Client\Response\EnableUserInGroupResponse; use Serhiy\Pushover\Client\Response\RemoveUserFromGroupResponse; @@ -145,6 +146,23 @@ public function create(string $name): CreateGroupResponse return $response; } + /** + * List the groups. + */ + public function list(): ListGroupResponse + { + $client = new GroupsClient($this, GroupsClient::ACTION_LIST_GROUPS); + $request = new Request($client->buildApiUrl(), Request::GET); + + $curlResponse = Curl::do($request); + + $response = new ListGroupResponse($curlResponse); + $response->setRequest($request); + + return $response; + } + + /** * Adds an existing Pushover user to your Delivery Group. * diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index d6e06f0..ea6a2de 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -28,6 +28,7 @@ class GroupsClient extends Client implements ClientInterface public const ACTION_ENABLE_USER = "enable_user"; public const ACTION_RENAME_GROUP = "rename"; public const ACTION_CREATE_GROUP = "create"; + public const ACTION_LIST_GROUPS = "list"; /** * @var Group @@ -58,6 +59,10 @@ public function buildApiUrl() return Curl::API_BASE_URL."/".Curl::API_VERSION."/groups.json"; } + if ($this->action == self::ACTION_LIST_GROUPS) { + return Curl::API_BASE_URL."/".Curl::API_VERSION."/groups.json?token=".$this->group->getApplication()->getToken(); + } + if ($this->action == self::ACTION_RETRIEVE_GROUP) { return Curl::API_BASE_URL."/".Curl::API_VERSION."/groups/".$this->group->getKey().".json?token=".$this->group->getApplication()->getToken(); } diff --git a/src/Client/Response/ListGroupResponse.php b/src/Client/Response/ListGroupResponse.php new file mode 100644 index 0000000..3203b25 --- /dev/null +++ b/src/Client/Response/ListGroupResponse.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Serhiy\Pushover\Client\Response; + +use Serhiy\Pushover\Client\Response\Base\Response; + +/** + * @author Serhiy Lunak + */ +class ListGroupResponse extends Response +{ + /** + * @var array + */ + public $groups = []; + + /** + * @param mixed $curlResponse + */ + public function __construct($curlResponse) + { + $this->processCurlResponse($curlResponse); + } + + /** + * @param mixed $curlResponse + */ + private function processCurlResponse($curlResponse): void + { + $decodedCurlResponse = $this->processInitialCurlResponse($curlResponse); + foreach ($decodedCurlResponse->groups as $grp) { + $this->groups[$grp->name] = $grp->group; + } + } + + public function getGroups(): array + { + return $this->groups; + } +} diff --git a/tests/Api/Groups/GroupTest.php b/tests/Api/Groups/GroupTest.php index 31bf084..7cc5f10 100644 --- a/tests/Api/Groups/GroupTest.php +++ b/tests/Api/Groups/GroupTest.php @@ -79,4 +79,18 @@ public function testCreate() $this->assertInstanceOf(CreateGroupResponse::class, $response); } + + /** + * @group Integration + */ + public function testList() + { + $application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token + $group = new Group("eeee5555EEEE5555ffff6666FFFF66", $application); + + $response = $group->list(); + + $this->assertInstanceOf(ListGroupResponse::class, $response); + } + } diff --git a/tests/Client/GroupsClientTest.php b/tests/Client/GroupsClientTest.php index 0b7b364..341ec20 100644 --- a/tests/Client/GroupsClientTest.php +++ b/tests/Client/GroupsClientTest.php @@ -44,6 +44,10 @@ public function testBuildApiUrl() $client = new GroupsClient($group, GroupsClient::ACTION_ADD_USER); $this->assertEquals("https://api.pushover.net/1/groups/eeee5555EEEE5555ffff6666FFFF66/add_user.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); + + $client = new GroupsClient($group, GroupsClient::ACTION_LIST_GROUPS); + $this->assertEquals("https://api.pushover.net/1/groups.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); + } public function testBuildCurlPostFields() From 206154376c9eac3eb2369743a0f07cdf74cc050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 05:13:12 +0200 Subject: [PATCH 02/29] Process only correct response #29 --- src/Client/Response/ListGroupResponse.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Client/Response/ListGroupResponse.php b/src/Client/Response/ListGroupResponse.php index 3203b25..7cf7171 100644 --- a/src/Client/Response/ListGroupResponse.php +++ b/src/Client/Response/ListGroupResponse.php @@ -36,9 +36,12 @@ public function __construct($curlResponse) */ private function processCurlResponse($curlResponse): void { + $this->groups = []; $decodedCurlResponse = $this->processInitialCurlResponse($curlResponse); - foreach ($decodedCurlResponse->groups as $grp) { - $this->groups[$grp->name] = $grp->group; + if (property_exists($decodedCurlResponse, 'groups')) { + foreach ($decodedCurlResponse->groups as $grp) { + $this->groups[$grp->name] = $grp->group; + } } } From 6301ee802a64749f7e77369dc335086c8462993b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 05:17:31 +0200 Subject: [PATCH 03/29] missing use added #29 --- tests/Api/Groups/GroupTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Api/Groups/GroupTest.php b/tests/Api/Groups/GroupTest.php index 7cc5f10..4e35b59 100644 --- a/tests/Api/Groups/GroupTest.php +++ b/tests/Api/Groups/GroupTest.php @@ -16,6 +16,7 @@ use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\Response\CreateGroupResponse; use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; +use Serhiy\Pushover\Client\Response\ListGroupResponse; /** * @author Serhiy Lunak From 12ad4c515a3dc60de7cba33829338b8ebaf71ac0 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Mon, 12 Aug 2024 12:15:54 +0200 Subject: [PATCH 04/29] Update tests/Client/GroupsClientTest.php Co-authored-by: Oskar Stark --- tests/Client/GroupsClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/GroupsClientTest.php b/tests/Client/GroupsClientTest.php index 341ec20..a8e55a8 100644 --- a/tests/Client/GroupsClientTest.php +++ b/tests/Client/GroupsClientTest.php @@ -46,7 +46,7 @@ public function testBuildApiUrl() $this->assertEquals("https://api.pushover.net/1/groups/eeee5555EEEE5555ffff6666FFFF66/add_user.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); $client = new GroupsClient($group, GroupsClient::ACTION_LIST_GROUPS); - $this->assertEquals("https://api.pushover.net/1/groups.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); + $this->assertSame("https://api.pushover.net/1/groups.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); } From 1e4e28b7ef23bd12129f9545e7b793e5309432f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 12:16:26 +0200 Subject: [PATCH 05/29] ListGroupResponse.php renamed to ListGroupsResponse.php Phpdoc update (thanks to @OskarStark) better Example (thanks to @slunak) --- Example/GroupsExample.php | 4 +++- src/Api/Groups/Group.php | 6 +++--- .../{ListGroupResponse.php => ListGroupsResponse.php} | 9 +++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) rename src/Client/Response/{ListGroupResponse.php => ListGroupsResponse.php} (84%) diff --git a/Example/GroupsExample.php b/Example/GroupsExample.php index 6e941bf..4b60d25 100644 --- a/Example/GroupsExample.php +++ b/Example/GroupsExample.php @@ -42,7 +42,9 @@ public function groupsExample() $newGroupKey = $createGroupResponse->getGroupKey(); // Obtain list of all groups - $currentGroups = $group->list(); + $listGroupsResponse = $group->list(); + /** @var array $groups ['name'=>'key','name2'=>'key2'] */ + $groups = $listGroupsResponse->getGroups(); // Retrieve information about the group from the API and populate the object with it. /** @var RetrieveGroupResponse $retrieveGroupResponse */ diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index 0915a4c..fb4b682 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -17,7 +17,7 @@ use Serhiy\Pushover\Client\Request\Request; use Serhiy\Pushover\Client\Response\AddUserToGroupResponse; use Serhiy\Pushover\Client\Response\CreateGroupResponse; -use Serhiy\Pushover\Client\Response\ListGroupResponse; +use Serhiy\Pushover\Client\Response\ListGroupsResponse; use Serhiy\Pushover\Client\Response\DisableUserInGroupResponse; use Serhiy\Pushover\Client\Response\EnableUserInGroupResponse; use Serhiy\Pushover\Client\Response\RemoveUserFromGroupResponse; @@ -149,14 +149,14 @@ public function create(string $name): CreateGroupResponse /** * List the groups. */ - public function list(): ListGroupResponse + public function list(): ListGroupsResponse { $client = new GroupsClient($this, GroupsClient::ACTION_LIST_GROUPS); $request = new Request($client->buildApiUrl(), Request::GET); $curlResponse = Curl::do($request); - $response = new ListGroupResponse($curlResponse); + $response = new ListGroupsResponse($curlResponse); $response->setRequest($request); return $response; diff --git a/src/Client/Response/ListGroupResponse.php b/src/Client/Response/ListGroupsResponse.php similarity index 84% rename from src/Client/Response/ListGroupResponse.php rename to src/Client/Response/ListGroupsResponse.php index 7cf7171..b92840c 100644 --- a/src/Client/Response/ListGroupResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -14,9 +14,9 @@ use Serhiy\Pushover\Client\Response\Base\Response; /** - * @author Serhiy Lunak + * @author Vítězslav Dvořák */ -class ListGroupResponse extends Response +class ListGroupsResponse extends Response { /** * @var array @@ -45,6 +45,11 @@ private function processCurlResponse($curlResponse): void } } + /** + * List of groups + * + * @return array group names with keys eg.['name'=>'key',..] + */ public function getGroups(): array { return $this->groups; From 0115681092e03ab881ebd44bf4f3bd436427f7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 12:20:34 +0200 Subject: [PATCH 06/29] php-cs-fixer fix src used --- src/Client/Response/ListGroupsResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index b92840c..26a9335 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -47,7 +47,7 @@ private function processCurlResponse($curlResponse): void /** * List of groups - * + * * @return array group names with keys eg.['name'=>'key',..] */ public function getGroups(): array From 6f9e012383d7372699ccbabbfae138c12f06e54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 13:31:30 +0200 Subject: [PATCH 07/29] Group and GroupTest fix --- src/Api/Groups/Group.php | 2 +- tests/Api/Groups/GroupTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index fb4b682..8027a8b 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -147,7 +147,7 @@ public function create(string $name): CreateGroupResponse } /** - * List the groups. + * List groups. */ public function list(): ListGroupsResponse { diff --git a/tests/Api/Groups/GroupTest.php b/tests/Api/Groups/GroupTest.php index 4e35b59..5b84ad4 100644 --- a/tests/Api/Groups/GroupTest.php +++ b/tests/Api/Groups/GroupTest.php @@ -16,7 +16,7 @@ use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\Response\CreateGroupResponse; use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; -use Serhiy\Pushover\Client\Response\ListGroupResponse; +use Serhiy\Pushover\Client\Response\ListGroupsResponse; /** * @author Serhiy Lunak @@ -91,7 +91,7 @@ public function testList() $response = $group->list(); - $this->assertInstanceOf(ListGroupResponse::class, $response); + $this->assertInstanceOf(ListGroupsResponse::class, $response); } } From 0c32fd9190aef3edb32928ff5bf0881008b552c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 13:57:41 +0200 Subject: [PATCH 08/29] The api response parsing to array of groups test. --- .../Response/ListGroupsResponseTest.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/Client/Response/ListGroupsResponseTest.php diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php new file mode 100644 index 0000000..38560f8 --- /dev/null +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Client\Response; + +use Serhiy\Pushover\Client\Response\ListGroupsResponse; +use PHPUnit\Framework\TestCase; +use Serhiy\Pushover\Recipient; + +class ListGroupsResponseTest extends TestCase +{ + /** + * @return RetrieveGroupResponse + */ + public function testCanBeCreated(): RetrieveGroupResponse + { + $successfulCurlResponse = '{"groups":[{"group":"111111111111111111111111111111","name":"Group1"},{"group":"222222222222222222222222222222","name":"group2"},{"group":"333333333333333333333333333333","name":"Group 3"}],"status":1,"request":"aaaaaaaa-1111-bbbb-2222-cccccccccccc"}'; + $response = new ListGroupsResponse($successfulCurlResponse); + + $this->assertInstanceOf(ListGroupsResponse::class, $response); + $this->assertFalse($response->isSuccessful()); + $this->assertEquals("aaaaaaaa-1111-bbbb-2222-cccccccccccc", $response->getRequestToken()); + return $response; + } + + + /** + * @depends testCanBeCreated + * @param ListGroupsResponse $response + */ + public function testGetGroups(RetrieveGroupResponse $response) + { + $groups = $response->getGroups(); + $this->assertEquals($groups,['Group1'=>'111111111111111111111111111111','group2'=>'222222222222222222222222222222', 'Group 3'=>'333333333333333333333333333333']); + } +} From 9a601cedd8f8cc0fa2b80d675c10f4271eb81e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 14:01:44 +0200 Subject: [PATCH 09/29] cs fixer used --- tests/Client/Response/ListGroupsResponseTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 38560f8..786241d 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -17,7 +17,7 @@ class ListGroupsResponseTest extends TestCase { - /** + /** * @return RetrieveGroupResponse */ public function testCanBeCreated(): RetrieveGroupResponse @@ -26,7 +26,7 @@ public function testCanBeCreated(): RetrieveGroupResponse $response = new ListGroupsResponse($successfulCurlResponse); $this->assertInstanceOf(ListGroupsResponse::class, $response); - $this->assertFalse($response->isSuccessful()); + $this->assertTrue($response->isSuccessful()); $this->assertEquals("aaaaaaaa-1111-bbbb-2222-cccccccccccc", $response->getRequestToken()); return $response; } @@ -35,10 +35,10 @@ public function testCanBeCreated(): RetrieveGroupResponse /** * @depends testCanBeCreated * @param ListGroupsResponse $response - */ + */ public function testGetGroups(RetrieveGroupResponse $response) { $groups = $response->getGroups(); - $this->assertEquals($groups,['Group1'=>'111111111111111111111111111111','group2'=>'222222222222222222222222222222', 'Group 3'=>'333333333333333333333333333333']); + $this->assertEquals($groups, ['Group1'=>'111111111111111111111111111111','group2'=>'222222222222222222222222222222', 'Group 3'=>'333333333333333333333333333333']); } } From 959246ba3e7374c751b516d5091f4aa8624e3177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 14:03:41 +0200 Subject: [PATCH 10/29] returned class fix --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 786241d..c9ed5bb 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -20,7 +20,7 @@ class ListGroupsResponseTest extends TestCase /** * @return RetrieveGroupResponse */ - public function testCanBeCreated(): RetrieveGroupResponse + public function testCanBeCreated(): ListGroupsResponse { $successfulCurlResponse = '{"groups":[{"group":"111111111111111111111111111111","name":"Group1"},{"group":"222222222222222222222222222222","name":"group2"},{"group":"333333333333333333333333333333","name":"Group 3"}],"status":1,"request":"aaaaaaaa-1111-bbbb-2222-cccccccccccc"}'; $response = new ListGroupsResponse($successfulCurlResponse); From ba9e3c7228853cec149324067d34a5752dc0421f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Mon, 12 Aug 2024 14:05:34 +0200 Subject: [PATCH 11/29] argument type fix --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index c9ed5bb..3c0641e 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -36,7 +36,7 @@ public function testCanBeCreated(): ListGroupsResponse * @depends testCanBeCreated * @param ListGroupsResponse $response */ - public function testGetGroups(RetrieveGroupResponse $response) + public function testGetGroups(ListGroupsResponse $response) { $groups = $response->getGroups(); $this->assertEquals($groups, ['Group1'=>'111111111111111111111111111111','group2'=>'222222222222222222222222222222', 'Group 3'=>'333333333333333333333333333333']); From 8ebf1f6a332aaebb82560fa478bbda39a9cde100 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Mon, 26 Aug 2024 02:22:09 +0200 Subject: [PATCH 12/29] Update PHPDoc for Group.php old syntax phpdoc comments removal --- src/Api/Groups/Group.php | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index fa26a2c..35b198c 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -73,7 +73,7 @@ public function __construct(string $key, Application $application) } /** - * @return string + * Get key for current group */ public function getKey(): string { @@ -89,6 +89,8 @@ public function getApplication(): Application } /** + * Users assigned to group + * * @return Recipient[] */ public function getUsers(): array @@ -97,7 +99,7 @@ public function getUsers(): array } /** - * @return string + * group Name */ public function getName(): string { @@ -106,8 +108,6 @@ public function getName(): string /** * Retrieves information about the group from the API and populates the object with it. - * - * @return RetrieveGroupResponse */ public function retrieveGroupInformation(): RetrieveGroupResponse { @@ -147,9 +147,6 @@ public function create(string $name): CreateGroupResponse /** * Adds an existing Pushover user to your Delivery Group. - * - * @param Recipient $recipient - * @return AddUserToGroupResponse */ public function addUser(Recipient $recipient) { @@ -166,9 +163,6 @@ public function addUser(Recipient $recipient) /** * Removes user to from Delivery Group. - * - * @param Recipient $recipient - * @return RemoveUserFromGroupResponse */ public function removeUser(Recipient $recipient): RemoveUserFromGroupResponse { @@ -185,9 +179,6 @@ public function removeUser(Recipient $recipient): RemoveUserFromGroupResponse /** * Enables user in Delivery Group. - * - * @param Recipient $recipient - * @return EnableUserInGroupResponse */ public function enableUser(Recipient $recipient): EnableUserInGroupResponse { @@ -204,9 +195,6 @@ public function enableUser(Recipient $recipient): EnableUserInGroupResponse /** * Disables user in Delivery Group. - * - * @param Recipient $recipient - * @return DisableUserInGroupResponse */ public function disableUser(Recipient $recipient): DisableUserInGroupResponse { @@ -223,9 +211,6 @@ public function disableUser(Recipient $recipient): DisableUserInGroupResponse /** * Renames the group. Reflected in the API and in the group editor on our website. - * - * @param string $name - * @return RenameGroupResponse */ public function rename(string $name): RenameGroupResponse { From df1719c6cc9a6af3498aeaf3c7aa9aaf96d26206 Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Mon, 26 Aug 2024 02:25:42 +0200 Subject: [PATCH 13/29] comments must be max 80 characters per line long --- src/Api/Groups/Group.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index 0c9895b..944ca98 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -31,10 +31,13 @@ /** * Pushover Delivery Group. * - * Delivery Groups allow broadcasting the same Pushover message to a number of different users at once with just a single group token, - * used in place of a user token (or in place of specifying multiple user keys in every request). For situations where subscriptions are not appropriate, - * or where automated manipulation of group members is required, such as changing an on-call notification group, - * or syncing with an external directory system, our Groups API is available. + * Delivery Groups allow broadcasting the same Pushover message to a number of + * different users at once with just a single group token, used in place of a + * user token (or in place of specifying multiple user keys in every request). + * For situations where subscriptions are not appropriate, or where automated + * manipulation of group members is required, such as changing an on-call + * notification group, or syncing with an external directory system, our Groups + * API is available. * * @author Serhiy Lunak */ From ec4fb11b7a57710e86adc80929037d96896238f7 Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Mon, 26 Aug 2024 02:30:40 +0200 Subject: [PATCH 14/29] missing variable for $group added --- src/Client/GroupsClient.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index 8a7c809..cad0d70 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -37,6 +37,11 @@ class GroupsClient extends Client implements ClientInterface */ private string $action; + /** + * @var Group + */ + private $group; + public function __construct(Group $group, string $action) { if (!$this->isActionValid($action)) { From 5da533649418e77a090e178658123e8873c1b6e3 Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Mon, 26 Aug 2024 02:34:53 +0200 Subject: [PATCH 15/29] ListGroupsResponseTest phpdoc fix --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 3c0641e..450bc23 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -18,7 +18,7 @@ class ListGroupsResponseTest extends TestCase { /** - * @return RetrieveGroupResponse + * prepare ListGroupsResponse Test */ public function testCanBeCreated(): ListGroupsResponse { From cb274ca6a2681240ac8faf2cef7243cb0da98921 Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Wed, 28 Aug 2024 09:15:51 +0200 Subject: [PATCH 16/29] php-cs-fixer used --- src/Api/Groups/Group.php | 15 ++++----- src/Client/GroupsClient.php | 33 +++++++++---------- src/Client/Response/Base/Response.php | 4 +-- src/Client/Response/ListGroupsResponse.php | 30 ++++++++--------- tests/Api/Groups/GroupTest.php | 15 ++++----- tests/Client/GroupsClientTest.php | 6 ++-- .../Response/ListGroupsResponseTest.php | 18 +++++----- 7 files changed, 57 insertions(+), 64 deletions(-) diff --git a/src/Api/Groups/Group.php b/src/Api/Groups/Group.php index 3efc59e..e87c6c0 100644 --- a/src/Api/Groups/Group.php +++ b/src/Api/Groups/Group.php @@ -19,9 +19,9 @@ use Serhiy\Pushover\Client\Request\Request; use Serhiy\Pushover\Client\Response\AddUserToGroupResponse; use Serhiy\Pushover\Client\Response\CreateGroupResponse; -use Serhiy\Pushover\Client\Response\ListGroupsResponse; use Serhiy\Pushover\Client\Response\DisableUserInGroupResponse; use Serhiy\Pushover\Client\Response\EnableUserInGroupResponse; +use Serhiy\Pushover\Client\Response\ListGroupsResponse; use Serhiy\Pushover\Client\Response\RemoveUserFromGroupResponse; use Serhiy\Pushover\Client\Response\RenameGroupResponse; use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; @@ -31,11 +31,11 @@ /** * Pushover Delivery Group. * - * Delivery Groups allow broadcasting the same Pushover message to a number of - * different users at once with just a single group token, used in place of a - * user token (or in place of specifying multiple user keys in every request). - * For situations where subscriptions are not appropriate, or where automated - * manipulation of group members is required, such as changing an on-call + * Delivery Groups allow broadcasting the same Pushover message to a number of + * different users at once with just a single group token, used in place of a + * user token (or in place of specifying multiple user keys in every request). + * For situations where subscriptions are not appropriate, or where automated + * manipulation of group members is required, such as changing an on-call * notification group, or syncing with an external directory system, our Groups * API is available. * @@ -155,8 +155,7 @@ public function list(): ListGroupsResponse return $response; } - - + /** * Adds an existing Pushover user to your Delivery Group. */ diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index cad0d70..dce2182 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -23,25 +23,22 @@ */ class GroupsClient extends Client implements ClientInterface { - public const ACTION_RETRIEVE_GROUP = "retrieve_group"; - public const ACTION_ADD_USER = "add_user"; - public const ACTION_REMOVE_USER = "delete_user"; - public const ACTION_DISABLE_USER = "disable_user"; - public const ACTION_ENABLE_USER = "enable_user"; - public const ACTION_RENAME_GROUP = "rename"; - public const ACTION_CREATE_GROUP = "create"; - public const ACTION_LIST_GROUPS = "list"; + public const ACTION_RETRIEVE_GROUP = 'retrieve_group'; + public const ACTION_ADD_USER = 'add_user'; + public const ACTION_REMOVE_USER = 'delete_user'; + public const ACTION_DISABLE_USER = 'disable_user'; + public const ACTION_ENABLE_USER = 'enable_user'; + public const ACTION_RENAME_GROUP = 'rename'; + public const ACTION_CREATE_GROUP = 'create'; + public const ACTION_LIST_GROUPS = 'list'; /** * Action that client performs. */ private string $action; - /** - * @var Group - */ - private $group; - + private Group $group; + public function __construct(Group $group, string $action) { if (!$this->isActionValid($action)) { @@ -61,12 +58,12 @@ public function buildApiUrl() return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/groups.json'; } - if ($this->action == self::ACTION_LIST_GROUPS) { - return Curl::API_BASE_URL."/".Curl::API_VERSION."/groups.json?token=".$this->group->getApplication()->getToken(); + if ($this->action === self::ACTION_LIST_GROUPS) { + return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/groups.json?token='.$this->group->getApplication()->getToken(); } - - if ($this->action == self::ACTION_RETRIEVE_GROUP) { - return Curl::API_BASE_URL."/".Curl::API_VERSION."/groups/".$this->group->getKey().".json?token=".$this->group->getApplication()->getToken(); + + if ($this->action === self::ACTION_RETRIEVE_GROUP) { + return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/groups/'.$this->group->getKey().'.json?token='.$this->group->getApplication()->getToken(); } return Curl::API_BASE_URL.'/'.Curl::API_VERSION.'/groups/'.$this->group->getKey().'/'.$this->action.'.json?token='.$this->group->getApplication()->getToken(); diff --git a/src/Client/Response/Base/Response.php b/src/Client/Response/Base/Response.php index 2a58e3e..b3e3b5c 100644 --- a/src/Client/Response/Base/Response.php +++ b/src/Client/Response/Base/Response.php @@ -44,10 +44,8 @@ class Response /** * Original curl response in json format. * Original, unmodified response from curl request. - * - * @var mixed */ - private $curlResponse; + private mixed $curlResponse; /** * Array detailing which parameters were invalid. diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index 26a9335..b268e87 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -1,6 +1,8 @@ @@ -18,10 +20,7 @@ */ class ListGroupsResponse extends Response { - /** - * @var array - */ - public $groups = []; + public array $groups = []; /** * @param mixed $curlResponse @@ -31,6 +30,16 @@ public function __construct($curlResponse) $this->processCurlResponse($curlResponse); } + /** + * List of groups. + * + * @return array group names with keys eg.['name'=>'key',..] + */ + public function getGroups(): array + { + return $this->groups; + } + /** * @param mixed $curlResponse */ @@ -38,20 +47,11 @@ private function processCurlResponse($curlResponse): void { $this->groups = []; $decodedCurlResponse = $this->processInitialCurlResponse($curlResponse); + if (property_exists($decodedCurlResponse, 'groups')) { foreach ($decodedCurlResponse->groups as $grp) { $this->groups[$grp->name] = $grp->group; } } } - - /** - * List of groups - * - * @return array group names with keys eg.['name'=>'key',..] - */ - public function getGroups(): array - { - return $this->groups; - } } diff --git a/tests/Api/Groups/GroupTest.php b/tests/Api/Groups/GroupTest.php index 4e66e37..b61fdbb 100644 --- a/tests/Api/Groups/GroupTest.php +++ b/tests/Api/Groups/GroupTest.php @@ -17,8 +17,8 @@ use Serhiy\Pushover\Api\Groups\Group; use Serhiy\Pushover\Application; use Serhiy\Pushover\Client\Response\CreateGroupResponse; -use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; use Serhiy\Pushover\Client\Response\ListGroupsResponse; +use Serhiy\Pushover\Client\Response\RetrieveGroupResponse; /** * @author Serhiy Lunak @@ -76,19 +76,18 @@ public function testCreate(): void $response = $group->create('unit test '.date('Y-m-d H:i:s')); $this->assertInstanceOf(CreateGroupResponse::class, $response); - } - + } + /** * @group Integration */ - public function testList() + public function testList(): void { - $application = new Application("cccc3333CCCC3333dddd4444DDDD44"); // using dummy token - $group = new Group("eeee5555EEEE5555ffff6666FFFF66", $application); + $application = new Application('cccc3333CCCC3333dddd4444DDDD44'); // using dummy token + $group = new Group('eeee5555EEEE5555ffff6666FFFF66', $application); $response = $group->list(); $this->assertInstanceOf(ListGroupsResponse::class, $response); - } - + } } diff --git a/tests/Client/GroupsClientTest.php b/tests/Client/GroupsClientTest.php index 8bf21bc..b5e23c0 100644 --- a/tests/Client/GroupsClientTest.php +++ b/tests/Client/GroupsClientTest.php @@ -45,10 +45,10 @@ public function testBuildApiUrl(): void $this->assertEquals('https://api.pushover.net/1/groups/eeee5555EEEE5555ffff6666FFFF66.json?token=cccc3333CCCC3333dddd4444DDDD44', $client->buildApiUrl()); $client = new GroupsClient($group, GroupsClient::ACTION_ADD_USER); - $this->assertEquals("https://api.pushover.net/1/groups/eeee5555EEEE5555ffff6666FFFF66/add_user.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); - + $this->assertEquals('https://api.pushover.net/1/groups/eeee5555EEEE5555ffff6666FFFF66/add_user.json?token=cccc3333CCCC3333dddd4444DDDD44', $client->buildApiUrl()); + $client = new GroupsClient($group, GroupsClient::ACTION_LIST_GROUPS); - $this->assertSame("https://api.pushover.net/1/groups.json?token=cccc3333CCCC3333dddd4444DDDD44", $client->buildApiUrl()); + $this->assertSame('https://api.pushover.net/1/groups.json?token=cccc3333CCCC3333dddd4444DDDD44', $client->buildApiUrl()); } public function testBuildCurlPostFields(): void diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 450bc23..107636b 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -1,6 +1,8 @@ @@ -11,14 +13,13 @@ namespace Client\Response; -use Serhiy\Pushover\Client\Response\ListGroupsResponse; use PHPUnit\Framework\TestCase; -use Serhiy\Pushover\Recipient; +use Serhiy\Pushover\Client\Response\ListGroupsResponse; class ListGroupsResponseTest extends TestCase { /** - * prepare ListGroupsResponse Test + * prepare ListGroupsResponse Test. */ public function testCanBeCreated(): ListGroupsResponse { @@ -27,18 +28,17 @@ public function testCanBeCreated(): ListGroupsResponse $this->assertInstanceOf(ListGroupsResponse::class, $response); $this->assertTrue($response->isSuccessful()); - $this->assertEquals("aaaaaaaa-1111-bbbb-2222-cccccccccccc", $response->getRequestToken()); + $this->assertEquals('aaaaaaaa-1111-bbbb-2222-cccccccccccc', $response->getRequestToken()); + return $response; } - /** * @depends testCanBeCreated - * @param ListGroupsResponse $response */ - public function testGetGroups(ListGroupsResponse $response) + public function testGetGroups(ListGroupsResponse $response): void { $groups = $response->getGroups(); - $this->assertEquals($groups, ['Group1'=>'111111111111111111111111111111','group2'=>'222222222222222222222222222222', 'Group 3'=>'333333333333333333333333333333']); + $this->assertEquals($groups, ['Group1' => '111111111111111111111111111111', 'group2' => '222222222222222222222222222222', 'Group 3' => '333333333333333333333333333333']); } } From 9ed03b2ed1312e4dd4b0fb8eb69a8a539ac5d31e Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:21:51 +0200 Subject: [PATCH 17/29] Update Example/GroupsExample.php Co-authored-by: Oskar Stark --- Example/GroupsExample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/GroupsExample.php b/Example/GroupsExample.php index 4b60d25..ae50497 100644 --- a/Example/GroupsExample.php +++ b/Example/GroupsExample.php @@ -43,7 +43,7 @@ public function groupsExample() // Obtain list of all groups $listGroupsResponse = $group->list(); - /** @var array $groups ['name'=>'key','name2'=>'key2'] */ + /** @var array $groups ['name' => 'key', 'name2' => 'key2'] */ $groups = $listGroupsResponse->getGroups(); // Retrieve information about the group from the API and populate the object with it. From 2579c062d79c93805e1ebf625592d3a8f64b254d Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:22:07 +0200 Subject: [PATCH 18/29] Update tests/Client/Response/ListGroupsResponseTest.php Co-authored-by: Oskar Stark --- tests/Client/Response/ListGroupsResponseTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 107636b..0710016 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -18,9 +18,6 @@ class ListGroupsResponseTest extends TestCase { - /** - * prepare ListGroupsResponse Test. - */ public function testCanBeCreated(): ListGroupsResponse { $successfulCurlResponse = '{"groups":[{"group":"111111111111111111111111111111","name":"Group1"},{"group":"222222222222222222222222222222","name":"group2"},{"group":"333333333333333333333333333333","name":"Group 3"}],"status":1,"request":"aaaaaaaa-1111-bbbb-2222-cccccccccccc"}'; From c7d8ba6069524f6193fc803269ded640d9def175 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:22:26 +0200 Subject: [PATCH 19/29] Update src/Client/GroupsClient.php Co-authored-by: Oskar Stark --- src/Client/GroupsClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index fbf2ed2..9a0c888 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -30,7 +30,7 @@ class GroupsClient extends Client implements ClientInterface public const ACTION_ENABLE_USER = 'enable_user'; public const ACTION_RENAME_GROUP = 'rename'; public const ACTION_CREATE_GROUP = 'create'; - public const ACTION_LIST_GROUPS = 'list'; + private const ACTION_LIST_GROUPS = 'list'; /** * Action that client performs. From dcfcf5b8a60a1eda060d5026f5ce061148fd06b8 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:22:50 +0200 Subject: [PATCH 20/29] Update tests/Client/Response/ListGroupsResponseTest.php Co-authored-by: Oskar Stark --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 0710016..23e7b5d 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -36,6 +36,6 @@ public function testCanBeCreated(): ListGroupsResponse public function testGetGroups(ListGroupsResponse $response): void { $groups = $response->getGroups(); - $this->assertEquals($groups, ['Group1' => '111111111111111111111111111111', 'group2' => '222222222222222222222222222222', 'Group 3' => '333333333333333333333333333333']); + $this->assertSame($groups, ['Group1' => '111111111111111111111111111111', 'group2' => '222222222222222222222222222222', 'Group 3' => '333333333333333333333333333333']); } } From 3a2b4bd147c801915743bcac36c33bc1a5637f03 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:23:01 +0200 Subject: [PATCH 21/29] Update tests/Client/Response/ListGroupsResponseTest.php Co-authored-by: Oskar Stark --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index 23e7b5d..b9f54b2 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use Serhiy\Pushover\Client\Response\ListGroupsResponse; -class ListGroupsResponseTest extends TestCase +final class ListGroupsResponseTest extends TestCase { public function testCanBeCreated(): ListGroupsResponse { From a0f23ac0d538b58e3e568a219abae823de0ac060 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:23:19 +0200 Subject: [PATCH 22/29] Update src/Client/Response/ListGroupsResponse.php Co-authored-by: Oskar Stark --- src/Client/Response/ListGroupsResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index b268e87..afed636 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -33,7 +33,7 @@ public function __construct($curlResponse) /** * List of groups. * - * @return array group names with keys eg.['name'=>'key',..] + * @return array group names with keys eg. ['name' => 'key', ...] */ public function getGroups(): array { From 8a034350e39d03921e1e73356779a9b0fb0e74eb Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:23:31 +0200 Subject: [PATCH 23/29] Update tests/Client/Response/ListGroupsResponseTest.php Co-authored-by: Oskar Stark --- tests/Client/Response/ListGroupsResponseTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Client/Response/ListGroupsResponseTest.php b/tests/Client/Response/ListGroupsResponseTest.php index b9f54b2..473733a 100644 --- a/tests/Client/Response/ListGroupsResponseTest.php +++ b/tests/Client/Response/ListGroupsResponseTest.php @@ -25,7 +25,7 @@ public function testCanBeCreated(): ListGroupsResponse $this->assertInstanceOf(ListGroupsResponse::class, $response); $this->assertTrue($response->isSuccessful()); - $this->assertEquals('aaaaaaaa-1111-bbbb-2222-cccccccccccc', $response->getRequestToken()); + $this->assertSame('aaaaaaaa-1111-bbbb-2222-cccccccccccc', $response->getRequestToken()); return $response; } From 9429ccee2df799d48db96696c7b59622ac1c75e5 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:23:43 +0200 Subject: [PATCH 24/29] Update src/Client/Response/ListGroupsResponse.php Co-authored-by: Oskar Stark --- src/Client/Response/ListGroupsResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index afed636..e017ff4 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -18,7 +18,7 @@ /** * @author Vítězslav Dvořák */ -class ListGroupsResponse extends Response +final class ListGroupsResponse extends Response { public array $groups = []; From 162e911ac4252f06dc7c183aa80161d384960e81 Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:23:58 +0200 Subject: [PATCH 25/29] Update src/Client/Response/ListGroupsResponse.php Co-authored-by: Oskar Stark --- src/Client/Response/ListGroupsResponse.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index e017ff4..a5eeae4 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -45,7 +45,6 @@ public function getGroups(): array */ private function processCurlResponse($curlResponse): void { - $this->groups = []; $decodedCurlResponse = $this->processInitialCurlResponse($curlResponse); if (property_exists($decodedCurlResponse, 'groups')) { From cba4a0592fe50829538a943e99f3faab7beaf4eb Mon Sep 17 00:00:00 2001 From: Cybervitexus Date: Wed, 28 Aug 2024 10:24:21 +0200 Subject: [PATCH 26/29] Update src/Client/Response/ListGroupsResponse.php Co-authored-by: Oskar Stark --- src/Client/Response/ListGroupsResponse.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index a5eeae4..7e88b9a 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -20,6 +20,7 @@ */ final class ListGroupsResponse extends Response { + /** @var array */ public array $groups = []; /** From 0e16a78bd124be1de95215b32b36906d04d34b4d Mon Sep 17 00:00:00 2001 From: Serhiy Lunak <8351121+slunak@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:51:44 +0100 Subject: [PATCH 27/29] Update src/Client/GroupsClient.php --- src/Client/GroupsClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index 9a0c888..fbf2ed2 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -30,7 +30,7 @@ class GroupsClient extends Client implements ClientInterface public const ACTION_ENABLE_USER = 'enable_user'; public const ACTION_RENAME_GROUP = 'rename'; public const ACTION_CREATE_GROUP = 'create'; - private const ACTION_LIST_GROUPS = 'list'; + public const ACTION_LIST_GROUPS = 'list'; /** * Action that client performs. From f79c224eb4fe86629cfdd887ae7d10a9951cbdb6 Mon Sep 17 00:00:00 2001 From: Serhiy Lunak Date: Wed, 28 Aug 2024 09:59:53 +0100 Subject: [PATCH 28/29] cs-fixer --- src/Client/Curl/Curl.php | 1 - src/Client/GroupsClient.php | 1 - src/Client/Response/ListGroupsResponse.php | 4 +++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Client/Curl/Curl.php b/src/Client/Curl/Curl.php index d41df29..3e3ea7d 100644 --- a/src/Client/Curl/Curl.php +++ b/src/Client/Curl/Curl.php @@ -24,7 +24,6 @@ class Curl { public const API_BASE_URL = 'https://api.pushover.net'; - public const API_VERSION = '1'; /** diff --git a/src/Client/GroupsClient.php b/src/Client/GroupsClient.php index d8c0cc1..469f77d 100644 --- a/src/Client/GroupsClient.php +++ b/src/Client/GroupsClient.php @@ -36,7 +36,6 @@ class GroupsClient extends Client implements ClientInterface * Action that client performs. */ private string $action; - private Group $group; public function __construct(Group $group, string $action) diff --git a/src/Client/Response/ListGroupsResponse.php b/src/Client/Response/ListGroupsResponse.php index 7e88b9a..e400c67 100644 --- a/src/Client/Response/ListGroupsResponse.php +++ b/src/Client/Response/ListGroupsResponse.php @@ -20,7 +20,9 @@ */ final class ListGroupsResponse extends Response { - /** @var array */ + /** + * @var array + */ public array $groups = []; /** From 7cad5e49fda7257a862034b3075600b1f18df03a Mon Sep 17 00:00:00 2001 From: Serhiy Lunak <8351121+slunak@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:01:16 +0100 Subject: [PATCH 29/29] Update src/Client/Response/Base/Response.php Co-authored-by: Oskar Stark --- src/Client/Response/Base/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/Response/Base/Response.php b/src/Client/Response/Base/Response.php index dc5ed5f..d97f07d 100644 --- a/src/Client/Response/Base/Response.php +++ b/src/Client/Response/Base/Response.php @@ -45,7 +45,7 @@ class Response * Original curl response in json format. * Original, unmodified response from curl request. */ - private mixed $curlResponse; + private string $curlResponse; /** * Array detailing which parameters were invalid.