Skip to content

Commit

Permalink
Fix typo for singular getMessageActions
Browse files Browse the repository at this point in the history
  • Loading branch information
seba-aln committed Jan 9, 2025
1 parent 277ad5a commit 994ac54
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 15 deletions.
17 changes: 17 additions & 0 deletions src/PubNub/Endpoints/MessageActions/GetMessageAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace PubNub\Endpoints\MessageActions;

use PubNub\PubNub;
use PubNub\Endpoints\MessageActions\GetMessageActions;

// TODO: Remove in 8.0.0
/** @package PubNub\Endpoints\MessageActions */
class GetMessageAction extends GetMessageActions
{
public function __construct(PubNub $pubnub)
{
trigger_error("This class is deprecated. Please use GetMessageActions instead.", E_USER_DEPRECATED);
parent::__construct($pubnub);
}
}
14 changes: 7 additions & 7 deletions src/PubNub/Endpoints/MessageActions/GetMessageActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use PubNub\Enums\PNOperationType;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Exceptions\PubNubBuildRequestException;
use PubNub\Models\Consumer\MessageActions\PNGetMessageActionResult;
use PubNub\Models\Consumer\MessageActions\PNGetMessageActionsResult;

/** @package PubNub\Endpoints\MessageActions */
class GetMessageActions extends Endpoint
Expand All @@ -17,7 +17,7 @@ class GetMessageActions extends Endpoint
protected int $endpointConnectTimeout;
protected int $endpointRequestTimeout;
protected string $endpointHttpMethod = PNHttpMethod::GET;
protected int $endpointOperationType = PNOperationType::PNGetMessageActionOperation;
protected int $endpointOperationType = PNOperationType::PNGetMessageActionsOperation;
protected string $endpointName = "Get Message Actions";

protected const GET_PATH = "/v1/message-actions/%s/channel/%s";
Expand Down Expand Up @@ -135,19 +135,19 @@ protected function buildPath()
}

/**
* @return PNGetMessageActionResult
* @return PNGetMessageActionsResult
*/
public function sync(): PNGetMessageActionResult
public function sync(): PNGetMessageActionsResult
{
return parent::sync();
}

/**
* @param array<string, string> $json Decoded json
* @return PNGetMessageActionResult
* @return PNGetMessageActionsResult
*/
protected function createResponse($json): PNGetMessageActionResult
protected function createResponse($json): PNGetMessageActionsResult
{
return PNGetMessageActionResult::fromJson($json);
return PNGetMessageActionsResult::fromJson($json);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RemoveMessageAction extends Endpoint
protected int $endpointConnectTimeout;
protected int $endpointRequestTimeout;
protected string $endpointHttpMethod = PNHttpMethod::DELETE;
protected int $endpointOperationType = PNOperationType::PNGetMessageActionOperation;
protected int $endpointOperationType = PNOperationType::PNRemoveMessageActionOperation;
protected string $endpointName = "Get Message Actions";

protected const DELETE_PATH = "/v1/message-actions/%s/channel/%s/message/%s/action/%s";
Expand Down
3 changes: 2 additions & 1 deletion src/PubNub/Enums/PNOperationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ class PNOperationType
const PNSendFileNotification = 52;

const PNAddMessageActionOperation = 53;
const PNGetMessageActionOperation = 54;
const PNGetMessageActionsOperation = 54;
const PNRemoveMessageActionOperation = 55;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use PubNub\Models\Consumer\MessageActions\PNMessageAction;

class PNGetMessageActionResult extends PNMessageAction
class PNGetMessageActionsResult extends PNMessageAction
{
/**
*
Expand All @@ -15,7 +15,7 @@ class PNGetMessageActionResult extends PNMessageAction
/**
*
* @param mixed $json
* @return PNGetMessageActionResult
* @return PNGetMessageActionsResult
*/
public static function fromJson(mixed $json): self
{
Expand Down
9 changes: 9 additions & 0 deletions src/PubNub/PubNub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PubNub;

use Monolog\Logger;
use PHPUnit\Framework\Error\Deprecated;
use PubNub\Builders\SubscribeBuilder;
use PubNub\Callbacks\SubscribeCallback;
use PubNub\Endpoints\Access\Audit;
Expand Down Expand Up @@ -56,6 +57,7 @@
use Psr\Log\LoggerAwareInterface;
use Psr\Log\NullLogger;
use PubNub\Endpoints\FileSharing\{SendFile, DeleteFile, DownloadFile, GetFileDownloadUrl, ListFiles};
use PubNub\Endpoints\MessageActions\GetMessageAction;
use PubNub\Models\Consumer\AccessManager\PNAccessManagerTokenResult;

class PubNub implements LoggerAwareInterface
Expand Down Expand Up @@ -616,6 +618,13 @@ public function addMessageAction(): AddMessageAction
return new AddMessageAction($this);
}

// TODO: Remove in 8.0.0
public function getMessageAction(): GetMessageAction
{
trigger_error("This method is deprecated. Use getMessageActions()", E_USER_DEPRECATED);
return new GetMessageAction($this);
}

public function getMessageActions(): GetMessageActions
{
return new GetMessageActions($this);
Expand Down
8 changes: 4 additions & 4 deletions tests/integrational/MessageActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Tests\Integrational;

use PubNub\Models\Consumer\MessageActions\PNAddMessageActionResult;
use PubNub\Models\Consumer\MessageActions\PNGetMessageActionResult;
use PubNub\Models\Consumer\MessageActions\PNGetMessageActionsResult;
use PubNub\Models\Consumer\MessageActions\PNMessageAction;
use PubNub\Models\Consumer\MessageActions\PNRemoveMessageActionResult;

Expand Down Expand Up @@ -56,15 +56,15 @@ public function testAddMessageAction(): void
$this->assertEquals($this->messageTimetoken, $addMessageActionResult->messageTimetoken);
}

public function testGetMessageAction(): void
public function testGetMessageActions(): void
{
$addMessageActionResult = $this->addTestMessageAction();
$getMessageActionsResult = $this->pubnub->getMessageActions()
->channel($this->channelName)
->sync();

$this->assertNotNull($getMessageActionsResult);
$this->assertInstanceOf(PNGetMessageActionResult::class, $getMessageActionsResult);
$this->assertInstanceOf(PNGetMessageActionsResult::class, $getMessageActionsResult);
$this->assertNotEmpty($getMessageActionsResult->actions);
$this->assertCount(1, $getMessageActionsResult->actions);

Expand All @@ -85,7 +85,7 @@ public function testDeleteMessageAction(): void
->sync();

$this->assertNotNull($getMessageActionsResult);
$this->assertInstanceOf(PNGetMessageActionResult::class, $getMessageActionsResult);
$this->assertInstanceOf(PNGetMessageActionsResult::class, $getMessageActionsResult);
$this->assertNotEmpty($getMessageActionsResult->actions);
$this->assertCount(1, $getMessageActionsResult->actions);

Expand Down

0 comments on commit 994ac54

Please sign in to comment.