Skip to content

Commit

Permalink
thnprijrwpjnt
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Jun 11, 2024
1 parent 20de5d8 commit ddc5636
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 22 deletions.
3 changes: 1 addition & 2 deletions src/PubNub/Endpoints/Push/AddChannelsToPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected function customParams()
];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
4 changes: 1 addition & 3 deletions src/PubNub/Endpoints/Push/ListPushProvisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
use PubNub\Enums\PNPushType;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\Push\PNPushListProvisionsResult;

class ListPushProvisions extends PushEndpoint
Expand All @@ -23,8 +22,7 @@ protected function customParams()
$params = [];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
5 changes: 5 additions & 0 deletions src/PubNub/Endpoints/Push/PushEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,9 @@ protected function getName()
{
return static::OPERATION_NAME;
}

protected function getPushType(): string
{
return $this->pushType == PNPushType::FCM ? 'gcm' : $this->pushType;
}
}
3 changes: 1 addition & 2 deletions src/PubNub/Endpoints/Push/RemoveChannelsFromPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ protected function customParams()
];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
4 changes: 1 addition & 3 deletions src/PubNub/Endpoints/Push/RemoveDeviceFromPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
use PubNub\Enums\PNPushType;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\Push\PNPushRemoveAllChannelsResult;

class RemoveDeviceFromPush extends PushEndpoint
Expand All @@ -24,8 +23,7 @@ protected function customParams()
$params = [];

if ($this->pushType != PNPushType::APNS2) {
// v1 push -> add type
$params['type'] = $this->pushType;
$params['type'] = $this->getPushType();
} else {
// apns2 push -> add topic and environment
$params['topic'] = $this->topic;
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/push/AddChannelsToPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function testPushAddFCM()
$this->assertEquals([
"pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()),
"uuid" => $this->pubnub->getConfiguration()->getUuid(),
"type" => "fcm",
"type" => "gcm",
"add" => "ch1,ch2,ch3"
], $add->buildParams());

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/push/ListPushProvisionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testListChannelGroupFCM()
$this->assertEquals([
"pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()),
"uuid" => $this->pubnub->getConfiguration()->getUuid(),
"type" => "fcm"
"type" => "gcm"
], $list->buildParams());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/push/RemoveChannelsFromPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testPushRemoveFCM()
$this->assertEquals([
"pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()),
"uuid" => $this->pubnub->getConfiguration()->getUuid(),
"type" => "fcm",
"type" => "gcm",
"remove" => "ch1,ch2,ch3"
], $remove->buildParams());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/push/RemoveDeviceFromPushTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testRemovePushFCM()
$this->assertEquals([
"pnsdk" => PubNubUtil::urlEncode(PubNub::getSdkFullName()),
"uuid" => $this->pubnub->getConfiguration()->getUuid(),
"type" => "fcm",
"type" => "gcm",
], $remove->buildParams());
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integrational/ListPushProvisionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testFCMSuccess()

$list->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"type" => "fcm",
"type" => "gcm",
"pnsdk" => $this->encodedSdkName,
"uuid" => "sampleUUID"
])
Expand Down
6 changes: 3 additions & 3 deletions tests/integrational/ModifyPushChannelsForDeviceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testFCMSuccessRemoveAll()

$listRemove->stubFor("/v1/push/sub-key/demo/devices/coolDevice/remove")
->withQuery([
"type" => "fcm",
"type" => "gcm",
"pnsdk" => $this->encodedSdkName,
"uuid" => "sampleUUID"
])
Expand Down Expand Up @@ -200,7 +200,7 @@ public function testAddFCMSuccessSync()
$listAdd->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"add" => "ch1,ch2,ch3",
"type" => "fcm",
"type" => "gcm",
"pnsdk" => $this->encodedSdkName,
"uuid" => "sampleUUID"
])
Expand Down Expand Up @@ -383,7 +383,7 @@ public function testFCMSuccessRemove()
$remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"remove" => "ch1,ch2,ch3",
"type" => "fcm",
"type" => "gcm",
"pnsdk" => $this->encodedSdkName,
"uuid" => "sampleUUID"
])
Expand Down
2 changes: 1 addition & 1 deletion tests/integrational/push/AddChannelsToPushEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testPushAddFCM()
->withQuery([
"pnsdk" => $this->encodedSdkName,
"add" => "ch1,ch2,ch3",
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testListChannelGroupFCM()
$list->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testPushRemoveFCM()
$remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
"remove" => "ch1,ch2,ch3"
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testRemovePushFCM()
$remove->stubFor("/v1/push/sub-key/demo/devices/coolDevice/remove")
->withQuery([
"pnsdk" => $this->encodedSdkName,
"type" => "fcm",
"type" => "gcm",
"uuid" => "sampleUUID",
])
->setResponseBody('[1, "Modified Channels"]');
Expand Down

0 comments on commit ddc5636

Please sign in to comment.