invoke method

FutureOr<Map> invoke({
  1. required Map parameters,
  2. required TelegramClientData telegramClientData,
  3. bool is_form = false,
  4. String? urlApi,
  5. String? clientType,
  6. void onUploadProgress(
    1. int bytes,
    2. int bytess
    )?,
  7. bool isVoid = false,
  8. bool? isUseCache,
  9. Duration? durationCacheExpire,
  10. Duration? delayDuration,
  11. Duration? invokeTimeOut,
  12. String? extra,
  13. bool? isAutoGetChat,
  14. bool isInvokeThrowOnError = true,
  15. bool isAutoExtendMessage = false,
  16. FutureOr<String> onGenerateExtraInvoke(
    1. int client_id,
    2. TdlibBase libTdJson
    )?,
  17. FutureOr<Map> onGetInvokeData(
    1. String,
    2. int client_id,
    3. TdlibBase libTdJson
    )?,
})

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;
}