Skip to content

Commit f7298c5

Browse files
authored
Add include_subscription_ids support to NotificationResolver.php (#173)
* Update NotificationResolver.php for support include_subscription_ids option see https://documentation.onesignal.com/reference/create-notification#send-to-specific-devices * Update notifications_get_all.json for support include_subscription_ids * Update NotificationResolverTest.php for support include_subscription_ids * Update NotificationsTest.php * test typo * typo * typo * codestyle * CodeStyle * cs-fixer * phpDoc * Update PHPDOC * phpdoc
1 parent c8eb8f5 commit f7298c5

15 files changed

+10
-33
lines changed

src/AbstractApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function createRequest(string $method, string $uri): RequestInterface
3232
}
3333

3434
/**
35-
* @param mixed $value
35+
* @param mixed $value String content with which to populate the stream
3636
*
3737
* @phpstan-param int<1, max> $maxDepth
3838
*/

src/Notifications.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function getOne(string $id): array
4242
*
4343
* @param int $limit How many notifications to return (max 50)
4444
* @param int $offset Results offset (results are sorted by ID)
45-
* @param int $kind Kind of notifications returned. Default (not set) is all notification types
45+
*
46+
* @phpstan-param int $kind Kind of notifications returned. Default (not set) is all notification types
4647
*/
4748
public function getAll(int $limit = null, int $offset = null/* , int $kind = null */): array
4849
{

src/Resolver/AppOutcomesResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
class AppOutcomesResolver implements ResolverInterface
1313
{
14-
/**
15-
* {@inheritdoc}
16-
*/
1714
public function resolve(array $data): array
1815
{
1916
return (new OptionsResolver())

src/Resolver/AppResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
class AppResolver implements ResolverInterface
1010
{
11-
/**
12-
* {@inheritdoc}
13-
*/
1411
public function resolve(array $data): array
1512
{
1613
return (new OptionsResolver())

src/Resolver/DeviceFocusResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
class DeviceFocusResolver implements ResolverInterface
1010
{
11-
/**
12-
* {@inheritdoc}
13-
*/
1411
public function resolve(array $data): array
1512
{
1613
return (new OptionsResolver())

src/Resolver/DevicePurchaseResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
class DevicePurchaseResolver implements ResolverInterface
1010
{
11-
/**
12-
* {@inheritdoc}
13-
*/
1411
public function resolve(array $data): array
1512
{
1613
$data = (new OptionsResolver())

src/Resolver/DeviceResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public function __construct(Config $config, bool $isNewDevice)
1919
$this->isNewDevice = $isNewDevice;
2020
}
2121

22-
/**
23-
* {@inheritdoc}
24-
*/
2522
public function resolve(array $data): array
2623
{
2724
$resolver = (new OptionsResolver())

src/Resolver/DeviceSessionResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
class DeviceSessionResolver implements ResolverInterface
1111
{
12-
/**
13-
* {@inheritdoc}
14-
*/
1512
public function resolve(array $data): array
1613
{
1714
return (new OptionsResolver())

src/Resolver/DeviceTagsResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
class DeviceTagsResolver implements ResolverInterface
1010
{
11-
/**
12-
* {@inheritdoc}
13-
*/
1411
public function resolve(array $data): array
1512
{
1613
return (new OptionsResolver())

src/Resolver/NotificationHistoryResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public function __construct(Config $config)
1616
$this->config = $config;
1717
}
1818

19-
/**
20-
* {@inheritdoc}
21-
*/
2219
public function resolve(array $data): array
2320
{
2421
return (new OptionsResolver())

src/Resolver/NotificationResolver.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ public function __construct(Config $config)
2121
$this->config = $config;
2222
}
2323

24-
/**
25-
* {@inheritdoc}
26-
*/
2724
public function resolve(array $data): array
2825
{
2926
return (new OptionsResolver())
@@ -61,6 +58,8 @@ public function resolve(array $data): array
6158
->setAllowedTypes('included_segments', 'array')
6259
->setDefined('excluded_segments')
6360
->setAllowedTypes('excluded_segments', 'array')
61+
->setDefined('include_subscription_ids')
62+
->setAllowedTypes('include_subscription_ids', 'array')
6463
->setDefined('include_player_ids')
6564
->setAllowedTypes('include_player_ids', 'array')
6665
->setDefined('include_ios_tokens')
@@ -262,7 +261,7 @@ private function normalizeFilters(Options $options, array $values): array
262261
}
263262

264263
/**
265-
* @param mixed $value
264+
* @param mixed $value Url value to filter
266265
*/
267266
private function filterUrl($value): bool
268267
{

src/Resolver/SegmentResolver.php

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
class SegmentResolver implements ResolverInterface
1111
{
12-
/**
13-
* {@inheritdoc}
14-
*/
1512
public function resolve(array $data): array
1613
{
1714
return (new OptionsResolver())

tests/Fixtures/notifications_get_all.json

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
},
5353
"id": "e664a747-324c-406a-bafb-ab51db71c960",
5454
"include_player_ids": null,
55+
"include_subscription_ids": null,
5556
"include_external_user_ids": null,
5657
"channel_for_external_user_ids": "push",
5758
"included_segments": ["All"],

tests/NotificationsTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function testGetAll(): void
128128
],
129129
'id' => 'e664a747-324c-406a-bafb-ab51db71c960',
130130
'include_player_ids' => null,
131+
'include_subscription_ids' => null,
131132
'include_external_user_ids' => null,
132133
'channel_for_external_user_ids' => 'push',
133134
'included_segments' => ['All'],

tests/Resolver/NotificationResolverTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function testResolveWithValidValues(): void
4747
'included_segments' => ['value'],
4848
'excluded_segments' => ['value'],
4949
'include_player_ids' => ['value'],
50+
'include_subscription_ids' => ['value'],
5051
'include_ios_tokens' => ['value'],
5152
'include_android_reg_ids' => ['value'],
5253
'include_external_user_ids' => ['value'],
@@ -156,6 +157,7 @@ public function wrongValueTypesProvider(): iterable
156157
yield [['included_segments' => 'wrongType']];
157158
yield [['excluded_segments' => 'wrongType']];
158159
yield [['include_player_ids' => 'wrongType']];
160+
yield [['include_subscription_ids' => 'wrongType']];
159161
yield [['include_ios_tokens' => 'wrongType']];
160162
yield [['include_android_reg_ids' => 666]];
161163
yield [['include_external_user_ids' => 666]];

0 commit comments

Comments
 (0)