getResponseTypes method

Future<List<ResponseType>> getResponseTypes()

Get all available response types for this client.

Implementation

Future<List<ResponseType>> getResponseTypes() async {
  final response = await _get(
    '/api/responses/types',
    {'clientId': _clientId},
  );

  if (response.statusCode != 200) {
    throw Exception('Failed to get response types: ${response.reasonPhrase}');
  }

  final data = json.decode(response.body) as Map<String, dynamic>;
  final types = (data['types'] as List<dynamic>?)
          ?.map((e) => ResponseType.fromJson(e as Map<String, dynamic>))
          .toList() ??
      [];

  return types;
}