invoke method

Future<Map> invoke(
  1. String method, {
  2. Map? parameters,
  3. required int clientId,
  4. Duration? functionTimeOut,
  5. bool isVoid = false,
  6. Duration? delayDuration,
  7. Duration? invokeTimeOut,
  8. bool? isUseCache = false,
  9. Duration? durationCacheExpire,
  10. String? extra,
  11. bool? isAutoGetChat,
  12. bool? isInvokeThrowOnError,
  13. FutureOr<String> onGenerateExtraInvoke(
    1. int client_id,
    2. TdlibBase libTdJson
    )?,
  14. FutureOr<Map> onGetInvokeData(
    1. String extra,
    2. int client_id,
    3. TdlibBase libTdJson
    )?,
})

call api latest Tdlib-Methods example:

tg.invoke(
 "getChat",
 parameters: {
   "chat_id": 0,
 },
 clientId: tg.client_id,
);

Implementation

Future<Map> invoke(
  String method, {
  Map? parameters,
  required int clientId,
  Duration? functionTimeOut,
  bool isVoid = false,
  Duration? delayDuration,
  Duration? invokeTimeOut,
  bool? isUseCache = false,
  Duration? durationCacheExpire,
  String? extra,
  bool? isAutoGetChat,
  bool? isInvokeThrowOnError,
  FutureOr<String> Function(int client_id, TdlibBase libTdJson)?
      onGenerateExtraInvoke,
  FutureOr<Map> Function(String extra, int client_id, TdlibBase libTdJson)?
      onGetInvokeData,
}) async {
  isUseCache ??= false;
  durationCacheExpire ??= Duration(
    minutes: 1,
  );
  isInvokeThrowOnError ??= is_invoke_throw_on_error;
  onGetInvokeData ??= on_get_invoke_data;
  onGenerateExtraInvoke ??= on_generate_extra_invoke;
  isAutoGetChat ??= is_auto_get_chat;
  //
  invokeTimeOut ??= invoke_time_out;
  parameters ??= {};
  parameters["@type"] = method;
  return await invokeRaw(
    parameters: parameters,
    clientId: clientId,
    isVoid: isVoid,
    delayDuration: delayDuration ?? Duration(microseconds: 1),
    invokeTimeOut: invokeTimeOut,
    functionTimeOut: functionTimeOut ?? Duration(minutes: 15),
    isUseCache: isUseCache,
    durationCacheExpire: durationCacheExpire,
    extra: extra ?? "",
    isAutoGetChat: isAutoGetChat,
    isInvokeThrowOnError: isInvokeThrowOnError,
    onGenerateExtraInvoke: onGenerateExtraInvoke,
    onGetInvokeData: onGetInvokeData,
  );
}