listCountry method

  1. @override
Future<Either<Failure, List<Country>>> listCountry()
override

Implementation

@override
Future<Either<Failure, List<Country>>> listCountry() async {
  try {
    var result = await apiService.get(
      url: Api.address.listCountry,
      withAccessToken: true,
      withToken: true,
    );

    var responseDTO = ListCountryDto.map(result);

    return Right(
      responseDTO.jsonResult
              ?.map((e) => AddressDataMapper.mapCountryResponseToDomain(e))
              .toList() ??
          [],
    );
  } on Exception catch (error) {
    return Left(FailureResponse.mapExceptionToFailure(error));
  }
}