setPaywallActionInterceptor static method

Future<PaywallActionInterceptorResult> setPaywallActionInterceptor()

Implementation

static Future<PaywallActionInterceptorResult>
    setPaywallActionInterceptor() async {
  final result = await _channel.invokeMethod('setPaywallActionInterceptor');
  final Map<dynamic, dynamic>? plan = result['parameters']['plan'];
  final Map<dynamic, dynamic>? offer = result['parameters']['offer'];
  final Map<dynamic, dynamic>? subscriptionOffer =
      result['parameters']['subscriptionOffer'];
  return PaywallActionInterceptorResult(
      PLYPaywallInfo(
          result['info']['contentId'],
          result['info']['presentationId'],
          result['info']['placementId'],
          result['info']['abTestId'],
          result['info']['abTestVariantId']),
      PLYPaywallAction.values.firstWhere(
          (e) => e.toString() == 'PLYPaywallAction.' + result['action']),
      PLYPaywallActionParameters(
          result['parameters']['url'],
          result['parameters']['title'],
          plan != null ? transformToPLYPlan(plan) : null,
          offer != null ? transformToPLYPromoOffer(offer) : null,
          subscriptionOffer != null
              ? transformToPLYSubscription(subscriptionOffer)
              : null,
          result['parameters']['presentation']));
}