19
19
use BushlanovDev \MaxMessengerBot \Models \Attachments \Requests \PhotoAttachmentRequest ;
20
20
use BushlanovDev \MaxMessengerBot \Models \Attachments \Requests \VideoAttachmentRequest ;
21
21
use BushlanovDev \MaxMessengerBot \Models \BotInfo ;
22
+ use BushlanovDev \MaxMessengerBot \Models \BotPatch ;
22
23
use BushlanovDev \MaxMessengerBot \Models \Chat ;
23
24
use BushlanovDev \MaxMessengerBot \Models \ChatAdmin ;
24
25
use BushlanovDev \MaxMessengerBot \Models \ChatList ;
25
26
use BushlanovDev \MaxMessengerBot \Models \ChatMember ;
26
27
use BushlanovDev \MaxMessengerBot \Models \ChatMembersList ;
28
+ use BushlanovDev \MaxMessengerBot \Models \ChatPatch ;
27
29
use BushlanovDev \MaxMessengerBot \Models \Message ;
28
30
use BushlanovDev \MaxMessengerBot \Models \MessageLink ;
29
31
use BushlanovDev \MaxMessengerBot \Models \Result ;
30
32
use BushlanovDev \MaxMessengerBot \Models \Subscription ;
31
33
use BushlanovDev \MaxMessengerBot \Models \UpdateList ;
32
34
use BushlanovDev \MaxMessengerBot \Models \Updates \AbstractUpdate ;
33
35
use BushlanovDev \MaxMessengerBot \Models \UploadEndpoint ;
36
+ use BushlanovDev \MaxMessengerBot \Models \VideoAttachmentDetails ;
34
37
use InvalidArgumentException ;
35
38
use LogicException ;
36
39
use Psr \Http \Message \ServerRequestInterface ;
@@ -51,7 +54,7 @@ class Api
51
54
private const string METHOD_GET = 'GET ' ;
52
55
private const string METHOD_POST = 'POST ' ;
53
56
private const string METHOD_DELETE = 'DELETE ' ;
54
- // private const string METHOD_PATCH = 'PATCH';
57
+ private const string METHOD_PATCH = 'PATCH ' ;
55
58
private const string METHOD_PUT = 'PUT ' ;
56
59
57
60
private const string ACTION_ME = '/me ' ;
@@ -67,6 +70,7 @@ class Api
67
70
private const string ACTION_CHATS_MEMBERS = '/chats/%d/members ' ;
68
71
private const string ACTION_UPDATES = '/updates ' ;
69
72
private const string ACTION_ANSWERS = '/answers ' ;
73
+ private const string ACTION_VIDEO_DETAILS = '/videos/%s ' ;
70
74
71
75
private readonly ClientApiInterface $ client ;
72
76
@@ -1068,6 +1072,81 @@ public function editMessage(
1068
1072
);
1069
1073
}
1070
1074
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
+
1071
1150
/**
1072
1151
* A helper to build the 'NewMessageBody' array structure consistently.
1073
1152
*
0 commit comments