Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit c2ff2cd

Browse files
committed
feat: add ProdcutDetailType and deprecate ProductIOS
1 parent 74bb411 commit c2ff2cd

7 files changed

Lines changed: 152 additions & 3 deletions

File tree

src/generated/Types.kt

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,33 @@ public enum class PaymentModeIOS(val rawValue: String) {
222222
fun toJson(): String = rawValue
223223
}
224224

225+
public enum class ProductDetailType(val rawValue: String) {
226+
Consumable("consumable"),
227+
NonConsumable("non-consumable"),
228+
AutoRenewableSubscription("auto-renewable-subscription"),
229+
NonRenewingSubscription("non-renewing-subscription")
230+
231+
companion object {
232+
fun fromJson(value: String): ProductDetailType = when (value) {
233+
"consumable" -> ProductDetailType.Consumable
234+
"CONSUMABLE" -> ProductDetailType.Consumable
235+
"Consumable" -> ProductDetailType.Consumable
236+
"non-consumable" -> ProductDetailType.NonConsumable
237+
"NON_CONSUMABLE" -> ProductDetailType.NonConsumable
238+
"NonConsumable" -> ProductDetailType.NonConsumable
239+
"auto-renewable-subscription" -> ProductDetailType.AutoRenewableSubscription
240+
"AUTO_RENEWABLE_SUBSCRIPTION" -> ProductDetailType.AutoRenewableSubscription
241+
"AutoRenewableSubscription" -> ProductDetailType.AutoRenewableSubscription
242+
"non-renewing-subscription" -> ProductDetailType.NonRenewingSubscription
243+
"NON_RENEWING_SUBSCRIPTION" -> ProductDetailType.NonRenewingSubscription
244+
"NonRenewingSubscription" -> ProductDetailType.NonRenewingSubscription
245+
else -> throw IllegalArgumentException("Unknown ProductDetailType value: $value")
246+
}
247+
}
248+
249+
fun toJson(): String = rawValue
250+
}
251+
225252
public enum class ProductQueryType(val rawValue: String) {
226253
InApp("in-app"),
227254
Subs("subs"),
@@ -389,6 +416,7 @@ public interface ProductCommon {
389416
val price: Double?
390417
val title: String
391418
val type: ProductType
419+
val typeDetails: ProductDetailType
392420
}
393421

394422
public interface PurchaseCommon {
@@ -685,7 +713,8 @@ public data class ProductAndroid(
685713
val price: Double? = null,
686714
val subscriptionOfferDetailsAndroid: List<ProductSubscriptionAndroidOfferDetails>? = null,
687715
val title: String,
688-
val type: ProductType
716+
val type: ProductType,
717+
val typeDetails: ProductDetailType
689718
) : ProductCommon, Product {
690719

691720
companion object {
@@ -704,6 +733,7 @@ public data class ProductAndroid(
704733
subscriptionOfferDetailsAndroid = (json["subscriptionOfferDetailsAndroid"] as List<*>?)?.map { ProductSubscriptionAndroidOfferDetails.fromJson((it as Map<String, Any?>)) },
705734
title = json["title"] as String,
706735
type = ProductType.fromJson(json["type"] as String),
736+
typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String),
707737
)
708738
}
709739
}
@@ -723,6 +753,7 @@ public data class ProductAndroid(
723753
"subscriptionOfferDetailsAndroid" to subscriptionOfferDetailsAndroid?.map { it.toJson() },
724754
"title" to title,
725755
"type" to type.toJson(),
756+
"typeDetails" to typeDetails.toJson(),
726757
)
727758
}
728759

@@ -765,6 +796,7 @@ public data class ProductIOS(
765796
val subscriptionInfoIOS: SubscriptionInfoIOS? = null,
766797
val title: String,
767798
val type: ProductType,
799+
val typeDetails: ProductDetailType,
768800
val typeIOS: ProductTypeIOS
769801
) : ProductCommon, Product {
770802

@@ -785,6 +817,7 @@ public data class ProductIOS(
785817
subscriptionInfoIOS = (json["subscriptionInfoIOS"] as Map<String, Any?>?)?.let { SubscriptionInfoIOS.fromJson(it) },
786818
title = json["title"] as String,
787819
type = ProductType.fromJson(json["type"] as String),
820+
typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String),
788821
typeIOS = ProductTypeIOS.fromJson(json["typeIOS"] as String),
789822
)
790823
}
@@ -806,6 +839,7 @@ public data class ProductIOS(
806839
"subscriptionInfoIOS" to subscriptionInfoIOS?.toJson(),
807840
"title" to title,
808841
"type" to type.toJson(),
842+
"typeDetails" to typeDetails.toJson(),
809843
"typeIOS" to typeIOS.toJson(),
810844
)
811845
}
@@ -823,7 +857,8 @@ public data class ProductSubscriptionAndroid(
823857
val price: Double? = null,
824858
val subscriptionOfferDetailsAndroid: List<ProductSubscriptionAndroidOfferDetails>,
825859
val title: String,
826-
val type: ProductType
860+
val type: ProductType,
861+
val typeDetails: ProductDetailType
827862
) : ProductCommon, ProductSubscription {
828863

829864
companion object {
@@ -842,6 +877,7 @@ public data class ProductSubscriptionAndroid(
842877
subscriptionOfferDetailsAndroid = (json["subscriptionOfferDetailsAndroid"] as List<*>).map { ProductSubscriptionAndroidOfferDetails.fromJson((it as Map<String, Any?>)) },
843878
title = json["title"] as String,
844879
type = ProductType.fromJson(json["type"] as String),
880+
typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String),
845881
)
846882
}
847883
}
@@ -861,6 +897,7 @@ public data class ProductSubscriptionAndroid(
861897
"subscriptionOfferDetailsAndroid" to subscriptionOfferDetailsAndroid.map { it.toJson() },
862898
"title" to title,
863899
"type" to type.toJson(),
900+
"typeDetails" to typeDetails.toJson(),
864901
)
865902
}
866903

@@ -917,6 +954,7 @@ public data class ProductSubscriptionIOS(
917954
val subscriptionPeriodUnitIOS: SubscriptionPeriodIOS? = null,
918955
val title: String,
919956
val type: ProductType,
957+
val typeDetails: ProductDetailType,
920958
val typeIOS: ProductTypeIOS
921959
) : ProductCommon, ProductSubscription {
922960

@@ -945,6 +983,7 @@ public data class ProductSubscriptionIOS(
945983
subscriptionPeriodUnitIOS = (json["subscriptionPeriodUnitIOS"] as String?)?.let { SubscriptionPeriodIOS.fromJson(it) },
946984
title = json["title"] as String,
947985
type = ProductType.fromJson(json["type"] as String),
986+
typeDetails = ProductDetailType.fromJson(json["typeDetails"] as String),
948987
typeIOS = ProductTypeIOS.fromJson(json["typeIOS"] as String),
949988
)
950989
}
@@ -974,6 +1013,7 @@ public data class ProductSubscriptionIOS(
9741013
"subscriptionPeriodUnitIOS" to subscriptionPeriodUnitIOS?.toJson(),
9751014
"title" to title,
9761015
"type" to type.toJson(),
1016+
"typeDetails" to typeDetails.toJson(),
9771017
"typeIOS" to typeIOS.toJson(),
9781018
)
9791019
}

src/generated/Types.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ public enum PaymentModeIOS: String, Codable, CaseIterable {
6262
case payUpFront = "pay-up-front"
6363
}
6464

65+
public enum ProductDetailType: String, Codable, CaseIterable {
66+
case consumable = "consumable"
67+
case nonConsumable = "non-consumable"
68+
case autoRenewableSubscription = "auto-renewable-subscription"
69+
case nonRenewingSubscription = "non-renewing-subscription"
70+
}
71+
6572
public enum ProductQueryType: String, Codable, CaseIterable {
6673
case inApp = "in-app"
6774
case subs = "subs"
@@ -115,6 +122,7 @@ public protocol ProductCommon: Codable {
115122
var price: Double? { get }
116123
var title: String { get }
117124
var type: ProductType { get }
125+
var typeDetails: ProductDetailType { get }
118126
}
119127

120128
public protocol PurchaseCommon: Codable {
@@ -223,6 +231,7 @@ public struct ProductAndroid: Codable, ProductCommon {
223231
public var subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails]?
224232
public var title: String
225233
public var type: ProductType
234+
public var typeDetails: ProductDetailType
226235
}
227236

228237
public struct ProductAndroidOneTimePurchaseOfferDetail: Codable {
@@ -246,6 +255,7 @@ public struct ProductIOS: Codable, ProductCommon {
246255
public var subscriptionInfoIOS: SubscriptionInfoIOS?
247256
public var title: String
248257
public var type: ProductType
258+
public var typeDetails: ProductDetailType
249259
public var typeIOS: ProductTypeIOS
250260
}
251261

@@ -263,6 +273,7 @@ public struct ProductSubscriptionAndroid: Codable, ProductCommon {
263273
public var subscriptionOfferDetailsAndroid: [ProductSubscriptionAndroidOfferDetails]
264274
public var title: String
265275
public var type: ProductType
276+
public var typeDetails: ProductDetailType
266277
}
267278

268279
public struct ProductSubscriptionAndroidOfferDetails: Codable {
@@ -296,6 +307,7 @@ public struct ProductSubscriptionIOS: Codable, ProductCommon {
296307
public var subscriptionPeriodUnitIOS: SubscriptionPeriodIOS?
297308
public var title: String
298309
public var type: ProductType
310+
public var typeDetails: ProductDetailType
299311
public var typeIOS: ProductTypeIOS
300312
}
301313

@@ -738,6 +750,15 @@ public enum Product: Codable, ProductCommon {
738750
return value.type
739751
}
740752
}
753+
754+
public var typeDetails: ProductDetailType {
755+
switch self {
756+
case let .productAndroid(value):
757+
return value.typeDetails
758+
case let .productIos(value):
759+
return value.typeDetails
760+
}
761+
}
741762
}
742763

743764
public enum ProductSubscription: Codable, ProductCommon {
@@ -833,6 +854,15 @@ public enum ProductSubscription: Codable, ProductCommon {
833854
return value.type
834855
}
835856
}
857+
858+
public var typeDetails: ProductDetailType {
859+
switch self {
860+
case let .productSubscriptionAndroid(value):
861+
return value.typeDetails
862+
case let .productSubscriptionIos(value):
863+
return value.typeDetails
864+
}
865+
}
836866
}
837867

838868
public enum Purchase: Codable, PurchaseCommon {

0 commit comments

Comments
 (0)