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

Support for Members and Membership type, status and include objects #114

Merged
merged 9 commits into from
Feb 5, 2025

Conversation

seba-aln
Copy link
Contributor

@seba-aln seba-aln commented Feb 3, 2025

feat: Support for Members and Membership type, status and include objects

Extended functionality of Channel Members and User Membership. Now it's possible to use fine-grade includes and set member/membership status and type.

* @param string $ch
* @return $this
*/
public function channel($ch)

Choose a reason for hiding this comment

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

What about:
public function channel(string $ch): self
?

Copy link
Contributor Author

@seba-aln seba-aln Feb 3, 2025

Choose a reason for hiding this comment

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

fixed for uniformity

Choose a reason for hiding this comment

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

I would check all files in this PR for this unification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hopefully I didn't miss anything

protected bool $endpointAuthRequired = true;
protected string $endpointHttpMethod = PNHttpMethod::PATCH;
protected int $endpointOperationType = PNOperationType::PNRemoveMembersOperation;
protected string $endpointName = "ManageMembers";

Choose a reason for hiding this comment

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

Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep. it's to lower the amount of copypaste between files. Down at the bottom you see that I removed a lot of boilerplate methods and in the meantime in Endpoint class I expose the values through proper methods

Choose a reason for hiding this comment

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

ok

$this->endpointConnectTimeout = $this->pubnub->getConfiguration()->getNonSubscribeRequestTimeout();
$this->endpointRequestTimeout = $this->pubnub->getConfiguration()->getConnectTimeout();
}

/**
* @param string $ch
* @return $this

Choose a reason for hiding this comment

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

Shouldn't be:
public function channel(string $ch): self
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Choose a reason for hiding this comment

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

I would check all files in this PR for this unification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -35,6 +59,8 @@ public function channel($ch)

/**
* @param array $uuids
* @deprecated Use members() method
*
* @return $this
*/
public function uuids($uuids)

Choose a reason for hiding this comment

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

Shouldn't be:
public function uuids(array $uuids): self
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a bit more complex than just say it's an array (phpStan watches for doc block describing what type of input it should be and since it is deprecated I omited it

Choose a reason for hiding this comment

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

ok

* @param PNChannelMember[] $members
* @return $this
*/
public function members(array $members)

Choose a reason for hiding this comment

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

Shouldn't be:
public function members(array $members): self
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

$this->status = $status;
}

public function setchannel(string $channel): self

Choose a reason for hiding this comment

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

setChannel ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

return $this->custom;
}

public function getType(): string

Choose a reason for hiding this comment

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

What about:
public function getType(): ?string
public function getStatus(): ?string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}

/**
* @return string[] | \StdClass

Choose a reason for hiding this comment

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

Shouldn't be:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well not exactly because mixed says it can be a primitive type yet here we may have an array or an StdClass object so it's a bit more precise

/**
* @return string[]
*/
public function toArray()

Choose a reason for hiding this comment

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

What about:
public function toArray(): array
?

*/
function __construct($id, $name, $description, $custom = null, $updated = null, $eTag = null)
{
public function __construct(

Choose a reason for hiding this comment

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

What about:
public function __construct(
string $id,
string $name,
string $description,
mixed $custom = null,
?string $updated = null,
?string $eTag = null,
?string $status = null,
?string $type = null
)
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no. this object is made from a response so it would require more attention to do a proper strict typing, so I would leave the docblock type hints only

@seba-aln seba-aln force-pushed the feat/membership-type-and-status branch from 6725275 to d4fc4a1 Compare February 4, 2025 13:28
@seba-aln
Copy link
Contributor Author

seba-aln commented Feb 5, 2025

@pubnub-release-bot release

@seba-aln seba-aln merged commit c476491 into master Feb 5, 2025
8 checks passed
@seba-aln seba-aln deleted the feat/membership-type-and-status branch February 5, 2025 12:45
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants