Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralize getMessageActions typo #113

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way you found a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. typical copy paste missed

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is not next to:
use PubNub\Endpoints\MessageActions\GetMessageActions;
?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autoimport messed this one up. fixed in new commit

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
Loading