@@ -3,6 +3,16 @@ use crate::{
33 IosIapTransactionReason ,
44} ;
55
6+ /// Marks an iOS 17 version dependant value. If it is set then the device supports minimum iOS 17.
7+ /// Not using `Option` here to be explicit about the cause for a missing value and to handle it with caution.
8+ #[ derive( Debug , Clone , Copy ) ]
9+ pub enum Ios17Specific < T > {
10+ /// The value is available on iOS 17.0 and later.
11+ Available ( T ) ,
12+ /// The value is not available on iOS 17.0 and later.
13+ NotAvailable ,
14+ }
15+
616/// Representation of a Transaction.
717/// Mirrors the Transcation type in Apple's StoreKit2 closely.
818/// See official docs for more details on the individual fields.
@@ -24,11 +34,10 @@ pub struct IosIapTransaction {
2434 pub is_upgraded : bool ,
2535 pub json_representation : String ,
2636 pub product_type : IosIapProductType ,
27- pub storefront : IosIapStorefront ,
37+ pub storefront : Ios17Specific < IosIapStorefront > ,
38+ pub reason : Ios17Specific < IosIapTransactionReason > ,
2839 pub environment : IosIapEnvironment ,
29- pub reason : IosIapTransactionReason ,
3040 pub currency : Option < IosIapCurrency > ,
31- pub currency_code : Option < String > ,
3241 pub revocation_reason : Option < IosIapRevocationReason > ,
3342 /// representing a UUID
3443 pub app_account_token : Option < String > ,
@@ -62,9 +71,7 @@ impl IosIapTransaction {
6271 original_id : u64 ,
6372 json_representation : String ,
6473 product_type : IosIapProductType ,
65- reason : IosIapTransactionReason ,
6674 environment : IosIapEnvironment ,
67- storefront : IosIapStorefront ,
6875 ) -> Self {
6976 Self {
7077 id,
@@ -75,24 +82,31 @@ impl IosIapTransaction {
7582 purchased_quantity,
7683 storefront_country_code,
7784 signed_date,
78- reason,
7985 app_account_token : None ,
8086 json_representation,
8187 product_type,
8288 revocation_date : None ,
8389 expiration_date : None ,
8490 is_upgraded,
8591 environment,
86- storefront,
8792 currency : None ,
88- currency_code : None ,
8993 original_id,
9094 revocation_reason : None ,
9195 subscription_group_id : None ,
9296 web_order_line_item_id : None ,
97+ storefront : Ios17Specific :: NotAvailable ,
98+ reason : Ios17Specific :: NotAvailable ,
9399 }
94100 }
95101
102+ pub fn add_storefront ( t : & mut Self , store : IosIapStorefront ) {
103+ t. storefront = Ios17Specific :: Available ( store) ;
104+ }
105+
106+ pub fn add_reason ( t : & mut Self , reason : IosIapTransactionReason ) {
107+ t. reason = Ios17Specific :: Available ( reason) ;
108+ }
109+
96110 pub fn add_revocation ( t : & mut Self , date : u64 ) {
97111 t. revocation_date = Some ( date) ;
98112 }
@@ -105,10 +119,6 @@ impl IosIapTransaction {
105119 t. currency = Some ( currency) ;
106120 }
107121
108- pub fn add_currency_code ( t : & mut Self , code : String ) {
109- t. currency_code = Some ( code) ;
110- }
111-
112122 pub fn revocation_reason ( t : & mut Self , reason : IosIapRevocationReason ) {
113123 t. revocation_reason = Some ( reason) ;
114124 }
0 commit comments