put method

Future<T> put({
  1. required TGPutRequest request,
  2. dynamic onSuccess(
    1. dynamic T
    )?,
  3. dynamic onError(
    1. dynamic T
    )?,
})

Implementation

Future<T> put(
    {required TGPutRequest request, onSuccess(T)?, onError(T)?}) async {
  try {
    Uri uri = Uri.parse(request.getUrl());
    TGLog.t("PUT", uri);
    TGRequestContent content =
        TGRequestContent(request.body(), request.headers());
    final httpRes = await _getClient(request.getUri(), "PUT").put(
      uri,
      body: content.body,
      headers: content.headers,
    );
    return _performCallback(httpRes, onError, onSuccess);
  } catch (error) {
    T t = _populateExceptionResponse(error);
    onError!(t);
    return t;
  }
}