Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dart-side handling of sku->skus
  • Loading branch information
GaryQian committed Jul 7, 2022
commit 40ba0fd8d8b817508fd70eddfae83730c0e5d40b
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ static HashMap<String, Object> fromPurchase(Purchase purchase) {
info.put("purchaseTime", purchase.getPurchaseTime());
info.put("purchaseToken", purchase.getPurchaseToken());
info.put("signature", purchase.getSignature());
// TODO(garyq): Remove deprecated `sku`.
// `sku` was deprecated in billion 4.0, but we cannot directly remove it from our
// API instantly. Thus, for backwards compatibility, we pass the first sku here
// and include the rest of the list under `skus`.
if (!skus.isEmpty()) {
info.put("sku", skus.get(0));
}
info.put("skus", skus);
info.put("isAutoRenewing", purchase.isAutoRenewing());
info.put("originalJson", purchase.getOriginalJson());
Expand All @@ -90,13 +83,6 @@ static HashMap<String, Object> fromPurchaseHistoryRecord(
info.put("purchaseTime", purchaseHistoryRecord.getPurchaseTime());
info.put("purchaseToken", purchaseHistoryRecord.getPurchaseToken());
info.put("signature", purchaseHistoryRecord.getSignature());
// TODO(garyq): Remove deprecated `sku`.
// `sku` was deprecated in billion 4.0, but we cannot directly remove it from our
// API instantly. Thus, for backwards compatibility, we pass the first sku here
// and include the rest of the list under `skus`.
if (!skus.isEmpty()) {
info.put("sku", skus.get(0));
}
info.put("skus", skus);
info.put("developerPayload", purchaseHistoryRecord.getDeveloperPayload());
info.put("originalJson", purchaseHistoryRecord.getOriginalJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ class PurchaseWrapper {
required this.purchaseToken,
required this.signature,
@Deprecated('Use skus instead')
this.sku = '', // Deprecated
required this.skus,
String? sku, // Deprecated
this.skus,
required this.isAutoRenewing,
required this.originalJson,
this.developerPayload,
required this.isAcknowledged,
required this.purchaseState,
this.obfuscatedAccountId,
this.obfuscatedProfileId,
});
}) : _sku(sku);

/// Factory for creating a [PurchaseWrapper] from a [Map] with the purchase details.
factory PurchaseWrapper.fromJson(Map<String, dynamic> map) =>
Expand Down Expand Up @@ -108,7 +108,8 @@ class PurchaseWrapper {
/// The product ID of this purchase.
@JsonKey(defaultValue: '')
@Deprecated('Use skus instead')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move the logic to dart, sku would be skus.first

final String sku;
final String get sku => _sku ?? skus.first;
final String? _sku;

/// The product IDs of this purchase.
@JsonKey(defaultValue: <String>[])
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.