From fbba5ea5be430f02c050662c1ca1c2ff9d295843 Mon Sep 17 00:00:00 2001 From: Hyo Date: Fri, 3 Oct 2025 04:32:59 +0900 Subject: [PATCH] feat: get plan info for subscriptions --- src/generated/Types.kt | 25 +++++++++++++++++++++++++ src/generated/Types.swift | 26 ++++++++++++++++++++++++++ src/generated/types.dart | 35 +++++++++++++++++++++++++++++++++++ src/generated/types.ts | 17 +++++++++++++++++ src/type-android.graphql | 1 + src/type-ios.graphql | 1 + src/type.graphql | 15 +++++++++++++++ 7 files changed, 120 insertions(+) diff --git a/src/generated/Types.kt b/src/generated/Types.kt index fed1bb8..0f44dc4 100644 --- a/src/generated/Types.kt +++ b/src/generated/Types.kt @@ -427,6 +427,13 @@ public interface ProductCommon { } public interface PurchaseCommon { + /** + * The current plan identifier. This is: + * - On Android: the basePlanId (e.g., "premium", "premium-year") + * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + * This provides a unified way to identify which specific plan/tier the user is subscribed to. + */ + val currentPlanId: String? val id: String val ids: List? val isAutoRenewing: Boolean @@ -445,6 +452,14 @@ public interface PurchaseCommon { public data class ActiveSubscription( val autoRenewingAndroid: Boolean? = null, + val basePlanIdAndroid: String? = null, + /** + * The current plan identifier. This is: + * - On Android: the basePlanId (e.g., "premium", "premium-year") + * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + * This provides a unified way to identify which specific plan/tier the user is subscribed to. + */ + val currentPlanId: String? = null, val daysUntilExpirationIOS: Double? = null, val environmentIOS: String? = null, val expirationDateIOS: Double? = null, @@ -460,6 +475,8 @@ public data class ActiveSubscription( fun fromJson(json: Map): ActiveSubscription { return ActiveSubscription( autoRenewingAndroid = json["autoRenewingAndroid"] as Boolean?, + basePlanIdAndroid = json["basePlanIdAndroid"] as String?, + currentPlanId = json["currentPlanId"] as String?, daysUntilExpirationIOS = (json["daysUntilExpirationIOS"] as Number?)?.toDouble(), environmentIOS = json["environmentIOS"] as String?, expirationDateIOS = (json["expirationDateIOS"] as Number?)?.toDouble(), @@ -476,6 +493,8 @@ public data class ActiveSubscription( fun toJson(): Map = mapOf( "__typename" to "ActiveSubscription", "autoRenewingAndroid" to autoRenewingAndroid, + "basePlanIdAndroid" to basePlanIdAndroid, + "currentPlanId" to currentPlanId, "daysUntilExpirationIOS" to daysUntilExpirationIOS, "environmentIOS" to environmentIOS, "expirationDateIOS" to expirationDateIOS, @@ -1015,6 +1034,7 @@ public data class ProductSubscriptionIOS( public data class PurchaseAndroid( val autoRenewingAndroid: Boolean? = null, + val currentPlanId: String? = null, val dataAndroid: String? = null, val developerPayloadAndroid: String? = null, val id: String, @@ -1038,6 +1058,7 @@ public data class PurchaseAndroid( fun fromJson(json: Map): PurchaseAndroid { return PurchaseAndroid( autoRenewingAndroid = json["autoRenewingAndroid"] as Boolean?, + currentPlanId = json["currentPlanId"] as String?, dataAndroid = json["dataAndroid"] as String?, developerPayloadAndroid = json["developerPayloadAndroid"] as String?, id = json["id"] as String, @@ -1062,6 +1083,7 @@ public data class PurchaseAndroid( override fun toJson(): Map = mapOf( "__typename" to "PurchaseAndroid", "autoRenewingAndroid" to autoRenewingAndroid, + "currentPlanId" to currentPlanId, "dataAndroid" to dataAndroid, "developerPayloadAndroid" to developerPayloadAndroid, "id" to id, @@ -1112,6 +1134,7 @@ public data class PurchaseIOS( val countryCodeIOS: String? = null, val currencyCodeIOS: String? = null, val currencySymbolIOS: String? = null, + val currentPlanId: String? = null, val environmentIOS: String? = null, val expirationDateIOS: Double? = null, val id: String, @@ -1148,6 +1171,7 @@ public data class PurchaseIOS( countryCodeIOS = json["countryCodeIOS"] as String?, currencyCodeIOS = json["currencyCodeIOS"] as String?, currencySymbolIOS = json["currencySymbolIOS"] as String?, + currentPlanId = json["currentPlanId"] as String?, environmentIOS = json["environmentIOS"] as String?, expirationDateIOS = (json["expirationDateIOS"] as Number?)?.toDouble(), id = json["id"] as String, @@ -1185,6 +1209,7 @@ public data class PurchaseIOS( "countryCodeIOS" to countryCodeIOS, "currencyCodeIOS" to currencyCodeIOS, "currencySymbolIOS" to currencySymbolIOS, + "currentPlanId" to currentPlanId, "environmentIOS" to environmentIOS, "expirationDateIOS" to expirationDateIOS, "id" to id, diff --git a/src/generated/Types.swift b/src/generated/Types.swift index 3319847..20ba253 100644 --- a/src/generated/Types.swift +++ b/src/generated/Types.swift @@ -131,6 +131,11 @@ public protocol ProductCommon: Codable { } public protocol PurchaseCommon: Codable { + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + var currentPlanId: String? { get } var id: String { get } var ids: [String]? { get } var isAutoRenewing: Bool { get } @@ -147,6 +152,12 @@ public protocol PurchaseCommon: Codable { public struct ActiveSubscription: Codable { public var autoRenewingAndroid: Bool? + public var basePlanIdAndroid: String? + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + public var currentPlanId: String? public var daysUntilExpirationIOS: Double? public var environmentIOS: String? public var expirationDateIOS: Double? @@ -314,6 +325,7 @@ public struct ProductSubscriptionIOS: Codable, ProductCommon { public struct PurchaseAndroid: Codable, PurchaseCommon { public var autoRenewingAndroid: Bool? + public var currentPlanId: String? public var dataAndroid: String? public var developerPayloadAndroid: String? public var id: String @@ -345,6 +357,7 @@ public struct PurchaseIOS: Codable, PurchaseCommon { public var countryCodeIOS: String? public var currencyCodeIOS: String? public var currencySymbolIOS: String? + public var currentPlanId: String? public var environmentIOS: String? public var expirationDateIOS: Double? public var id: String @@ -853,6 +866,19 @@ public enum Purchase: Codable, PurchaseCommon { case purchaseAndroid(PurchaseAndroid) case purchaseIos(PurchaseIOS) + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + public var currentPlanId: String? { + switch self { + case let .purchaseAndroid(value): + return value.currentPlanId + case let .purchaseIos(value): + return value.currentPlanId + } + } + public var id: String { switch self { case let .purchaseAndroid(value): diff --git a/src/generated/types.dart b/src/generated/types.dart index 5c30804..beb7033 100644 --- a/src/generated/types.dart +++ b/src/generated/types.dart @@ -522,6 +522,11 @@ abstract class ProductCommon { } abstract class PurchaseCommon { + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + String? get currentPlanId; String get id; List? get ids; bool get isAutoRenewing; @@ -539,6 +544,12 @@ abstract class PurchaseCommon { class ActiveSubscription { const ActiveSubscription({ this.autoRenewingAndroid, + this.basePlanIdAndroid, + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + this.currentPlanId, this.daysUntilExpirationIOS, this.environmentIOS, this.expirationDateIOS, @@ -551,6 +562,12 @@ class ActiveSubscription { }); final bool? autoRenewingAndroid; + final String? basePlanIdAndroid; + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + final String? currentPlanId; final double? daysUntilExpirationIOS; final String? environmentIOS; final double? expirationDateIOS; @@ -564,6 +581,8 @@ class ActiveSubscription { factory ActiveSubscription.fromJson(Map json) { return ActiveSubscription( autoRenewingAndroid: json['autoRenewingAndroid'] as bool?, + basePlanIdAndroid: json['basePlanIdAndroid'] as String?, + currentPlanId: json['currentPlanId'] as String?, daysUntilExpirationIOS: (json['daysUntilExpirationIOS'] as num?)?.toDouble(), environmentIOS: json['environmentIOS'] as String?, expirationDateIOS: (json['expirationDateIOS'] as num?)?.toDouble(), @@ -580,6 +599,8 @@ class ActiveSubscription { return { '__typename': 'ActiveSubscription', 'autoRenewingAndroid': autoRenewingAndroid, + 'basePlanIdAndroid': basePlanIdAndroid, + 'currentPlanId': currentPlanId, 'daysUntilExpirationIOS': daysUntilExpirationIOS, 'environmentIOS': environmentIOS, 'expirationDateIOS': expirationDateIOS, @@ -1260,6 +1281,7 @@ class ProductSubscriptionIOS extends ProductSubscription implements ProductCommo class PurchaseAndroid extends Purchase implements PurchaseCommon { const PurchaseAndroid({ this.autoRenewingAndroid, + this.currentPlanId, this.dataAndroid, this.developerPayloadAndroid, required this.id, @@ -1281,6 +1303,7 @@ class PurchaseAndroid extends Purchase implements PurchaseCommon { }); final bool? autoRenewingAndroid; + final String? currentPlanId; final String? dataAndroid; final String? developerPayloadAndroid; final String id; @@ -1303,6 +1326,7 @@ class PurchaseAndroid extends Purchase implements PurchaseCommon { factory PurchaseAndroid.fromJson(Map json) { return PurchaseAndroid( autoRenewingAndroid: json['autoRenewingAndroid'] as bool?, + currentPlanId: json['currentPlanId'] as String?, dataAndroid: json['dataAndroid'] as String?, developerPayloadAndroid: json['developerPayloadAndroid'] as String?, id: json['id'] as String, @@ -1329,6 +1353,7 @@ class PurchaseAndroid extends Purchase implements PurchaseCommon { return { '__typename': 'PurchaseAndroid', 'autoRenewingAndroid': autoRenewingAndroid, + 'currentPlanId': currentPlanId, 'dataAndroid': dataAndroid, 'developerPayloadAndroid': developerPayloadAndroid, 'id': id, @@ -1387,6 +1412,7 @@ class PurchaseIOS extends Purchase implements PurchaseCommon { this.countryCodeIOS, this.currencyCodeIOS, this.currencySymbolIOS, + this.currentPlanId, this.environmentIOS, this.expirationDateIOS, required this.id, @@ -1421,6 +1447,7 @@ class PurchaseIOS extends Purchase implements PurchaseCommon { final String? countryCodeIOS; final String? currencyCodeIOS; final String? currencySymbolIOS; + final String? currentPlanId; final String? environmentIOS; final double? expirationDateIOS; final String id; @@ -1456,6 +1483,7 @@ class PurchaseIOS extends Purchase implements PurchaseCommon { countryCodeIOS: json['countryCodeIOS'] as String?, currencyCodeIOS: json['currencyCodeIOS'] as String?, currencySymbolIOS: json['currencySymbolIOS'] as String?, + currentPlanId: json['currentPlanId'] as String?, environmentIOS: json['environmentIOS'] as String?, expirationDateIOS: (json['expirationDateIOS'] as num?)?.toDouble(), id: json['id'] as String, @@ -1495,6 +1523,7 @@ class PurchaseIOS extends Purchase implements PurchaseCommon { 'countryCodeIOS': countryCodeIOS, 'currencyCodeIOS': currencyCodeIOS, 'currencySymbolIOS': currencySymbolIOS, + 'currentPlanId': currentPlanId, 'environmentIOS': environmentIOS, 'expirationDateIOS': expirationDateIOS, 'id': id, @@ -2528,6 +2557,12 @@ sealed class Purchase implements PurchaseCommon { throw ArgumentError('Unknown __typename for Purchase: $typeName'); } + /// The current plan identifier. This is: + /// - On Android: the basePlanId (e.g., "premium", "premium-year") + /// - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + /// This provides a unified way to identify which specific plan/tier the user is subscribed to. + @override + String? get currentPlanId; @override String get id; @override diff --git a/src/generated/types.ts b/src/generated/types.ts index 32e74f5..537c436 100644 --- a/src/generated/types.ts +++ b/src/generated/types.ts @@ -5,6 +5,14 @@ export interface ActiveSubscription { autoRenewingAndroid?: (boolean | null); + basePlanIdAndroid?: (string | null); + /** + * The current plan identifier. This is: + * - On Android: the basePlanId (e.g., "premium", "premium-year") + * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + * This provides a unified way to identify which specific plan/tier the user is subscribed to. + */ + currentPlanId?: (string | null); daysUntilExpirationIOS?: (number | null); environmentIOS?: (string | null); expirationDateIOS?: (number | null); @@ -381,6 +389,7 @@ export type Purchase = PurchaseAndroid | PurchaseIOS; export interface PurchaseAndroid extends PurchaseCommon { autoRenewingAndroid?: (boolean | null); + currentPlanId?: (string | null); dataAndroid?: (string | null); developerPayloadAndroid?: (string | null); id: string; @@ -401,6 +410,13 @@ export interface PurchaseAndroid extends PurchaseCommon { } export interface PurchaseCommon { + /** + * The current plan identifier. This is: + * - On Android: the basePlanId (e.g., "premium", "premium-year") + * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + * This provides a unified way to identify which specific plan/tier the user is subscribed to. + */ + currentPlanId?: (string | null); id: string; ids?: (string[] | null); isAutoRenewing: boolean; @@ -425,6 +441,7 @@ export interface PurchaseIOS extends PurchaseCommon { countryCodeIOS?: (string | null); currencyCodeIOS?: (string | null); currencySymbolIOS?: (string | null); + currentPlanId?: (string | null); environmentIOS?: (string | null); expirationDateIOS?: (number | null); id: string; diff --git a/src/type-android.graphql b/src/type-android.graphql index bc8efe1..21c3685 100644 --- a/src/type-android.graphql +++ b/src/type-android.graphql @@ -78,6 +78,7 @@ type PurchaseAndroid implements PurchaseCommon { quantity: Int! purchaseState: PurchaseState! isAutoRenewing: Boolean! + currentPlanId: String # Android-specific fields dataAndroid: String diff --git a/src/type-ios.graphql b/src/type-ios.graphql index 91624cd..fda4527 100644 --- a/src/type-ios.graphql +++ b/src/type-ios.graphql @@ -132,6 +132,7 @@ type PurchaseIOS implements PurchaseCommon { quantity: Int! purchaseState: PurchaseState! isAutoRenewing: Boolean! + currentPlanId: String # iOS-specific fields transactionId: String! diff --git a/src/type.graphql b/src/type.graphql index a5fe881..5329fc8 100644 --- a/src/type.graphql +++ b/src/type.graphql @@ -57,6 +57,13 @@ interface PurchaseCommon { quantity: Int! purchaseState: PurchaseState! isAutoRenewing: Boolean! + """ + The current plan identifier. This is: + - On Android: the basePlanId (e.g., "premium", "premium-year") + - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + This provides a unified way to identify which specific plan/tier the user is subscribed to. + """ + currentPlanId: String } # Unions for platform-specific types @@ -203,6 +210,14 @@ type ActiveSubscription { transactionId: String! purchaseToken: String transactionDate: Float! + basePlanIdAndroid: String + """ + The current plan identifier. This is: + - On Android: the basePlanId (e.g., "premium", "premium-year") + - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly") + This provides a unified way to identify which specific plan/tier the user is subscribed to. + """ + currentPlanId: String } # Initialization configuration