readAddressByCep function

Future<Cep> readAddressByCep(
  1. String cepRawValue
)

Receive a CEP and return the address corresponding by that CEP

Implementation

Future<Cep> readAddressByCep(String cepRawValue) async {
  var cep = const Cep();

  try {
    var cepStringTreated = removeSpecialCharacters(cepRawValue);

    cepStringTreated = validateInputLength(cepStringTreated);

    cepStringTreated = leftPadWithZeros(cepStringTreated);

    cep = await fetchCepFromServices(cepStringTreated);
  } catch (e) {
    handleServicesError(e);
    throwApplicationError(e);
  }

  return cep;
}