Skip to content

Commit

Permalink
Add include_subscription_ids support to NotificationResolver.php (#173)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
metaseller authored Oct 3, 2023
1 parent c8eb8f5 commit f7298c5
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function createRequest(string $method, string $uri): RequestInterface
}

/**
* @param mixed $value
* @param mixed $value String content with which to populate the stream
*
* @phpstan-param int<1, max> $maxDepth
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function getOne(string $id): array
*
* @param int $limit How many notifications to return (max 50)
* @param int $offset Results offset (results are sorted by ID)
* @param int $kind Kind of notifications returned. Default (not set) is all notification types
*
* @phpstan-param int $kind Kind of notifications returned. Default (not set) is all notification types
*/
public function getAll(int $limit = null, int $offset = null/* , int $kind = null */): array
{
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/AppOutcomesResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class AppOutcomesResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/AppResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class AppResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/DeviceFocusResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class DeviceFocusResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/DevicePurchaseResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class DevicePurchaseResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
$data = (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/DeviceResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function __construct(Config $config, bool $isNewDevice)
$this->isNewDevice = $isNewDevice;
}

/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
$resolver = (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/DeviceSessionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

class DeviceSessionResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/DeviceTagsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

class DeviceTagsResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/NotificationHistoryResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function __construct(Config $config)
$this->config = $config;
}

/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
7 changes: 3 additions & 4 deletions src/Resolver/NotificationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function __construct(Config $config)
$this->config = $config;
}

/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down Expand Up @@ -61,6 +58,8 @@ public function resolve(array $data): array
->setAllowedTypes('included_segments', 'array')
->setDefined('excluded_segments')
->setAllowedTypes('excluded_segments', 'array')
->setDefined('include_subscription_ids')
->setAllowedTypes('include_subscription_ids', 'array')
->setDefined('include_player_ids')
->setAllowedTypes('include_player_ids', 'array')
->setDefined('include_ios_tokens')
Expand Down Expand Up @@ -262,7 +261,7 @@ private function normalizeFilters(Options $options, array $values): array
}

/**
* @param mixed $value
* @param mixed $value Url value to filter
*/
private function filterUrl($value): bool
{
Expand Down
3 changes: 0 additions & 3 deletions src/Resolver/SegmentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

class SegmentResolver implements ResolverInterface
{
/**
* {@inheritdoc}
*/
public function resolve(array $data): array
{
return (new OptionsResolver())
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/notifications_get_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"id": "e664a747-324c-406a-bafb-ab51db71c960",
"include_player_ids": null,
"include_subscription_ids": null,
"include_external_user_ids": null,
"channel_for_external_user_ids": "push",
"included_segments": ["All"],
Expand Down
1 change: 1 addition & 0 deletions tests/NotificationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function testGetAll(): void
],
'id' => 'e664a747-324c-406a-bafb-ab51db71c960',
'include_player_ids' => null,
'include_subscription_ids' => null,
'include_external_user_ids' => null,
'channel_for_external_user_ids' => 'push',
'included_segments' => ['All'],
Expand Down
2 changes: 2 additions & 0 deletions tests/Resolver/NotificationResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function testResolveWithValidValues(): void
'included_segments' => ['value'],
'excluded_segments' => ['value'],
'include_player_ids' => ['value'],
'include_subscription_ids' => ['value'],
'include_ios_tokens' => ['value'],
'include_android_reg_ids' => ['value'],
'include_external_user_ids' => ['value'],
Expand Down Expand Up @@ -156,6 +157,7 @@ public function wrongValueTypesProvider(): iterable
yield [['included_segments' => 'wrongType']];
yield [['excluded_segments' => 'wrongType']];
yield [['include_player_ids' => 'wrongType']];
yield [['include_subscription_ids' => 'wrongType']];
yield [['include_ios_tokens' => 'wrongType']];
yield [['include_android_reg_ids' => 666]];
yield [['include_external_user_ids' => 666]];
Expand Down

0 comments on commit f7298c5

Please sign in to comment.