diff --git a/example/lib/main.dart b/example/lib/main.dart index e312920fe..07ad2d001 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -11,6 +11,7 @@ void main() { )); } +// ignore: public_member_api_docs class InitialScreen extends StatefulWidget { @override State createState() => _MyAppState(); @@ -61,6 +62,7 @@ class _MyAppState extends State { } } +// ignore: public_member_api_docs class UpsellScreen extends StatefulWidget { @override State createState() => _UpsellScreenState(); @@ -104,8 +106,8 @@ class _UpsellScreenState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - PurchaseButton(package: monthly), - PurchaseButton(package: lifetime) + _PurchaseButton(package: monthly), + _PurchaseButton(package: lifetime) ], ))); } @@ -119,14 +121,15 @@ class _UpsellScreenState extends State { } } -class PurchaseButton extends StatelessWidget { +class _PurchaseButton extends StatelessWidget { final Package package; - PurchaseButton({Key key, @required this.package}) : super(key: key); + // ignore: public_member_api_docs + _PurchaseButton({Key key, @required this.package}) : super(key: key); @override Widget build(BuildContext context) { - return RaisedButton( + return ElevatedButton( onPressed: () async { try { PurchaserInfo purchaserInfo = @@ -150,6 +153,7 @@ class PurchaseButton extends StatelessWidget { } } +// ignore: public_member_api_docs class CatsScreen extends StatelessWidget { @override Widget build(BuildContext context) { diff --git a/lib/entitlement_info_wrapper.dart b/lib/entitlement_info_wrapper.dart index 0062d9e51..c9796ff0a 100644 --- a/lib/entitlement_info_wrapper.dart +++ b/lib/entitlement_info_wrapper.dart @@ -46,6 +46,7 @@ class EntitlementInfo { /// Check the `isActive` property. final String billingIssueDetectedAt; + /// Construct an EntitlementInfo EntitlementInfo( this.identifier, this.isActive, @@ -60,6 +61,7 @@ class EntitlementInfo { this.unsubscribeDetectedAt, this.billingIssueDetectedAt); + /// Constructs an EntitlementInfo from a JSON object factory EntitlementInfo.fromJson(Map json) { var periodType; switch (json["periodType"] as String) { diff --git a/lib/entitlement_infos_wrapper.dart b/lib/entitlement_infos_wrapper.dart index 8182c286a..a0ac1709c 100644 --- a/lib/entitlement_infos_wrapper.dart +++ b/lib/entitlement_infos_wrapper.dart @@ -10,6 +10,7 @@ class EntitlementInfos { /// entitlement identifier. final Map active; + /// Constructs an EntitlementInfos from a JSON object EntitlementInfos.fromJson(Map json) : all = (json["all"] as Map).map( (key, value) => MapEntry(key, EntitlementInfo.fromJson(value))), diff --git a/lib/errors.dart b/lib/errors.dart index 58d9a23da..24191f133 100644 --- a/lib/errors.dart +++ b/lib/errors.dart @@ -1,27 +1,74 @@ import 'package:flutter/services.dart'; +/// Different error codes returned by the Purchases functions. enum PurchasesErrorCode { + /// Unknown error unknownError, + + /// Purchase was cancelled. purchaseCancelledError, + + /// There was a problem with the store. storeProblemError, + + /// The device or user is not allowed to make the purchase. purchaseNotAllowedError, + + /// One or more of the arguments provided are invalid. purchaseInvalidError, + + /// The product is not available for purchase. productNotAvailableForPurchaseError, + + /// This product is already active for the user. productAlreadyPurchasedError, + + /// There is already another active subscriber using the same receipt. receiptAlreadyInUseError, + + /// The receipt is not valid. invalidReceiptError, + + /// The receipt is missing. missingReceiptFileError, + + /// Error performing request. networkError, + + /// There was a credentials issue. Check the message for more info. invalidCredentialsError, + + /// Received malformed response from the backend. unexpectedBackendResponseError, + + /// There is already another active subscriber using the same receipt. receiptInUseByOtherSubscriberError, + + /// The app user id is not valid. invalidAppUserIdError, + + /// The operation is already in progress. operationAlreadyInProgressError, + + /// There was an unknown backend error. unknownBackendError, + + /// Apple Subscription Key is invalid or not present. In order to provide + /// subscription offers, you must first generate a subscription key. Please + /// see https://docs.revenuecat.com/docs/ios-subscription-offers + /// for more info. invalidAppleSubscriptionKeyError, + + /// The User is ineligible for that action. ineligibleError, + + /// App does not have sufficient permissions to make purchases. insufficientPermissionsError, + + /// The payment is pending. paymentPendingError, + + /// One or more of the attributes sent could not be saved. invalidSubscriberAttributesError } diff --git a/lib/offering_wrapper.dart b/lib/offering_wrapper.dart index dc33b796c..85246d845 100644 --- a/lib/offering_wrapper.dart +++ b/lib/offering_wrapper.dart @@ -33,6 +33,7 @@ class Offering { /// Weekly package type configured in the RevenueCat dashboard, if available. final Package weekly; + /// Constructs an Offering from a JSON object. Offering.fromJson(Map map) : identifier = map["identifier"], serverDescription = map['serverDescription'], diff --git a/lib/offerings_wrapper.dart b/lib/offerings_wrapper.dart index 6e6349b91..9f258a826 100644 --- a/lib/offerings_wrapper.dart +++ b/lib/offerings_wrapper.dart @@ -9,6 +9,7 @@ class Offerings { /// Map of all Offerings [Offering] objects keyed by their identifier. final Map all; + /// Constructs an Offerings object from a JSON object. Offerings.fromJson(Map map) : current = map['current'] != null ? Offering.fromJson(map['current']) : null, diff --git a/lib/package_wrapper.dart b/lib/package_wrapper.dart index 14363c89b..6b2603a13 100644 --- a/lib/package_wrapper.dart +++ b/lib/package_wrapper.dart @@ -16,6 +16,7 @@ class Package { /// Offering this package belongs to. final String offeringIdentifier; + /// Constructs a Package from a JSON object. Package.fromJson(Map json) : identifier = json['identifier'], packageType = _PackageTypeHelper.getFromString(json['packageType']), diff --git a/lib/product_wrapper.dart b/lib/product_wrapper.dart index 090c82441..961a08be0 100644 --- a/lib/product_wrapper.dart +++ b/lib/product_wrapper.dart @@ -1,5 +1,6 @@ import 'discount.dart'; +/// Contains all the product details associated with a Store product id class Product { /// Product Id. final String identifier; @@ -25,6 +26,7 @@ class Product { /// Collection of discount offers for a product. Null for Android. final List discounts; + /// Constructs a Product from a JSON object. Product.fromJson(Map json) : identifier = json['identifier'], description = json['description'], @@ -47,6 +49,7 @@ class Product { } } +/// Contains all the introductory information associated with a [Product] class IntroductoryPrice { /// Introductory price of a subscription in the local currency. final double introPrice; @@ -70,6 +73,7 @@ class IntroductoryPrice { /// user will be given the introductory price, such as 3. final int introPriceCycles; + /// Constructs an IntroductoryPrice from a JSON object. IntroductoryPrice.fromJson(Map json) : introPrice = json['intro_price'].toDouble(), introPriceString = json['intro_price_string'], diff --git a/lib/purchaser_info_wrapper.dart b/lib/purchaser_info_wrapper.dart index c30e6c78f..dcdc9ca35 100644 --- a/lib/purchaser_info_wrapper.dart +++ b/lib/purchaser_info_wrapper.dart @@ -1,6 +1,7 @@ import 'package:purchases_flutter/entitlement_infos_wrapper.dart'; import 'package:purchases_flutter/transaction.dart'; +/// Class containing all information regarding the purchaser class PurchaserInfo { /// Entitlements attached to this purchaser info final EntitlementInfos entitlements; @@ -52,6 +53,7 @@ class PurchaserInfo { /// If there are multiple for different platforms, it will point to the device store. final String managementURL; + /// Constructs a PurchaserInfo from a JSON object. PurchaserInfo.fromJson(Map map) : entitlements = EntitlementInfos.fromJson( map["entitlements"] as Map), diff --git a/lib/purchases_flutter.dart b/lib/purchases_flutter.dart index 604ba619b..a9389de6b 100644 --- a/lib/purchases_flutter.dart +++ b/lib/purchases_flutter.dart @@ -7,8 +7,11 @@ import 'object_wrappers.dart'; export 'object_wrappers.dart'; +/// Used to handle async updates from [Purchases]. +/// Should be implemented to receive updates when the [PurchaserInfo] changes. typedef void PurchaserInfoUpdateListener(PurchaserInfo purchaserInfo); +/// Entry point for Purchases. class Purchases { static final Set _purchaserInfoUpdateListeners = Set(); @@ -531,18 +534,21 @@ class Purchases { } /// This class holds the information used when upgrading from another sku. -/// -/// [oldSKU] The oldSKU to upgrade from. -/// [prorationMode] The [ProrationMode] to use when upgrading the given oldSKU. +/// To be used with purchaseProduct and purchasePackage. class UpgradeInfo { + /// The oldSKU to upgrade from. String oldSKU; + + /// The [ProrationMode] to use when upgrading the given oldSKU. ProrationMode prorationMode; + /// Constructs an UpgradeInfo UpgradeInfo(this.oldSKU, {this.prorationMode}); } /// Replace SKU's ProrationMode. enum ProrationMode { + /// The Upgrade or Downgrade policy is unknown. unknownSubscriptionUpgradeDowngradePolicy, /// Replacement takes effect immediately, and the remaining time will be @@ -574,14 +580,27 @@ enum PurchaseType { /// Supported Attribution networks. enum PurchasesAttributionNetwork { + /// [https://searchads.apple.com/] appleSearchAds, + + /// [https://www.adjust.com/] adjust, + + /// [https://www.appsflyer.com/] appsflyer, + + /// [http://branch.io/] branch, + + /// [http://tenjin.io/] tenjin, + + /// [https://developers.facebook.com/] facebook } +/// Possible IntroEligibility status. +/// Use [checkTrialOrIntroductoryPriceEligibility] to determine the eligibility enum IntroEligibilityStatus { /// RevenueCat doesn't have enough information to determine eligibility. introEligibilityStatusUnknown, @@ -601,6 +620,7 @@ class IntroEligibility { /// Description of the status String description; + /// Constructs an Transaction from a JSON object IntroEligibility.fromJson(Map map) : status = IntroEligibilityStatus.values[map["status"]], description = map["description"]; diff --git a/lib/transaction.dart b/lib/transaction.dart index 7c1d858a9..a234b5d06 100644 --- a/lib/transaction.dart +++ b/lib/transaction.dart @@ -1,3 +1,4 @@ +/// Represents a purchase transaction class Transaction { /// RevenueCat Id associated to the transaction. final String revenueCatId; @@ -8,6 +9,7 @@ class Transaction { /// Purchase date of the transaction in ISO 8601 format. final String purchaseDate; + /// Constructs an Transaction from a JSON object Transaction.fromJson(Map map) : revenueCatId = map["revenueCatId"], productId = map["productId"],