getLocation static method

Future<MaybeError<Location>> getLocation(
  1. int locationId, {
  2. UriProductHelper uriHelper = uriHelperFoodProd,
})

Implementation

static Future<MaybeError<Location>> getLocation(
  final int locationId, {
  final UriProductHelper uriHelper = uriHelperFoodProd,
}) async {
  final Uri uri = uriHelper.getUri(
    path: '/api/v1/locations/$locationId',
    forcedHost: _getHost(uriHelper),
  );
  final Response response = await HttpHelper().doGetRequest(
    uri,
    uriHelper: uriHelper,
  );
  if (response.statusCode == 200) {
    try {
      final dynamic decodedResponse = HttpHelper().jsonDecodeUtf8(response);
      return MaybeError<Location>.value(Location.fromJson(decodedResponse));
    } catch (e) {
      //
    }
  }
  return MaybeError<Location>.responseError(response);
}