diff --git a/src/generated/Types.kt b/src/generated/Types.kt index 77dc6af..5c38a86 100644 --- a/src/generated/Types.kt +++ b/src/generated/Types.kt @@ -222,6 +222,33 @@ public enum class PaymentModeIOS(val rawValue: String) { fun toJson(): String = rawValue } +public enum class ProductDetailType(val rawValue: String) { + Consumable("consumable"), + NonConsumable("non-consumable"), + AutoRenewableSubscription("auto-renewable-subscription"), + NonRenewingSubscription("non-renewing-subscription") + + companion object { + fun fromJson(value: String): ProductDetailType = when (value) { + "consumable" -> ProductDetailType.Consumable + "CONSUMABLE" -> ProductDetailType.Consumable + "Consumable" -> ProductDetailType.Consumable + "non-consumable" -> ProductDetailType.NonConsumable + "NON_CONSUMABLE" -> ProductDetailType.NonConsumable + "NonConsumable" -> ProductDetailType.NonConsumable + "auto-renewable-subscription" -> ProductDetailType.AutoRenewableSubscription + "AUTO_RENEWABLE_SUBSCRIPTION" -> ProductDetailType.AutoRenewableSubscription + "AutoRenewableSubscription" -> ProductDetailType.AutoRenewableSubscription + "non-renewing-subscription" -> ProductDetailType.NonRenewingSubscription + "NON_RENEWING_SUBSCRIPTION" -> ProductDetailType.NonRenewingSubscription + "NonRenewingSubscription" -> ProductDetailType.NonRenewingSubscription + else -> throw IllegalArgumentException("Unknown ProductDetailType value: $value") + } + } + + fun toJson(): String = rawValue +} + public enum class ProductQueryType(val rawValue: String) { InApp("in-app"), Subs("subs"), @@ -389,6 +416,7 @@ public interface ProductCommon { val price: Double? val title: String val type: ProductType + val typeDetails: ProductDetailType } public interface PurchaseCommon { @@ -685,7 +713,8 @@ public data class ProductAndroid( val price: Double? = null, val subscriptionOfferDetailsAndroid: List? = null, val title: String, - val type: ProductType + val type: ProductType, + val typeDetails: ProductDetailType ) : ProductCommon, Product { companion object { @@ -704,6 +733,7 @@ public data class ProductAndroid( subscriptionOfferDetailsAndroid = (json["subscriptionOfferDetailsAndroid"] as List<*>?)?.map { ProductSubscriptionAndroidOfferDetails.fromJson((it as Map)) }, title = json["title"] as String, type = ProductType.fromJson(json["type"] as String), + typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String), ) } } @@ -723,6 +753,7 @@ public data class ProductAndroid( "subscriptionOfferDetailsAndroid" to subscriptionOfferDetailsAndroid?.map { it.toJson() }, "title" to title, "type" to type.toJson(), + "typeDetails" to typeDetails.toJson(), ) } @@ -765,6 +796,7 @@ public data class ProductIOS( val subscriptionInfoIOS: SubscriptionInfoIOS? = null, val title: String, val type: ProductType, + val typeDetails: ProductDetailType, val typeIOS: ProductTypeIOS ) : ProductCommon, Product { @@ -785,6 +817,7 @@ public data class ProductIOS( subscriptionInfoIOS = (json["subscriptionInfoIOS"] as Map?)?.let { SubscriptionInfoIOS.fromJson(it) }, title = json["title"] as String, type = ProductType.fromJson(json["type"] as String), + typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String), typeIOS = ProductTypeIOS.fromJson(json["typeIOS"] as String), ) } @@ -806,6 +839,7 @@ public data class ProductIOS( "subscriptionInfoIOS" to subscriptionInfoIOS?.toJson(), "title" to title, "type" to type.toJson(), + "typeDetails" to typeDetails.toJson(), "typeIOS" to typeIOS.toJson(), ) } @@ -823,7 +857,8 @@ public data class ProductSubscriptionAndroid( val price: Double? = null, val subscriptionOfferDetailsAndroid: List, val title: String, - val type: ProductType + val type: ProductType, + val typeDetails: ProductDetailType ) : ProductCommon, ProductSubscription { companion object { @@ -842,6 +877,7 @@ public data class ProductSubscriptionAndroid( subscriptionOfferDetailsAndroid = (json["subscriptionOfferDetailsAndroid"] as List<*>).map { ProductSubscriptionAndroidOfferDetails.fromJson((it as Map)) }, title = json["title"] as String, type = ProductType.fromJson(json["type"] as String), + typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String), ) } } @@ -861,6 +897,7 @@ public data class ProductSubscriptionAndroid( "subscriptionOfferDetailsAndroid" to subscriptionOfferDetailsAndroid.map { it.toJson() }, "title" to title, "type" to type.toJson(), + "typeDetails" to typeDetails.toJson(), ) } @@ -917,6 +954,7 @@ public data class ProductSubscriptionIOS( val subscriptionPeriodUnitIOS: SubscriptionPeriodIOS? = null, val title: String, val type: ProductType, + val typeDetails: ProductDetailType, val typeIOS: ProductTypeIOS ) : ProductCommon, ProductSubscription { @@ -945,6 +983,7 @@ public data class ProductSubscriptionIOS( subscriptionPeriodUnitIOS = (json["subscriptionPeriodUnitIOS"] as String?)?.let { SubscriptionPeriodIOS.fromJson(it) }, title = json["title"] as String, type = ProductType.fromJson(json["type"] as String), + typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String), typeIOS = ProductTypeIOS.fromJson(json["typeIOS"] as String), ) } @@ -974,6 +1013,7 @@ public data class ProductSubscriptionIOS( "subscriptionPeriodUnitIOS" to subscriptionPeriodUnitIOS?.toJson(), "title" to title, "type" to type.toJson(), + "typeDetails" to typeDetails.toJson(), "typeIOS" to typeIOS.toJson(), ) } diff --git a/src/generated/Types.swift b/src/generated/Types.swift index 14edf9b..4829efd 100644 --- a/src/generated/Types.swift +++ b/src/generated/Types.swift @@ -62,6 +62,13 @@ public enum PaymentModeIOS: String, Codable, CaseIterable { case payUpFront = "pay-up-front" } +public enum ProductDetailType: String, Codable, CaseIterable { + case consumable = "consumable" + case nonConsumable = "non-consumable" + case autoRenewableSubscription = "auto-renewable-subscription" + case nonRenewingSubscription = "non-renewing-subscription" +} + public enum ProductQueryType: String, Codable, CaseIterable { case inApp = "in-app" case subs = "subs" @@ -115,6 +122,7 @@ public protocol ProductCommon: Codable { var price: Double? { get } var title: String { get } var type: ProductType { get } + var typeDetails: ProductDetailType { get } } public protocol PurchaseCommon: Codable { @@ -223,6 +231,7 @@ public struct ProductAndroid: Codable, ProductCommon { public var subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails]? public var title: String public var type: ProductType + public var typeDetails: ProductDetailType } public struct ProductAndroidOneTimePurchaseOfferDetail: Codable { @@ -246,6 +255,7 @@ public struct ProductIOS: Codable, ProductCommon { public var subscriptionInfoIOS: SubscriptionInfoIOS? public var title: String public var type: ProductType + public var typeDetails: ProductDetailType public var typeIOS: ProductTypeIOS } @@ -263,6 +273,7 @@ public struct ProductSubscriptionAndroid: Codable, ProductCommon { public var subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails] public var title: String public var type: ProductType + public var typeDetails: ProductDetailType } public struct ProductSubscriptionAndroidOfferDetails: Codable { @@ -296,6 +307,7 @@ public struct ProductSubscriptionIOS: Codable, ProductCommon { public var subscriptionPeriodUnitIOS: SubscriptionPeriodIOS? public var title: String public var type: ProductType + public var typeDetails: ProductDetailType public var typeIOS: ProductTypeIOS } @@ -733,6 +745,15 @@ public enum Product: Codable, ProductCommon { return value.type } } + + public var typeDetails: ProductDetailType { + switch self { + case let .productAndroid(value): + return value.typeDetails + case let .productIos(value): + return value.typeDetails + } + } } public enum ProductSubscription: Codable, ProductCommon { @@ -828,6 +849,15 @@ public enum ProductSubscription: Codable, ProductCommon { return value.type } } + + public var typeDetails: ProductDetailType { + switch self { + case let .productSubscriptionAndroid(value): + return value.typeDetails + case let .productSubscriptionIos(value): + return value.typeDetails + } + } } public enum Purchase: Codable, PurchaseCommon { diff --git a/src/generated/types.dart b/src/generated/types.dart index 6ac3374..01b9310 100644 --- a/src/generated/types.dart +++ b/src/generated/types.dart @@ -279,6 +279,40 @@ enum PaymentModeIOS { String toJson() => value; } +enum ProductDetailType { + Consumable('consumable'), + NonConsumable('non-consumable'), + AutoRenewableSubscription('auto-renewable-subscription'), + NonRenewingSubscription('non-renewing-subscription'); + + const ProductDetailType(this.value); + final String value; + + factory ProductDetailType.fromJson(String value) { + switch (value) { + case 'consumable': + case 'CONSUMABLE': + case 'Consumable': + return ProductDetailType.Consumable; + case 'non-consumable': + case 'NON_CONSUMABLE': + case 'NonConsumable': + return ProductDetailType.NonConsumable; + case 'auto-renewable-subscription': + case 'AUTO_RENEWABLE_SUBSCRIPTION': + case 'AutoRenewableSubscription': + return ProductDetailType.AutoRenewableSubscription; + case 'non-renewing-subscription': + case 'NON_RENEWING_SUBSCRIPTION': + case 'NonRenewingSubscription': + return ProductDetailType.NonRenewingSubscription; + } + throw ArgumentError('Unknown ProductDetailType value: $value'); + } + + String toJson() => value; +} + enum ProductQueryType { InApp('in-app'), Subs('subs'), @@ -486,6 +520,7 @@ abstract class ProductCommon { double? get price; String get title; ProductType get type; + ProductDetailType get typeDetails; } abstract class PurchaseCommon { @@ -845,6 +880,7 @@ class ProductAndroid extends Product implements ProductCommon { this.subscriptionOfferDetailsAndroid, required this.title, required this.type, + required this.typeDetails, }); final String currency; @@ -860,6 +896,7 @@ class ProductAndroid extends Product implements ProductCommon { final List? subscriptionOfferDetailsAndroid; final String title; final ProductType type; + final ProductDetailType typeDetails; factory ProductAndroid.fromJson(Map json) { return ProductAndroid( @@ -876,6 +913,7 @@ class ProductAndroid extends Product implements ProductCommon { subscriptionOfferDetailsAndroid: (json['subscriptionOfferDetailsAndroid'] as List?) == null ? null : (json['subscriptionOfferDetailsAndroid'] as List?)!.map((e) => ProductSubscriptionAndroidOfferDetails.fromJson(e as Map)).toList(), title: json['title'] as String, type: ProductType.fromJson(json['type'] as String), + typeDetails: ProductDetailType.fromJson(json['typeDetails'] as String), ); } @@ -896,6 +934,7 @@ class ProductAndroid extends Product implements ProductCommon { 'subscriptionOfferDetailsAndroid': subscriptionOfferDetailsAndroid == null ? null : subscriptionOfferDetailsAndroid!.map((e) => e.toJson()).toList(), 'title': title, 'type': type.toJson(), + 'typeDetails': typeDetails.toJson(), }; } } @@ -945,6 +984,7 @@ class ProductIOS extends Product implements ProductCommon { this.subscriptionInfoIOS, required this.title, required this.type, + required this.typeDetails, required this.typeIOS, }); @@ -962,6 +1002,7 @@ class ProductIOS extends Product implements ProductCommon { final SubscriptionInfoIOS? subscriptionInfoIOS; final String title; final ProductType type; + final ProductDetailType typeDetails; final ProductTypeIOS typeIOS; factory ProductIOS.fromJson(Map json) { @@ -980,6 +1021,7 @@ class ProductIOS extends Product implements ProductCommon { subscriptionInfoIOS: json['subscriptionInfoIOS'] != null ? SubscriptionInfoIOS.fromJson(json['subscriptionInfoIOS'] as Map) : null, title: json['title'] as String, type: ProductType.fromJson(json['type'] as String), + typeDetails: ProductDetailType.fromJson(json['typeDetails'] as String), typeIOS: ProductTypeIOS.fromJson(json['typeIOS'] as String), ); } @@ -1002,6 +1044,7 @@ class ProductIOS extends Product implements ProductCommon { 'subscriptionInfoIOS': subscriptionInfoIOS?.toJson(), 'title': title, 'type': type.toJson(), + 'typeDetails': typeDetails.toJson(), 'typeIOS': typeIOS.toJson(), }; } @@ -1022,6 +1065,7 @@ class ProductSubscriptionAndroid extends ProductSubscription implements ProductC required this.subscriptionOfferDetailsAndroid, required this.title, required this.type, + required this.typeDetails, }); final String currency; @@ -1037,6 +1081,7 @@ class ProductSubscriptionAndroid extends ProductSubscription implements ProductC final List subscriptionOfferDetailsAndroid; final String title; final ProductType type; + final ProductDetailType typeDetails; factory ProductSubscriptionAndroid.fromJson(Map json) { return ProductSubscriptionAndroid( @@ -1053,6 +1098,7 @@ class ProductSubscriptionAndroid extends ProductSubscription implements ProductC subscriptionOfferDetailsAndroid: (json['subscriptionOfferDetailsAndroid'] as List).map((e) => ProductSubscriptionAndroidOfferDetails.fromJson(e as Map)).toList(), title: json['title'] as String, type: ProductType.fromJson(json['type'] as String), + typeDetails: ProductDetailType.fromJson(json['typeDetails'] as String), ); } @@ -1073,6 +1119,7 @@ class ProductSubscriptionAndroid extends ProductSubscription implements ProductC 'subscriptionOfferDetailsAndroid': subscriptionOfferDetailsAndroid.map((e) => e.toJson()).toList(), 'title': title, 'type': type.toJson(), + 'typeDetails': typeDetails.toJson(), }; } } @@ -1138,6 +1185,7 @@ class ProductSubscriptionIOS extends ProductSubscription implements ProductCommo this.subscriptionPeriodUnitIOS, required this.title, required this.type, + required this.typeDetails, required this.typeIOS, }); @@ -1163,6 +1211,7 @@ class ProductSubscriptionIOS extends ProductSubscription implements ProductCommo final SubscriptionPeriodIOS? subscriptionPeriodUnitIOS; final String title; final ProductType type; + final ProductDetailType typeDetails; final ProductTypeIOS typeIOS; factory ProductSubscriptionIOS.fromJson(Map json) { @@ -1189,6 +1238,7 @@ class ProductSubscriptionIOS extends ProductSubscription implements ProductCommo subscriptionPeriodUnitIOS: json['subscriptionPeriodUnitIOS'] != null ? SubscriptionPeriodIOS.fromJson(json['subscriptionPeriodUnitIOS'] as String) : null, title: json['title'] as String, type: ProductType.fromJson(json['type'] as String), + typeDetails: ProductDetailType.fromJson(json['typeDetails'] as String), typeIOS: ProductTypeIOS.fromJson(json['typeIOS'] as String), ); } @@ -1219,6 +1269,7 @@ class ProductSubscriptionIOS extends ProductSubscription implements ProductCommo 'subscriptionPeriodUnitIOS': subscriptionPeriodUnitIOS?.toJson(), 'title': title, 'type': type.toJson(), + 'typeDetails': typeDetails.toJson(), 'typeIOS': typeIOS.toJson(), }; } @@ -2465,6 +2516,8 @@ sealed class Product implements ProductCommon { String get title; @override ProductType get type; + @override + ProductDetailType get typeDetails; Map toJson(); } @@ -2503,6 +2556,8 @@ sealed class ProductSubscription implements ProductCommon { String get title; @override ProductType get type; + @override + ProductDetailType get typeDetails; Map toJson(); } diff --git a/src/generated/types.ts b/src/generated/types.ts index fe48b65..b9daed3 100644 --- a/src/generated/types.ts +++ b/src/generated/types.ts @@ -227,6 +227,7 @@ export interface ProductAndroid extends ProductCommon { subscriptionOfferDetailsAndroid?: (ProductSubscriptionAndroidOfferDetails[] | null); title: string; type: ProductType; + typeDetails: ProductDetailType; } export interface ProductAndroidOneTimePurchaseOfferDetail { @@ -246,8 +247,11 @@ export interface ProductCommon { price?: (number | null); title: string; type: ProductType; + typeDetails: ProductDetailType; } +export type ProductDetailType = 'consumable' | 'non-consumable' | 'auto-renewable-subscription' | 'non-renewing-subscription'; + export interface ProductIOS extends ProductCommon { currency: string; debugDescription?: (string | null); @@ -263,6 +267,7 @@ export interface ProductIOS extends ProductCommon { subscriptionInfoIOS?: (SubscriptionInfoIOS | null); title: string; type: ProductType; + typeDetails: ProductDetailType; typeIOS: ProductTypeIOS; } @@ -289,6 +294,7 @@ export interface ProductSubscriptionAndroid extends ProductCommon { subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[]; title: string; type: ProductType; + typeDetails: ProductDetailType; } export interface ProductSubscriptionAndroidOfferDetails { @@ -322,6 +328,7 @@ export interface ProductSubscriptionIOS extends ProductCommon { subscriptionPeriodUnitIOS?: (SubscriptionPeriodIOS | null); title: string; type: ProductType; + typeDetails: ProductDetailType; typeIOS: ProductTypeIOS; } diff --git a/src/type-android.graphql b/src/type-android.graphql index 3709ceb..ce7dd62 100644 --- a/src/type-android.graphql +++ b/src/type-android.graphql @@ -43,6 +43,7 @@ type ProductAndroid implements ProductCommon { # Android-specific nameAndroid: String! + typeDetails: ProductDetailType! oneTimePurchaseOfferDetailsAndroid: ProductAndroidOneTimePurchaseOfferDetail subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails!] } @@ -62,6 +63,7 @@ type ProductSubscriptionAndroid implements ProductCommon { # Android-specific nameAndroid: String! + typeDetails: ProductDetailType! oneTimePurchaseOfferDetailsAndroid: ProductAndroidOneTimePurchaseOfferDetail subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails!]! } diff --git a/src/type-ios.graphql b/src/type-ios.graphql index a242e42..71fe78d 100644 --- a/src/type-ios.graphql +++ b/src/type-ios.graphql @@ -1,7 +1,8 @@ # iOS-specific GraphQL Types # iOS detailed product types -enum ProductTypeIOS { +# @deprecated Use ProductDetailType from type.graphql instead +enum ProductTypeIOS @deprecated(reason: "Use ProductDetailType from common types instead") { Consumable NonConsumable AutoRenewableSubscription @@ -75,6 +76,7 @@ type ProductIOS implements ProductCommon { jsonRepresentationIOS: String! subscriptionInfoIOS: SubscriptionInfoIOS typeIOS: ProductTypeIOS! + typeDetails: ProductDetailType! } # iOS subscription product @@ -97,6 +99,7 @@ type ProductSubscriptionIOS implements ProductCommon { jsonRepresentationIOS: String! subscriptionInfoIOS: SubscriptionInfoIOS typeIOS: ProductTypeIOS! + typeDetails: ProductDetailType! discountsIOS: [DiscountIOS!] introductoryPriceIOS: String diff --git a/src/type.graphql b/src/type.graphql index 57bd0e0..7b10602 100644 --- a/src/type.graphql +++ b/src/type.graphql @@ -12,6 +12,17 @@ enum ProductType { Subs } +# Detailed product types (unified for both Android and iOS) +enum ProductDetailType { + # In-app purchases (one-time) + Consumable + NonConsumable + + # Subscriptions + AutoRenewableSubscription + NonRenewingSubscription +} + # Purchase lifecycle states enum PurchaseState { Pending @@ -35,6 +46,7 @@ interface ProductCommon { title: String! description: String! type: ProductType! + typeDetails: ProductDetailType! displayName: String displayPrice: String! currency: String!