getOfferings method

Refreshes offerings from the backend that owns the session.

Implementation

@override
Future<InappifySdkResult<OfferingsModel>> getOfferings(
  InappifyRefreshRequest request,
) async {
  final cancellation = request.cancellation;
  if (cancellation?.isCancelled ?? false) {
    return _cancelled<OfferingsModel>('getOfferings');
  }
  return _run<OfferingsModel>(
    'getOfferings',
    action: () async {
      try {
        final raw = await _bridge.call(
          'getOfferings',
          positionalArguments: <Object?>[
            <String, Object?>{'forceRefresh': request.force},
          ],
          cancellation: cancellation,
          injectAbortSignal: cancellation != null,
        );
        final offerings = InappifyWebPayloadCodec.offerings(raw);
        _commitOfferings(offerings);
        _failedToLoadOfferings = false;
        return offerings;
      } catch (_) {
        _failedToLoadOfferings = true;
        rethrow;
      }
    },
    cancellation: cancellation,
  );
}