loadForm method

Future<FormData> loadForm({
  1. required Uri uri,
  2. Map<String, String> headers = const {},
  3. bool isRetry = false,
})

Loads a FormData represented by formUri

headers will be added in addition to ApptiveGridClient.defaultHeaders

Based on formUri this might require Authentication throws Response if the request fails

Implementation

Future<FormData> loadForm({
  required Uri uri,
  Map<String, String> headers = const {},
  bool isRetry = false,
}) async {
  final url = _generateApptiveGridUri(uri);
  final sanitizedUrl =
      url.replace(path: url.path.replaceAll(RegExp('/r/'), '/a/'));

  final data = await performApptiveLink<FormData>(
    link: ApptiveLink(uri: sanitizedUrl, method: 'get'),
    headers: headers,
    parseResponse: (response) async {
      return FormData.fromJson(json.decode(response.body));
    },
  );

  return data!;
}