defaultResponseParser<T extends MandrillResponse> function

T defaultResponseParser<T extends MandrillResponse>(
  1. T responseCoding,
  2. dynamic response
)

The default ResponseParser simply takes the response Map, and invokes .decode(archive) on the provided Coding object.

If the response is a List, then it will be converted to a Map: {'list': response}.

Implementation

T defaultResponseParser<T extends MandrillResponse>(
    T responseCoding, dynamic response) {
  if (response is List) {
    response = <String, dynamic>{'list': response};
  } else if (response is! Map<String, dynamic>) {
    // If this exception is thrown here, it probably means that you need to
    // provide your own ResponseParser (or Mandrill is bugging out).
    throw InvalidResponseException('The returned response was not a Map.');
  }
  final archive = KeyedArchive.unarchive(response as Map<String, dynamic>);
  return responseCoding..decode(archive);
}