extractValuesFromSuccessResponse function

Cep extractValuesFromSuccessResponse(
  1. Map<String, dynamic> response
)

Implementation

Cep extractValuesFromSuccessResponse(Map<String, dynamic> response) {
  try {
    final responseReturn = response['soap:Envelope']['soap:Body']
        ['ns2:consultaCEPResponse']['return'];

    return Cep(
      cep: responseReturn['cep'],
      city: responseReturn['cidade'],
      neighborhood: responseReturn['bairro'],
      state: responseReturn['uf'],
      street: responseReturn['end'],
    );
  } catch (e) {
    throw SimpleError('Não foi possível interpretar a resposta.');
  }
}