@@ -39,12 +39,7 @@ class ApphudSdk: NSObject {
3939 let products : [ SKProduct ] ? = Apphud . products ( ) ;
4040 resolve (
4141 products? . map { ( product) -> NSDictionary in
42- return [
43- " id " : product. productIdentifier,
44- " price " : product. price,
45- " regionCode " : product. priceLocale. regionCode as Any ,
46- " currencyCode " : product. priceLocale. currencyCode as Any ,
47- ] ;
42+ return DataTransformer . skProduct ( product: product) ;
4843 }
4944 ) ;
5045 }
@@ -61,26 +56,8 @@ class ApphudSdk: NSObject {
6156 Apphud . purchase ( productIdentifier) { ( result: ApphudPurchaseResult ) in
6257 let transaction : SKPaymentTransaction ? = result. transaction;
6358 var response = [
64- " subscription " : [
65- " productId " : result. subscription? . productId as Any ,
66- " expiresDate " : result. subscription? . expiresDate. timeIntervalSince1970 as Any ,
67- " startedAt " : result. subscription? . startedAt. timeIntervalSince1970 as Any ,
68- " canceledAt " : result. subscription? . canceledAt? . timeIntervalSince1970 as Any ,
69- " isInRetryBilling " : result. subscription? . isInRetryBilling as Any ,
70- " isAutorenewEnabled " : result. subscription? . isAutorenewEnabled as Any ,
71- " isIntroductoryActivated " : result. subscription? . isIntroductoryActivated as Any ,
72- " isActive " : result. subscription? . isActive ( ) as Any ,
73- " status " : result. subscription? . status. rawValue as Any ,
74- " isLocal " : result. subscription? . isLocal as Any ,
75- " isSandbox " : result. subscription? . isSandbox as Any
76- ] ,
77- " nonRenewingPurchase " : [
78- " productId " : result. nonRenewingPurchase? . productId as Any ,
79- " purchasedAt " : result. nonRenewingPurchase? . purchasedAt. timeIntervalSince1970 as Any ,
80- " canceledAt " : result. nonRenewingPurchase? . canceledAt? . timeIntervalSince1970 as Any ,
81- " isLocal " : result. nonRenewingPurchase? . isLocal as Any ,
82- " isSandbox " : result. nonRenewingPurchase? . isSandbox as Any
83- ] ,
59+ " subscription " : DataTransformer . apphudSubscription ( subscription: result. subscription) ,
60+ " nonRenewingPurchase " : DataTransformer . nonRenewingPurchase ( nonRenewingPurchase: result. nonRenewingPurchase) ,
8461 " error " : result. error. debugDescription
8562 ] as [ String : Any ] ;
8663 if ( transaction != nil ) {
@@ -102,19 +79,7 @@ class ApphudSdk: NSObject {
10279 @objc ( subscription: withRejecter: )
10380 func subscription( resolve: RCTPromiseResolveBlock , reject: RCTPromiseRejectBlock ) -> Void {
10481 let subscription = Apphud . subscription ( ) ;
105- resolve ( [
106- " productId " : subscription? . productId as Any ,
107- " expiresDate " : subscription? . expiresDate. timeIntervalSince1970 as Any ,
108- " startedAt " : subscription? . startedAt. timeIntervalSince1970 as Any ,
109- " canceledAt " : subscription? . canceledAt? . timeIntervalSince1970 as Any ,
110- " isInRetryBilling " : subscription? . isInRetryBilling as Any ,
111- " isAutorenewEnabled " : subscription? . isAutorenewEnabled as Any ,
112- " isIntroductoryActivated " : subscription? . isIntroductoryActivated as Any ,
113- " isActive " : subscription? . isActive ( ) as Any ,
114- " status " : subscription? . status. rawValue as Any ,
115- " isLocal " : subscription? . isLocal as Any ,
116- " isSandbox " : subscription? . isSandbox as Any
117- ] ) ;
82+ resolve ( DataTransformer . apphudSubscription ( subscription: subscription) ) ;
11883 }
11984
12085 @objc ( isNonRenewingPurchaseActive: withResolver: withRejecter: )
@@ -129,13 +94,7 @@ class ApphudSdk: NSObject {
12994 let purchases = Apphud . nonRenewingPurchases ( ) ;
13095 resolve (
13196 purchases? . map ( { ( purchase) -> NSDictionary in
132- return [
133- " productId " : purchase. productId,
134- " canceledAt " : purchase. canceledAt? . timeIntervalSince1970 as Any ,
135- " purchasedAt " : purchase. purchasedAt. timeIntervalSince1970 as Any ,
136- " isLocal " : purchase. isLocal as Any ,
137- " isSandbox " : purchase. isSandbox as Any
138- ]
97+ return DataTransformer . nonRenewingPurchase ( nonRenewingPurchase: purchase) ;
13998 } )
14099 ) ;
141100 }
@@ -145,19 +104,7 @@ class ApphudSdk: NSObject {
145104 Apphud . restorePurchases { ( subscriptions, purchases, error) in
146105 resolve ( [
147106 " subscriptions " : subscriptions? . map { ( subscription) -> NSDictionary in
148- return [
149- " productId " : subscription. productId as Any ,
150- " expiresDate " : subscription. expiresDate. timeIntervalSince1970 as Any ,
151- " startedAt " : subscription. startedAt. timeIntervalSince1970 as Any ,
152- " canceledAt " : subscription. canceledAt? . timeIntervalSince1970 as Any ,
153- " isInRetryBilling " : subscription. isInRetryBilling as Any ,
154- " isAutorenewEnabled " : subscription. isAutorenewEnabled as Any ,
155- " isIntroductoryActivated " : subscription. isIntroductoryActivated as Any ,
156- " isActive " : subscription. isActive ( ) as Any ,
157- " status " : subscription. status. rawValue as Any ,
158- " isLocal " : subscription. isLocal as Any ,
159- " isSandbox " : subscription. isSandbox as Any
160- ]
107+ return DataTransformer . apphudSubscription ( subscription: subscription) ;
161108 } as Any ,
162109 " purchases " : purchases? . map { ( purchase) -> NSDictionary in
163110 return [
0 commit comments