getPrices static method

Future<MaybeError<GetPricesResult>> getPrices(
  1. GetPricesParameters parameters, {
  2. UriProductHelper uriHelper = uriHelperFoodProd,
  3. String? bearerToken,
})

Implementation

static Future<MaybeError<GetPricesResult>> getPrices(
  final GetPricesParameters parameters, {
  final UriProductHelper uriHelper = uriHelperFoodProd,
  final String? bearerToken,
}) async {
  final Uri uri = uriHelper.getUri(
    path: '/api/v1/prices',
    queryParameters: parameters.getQueryParameters(),
    forcedHost: _getHost(uriHelper),
  );
  final Response response = await HttpHelper().doGetRequest(
    uri,
    uriHelper: uriHelper,
    bearerToken: bearerToken,
  );
  if (response.statusCode == 200) {
    try {
      final dynamic decodedResponse = HttpHelper().jsonDecodeUtf8(response);
      return MaybeError<GetPricesResult>.value(
        GetPricesResult.fromJson(decodedResponse),
      );
    } catch (e) {
      //
    }
  }
  return MaybeError<GetPricesResult>.responseError(response);
}