Skip to content

Commit

Permalink
fix: refactored ts interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Makarov committed Apr 14, 2021
1 parent 41b4040 commit b246ddf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
38 changes: 21 additions & 17 deletions ios/DataTransformer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,34 @@ public class DataTransformer {
var result:NSDictionary = NSDictionary();
if (subscription != nil) {
result = [
"productId": subscription?.productId as Any,
"expiresDate": subscription?.expiresDate.timeIntervalSince1970 as Any,
"startedAt": subscription?.startedAt.timeIntervalSince1970 as Any,
"productId": subscription!.productId as Any,
"expiresDate": subscription!.expiresDate.timeIntervalSince1970 as Any,
"startedAt": subscription!.startedAt.timeIntervalSince1970 as Any,
"canceledAt": subscription?.canceledAt?.timeIntervalSince1970 as Any,
"isInRetryBilling": subscription?.isInRetryBilling as Any,
"isAutorenewEnabled": subscription?.isAutorenewEnabled as Any,
"isIntroductoryActivated": subscription?.isIntroductoryActivated as Any,
"isActive": subscription?.isActive() as Any,
"status": subscription?.status.rawValue as Any,
"isLocal": subscription?.isLocal as Any,
"isSandbox": subscription?.isSandbox as Any
"isInRetryBilling": subscription!.isInRetryBilling as Any,
"isAutorenewEnabled": subscription!.isAutorenewEnabled as Any,
"isIntroductoryActivated": subscription!.isIntroductoryActivated as Any,
"isActive": subscription!.isActive() as Any,
"status": subscription!.status.rawValue as Any,
"isLocal": subscription!.isLocal as Any,
"isSandbox": subscription!.isSandbox as Any
]
}
return result;
}

public static func nonRenewingPurchase(nonRenewingPurchase: ApphudNonRenewingPurchase?) -> NSDictionary {
return [
"productId": nonRenewingPurchase?.productId as Any,
"purchasedAt": nonRenewingPurchase?.purchasedAt.timeIntervalSince1970 as Any,
"canceledAt": nonRenewingPurchase?.canceledAt?.timeIntervalSince1970 as Any,
"isLocal": nonRenewingPurchase?.isLocal as Any,
"isSandbox": nonRenewingPurchase?.isSandbox as Any
]
var result:NSDictionary = NSDictionary();
if (nonRenewingPurchase != nil) {
result = [
"productId": nonRenewingPurchase!.productId as Any,
"purchasedAt": nonRenewingPurchase!.purchasedAt.timeIntervalSince1970 as Any,
"canceledAt": nonRenewingPurchase?.canceledAt?.timeIntervalSince1970 as Any,
"isLocal": nonRenewingPurchase!.isLocal as Any,
"isSandbox": nonRenewingPurchase!.isSandbox as Any
]
}
return result;
}
}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apphud/react-native-apphud-sdk",
"version": "1.0.5",
"version": "1.0.6",
"description": "Apphud SDK for react native",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
30 changes: 11 additions & 19 deletions src/ApphudSdkType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,12 @@ export interface AttributionProperties {
| AndroidApphudAttributionProvider;
}

export interface ApphudSubscriptionStatus {
productId: string;
expiresDate: string;
startedAt: string;
canceledAt: string;
isInRetryBilling: boolean;
isAutorenewEnabled: boolean;
isIntroductoryActivated: boolean;
}

export interface ApphudNonRenewingPurchase {
productId: string;
purchasedAt: string;
canceledAt?: string;
isLocal: string;
isSandbox: string;
}

export interface PurchaseResponse {
Expand All @@ -63,27 +55,27 @@ export interface PurchaseResponse {
sku?: string;

/* iOS: ApphudPurchaseResult class */
subscription?: ApphudSubscriptionStatus;
subscription?: ApphudSubscription;
nonRenewingPurchase?: ApphudNonRenewingPurchase;
transaction?: object;
error?: any;
}

export interface ApphudSubscription {
status: string;
productId?: string;
expiresAt?: string;
startedAt?: string;
productId: string;
expiresAt: string;
startedAt: string;
cancelledAt?: string;
isInRetryBilling?: Boolean;
isAutoRenewEnabled?: Boolean;
isIntroductoryActivated?: Boolean;
isInRetryBilling: Boolean;
isAutoRenewEnabled: Boolean;
isIntroductoryActivated: Boolean;
isActive: Boolean;
kind: string;
}

export interface RestorePurchase {
subscriptions: Array<ApphudSubscriptionStatus>;
subscriptions: Array<ApphudSubscription>;
purchases: Array<PurchaseResponse>;
error: any;
}
Expand All @@ -101,7 +93,7 @@ export type ApphudSdkType = {
logout(): Promise<boolean>;
hasActiveSubscription(): Promise<boolean>;
products(): Promise<Array<ApphudProduct>>;
subscription(): Promise<ApphudSubscriptionStatus>;
subscription(): Promise<ApphudSubscription>;
subscriptions(): Promise<Array<ApphudSubscription>>;
purchase(productIdentifier: string): Promise<PurchaseResponse>;
isNonRenewingPurchaseActive(productIdentifier: string): Promise<boolean>;
Expand Down

0 comments on commit b246ddf

Please sign in to comment.