execute<R extends TdObject> static method
Executes a request synchronously through td_execute, without a
client. Only requests with TdFunction.canBeCalledSynchronously work.
Loads libtdjson from its default place if start hasn't run yet.
Implementation
static R execute<R extends TdObject>(TdFunction<R> request) {
tdjson.loadTdJson();
final raw = tdjson.tdExecuteJson(jsonEncode(request.toJson()));
if (raw == null) {
throw TdException(
const TdError(code: 0, message: 'td_execute returned nothing'),
request,
);
}
final object = convertMapToObject(jsonDecode(raw) as Map<String, dynamic>);
if (object is TdError) throw TdException(object, request);
if (object is R) return object;
throw TdUnexpectedResponseException(object, request);
}