1919use BushlanovDev \MaxMessengerBot \Models \Attachments \Requests \PhotoAttachmentRequest ;
2020use BushlanovDev \MaxMessengerBot \Models \Attachments \Requests \VideoAttachmentRequest ;
2121use BushlanovDev \MaxMessengerBot \Models \BotInfo ;
22+ use BushlanovDev \MaxMessengerBot \Models \BotPatch ;
2223use BushlanovDev \MaxMessengerBot \Models \Chat ;
2324use BushlanovDev \MaxMessengerBot \Models \ChatAdmin ;
2425use BushlanovDev \MaxMessengerBot \Models \ChatList ;
2526use BushlanovDev \MaxMessengerBot \Models \ChatMember ;
2627use BushlanovDev \MaxMessengerBot \Models \ChatMembersList ;
28+ use BushlanovDev \MaxMessengerBot \Models \ChatPatch ;
2729use BushlanovDev \MaxMessengerBot \Models \Message ;
2830use BushlanovDev \MaxMessengerBot \Models \MessageLink ;
2931use BushlanovDev \MaxMessengerBot \Models \Result ;
3032use BushlanovDev \MaxMessengerBot \Models \Subscription ;
3133use BushlanovDev \MaxMessengerBot \Models \UpdateList ;
3234use BushlanovDev \MaxMessengerBot \Models \Updates \AbstractUpdate ;
3335use BushlanovDev \MaxMessengerBot \Models \UploadEndpoint ;
36+ use BushlanovDev \MaxMessengerBot \Models \VideoAttachmentDetails ;
3437use InvalidArgumentException ;
3538use LogicException ;
3639use Psr \Http \Message \ServerRequestInterface ;
@@ -51,7 +54,7 @@ class Api
5154 private const string METHOD_GET = 'GET ' ;
5255 private const string METHOD_POST = 'POST ' ;
5356 private const string METHOD_DELETE = 'DELETE ' ;
54- // private const string METHOD_PATCH = 'PATCH';
57+ private const string METHOD_PATCH = 'PATCH ' ;
5558 private const string METHOD_PUT = 'PUT ' ;
5659
5760 private const string ACTION_ME = '/me ' ;
@@ -67,6 +70,7 @@ class Api
6770 private const string ACTION_CHATS_MEMBERS = '/chats/%d/members ' ;
6871 private const string ACTION_UPDATES = '/updates ' ;
6972 private const string ACTION_ANSWERS = '/answers ' ;
73+ private const string ACTION_VIDEO_DETAILS = '/videos/%s ' ;
7074
7175 private readonly ClientApiInterface $ client ;
7276
@@ -1068,6 +1072,81 @@ public function editMessage(
10681072 );
10691073 }
10701074
1075+ /**
1076+ * Edits the bot info.
1077+ *
1078+ * Example: editBotInfo(new BotPatch(name: 'New Bot Name', description: null));
1079+ *
1080+ * @param BotPatch $botPatch
1081+ *
1082+ * @return BotInfo
1083+ * @throws ClientApiException
1084+ * @throws NetworkException
1085+ * @throws ReflectionException
1086+ * @throws SerializationException
1087+ */
1088+ public function editBotInfo (BotPatch $ botPatch ): BotInfo
1089+ {
1090+ return $ this ->modelFactory ->createBotInfo (
1091+ $ this ->client ->request (
1092+ self ::METHOD_PATCH ,
1093+ self ::ACTION_ME ,
1094+ [],
1095+ $ botPatch ->toArray (),
1096+ )
1097+ );
1098+ }
1099+
1100+ /**
1101+ * Edits chat info such as title, icon, etc.
1102+ * Instantiate ChatPatch with named arguments for the fields you want to change.
1103+ *
1104+ * Example:
1105+ * $patch = new ChatPatch(title: 'New Cool Title');
1106+ * $api->editChat(12345, $patch);
1107+ *
1108+ * @param int $chatId The identifier of the chat to edit.
1109+ * @param ChatPatch $chatPatch An object containing the fields to update.
1110+ *
1111+ * @return Chat
1112+ * @throws ClientApiException
1113+ * @throws NetworkException
1114+ * @throws ReflectionException
1115+ * @throws SerializationException
1116+ */
1117+ public function editChat (int $ chatId , ChatPatch $ chatPatch ): Chat
1118+ {
1119+ return $ this ->modelFactory ->createChat (
1120+ $ this ->client ->request (
1121+ self ::METHOD_PATCH ,
1122+ self ::ACTION_CHATS . '/ ' . $ chatId ,
1123+ [],
1124+ $ chatPatch ->toArray (),
1125+ )
1126+ );
1127+ }
1128+
1129+ /**
1130+ * Returns detailed information about a video attachment, including playback URLs.
1131+ *
1132+ * @param string $videoToken The token of the video attachment.
1133+ *
1134+ * @return VideoAttachmentDetails
1135+ * @throws ClientApiException
1136+ * @throws NetworkException
1137+ * @throws ReflectionException
1138+ * @throws SerializationException
1139+ */
1140+ public function getVideoAttachmentDetails (string $ videoToken ): VideoAttachmentDetails
1141+ {
1142+ return $ this ->modelFactory ->createVideoAttachmentDetails (
1143+ $ this ->client ->request (
1144+ self ::METHOD_GET ,
1145+ sprintf (self ::ACTION_VIDEO_DETAILS , $ videoToken ),
1146+ )
1147+ );
1148+ }
1149+
10711150 /**
10721151 * A helper to build the 'NewMessageBody' array structure consistently.
10731152 *
0 commit comments