-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from DJTommek/pr/api-type-updates
TelegramTypes updates
- Loading branch information
Showing
7 changed files
with
368 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
|
||
/** | ||
* Represents an invite link for a chat. | ||
* | ||
* @see https://core.telegram.org/bots/api#chatinvitelink | ||
*/ | ||
class ChatInviteLink extends TelegramTypes | ||
{ | ||
/** | ||
* The invite link. If the link was created by another chat administrator, then the second part of the link will be | ||
* replaced with “…”. | ||
* @var string | ||
*/ | ||
public $invite_link; | ||
|
||
/** | ||
* Creator of the link | ||
* @var User | ||
*/ | ||
public $creator; | ||
|
||
/** | ||
* True, if users joining the chat via the link need to be approved by chat administrators | ||
* @var bool | ||
*/ | ||
public $creates_join_request = false; | ||
|
||
/** | ||
* True, if the link is primary | ||
* @var bool | ||
*/ | ||
public $is_primary = false; | ||
|
||
/** | ||
* True, if the link is revoked | ||
* @var bool | ||
*/ | ||
public $is_revoked = false; | ||
|
||
/** | ||
* Optional. Invite link name | ||
* @var string | ||
*/ | ||
public $name; | ||
|
||
/** | ||
* Optional. Point in time (Unix timestamp) when the link will expire or has been expired | ||
* @var int | ||
*/ | ||
public $expire_date; | ||
|
||
/** | ||
* Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat via | ||
* this invite link; 1-99999 | ||
* @var int | ||
*/ | ||
public $member_limit; | ||
|
||
/** | ||
* Optional. Number of pending join requests created using this link | ||
* @var int | ||
*/ | ||
public $pending_join_request_count; | ||
|
||
public function mapSubObjects(string $key, array $data): TelegramTypes | ||
{ | ||
switch ($key) { | ||
case 'creator': | ||
return new User($data, $this->logger); | ||
} | ||
|
||
return parent::mapSubObjects($key, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
|
||
/** | ||
* Represents a join request sent to a chat. | ||
* | ||
* @see https://core.telegram.org/bots/api#chatjoinrequest | ||
*/ | ||
class ChatJoinRequest extends TelegramTypes | ||
{ | ||
/** | ||
* Chat to which the request was sent | ||
* | ||
* @var Chat | ||
*/ | ||
public $chat; | ||
|
||
/** | ||
* User that sent the join request | ||
* | ||
* @var User | ||
*/ | ||
public $from; | ||
|
||
/** | ||
* Identifier of a private chat with the user who sent the join request. The bot can use this identifier | ||
* for 24 hours to send messages until the join request is processed, assuming no other administrator contacted | ||
* the user. | ||
* | ||
* @var int | ||
*/ | ||
public $user_chat_id; | ||
|
||
/** | ||
* Date the request was sent in Unix time | ||
* | ||
* @var int | ||
*/ | ||
public $date; | ||
|
||
/** | ||
* Optional. Bio of the user. | ||
* | ||
* @var string | ||
*/ | ||
public $bio; | ||
|
||
/** | ||
* Optional. Chat invite link that was used by the user to send the join request | ||
* | ||
* @var ChatInviteLink | ||
*/ | ||
public $invite_link; | ||
|
||
public function mapSubObjects(string $key, array $data): TelegramTypes | ||
{ | ||
switch ($key) { | ||
case 'chat': | ||
return new Chat($data, $this->logger); | ||
case 'from': | ||
return new User($data, $this->logger); | ||
case 'invite_link': | ||
return new ChatInviteLink($data, $this->logger); | ||
} | ||
|
||
return parent::mapSubObjects($key, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace unreal4u\TelegramAPI\Telegram\Types; | ||
|
||
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; | ||
|
||
/** | ||
* This object represents changes in the status of a chat member. | ||
* | ||
* @see https://core.telegram.org/bots/api#chatmemberupdated | ||
*/ | ||
class ChatMemberUpdated extends TelegramTypes | ||
{ | ||
/** | ||
* Chat the user belongs to | ||
* @var Chat | ||
*/ | ||
public $chat; | ||
|
||
/** | ||
* Performer of the action, which resulted in the change | ||
* @var User | ||
*/ | ||
public $from; | ||
|
||
/** | ||
* Date the change was done in Unix time | ||
* @var int | ||
*/ | ||
public $date; | ||
|
||
/** | ||
* Previous information about the chat member | ||
* @var ChatMember | ||
*/ | ||
public $old_chat_member; | ||
|
||
/** | ||
* New information about the chat member | ||
* @var ChatMember | ||
*/ | ||
public $new_chat_member; | ||
|
||
/** | ||
* Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. | ||
* @var ChatInviteLink | ||
*/ | ||
public $invite_link; | ||
|
||
/** | ||
* Optional. True, if the user joined the chat via a chat folder invite link | ||
* @var bool | ||
*/ | ||
public $via_chat_folder_invite_link; | ||
|
||
public function mapSubObjects(string $key, array $data): TelegramTypes | ||
{ | ||
switch ($key) { | ||
case 'chat': | ||
return new Chat($data, $this->logger); | ||
case 'from': | ||
return new User($data, $this->logger); | ||
case 'old_chat_member': | ||
case 'new_chat_member': | ||
return new ChatMember($data, $this->logger); | ||
case 'invite_link': | ||
return new ChatInviteLink($data, $this->logger); | ||
} | ||
|
||
return parent::mapSubObjects($key, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.