getRetailer method

Future<ApiResponse> getRetailer(
  1. String retailerId
)

Implementation

Future<ApiResponse> getRetailer(String retailerId) async {

  _apiResponse = ApiResponse.loading("Loading");
  notifyListeners();
  try {
    SpinachUser? _retailer = await RegistrationRepository.getInstance()?.getRetailerById(retailerId);
    if(_retailer != null)
      {
        BusinessDetails? businessDetails = await RegistrationRepository.getInstance()?.getRetailerDetails(retailerId);
        if(businessDetails != null)
          {
            _retailer.businessDetails = businessDetails;
          }
        else
          {
            throw SpinachNotFoundException("Retailer's details are not found.");
          }
      }
    else
      {
        throw SpinachNotFoundException("Retailer is not found.");
      }
    _apiResponse = ApiResponse.completed(_retailer);
  } on SpinachNotFoundException catch (e) {
    _apiResponse = ApiResponse.error(e.toString());
    // throw e;
  }
  on SpinachInvalidOperationException catch (e) {
    _apiResponse = ApiResponse.error(e.toString());
  }
  catch (e) {
    _apiResponse = ApiResponse.error(e.toString());
    //  throw e;
  }
  notifyListeners();
  return _apiResponse;
}