fromJson static method

IntentStateDetails fromJson(
  1. dynamic data
)

Implementation

static IntentStateDetails fromJson(dynamic data) {
  var json = DynamicJsonExtension.getJsonMap(data);
  switch (json['type']) {
    case 'method_selection':
      return MethodSelection(
          methods: IntentMethods.fromJson(json['methods']));
    case 'intent_form':
      return IntentForm();
    case 'intent_processed':
      return IntentProcessed();
    case 'transaction_waiting_user_action':
      return TransactionWaitingUserAction();
    case 'transaction_failed':
      return TransactionFailed(
          recommendedMethods: json['recommendedMethods'] != null
              ? IntentMethods.fromJson(json['recommendedMethods'])
              : null);
    case 'expired':
      return Expired();
    case 'closed':
      return Closed();
    case 'form_fields':
      return FormFields(
        tokenizeCardInfo: json['tokenizeCardInfo'] != null
            ? TokenizeCardInfo.fromJson(json['tokenizeCardInfo'])
            : null,
        billingFields: json['billingFields'] != null
            ? (json['billingFields'] as List)
                .map((e) => InputField.fromJson(e))
                .toList()
            : null,
        shippingFields: json['shippingFields'] != null
            ? (json['shippingFields'] as List)
                .map((e) => InputField.fromJson(e))
                .toList()
            : null,
      );
    case 'url_to_render':
      return UrlToRender(
        url: json['url'],
        renderStrategy: json['renderStrategy'] != null
            ? RenderStrategyExtension.fromJson(json['renderStrategy'])
            : null,
      );
    case 'saved_card_cvv':
      return SavedCardCVV(
        cvvField: InputField.fromJson(json['cvvField']),
        cardTokenData: json['cardTokenData'] != null
            ? CardTokenData.fromJson(json['cardTokenData'])
            : null,
      );
    case 'native_pay':
      return NativePay(
        nativePayData: json['nativePayData'] != null
            ? NativePayDataExtension.fromJson(json['nativePayData'])
            : null,
      );
    case 'card_intent_successful':
      return CardIntentSuccessful();
    case 'card_intent_failed':
      return CardIntentFailed();
    default:
      throw Exception("Unknown type: ${json['type']}");
  }
}