forked from superwall/Superwall-Flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iOS and Dart
handleSuperwallEvent
logic
- Loading branch information
1 parent
833c9c4
commit bacc99c
Showing
9 changed files
with
445 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import 'package:superwallkit_flutter/superwallkit_flutter.dart'; | ||
|
||
/// The status of the paywall request | ||
class PaywallPresentationRequestStatus { | ||
final PaywallPresentationRequestStatusType type; | ||
|
||
PaywallPresentationRequestStatus._(this.type); | ||
|
||
factory PaywallPresentationRequestStatus.fromJson(Map<String, dynamic> json) { | ||
switch (json['status']) { | ||
case 'presentation': | ||
return PaywallPresentationRequestStatus._(PaywallPresentationRequestStatusType.presentation); | ||
case 'noPresentation': | ||
return PaywallPresentationRequestStatus._(PaywallPresentationRequestStatusType.noPresentation); | ||
case 'timeout': | ||
return PaywallPresentationRequestStatus._(PaywallPresentationRequestStatusType.timeout); | ||
default: | ||
throw ArgumentError('Invalid PaywallPresentationRequestStatus type'); | ||
} | ||
} | ||
} | ||
|
||
enum PaywallPresentationRequestStatusType { presentation, noPresentation, timeout } | ||
|
||
/// The reason to why the paywall couldn't present. | ||
class PaywallPresentationRequestStatusReason { | ||
final PaywallPresentationRequestStatusReasonType type; | ||
final Experiment? experiment; | ||
|
||
PaywallPresentationRequestStatusReason._({required this.type, this.experiment}); | ||
|
||
factory PaywallPresentationRequestStatusReason.fromJson(Map<String, dynamic> json) { | ||
switch (json['reason']) { | ||
case 'debuggerPresented': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.debuggerPresented); | ||
case 'paywallAlreadyPresented': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.paywallAlreadyPresented); | ||
case 'userIsSubscribed': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.userIsSubscribed); | ||
case 'holdout': | ||
return PaywallPresentationRequestStatusReason._( | ||
type: PaywallPresentationRequestStatusReasonType.holdout, | ||
experiment: Experiment(bridgeId: json['experimentBridgeId']), | ||
); | ||
case 'noRuleMatch': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.noRuleMatch); | ||
case 'eventNotFound': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.eventNotFound); | ||
case 'noPaywallViewController': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.noPaywallViewController); | ||
case 'noPresenter': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.noPresenter); | ||
case 'noConfig': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.noConfig); | ||
case 'subscriptionStatusTimeout': | ||
return PaywallPresentationRequestStatusReason._(type: PaywallPresentationRequestStatusReasonType.subscriptionStatusTimeout); | ||
default: | ||
throw ArgumentError('Invalid PaywallPresentationRequestStatusReason type'); | ||
} | ||
} | ||
} | ||
|
||
enum PaywallPresentationRequestStatusReasonType { | ||
debuggerPresented, | ||
paywallAlreadyPresented, | ||
userIsSubscribed, | ||
holdout, | ||
noRuleMatch, | ||
eventNotFound, | ||
noPaywallViewController, | ||
noPresenter, | ||
noConfig, | ||
subscriptionStatusTimeout | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,50 @@ | ||
/// A wrapper around a store transaction. | ||
class StoreTransaction { | ||
// TODO | ||
// final String configRequestId; | ||
// final String appSessionId; | ||
// final DateTime? transactionDate; | ||
// final String originalTransactionIdentifier; | ||
// final StoreTransactionState state; | ||
// final String? storeTransactionId; | ||
// final StorePayment payment; | ||
// final DateTime? originalTransactionDate; | ||
// final String? webOrderLineItemID; | ||
// final String? appBundleId; | ||
// final String? subscriptionGroupId; | ||
// final bool? isUpgraded; | ||
// final DateTime? expirationDate; | ||
// final String? offerId; | ||
// final DateTime? revocationDate; | ||
// final String? appAccountToken; | ||
} | ||
final String configRequestId; | ||
final String appSessionId; | ||
final DateTime? transactionDate; | ||
final String originalTransactionIdentifier; | ||
final String? storeTransactionId; | ||
final DateTime? originalTransactionDate; | ||
final String? webOrderLineItemID; | ||
final String? appBundleId; | ||
final String? subscriptionGroupId; | ||
final bool? isUpgraded; | ||
final DateTime? expirationDate; | ||
final String? offerId; | ||
final DateTime? revocationDate; | ||
|
||
enum StoreTransactionState { | ||
purchasing, | ||
purchased, | ||
failed, | ||
restored, | ||
deferred, | ||
} | ||
StoreTransaction({ | ||
required this.configRequestId, | ||
required this.appSessionId, | ||
this.transactionDate, | ||
required this.originalTransactionIdentifier, | ||
this.storeTransactionId, | ||
this.originalTransactionDate, | ||
this.webOrderLineItemID, | ||
this.appBundleId, | ||
this.subscriptionGroupId, | ||
this.isUpgraded, | ||
this.expirationDate, | ||
this.offerId, | ||
this.revocationDate, | ||
}); | ||
|
||
/// The payment for the transaction. | ||
class StorePayment { | ||
// TODO | ||
// /// The ID of a product being bought. | ||
// final String productIdentifier; | ||
// | ||
// /// The number of items the user wants to purchase. | ||
// final int quantity; | ||
// | ||
// /// The ID for the discount offer to apply to the payment. | ||
// final String? discountIdentifier; | ||
factory StoreTransaction.fromJson(Map<String, dynamic> json) { | ||
return StoreTransaction( | ||
configRequestId: json['configRequestId'], | ||
appSessionId: json['appSessionId'], | ||
transactionDate: json['transactionDate'] != null ? DateTime.parse(json['transactionDate']) : null, | ||
originalTransactionIdentifier: json['originalTransactionIdentifier'], | ||
storeTransactionId: json['storeTransactionId'], | ||
originalTransactionDate: json['originalTransactionDate'] != null ? DateTime.parse(json['originalTransactionDate']) : null, | ||
webOrderLineItemID: json['webOrderLineItemID'], | ||
appBundleId: json['appBundleId'], | ||
subscriptionGroupId: json['subscriptionGroupId'], | ||
isUpgraded: json['isUpgraded'], | ||
expirationDate: json['expirationDate'] != null ? DateTime.parse(json['expirationDate']) : null, | ||
offerId: json['offerId'], | ||
revocationDate: json['revocationDate'] != null ? DateTime.parse(json['revocationDate']) : null, | ||
); | ||
} | ||
} |
Oops, something went wrong.