readAll method

Future<(UResponse<UAppSettings>?, UEmptyResponse?, String?)> readAll({
  1. required dynamic onOk(
    1. UResponse<UAppSettings> r
    ),
  2. required dynamic onError(
    1. UEmptyResponse e
    ),
  3. required dynamic onException(
    1. String e
    ),
})

Implementation

Future<(UResponse<UAppSettings>?, UEmptyResponse?, String?)> readAll({
  required Function(UResponse<UAppSettings> r) onOk,
  required Function(UEmptyResponse e) onError,
  required Function(String e) onException,
}) async {
  (UResponse<UAppSettings>?, UEmptyResponse?, String?) result = (null, null, null);
  await UHttpClient.send(
    method: "POST",
    endpoint: "${U.baseUrl}/AppSettings/ReadAll",
    body: <String, dynamic>{"apiKey": U.apiKey, "token": ULocalStorage.getToken()},
    onSuccess: (Response r) {
      final UResponse<UAppSettings> ok = UResponse<UAppSettings>.fromJson(r.body, (dynamic i) => UAppSettings.fromMap(i));
      result = (ok, null, null);
      onOk(ok);
    },
    onError: (Response r) {
      final UEmptyResponse err = UEmptyResponse.fromJson(r.body);
      result = (null, err, null);
      onError(err);
    },
    onException: (String e) {
      result = (null, null, e);
      onException(e);
    },
  );
  return result;
}