Skip to content

Commit

Permalink
Prep for release 3.10.0 (#345)
Browse files Browse the repository at this point in the history
Co-authored-by: Cesar de la Vega <[email protected]>
  • Loading branch information
vegaro committed Apr 20, 2022
1 parent 9ad509d commit a232922
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class PurchasesFlutterPlugin implements FlutterPlugin, MethodCallHandler, ActivityAware {
private String INVALID_ARGS_ERROR_CODE = "invalidArgs";

private static final String PURCHASER_INFO_UPDATED = "Purchases-PurchaserInfoUpdated";
private static final String CUSTOMER_INFO_UPDATED = "Purchases-CustomerInfoUpdated";

// Only set registrar for v1 embedder.
@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -198,7 +198,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
String proxyURLString = call.argument("proxyURLString");
setProxyURLString(proxyURLString, result);
break;
case "getPurchaserInfo":
case "getCustomerInfo":
getPurchaserInfo(result);
break;
case "syncPurchases":
Expand All @@ -217,7 +217,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
productIdentifiers = call.argument("productIdentifiers");
checkTrialOrIntroductoryPriceEligibility(productIdentifiers, result);
break;
case "invalidatePurchaserInfoCache":
case "invalidateCustomerInfoCache":
invalidatePurchaserInfoCache(result);
break;
case "presentCodeRedemptionSheet":
Expand Down Expand Up @@ -325,12 +325,9 @@ private void setupPurchases(String apiKey, String appUserID, @Nullable Boolean o
}

private void setupUpdatedPurchaserInfoListener() {
Purchases.getSharedInstance().setUpdatedPurchaserInfoListener(new UpdatedPurchaserInfoListener() {
@Override
public void onReceived(@NonNull PurchaserInfo purchaserInfo) {
if (channel != null) {
channel.invokeMethod(PURCHASER_INFO_UPDATED, PurchaserInfoMapperKt.map(purchaserInfo));
}
Purchases.getSharedInstance().setUpdatedPurchaserInfoListener(purchaserInfo -> {
if (channel != null) {
channel.invokeMethod(CUSTOMER_INFO_UPDATED, PurchaserInfoMapperKt.map(purchaserInfo));
}
});
}
Expand Down
25 changes: 12 additions & 13 deletions ios/Classes/PurchasesFlutterPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ @interface PurchasesFlutterPlugin () <RCPurchasesDelegate>
@end


NSString *PurchasesPurchaserInfoUpdatedEvent = @"Purchases-PurchaserInfoUpdated";
NSString *PurchasesCustomerInfoUpdatedEvent = @"Purchases-CustomerInfoUpdated";
NSString *PurchasesReadyForPromotedProductPurchaseEvent = @"Purchases-ReadyForPromotedProductPurchase";


@implementation PurchasesFlutterPlugin

- (instancetype)initWithChannel:(FlutterMethodChannel *)channel
Expand Down Expand Up @@ -94,8 +93,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
[self setSimulatesAskToBuyInSandbox:[arguments[@"enabled"] boolValue] result:result];
} else if ([@"setProxyURLString" isEqualToString:call.method]) {
[self setProxyURLString:arguments[@"proxyURLString"] result:result];
} else if ([@"getPurchaserInfo" isEqualToString:call.method]) {
[self getPurchaserInfoWithResult:result];
} else if ([@"getCustomerInfo" isEqualToString:call.method]) {
[self getCustomerInfoWithResult:result];
} else if ([@"syncPurchases" isEqualToString:call.method]) {
[self syncPurchasesWithResult:result];
} else if ([@"setAutomaticAppleSearchAdsAttributionCollection" isEqualToString:call.method]) {
Expand All @@ -106,8 +105,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call
[self isConfiguredWithResult:result];
} else if ([@"checkTrialOrIntroductoryPriceEligibility" isEqualToString:call.method]) {
[self checkTrialOrIntroductoryPriceEligibility:arguments[@"productIdentifiers"] result:result];
} else if ([@"invalidatePurchaserInfoCache" isEqualToString:call.method]) {
[self invalidatePurchaserInfoCacheWithResult:result];
} else if ([@"invalidateCustomerInfoCache" isEqualToString:call.method]) {
[self invalidateCustomerInfoCacheWithResult:result];
} else if ([@"presentCodeRedemptionSheet" isEqualToString:call.method]) {
[self presentCodeRedemptionSheetWithResult:result];
} else if ([@"setAttributes" isEqualToString:call.method]) {
Expand Down Expand Up @@ -322,8 +321,8 @@ - (void)setSimulatesAskToBuyInSandbox:(BOOL)enabled
result(nil);
}

- (void)getPurchaserInfoWithResult:(FlutterResult)result {
[RCCommonFunctionality getPurchaserInfoWithCompletionBlock:[self getResponseCompletionBlock:result]];
- (void)getCustomerInfoWithResult:(FlutterResult)result {
[RCCommonFunctionality getCustomerInfoWithCompletionBlock:[self getResponseCompletionBlock:result]];
}

- (void)setAutomaticAppleSearchAdsAttributionCollection:(BOOL)enabled
Expand All @@ -348,8 +347,8 @@ - (void)checkTrialOrIntroductoryPriceEligibility:(NSArray *)products
}];
}

- (void)invalidatePurchaserInfoCacheWithResult:(FlutterResult)result {
[RCCommonFunctionality invalidatePurchaserInfoCache];
- (void)invalidateCustomerInfoCacheWithResult:(FlutterResult)result {
[RCCommonFunctionality invalidateCustomerInfoCache];
result(nil);
}

Expand Down Expand Up @@ -492,9 +491,9 @@ - (void)closeWithResult:(FlutterResult)result {
#pragma mark -
#pragma mark Delegate Methods

- (void)purchases:(RCPurchases *)purchases didReceiveUpdatedPurchaserInfo:(RCPurchaserInfo *)purchaserInfo {
[self.channel invokeMethod:PurchasesPurchaserInfoUpdatedEvent
arguments:purchaserInfo.dictionary];
- (void)purchases:(RCPurchases *)purchases didReceiveUpdatedCustomerInfo:(RCCustomerInfo *)customerInfo {
[self.channel invokeMethod:PurchasesCustomerInfoUpdatedEvent
arguments:customerInfo.dictionary];
}

- (void) purchases:(RCPurchases *)purchases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'entitlement_infos_wrapper.dart';
import 'transaction.dart';

part 'purchaser_info_wrapper.freezed.dart';
part 'purchaser_info_wrapper.g.dart';
part 'customer_info_wrapper.freezed.dart';
part 'customer_info_wrapper.g.dart';

@freezed

/// Class containing all information regarding the purchaser
class PurchaserInfo with _$PurchaserInfo {
const factory PurchaserInfo(
/// Entitlements attached to this purchaser info
/// Class containing all information regarding the customer
class CustomerInfo with _$CustomerInfo {
const factory CustomerInfo(
/// Entitlements attached to this customer info
@JsonKey(name: 'entitlements') EntitlementInfos entitlements,

/// Map of skus to purchase dates
Expand Down Expand Up @@ -66,8 +66,8 @@ class PurchaserInfo with _$PurchaserInfo {
/// it will point there. If there are no active subscriptions it will be null.
/// If there are multiple for different platforms, it will point to the device store.
@JsonKey(name: 'managementURL') String? managementURL,
}) = _PurchaserInfo;
}) = _CustomerInfo;

factory PurchaserInfo.fromJson(Map<String, dynamic> json) =>
_$PurchaserInfoFromJson(json);
factory CustomerInfo.fromJson(Map<String, dynamic> json) =>
_$CustomerInfoFromJson(json);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target

part of 'purchaser_info_wrapper.dart';
part of 'customer_info_wrapper.dart';

// **************************************************************************
// FreezedGenerator
Expand All @@ -14,15 +14,15 @@ T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

PurchaserInfo _$PurchaserInfoFromJson(Map<String, dynamic> json) {
return _PurchaserInfo.fromJson(json);
CustomerInfo _$CustomerInfoFromJson(Map<String, dynamic> json) {
return _CustomerInfo.fromJson(json);
}

/// @nodoc
class _$PurchaserInfoTearOff {
const _$PurchaserInfoTearOff();
class _$CustomerInfoTearOff {
const _$CustomerInfoTearOff();

_PurchaserInfo call(
_CustomerInfo call(
@JsonKey(name: 'entitlements')
EntitlementInfos entitlements,
@JsonKey(name: 'allPurchaseDates')
Expand All @@ -49,7 +49,7 @@ class _$PurchaserInfoTearOff {
String? originalApplicationVersion,
@JsonKey(name: 'managementURL')
String? managementURL}) {
return _PurchaserInfo(
return _CustomerInfo(
entitlements,
allPurchaseDates,
activeSubscriptions,
Expand All @@ -66,17 +66,17 @@ class _$PurchaserInfoTearOff {
);
}

PurchaserInfo fromJson(Map<String, Object?> json) {
return PurchaserInfo.fromJson(json);
CustomerInfo fromJson(Map<String, Object?> json) {
return CustomerInfo.fromJson(json);
}
}

/// @nodoc
const $PurchaserInfo = _$PurchaserInfoTearOff();
const $CustomerInfo = _$CustomerInfoTearOff();

/// @nodoc
mixin _$PurchaserInfo {
/// Entitlements attached to this purchaser info
mixin _$CustomerInfo {
/// Entitlements attached to this customer info
@JsonKey(name: 'entitlements')
EntitlementInfos get entitlements => throw _privateConstructorUsedError;

Expand Down Expand Up @@ -145,15 +145,15 @@ mixin _$PurchaserInfo {

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$PurchaserInfoCopyWith<PurchaserInfo> get copyWith =>
$CustomerInfoCopyWith<CustomerInfo> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $PurchaserInfoCopyWith<$Res> {
factory $PurchaserInfoCopyWith(
PurchaserInfo value, $Res Function(PurchaserInfo) then) =
_$PurchaserInfoCopyWithImpl<$Res>;
abstract class $CustomerInfoCopyWith<$Res> {
factory $CustomerInfoCopyWith(
CustomerInfo value, $Res Function(CustomerInfo) then) =
_$CustomerInfoCopyWithImpl<$Res>;
$Res call(
{@JsonKey(name: 'entitlements')
EntitlementInfos entitlements,
Expand Down Expand Up @@ -186,13 +186,12 @@ abstract class $PurchaserInfoCopyWith<$Res> {
}

/// @nodoc
class _$PurchaserInfoCopyWithImpl<$Res>
implements $PurchaserInfoCopyWith<$Res> {
_$PurchaserInfoCopyWithImpl(this._value, this._then);
class _$CustomerInfoCopyWithImpl<$Res> implements $CustomerInfoCopyWith<$Res> {
_$CustomerInfoCopyWithImpl(this._value, this._then);

final PurchaserInfo _value;
final CustomerInfo _value;
// ignore: unused_field
final $Res Function(PurchaserInfo) _then;
final $Res Function(CustomerInfo) _then;

@override
$Res call({
Expand Down Expand Up @@ -275,11 +274,11 @@ class _$PurchaserInfoCopyWithImpl<$Res>
}

/// @nodoc
abstract class _$PurchaserInfoCopyWith<$Res>
implements $PurchaserInfoCopyWith<$Res> {
factory _$PurchaserInfoCopyWith(
_PurchaserInfo value, $Res Function(_PurchaserInfo) then) =
__$PurchaserInfoCopyWithImpl<$Res>;
abstract class _$CustomerInfoCopyWith<$Res>
implements $CustomerInfoCopyWith<$Res> {
factory _$CustomerInfoCopyWith(
_CustomerInfo value, $Res Function(_CustomerInfo) then) =
__$CustomerInfoCopyWithImpl<$Res>;
@override
$Res call(
{@JsonKey(name: 'entitlements')
Expand Down Expand Up @@ -314,15 +313,14 @@ abstract class _$PurchaserInfoCopyWith<$Res>
}

/// @nodoc
class __$PurchaserInfoCopyWithImpl<$Res>
extends _$PurchaserInfoCopyWithImpl<$Res>
implements _$PurchaserInfoCopyWith<$Res> {
__$PurchaserInfoCopyWithImpl(
_PurchaserInfo _value, $Res Function(_PurchaserInfo) _then)
: super(_value, (v) => _then(v as _PurchaserInfo));
class __$CustomerInfoCopyWithImpl<$Res> extends _$CustomerInfoCopyWithImpl<$Res>
implements _$CustomerInfoCopyWith<$Res> {
__$CustomerInfoCopyWithImpl(
_CustomerInfo _value, $Res Function(_CustomerInfo) _then)
: super(_value, (v) => _then(v as _CustomerInfo));

@override
_PurchaserInfo get _value => super._value as _PurchaserInfo;
_CustomerInfo get _value => super._value as _CustomerInfo;

@override
$Res call({
Expand All @@ -340,7 +338,7 @@ class __$PurchaserInfoCopyWithImpl<$Res>
Object? originalApplicationVersion = freezed,
Object? managementURL = freezed,
}) {
return _then(_PurchaserInfo(
return _then(_CustomerInfo(
entitlements == freezed
? _value.entitlements
: entitlements // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -399,8 +397,8 @@ class __$PurchaserInfoCopyWithImpl<$Res>

/// @nodoc
@JsonSerializable()
class _$_PurchaserInfo implements _PurchaserInfo {
const _$_PurchaserInfo(
class _$_CustomerInfo implements _CustomerInfo {
const _$_CustomerInfo(
@JsonKey(name: 'entitlements')
this.entitlements,
@JsonKey(name: 'allPurchaseDates')
Expand Down Expand Up @@ -428,12 +426,12 @@ class _$_PurchaserInfo implements _PurchaserInfo {
@JsonKey(name: 'managementURL')
this.managementURL});

factory _$_PurchaserInfo.fromJson(Map<String, dynamic> json) =>
_$$_PurchaserInfoFromJson(json);
factory _$_CustomerInfo.fromJson(Map<String, dynamic> json) =>
_$$_CustomerInfoFromJson(json);

@override

/// Entitlements attached to this purchaser info
/// Entitlements attached to this customer info
@JsonKey(name: 'entitlements')
final EntitlementInfos entitlements;
@override
Expand Down Expand Up @@ -510,14 +508,14 @@ class _$_PurchaserInfo implements _PurchaserInfo {

@override
String toString() {
return 'PurchaserInfo(entitlements: $entitlements, allPurchaseDates: $allPurchaseDates, activeSubscriptions: $activeSubscriptions, allPurchasedProductIdentifiers: $allPurchasedProductIdentifiers, nonSubscriptionTransactions: $nonSubscriptionTransactions, firstSeen: $firstSeen, originalAppUserId: $originalAppUserId, allExpirationDates: $allExpirationDates, requestDate: $requestDate, latestExpirationDate: $latestExpirationDate, originalPurchaseDate: $originalPurchaseDate, originalApplicationVersion: $originalApplicationVersion, managementURL: $managementURL)';
return 'CustomerInfo(entitlements: $entitlements, allPurchaseDates: $allPurchaseDates, activeSubscriptions: $activeSubscriptions, allPurchasedProductIdentifiers: $allPurchasedProductIdentifiers, nonSubscriptionTransactions: $nonSubscriptionTransactions, firstSeen: $firstSeen, originalAppUserId: $originalAppUserId, allExpirationDates: $allExpirationDates, requestDate: $requestDate, latestExpirationDate: $latestExpirationDate, originalPurchaseDate: $originalPurchaseDate, originalApplicationVersion: $originalApplicationVersion, managementURL: $managementURL)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _PurchaserInfo &&
other is _CustomerInfo &&
const DeepCollectionEquality()
.equals(other.entitlements, entitlements) &&
const DeepCollectionEquality()
Expand Down Expand Up @@ -566,17 +564,17 @@ class _$_PurchaserInfo implements _PurchaserInfo {

@JsonKey(ignore: true)
@override
_$PurchaserInfoCopyWith<_PurchaserInfo> get copyWith =>
__$PurchaserInfoCopyWithImpl<_PurchaserInfo>(this, _$identity);
_$CustomerInfoCopyWith<_CustomerInfo> get copyWith =>
__$CustomerInfoCopyWithImpl<_CustomerInfo>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$_PurchaserInfoToJson(this);
return _$$_CustomerInfoToJson(this);
}
}

abstract class _PurchaserInfo implements PurchaserInfo {
const factory _PurchaserInfo(
abstract class _CustomerInfo implements CustomerInfo {
const factory _CustomerInfo(
@JsonKey(name: 'entitlements')
EntitlementInfos entitlements,
@JsonKey(name: 'allPurchaseDates')
Expand All @@ -602,14 +600,14 @@ abstract class _PurchaserInfo implements PurchaserInfo {
@JsonKey(name: 'originalApplicationVersion', nullable: true)
String? originalApplicationVersion,
@JsonKey(name: 'managementURL')
String? managementURL}) = _$_PurchaserInfo;
String? managementURL}) = _$_CustomerInfo;

factory _PurchaserInfo.fromJson(Map<String, dynamic> json) =
_$_PurchaserInfo.fromJson;
factory _CustomerInfo.fromJson(Map<String, dynamic> json) =
_$_CustomerInfo.fromJson;

@override

/// Entitlements attached to this purchaser info
/// Entitlements attached to this customer info
@JsonKey(name: 'entitlements')
EntitlementInfos get entitlements;
@override
Expand Down Expand Up @@ -685,6 +683,6 @@ abstract class _PurchaserInfo implements PurchaserInfo {
String? get managementURL;
@override
@JsonKey(ignore: true)
_$PurchaserInfoCopyWith<_PurchaserInfo> get copyWith =>
_$CustomerInfoCopyWith<_CustomerInfo> get copyWith =>
throw _privateConstructorUsedError;
}
Loading

0 comments on commit a232922

Please sign in to comment.