invoke method
FutureOr<Map>
invoke({
- required Map parameters,
- required TelegramClientData telegramClientData,
- bool is_form = false,
- String? urlApi,
- String? clientType,
- void onUploadProgress()?,
- bool isVoid = false,
- bool? isUseCache,
- Duration? durationCacheExpire,
- Duration? delayDuration,
- Duration? invokeTimeOut,
- String? extra,
- bool? isAutoGetChat,
- bool isInvokeThrowOnError = true,
- bool isAutoExtendMessage = false,
- FutureOr<
String> onGenerateExtraInvoke()?, - FutureOr<
Map> onGetInvokeData()?,
return original data json
Implementation
FutureOr<Map> invoke({
required Map parameters,
required TelegramClientData telegramClientData,
bool is_form = false,
String? urlApi,
String? clientType,
void Function(int bytes, int bytess)? onUploadProgress,
bool isVoid = false,
bool? isUseCache,
Duration? durationCacheExpire,
Duration? delayDuration,
Duration? invokeTimeOut,
String? extra,
bool? isAutoGetChat,
bool isInvokeThrowOnError = true,
bool isAutoExtendMessage = false,
FutureOr<String> Function(int client_id, TdlibBase libTdJson)?
onGenerateExtraInvoke,
FutureOr<Map<dynamic, dynamic>> Function(
String, int client_id, TdlibBase libTdJson)?
onGetInvokeData,
}) async {
// telegramClientLib ??= telegram_client_lib;
if (telegramClientData.telegramClientType ==
TelegramClientType.telegam_bot_api) {
final Map respond = await telegramBotApi.request(
parameters["@type"],
tokenBot: telegramClientData.telegram_bot_api_token_bot,
parameters: parameters,
is_form: is_form,
urlApi: urlApi,
clientType: clientType,
isAutoExtendMessage: isAutoExtendMessage,
isThrowOnError: isInvokeThrowOnError,
onUploadProgress: onUploadProgress,
);
return respond;
}
if ((telegramClientData.telegramClientType == TelegramClientType.tdlib)) {
final Map respond = (await tdlib.invoke(
parameters["@type"],
parameters: parameters,
clientId: telegramClientData.tdlib_client_id,
isVoid: isVoid,
isUseCache: isUseCache,
durationCacheExpire: durationCacheExpire,
delayDuration: delayDuration,
invokeTimeOut: invokeTimeOut,
extra: extra,
isAutoGetChat: isAutoGetChat,
isInvokeThrowOnError: isInvokeThrowOnError,
onGenerateExtraInvoke: onGenerateExtraInvoke,
onGetInvokeData: onGetInvokeData,
));
return respond;
}
final TelegramClientLibraryError error = TelegramClientLibraryError.create(
special_extra: "error",
code: 500,
message: "telegram_client_type_not_found",
description: "",
);
if (isInvokeThrowOnError) {
throw error.rawData;
}
return error.rawData;
}