affise-attribution-lib 1.6.18 → 1.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -21
- package/affise-attribution-native.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/affise/attribution/react/AffiseAttributionNativeModule.kt +10 -0
- package/android/src/main/java/com/affise/attribution/react/ResultWrapper.kt +2 -2
- package/ios/ResultWrapper.swift +1 -1
- package/lib/commonjs/Export.js +99 -0
- package/lib/commonjs/Export.js.map +1 -1
- package/lib/commonjs/debug/validate/ValidationStatus.js +1 -0
- package/lib/commonjs/debug/validate/ValidationStatus.js.map +1 -1
- package/lib/commonjs/index.js +51 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/module/AffiseModules.js +1 -0
- package/lib/commonjs/module/AffiseModules.js.map +1 -1
- package/lib/commonjs/module/AffiseResult.js +45 -0
- package/lib/commonjs/module/AffiseResult.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseProduct.js +41 -0
- package/lib/commonjs/module/subscription/AffiseProduct.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseProductPrice.js +29 -0
- package/lib/commonjs/module/subscription/AffiseProductPrice.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseProductSubscriptionDetail.js +32 -0
- package/lib/commonjs/module/subscription/AffiseProductSubscriptionDetail.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseProductType.js +21 -0
- package/lib/commonjs/module/subscription/AffiseProductType.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseProductsResult.js +26 -0
- package/lib/commonjs/module/subscription/AffiseProductsResult.js.map +1 -0
- package/lib/commonjs/module/subscription/AffisePurchasedInfo.js +32 -0
- package/lib/commonjs/module/subscription/AffisePurchasedInfo.js.map +1 -0
- package/lib/commonjs/module/subscription/AffiseResultCallback.js +6 -0
- package/lib/commonjs/module/subscription/AffiseResultCallback.js.map +1 -0
- package/lib/commonjs/module/subscription/TimeUnitType.js +21 -0
- package/lib/commonjs/module/subscription/TimeUnitType.js.map +1 -0
- package/lib/commonjs/native/AffiseApiMethod.js +7 -2
- package/lib/commonjs/native/AffiseApiMethod.js.map +1 -1
- package/lib/commonjs/native/AffiseNative.js +55 -32
- package/lib/commonjs/native/AffiseNative.js.map +1 -1
- package/lib/commonjs/native/data/DataMapper.js +158 -0
- package/lib/commonjs/native/data/DataMapper.js.map +1 -0
- package/lib/commonjs/native/data/DataName.js +51 -0
- package/lib/commonjs/native/data/DataName.js.map +1 -0
- package/lib/commonjs/network/HttpMethod.js +1 -0
- package/lib/commonjs/network/HttpMethod.js.map +1 -1
- package/lib/module/Export.js +9 -0
- package/lib/module/Export.js.map +1 -1
- package/lib/module/debug/validate/ValidationStatus.js +1 -0
- package/lib/module/debug/validate/ValidationStatus.js.map +1 -1
- package/lib/module/index.js +51 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/module/AffiseModules.js +1 -0
- package/lib/module/module/AffiseModules.js.map +1 -1
- package/lib/module/module/AffiseResult.js +38 -0
- package/lib/module/module/AffiseResult.js.map +1 -0
- package/lib/module/module/subscription/AffiseProduct.js +34 -0
- package/lib/module/module/subscription/AffiseProduct.js.map +1 -0
- package/lib/module/module/subscription/AffiseProductPrice.js +22 -0
- package/lib/module/module/subscription/AffiseProductPrice.js.map +1 -0
- package/lib/module/module/subscription/AffiseProductSubscriptionDetail.js +25 -0
- package/lib/module/module/subscription/AffiseProductSubscriptionDetail.js.map +1 -0
- package/lib/module/module/subscription/AffiseProductType.js +13 -0
- package/lib/module/module/subscription/AffiseProductType.js.map +1 -0
- package/lib/module/module/subscription/AffiseProductsResult.js +19 -0
- package/lib/module/module/subscription/AffiseProductsResult.js.map +1 -0
- package/lib/module/module/subscription/AffisePurchasedInfo.js +25 -0
- package/lib/module/module/subscription/AffisePurchasedInfo.js.map +1 -0
- package/lib/module/module/subscription/AffiseResultCallback.js +2 -0
- package/lib/module/module/subscription/AffiseResultCallback.js.map +1 -0
- package/lib/module/module/subscription/TimeUnitType.js +13 -0
- package/lib/module/module/subscription/TimeUnitType.js.map +1 -0
- package/lib/module/native/AffiseApiMethod.js +7 -2
- package/lib/module/native/AffiseApiMethod.js.map +1 -1
- package/lib/module/native/AffiseNative.js +55 -32
- package/lib/module/native/AffiseNative.js.map +1 -1
- package/lib/module/native/data/DataMapper.js +151 -0
- package/lib/module/native/data/DataMapper.js.map +1 -0
- package/lib/module/native/data/DataName.js +44 -0
- package/lib/module/native/data/DataName.js.map +1 -0
- package/lib/module/network/HttpMethod.js +1 -0
- package/lib/module/network/HttpMethod.js.map +1 -1
- package/lib/typescript/Export.d.ts +9 -0
- package/lib/typescript/Export.d.ts.map +1 -1
- package/lib/typescript/debug/validate/ValidationStatus.d.ts +1 -1
- package/lib/typescript/debug/validate/ValidationStatus.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +33 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/module/AffiseModules.d.ts +2 -1
- package/lib/typescript/module/AffiseModules.d.ts.map +1 -1
- package/lib/typescript/module/AffiseResult.d.ts +9 -0
- package/lib/typescript/module/AffiseResult.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseProduct.d.ts +21 -0
- package/lib/typescript/module/subscription/AffiseProduct.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseProductPrice.d.ts +12 -0
- package/lib/typescript/module/subscription/AffiseProductPrice.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseProductSubscriptionDetail.d.ts +15 -0
- package/lib/typescript/module/subscription/AffiseProductSubscriptionDetail.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseProductType.d.ts +8 -0
- package/lib/typescript/module/subscription/AffiseProductType.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseProductsResult.d.ts +11 -0
- package/lib/typescript/module/subscription/AffiseProductsResult.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffisePurchasedInfo.d.ts +15 -0
- package/lib/typescript/module/subscription/AffisePurchasedInfo.d.ts.map +1 -0
- package/lib/typescript/module/subscription/AffiseResultCallback.d.ts +3 -0
- package/lib/typescript/module/subscription/AffiseResultCallback.d.ts.map +1 -0
- package/lib/typescript/module/subscription/TimeUnitType.d.ts +8 -0
- package/lib/typescript/module/subscription/TimeUnitType.d.ts.map +1 -0
- package/lib/typescript/native/AffiseApiMethod.d.ts +8 -4
- package/lib/typescript/native/AffiseApiMethod.d.ts.map +1 -1
- package/lib/typescript/native/AffiseNative.d.ts +11 -8
- package/lib/typescript/native/AffiseNative.d.ts.map +1 -1
- package/lib/typescript/native/data/DataMapper.d.ts +26 -0
- package/lib/typescript/native/data/DataMapper.d.ts.map +1 -0
- package/lib/typescript/native/data/DataName.d.ts +42 -0
- package/lib/typescript/native/data/DataName.d.ts.map +1 -0
- package/lib/typescript/network/HttpMethod.d.ts +1 -1
- package/lib/typescript/network/HttpMethod.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Export.ts +9 -0
- package/src/debug/validate/ValidationStatus.ts +2 -1
- package/src/index.ts +53 -3
- package/src/module/AffiseModules.ts +1 -0
- package/src/module/AffiseResult.ts +45 -0
- package/src/module/subscription/AffiseProduct.ts +46 -0
- package/src/module/subscription/AffiseProductPrice.ts +25 -0
- package/src/module/subscription/AffiseProductSubscriptionDetail.ts +31 -0
- package/src/module/subscription/AffiseProductType.ts +13 -0
- package/src/module/subscription/AffiseProductsResult.ts +24 -0
- package/src/module/subscription/AffisePurchasedInfo.ts +31 -0
- package/src/module/subscription/AffiseResultCallback.ts +3 -0
- package/src/module/subscription/TimeUnitType.ts +13 -0
- package/src/native/AffiseApiMethod.ts +9 -3
- package/src/native/AffiseNative.ts +67 -22
- package/src/native/data/DataMapper.ts +193 -0
- package/src/native/data/DataName.ts +46 -0
- package/src/network/HttpMethod.ts +2 -1
- package/lib/commonjs/native/utils/DataMapper.js +0 -33
- package/lib/commonjs/native/utils/DataMapper.js.map +0 -1
- package/lib/module/native/utils/DataMapper.js +0 -26
- package/lib/module/native/utils/DataMapper.js.map +0 -1
- package/lib/typescript/native/utils/DataMapper.d.ts +0 -8
- package/lib/typescript/native/utils/DataMapper.d.ts.map +0 -1
- package/src/native/utils/DataMapper.ts +0 -37
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {AffiseProductType} from "./AffiseProductType";
|
|
2
|
+
import type {AffiseProductPrice} from "./AffiseProductPrice";
|
|
3
|
+
import type {AffiseProductSubscriptionDetail} from "./AffiseProductSubscriptionDetail";
|
|
4
|
+
|
|
5
|
+
export class AffiseProduct {
|
|
6
|
+
public productId: string;
|
|
7
|
+
public title: string;
|
|
8
|
+
public description: string;
|
|
9
|
+
|
|
10
|
+
public productType: AffiseProductType;
|
|
11
|
+
|
|
12
|
+
public price?: AffiseProductPrice | null;
|
|
13
|
+
|
|
14
|
+
public subscription?: AffiseProductSubscriptionDetail | null;
|
|
15
|
+
|
|
16
|
+
// public productDetails?: string | null;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
{
|
|
20
|
+
productId,
|
|
21
|
+
title,
|
|
22
|
+
description,
|
|
23
|
+
productType,
|
|
24
|
+
price,
|
|
25
|
+
subscription,
|
|
26
|
+
}: {
|
|
27
|
+
productId: string,
|
|
28
|
+
title: string,
|
|
29
|
+
description: string,
|
|
30
|
+
productType: AffiseProductType,
|
|
31
|
+
price?: AffiseProductPrice | null,
|
|
32
|
+
subscription?: AffiseProductSubscriptionDetail | null,
|
|
33
|
+
}
|
|
34
|
+
) {
|
|
35
|
+
this.productId = productId;
|
|
36
|
+
this.title = title;
|
|
37
|
+
this.description = description;
|
|
38
|
+
this.productType = productType;
|
|
39
|
+
this.price = price;
|
|
40
|
+
this.subscription = subscription;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
toString(): string {
|
|
44
|
+
return `AffiseProduct(productId=${this.productId}, title=${this.title}, description=${this.description}, productType=${this.productType}, price=${this.price?.toString()}, subscription=${this.subscription?.toString()})`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class AffiseProductPrice {
|
|
2
|
+
public readonly value: number;
|
|
3
|
+
public readonly currencyCode: string;
|
|
4
|
+
public readonly formattedPrice: string;
|
|
5
|
+
|
|
6
|
+
constructor(
|
|
7
|
+
{
|
|
8
|
+
value,
|
|
9
|
+
currencyCode,
|
|
10
|
+
formattedPrice,
|
|
11
|
+
}: {
|
|
12
|
+
value: number,
|
|
13
|
+
currencyCode: string,
|
|
14
|
+
formattedPrice: string,
|
|
15
|
+
}
|
|
16
|
+
) {
|
|
17
|
+
this.value = value;
|
|
18
|
+
this.currencyCode = currencyCode;
|
|
19
|
+
this.formattedPrice = formattedPrice;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toString(): string {
|
|
23
|
+
return `AffiseProductPrice(value=${this.value}, currencyCode=${this.currencyCode}, formattedPrice=${this.formattedPrice})`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {TimeUnitType} from "./TimeUnitType";
|
|
2
|
+
|
|
3
|
+
export class AffiseProductSubscriptionDetail {
|
|
4
|
+
public readonly offerToken?: string | null;
|
|
5
|
+
public readonly offerId?: string | null;
|
|
6
|
+
public readonly timeUnit?: TimeUnitType | null;
|
|
7
|
+
public readonly numberOfUnits?: number | null;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
{
|
|
11
|
+
offerToken,
|
|
12
|
+
offerId,
|
|
13
|
+
timeUnit,
|
|
14
|
+
numberOfUnits,
|
|
15
|
+
}: {
|
|
16
|
+
offerToken?: string | null,
|
|
17
|
+
offerId?: string | null,
|
|
18
|
+
timeUnit?: TimeUnitType | null,
|
|
19
|
+
numberOfUnits?: number | null,
|
|
20
|
+
}
|
|
21
|
+
) {
|
|
22
|
+
this.offerToken = offerToken;
|
|
23
|
+
this.offerId = offerId;
|
|
24
|
+
this.timeUnit = timeUnit;
|
|
25
|
+
this.numberOfUnits = numberOfUnits;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString(): string {
|
|
29
|
+
return `AffiseProductSubscriptionDetail(offerToken=${this.offerToken}, offerId=${this.offerId}, timeUnit=${this.timeUnit}, numberOfUnits=${this.numberOfUnits})`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {getEnumFromString} from "../../utils/EnumUtils";
|
|
2
|
+
|
|
3
|
+
export enum AffiseProductType {
|
|
4
|
+
CONSUMABLE = "consumable",
|
|
5
|
+
NON_CONSUMABLE = "non_consumable",
|
|
6
|
+
RENEWABLE_SUBSCRIPTION = "renewable_subscription",
|
|
7
|
+
NON_RENEWABLE_SUBSCRIPTION = "non_renewable_subscription",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function affiseProductTypeFrom(name: string | null): AffiseProductType | null {
|
|
11
|
+
if (name == null) return null;
|
|
12
|
+
return getEnumFromString(AffiseProductType, name);
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type {AffiseProduct} from "./AffiseProduct";
|
|
2
|
+
|
|
3
|
+
export class AffiseProductsResult {
|
|
4
|
+
public readonly products: AffiseProduct[];
|
|
5
|
+
public readonly invalidIds: string[];
|
|
6
|
+
|
|
7
|
+
constructor(
|
|
8
|
+
{
|
|
9
|
+
products,
|
|
10
|
+
invalidIds,
|
|
11
|
+
}: {
|
|
12
|
+
products: AffiseProduct[],
|
|
13
|
+
invalidIds: string[],
|
|
14
|
+
}
|
|
15
|
+
) {
|
|
16
|
+
this.products = products || [];
|
|
17
|
+
this.invalidIds = invalidIds || [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
toString(): string {
|
|
22
|
+
return `AffiseProductsResult(products=[${this.products.join(", ")}], invalidIds=[${this.invalidIds.join(", ")}])`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {AffiseProduct} from "./AffiseProduct";
|
|
2
|
+
|
|
3
|
+
export class AffisePurchasedInfo {
|
|
4
|
+
public readonly product?: AffiseProduct | null;
|
|
5
|
+
public readonly orderId?: string | null;
|
|
6
|
+
public readonly originalOrderId?: string | null;
|
|
7
|
+
public readonly purchase?: string | null;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
{
|
|
11
|
+
product,
|
|
12
|
+
orderId,
|
|
13
|
+
originalOrderId,
|
|
14
|
+
purchase,
|
|
15
|
+
}: {
|
|
16
|
+
product?: AffiseProduct | null,
|
|
17
|
+
orderId?: string | null,
|
|
18
|
+
originalOrderId?: string | null,
|
|
19
|
+
purchase?: string | null,
|
|
20
|
+
}
|
|
21
|
+
) {
|
|
22
|
+
this.product = product;
|
|
23
|
+
this.orderId = orderId;
|
|
24
|
+
this.originalOrderId = originalOrderId;
|
|
25
|
+
this.purchase = purchase;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
toString(): string {
|
|
29
|
+
return `AffisePurchasedInfo(product=${this.product}, orderId=${this.orderId}, originalOrderId=${this.originalOrderId}, purchase=${this.purchase})`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {getEnumFromString} from "../../utils/EnumUtils";
|
|
2
|
+
|
|
3
|
+
export enum TimeUnitType {
|
|
4
|
+
DAY = "day",
|
|
5
|
+
WEEK = "week",
|
|
6
|
+
MONTH = "month",
|
|
7
|
+
YEAR = "year",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function timeUnitTypeFrom(name: string | null): TimeUnitType | null {
|
|
11
|
+
if (name == null) return null;
|
|
12
|
+
return getEnumFromString(TimeUnitType, name);
|
|
13
|
+
}
|
|
@@ -25,8 +25,10 @@ export enum AffiseApiMethod {
|
|
|
25
25
|
IS_FIRST_RUN = "is_first_run",
|
|
26
26
|
|
|
27
27
|
// callback methods
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
GET_REFERRER_URL_CALLBACK = "get_referrer_url_callback",
|
|
29
|
+
GET_REFERRER_URL_VALUE_CALLBACK = "get_referrer_url_value_callback",
|
|
30
|
+
GET_REFERRER_ON_SERVER_CALLBACK = "get_referrer_on_server_callback",
|
|
31
|
+
GET_REFERRER_ON_SERVER_VALUE_CALLBACK = "get_referrer_on_server_value_callback",
|
|
30
32
|
REGISTER_DEEPLINK_CALLBACK = "register_deeplink_callback",
|
|
31
33
|
SKAD_REGISTER_ERROR_CALLBACK = "skad_register_error_callback",
|
|
32
34
|
SKAD_POSTBACK_ERROR_CALLBACK = "skad_postback_error_callback",
|
|
@@ -43,11 +45,15 @@ export enum AffiseApiMethod {
|
|
|
43
45
|
GET_STATUS_CALLBACK = "get_status_callback",
|
|
44
46
|
// Link Module
|
|
45
47
|
MODULE_LINK_LINK_RESOLVE_CALLBACK = "module_link_link_resolve_callback",
|
|
48
|
+
// Subscription Module
|
|
49
|
+
MODULE_SUBS_FETCH_PRODUCTS_CALLBACK = "module_subs_fetch_products_callback",
|
|
50
|
+
MODULE_SUBS_PURCHASE_CALLBACK = "module_subs_purchase_callback",
|
|
46
51
|
////////////////////////////////////////
|
|
47
52
|
// modules
|
|
48
53
|
////////////////////////////////////////
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
export function apiMethodFrom(name: string): AffiseApiMethod | null {
|
|
56
|
+
export function apiMethodFrom(name: string | null): AffiseApiMethod | null {
|
|
57
|
+
if (name == null) return null;
|
|
52
58
|
return getEnumFromString(AffiseApiMethod, name);
|
|
53
59
|
}
|
|
@@ -18,17 +18,16 @@ import {DebugUtils} from "./utils/DebugUtils";
|
|
|
18
18
|
import type {OnSendSuccessCallback} from "../events/OnSendSuccessCallback";
|
|
19
19
|
import type {OnSendFailedCallback} from "../events/OnSendFailedCallback";
|
|
20
20
|
import type {AffiseLinkCallback} from "../module/link/AffiseLinkCallback";
|
|
21
|
-
import {DataMapper} from "./
|
|
21
|
+
import {DataMapper} from "./data/DataMapper";
|
|
22
|
+
import type {AffiseResultCallback} from "../module/subscription/AffiseResultCallback";
|
|
23
|
+
import type {AffiseProductsResult} from "../module/subscription/AffiseProductsResult";
|
|
24
|
+
import type {AffiseProduct} from "../module/subscription/AffiseProduct";
|
|
25
|
+
import type {AffiseProductType} from "../module/subscription/AffiseProductType";
|
|
26
|
+
import type {AffisePurchasedInfo} from "../module/subscription/AffisePurchasedInfo";
|
|
27
|
+
import {DataName} from "./data/DataName";
|
|
22
28
|
|
|
23
29
|
export class AffiseNative extends NativeBase {
|
|
24
30
|
|
|
25
|
-
protected FINE_VALUE = "fineValue";
|
|
26
|
-
protected COARSE_VALUE = "coarseValue";
|
|
27
|
-
protected SUCCESS: string = "success";
|
|
28
|
-
protected FAILED: string = "failed";
|
|
29
|
-
protected REQUEST: string = "request";
|
|
30
|
-
protected RESPONSE: string = "response";
|
|
31
|
-
|
|
32
31
|
init(initProperties: AffiseInitProperties | AffiseInitPropertiesType) {
|
|
33
32
|
let option: AffiseInitProperties;
|
|
34
33
|
if (isAffiseInitPropertiesType(initProperties)) {
|
|
@@ -52,8 +51,8 @@ export class AffiseNative extends NativeBase {
|
|
|
52
51
|
this.nativeCallbackGroup(
|
|
53
52
|
AffiseApiMethod.SEND_EVENT_NOW,
|
|
54
53
|
new Map([
|
|
55
|
-
[
|
|
56
|
-
[
|
|
54
|
+
[DataName.SUCCESS, success],
|
|
55
|
+
[DataName.FAILED, failed],
|
|
57
56
|
]),
|
|
58
57
|
event.toRecord()
|
|
59
58
|
);
|
|
@@ -112,12 +111,20 @@ export class AffiseNative extends NativeBase {
|
|
|
112
111
|
this.native(AffiseApiMethod.CRASH_APPLICATION);
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
this.nativeCallbackOnce(AffiseApiMethod.
|
|
114
|
+
getReferrerUrl(callback: ReferrerCallback) {
|
|
115
|
+
this.nativeCallbackOnce(AffiseApiMethod.GET_REFERRER_URL_CALLBACK, callback);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getReferrerUrlValue(key: ReferrerKey, callback: ReferrerCallback) {
|
|
119
|
+
this.nativeCallbackOnce(AffiseApiMethod.GET_REFERRER_URL_VALUE_CALLBACK, callback, key);
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
this.nativeCallbackOnce(AffiseApiMethod.
|
|
122
|
+
getReferrerOnServer(callback: ReferrerCallback) {
|
|
123
|
+
this.nativeCallbackOnce(AffiseApiMethod.GET_REFERRER_ON_SERVER_CALLBACK, callback);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getReferrerOnServerValue(key: ReferrerKey, callback: ReferrerCallback) {
|
|
127
|
+
this.nativeCallbackOnce(AffiseApiMethod.GET_REFERRER_ON_SERVER_VALUE_CALLBACK, callback, key);
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
isFirstRun(): Promise<boolean> {
|
|
@@ -142,8 +149,8 @@ export class AffiseNative extends NativeBase {
|
|
|
142
149
|
|
|
143
150
|
updatePostbackConversionValue(fineValue: bigint, coarseValue: CoarseValue, completionHandler: ErrorCallback) {
|
|
144
151
|
const value: Record<string, any> = {};
|
|
145
|
-
value[
|
|
146
|
-
value[
|
|
152
|
+
value[DataName.FINE_VALUE] = Number(fineValue);
|
|
153
|
+
value[DataName.COARSE_VALUE] = coarseValue.value;
|
|
147
154
|
this.nativeCallbackOnce(AffiseApiMethod.SKAD_POSTBACK_ERROR_CALLBACK, completionHandler, value);
|
|
148
155
|
}
|
|
149
156
|
|
|
@@ -170,6 +177,7 @@ export class AffiseNative extends NativeBase {
|
|
|
170
177
|
return this.nativeResult(AffiseApiMethod.GET_MODULES_INSTALLED);
|
|
171
178
|
}
|
|
172
179
|
|
|
180
|
+
// Link Module
|
|
173
181
|
linkResolve(url: string, callback: AffiseLinkCallback) {
|
|
174
182
|
this.nativeCallbackOnce(
|
|
175
183
|
AffiseApiMethod.MODULE_LINK_LINK_RESOLVE_CALLBACK,
|
|
@@ -177,6 +185,28 @@ export class AffiseNative extends NativeBase {
|
|
|
177
185
|
url
|
|
178
186
|
);
|
|
179
187
|
}
|
|
188
|
+
|
|
189
|
+
// Subscription Module
|
|
190
|
+
fetchProducts(ids: string[], callback: AffiseResultCallback<AffiseProductsResult>) {
|
|
191
|
+
this.nativeCallbackOnce(
|
|
192
|
+
AffiseApiMethod.MODULE_SUBS_FETCH_PRODUCTS_CALLBACK,
|
|
193
|
+
callback,
|
|
194
|
+
ids,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Subscription Module
|
|
199
|
+
purchase(product: AffiseProduct, type: AffiseProductType, callback: AffiseResultCallback<AffisePurchasedInfo>) {
|
|
200
|
+
const data: Record<string, any> = {};
|
|
201
|
+
data[DataName.PRODUCT] = DataMapper.fromProduct(product);
|
|
202
|
+
data[DataName.TYPE] = type;
|
|
203
|
+
|
|
204
|
+
this.nativeCallbackOnce(
|
|
205
|
+
AffiseApiMethod.MODULE_SUBS_PURCHASE_CALLBACK,
|
|
206
|
+
callback,
|
|
207
|
+
data,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
180
210
|
////////////////////////////////////////
|
|
181
211
|
// modules
|
|
182
212
|
////////////////////////////////////////
|
|
@@ -185,20 +215,26 @@ export class AffiseNative extends NativeBase {
|
|
|
185
215
|
switch (api) {
|
|
186
216
|
case AffiseApiMethod.SEND_EVENT_NOW:
|
|
187
217
|
switch (tag) {
|
|
188
|
-
case
|
|
218
|
+
case DataName.SUCCESS:
|
|
189
219
|
tryCast<OnSendSuccessCallback>(callback)?.();
|
|
190
220
|
break;
|
|
191
|
-
case
|
|
221
|
+
case DataName.FAILED:
|
|
192
222
|
tryCast<OnSendFailedCallback>(callback)?.(DebugUtils.toResponse(data));
|
|
193
223
|
break;
|
|
194
224
|
default:
|
|
195
225
|
break;
|
|
196
226
|
}
|
|
197
227
|
break;
|
|
198
|
-
case AffiseApiMethod.
|
|
228
|
+
case AffiseApiMethod.GET_REFERRER_URL_CALLBACK:
|
|
199
229
|
tryCast<ReferrerCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
200
230
|
break;
|
|
201
|
-
case AffiseApiMethod.
|
|
231
|
+
case AffiseApiMethod.GET_REFERRER_URL_VALUE_CALLBACK:
|
|
232
|
+
tryCast<ReferrerCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
233
|
+
break;
|
|
234
|
+
case AffiseApiMethod.GET_REFERRER_ON_SERVER_CALLBACK:
|
|
235
|
+
tryCast<ReferrerCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
236
|
+
break;
|
|
237
|
+
case AffiseApiMethod.GET_REFERRER_ON_SERVER_VALUE_CALLBACK:
|
|
202
238
|
tryCast<ReferrerCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
203
239
|
break;
|
|
204
240
|
case AffiseApiMethod.REGISTER_DEEPLINK_CALLBACK:
|
|
@@ -215,8 +251,8 @@ export class AffiseNative extends NativeBase {
|
|
|
215
251
|
break;
|
|
216
252
|
case AffiseApiMethod.DEBUG_NETWORK_CALLBACK:
|
|
217
253
|
tryCast<DebugOnNetworkCallback>(callback)?.(
|
|
218
|
-
DebugUtils.toRequestWithKey(data,
|
|
219
|
-
DebugUtils.toResponseWithKey(data,
|
|
254
|
+
DebugUtils.toRequestWithKey(data, DataName.REQUEST),
|
|
255
|
+
DebugUtils.toResponseWithKey(data, DataName.RESPONSE)
|
|
220
256
|
);
|
|
221
257
|
break;
|
|
222
258
|
////////////////////////////////////////
|
|
@@ -228,6 +264,15 @@ export class AffiseNative extends NativeBase {
|
|
|
228
264
|
case AffiseApiMethod.MODULE_LINK_LINK_RESOLVE_CALLBACK:
|
|
229
265
|
tryCast<AffiseLinkCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
230
266
|
break;
|
|
267
|
+
// Subscription Module
|
|
268
|
+
case AffiseApiMethod.MODULE_SUBS_FETCH_PRODUCTS_CALLBACK:
|
|
269
|
+
tryCast<AffiseResultCallback<AffiseProductsResult>>(callback)
|
|
270
|
+
?.(DataMapper.toResultAffiseProductsResult(data));
|
|
271
|
+
break;
|
|
272
|
+
case AffiseApiMethod.MODULE_SUBS_PURCHASE_CALLBACK:
|
|
273
|
+
tryCast<AffiseResultCallback<AffisePurchasedInfo>>(callback)
|
|
274
|
+
?.(DataMapper.toResultAffisePurchasedInfo(data));
|
|
275
|
+
break;
|
|
231
276
|
////////////////////////////////////////
|
|
232
277
|
// modules
|
|
233
278
|
////////////////////////////////////////
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {AffiseKeyValue} from "../../module/AffiseKeyValue";
|
|
2
|
+
import {tryCast} from "../../utils/TryCast";
|
|
3
|
+
import {DeeplinkValue} from "../../deeplink/DeeplinkValue";
|
|
4
|
+
import {AffiseProduct} from "../../module/subscription/AffiseProduct";
|
|
5
|
+
import {DataName} from "./DataName";
|
|
6
|
+
import {AffiseProductPrice} from "../../module/subscription/AffiseProductPrice";
|
|
7
|
+
import {AffiseProductSubscriptionDetail} from "../../module/subscription/AffiseProductSubscriptionDetail";
|
|
8
|
+
import {AffisePurchasedInfo} from "../../module/subscription/AffisePurchasedInfo";
|
|
9
|
+
import {AffiseResult} from "../../module/AffiseResult";
|
|
10
|
+
import {AffiseProductsResult} from "../../module/subscription/AffiseProductsResult";
|
|
11
|
+
import {AffiseProductType, affiseProductTypeFrom} from "../../module/subscription/AffiseProductType";
|
|
12
|
+
import {timeUnitTypeFrom} from "../../module/subscription/TimeUnitType";
|
|
13
|
+
|
|
14
|
+
type Transform<T> = (from: any) => T;
|
|
15
|
+
|
|
16
|
+
export class DataMapper {
|
|
17
|
+
static toNonNullString(from: any): string {
|
|
18
|
+
return from as string || "";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static toAffiseKeyValueList(from: any): AffiseKeyValue[] {
|
|
22
|
+
const data = tryCast<Array<any>>(from) || [];
|
|
23
|
+
const result: AffiseKeyValue[] = [];
|
|
24
|
+
for (const item of data) {
|
|
25
|
+
const cast: Record<string, string> = item as Record<string, string>;
|
|
26
|
+
const key = cast["key"];
|
|
27
|
+
const value = cast["value"];
|
|
28
|
+
|
|
29
|
+
if (!(key && value)) continue;
|
|
30
|
+
|
|
31
|
+
result.push(new AffiseKeyValue(key, value));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static toDeeplinkValue(from: any): DeeplinkValue {
|
|
38
|
+
const data = tryCast<Record<string, any>>(from) || {};
|
|
39
|
+
const parameters = tryCast<Record<string, string[]>>(data[DataName.PARAMETERS]) || {};
|
|
40
|
+
return new DeeplinkValue(
|
|
41
|
+
data[DataName.DEEPLINK],
|
|
42
|
+
data[DataName.SCHEME],
|
|
43
|
+
data[DataName.HOST],
|
|
44
|
+
data[DataName.PATH],
|
|
45
|
+
parameters
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromProduct(product: AffiseProduct): Record<string, any> {
|
|
50
|
+
return {
|
|
51
|
+
[DataName.PRODUCT_ID]: product.productId,
|
|
52
|
+
[DataName.TITLE]: product.title,
|
|
53
|
+
[DataName.DESCRIPTION]: product.description,
|
|
54
|
+
[DataName.PRODUCT_TYPE]: product.productType,
|
|
55
|
+
[DataName.PRICE]: this.fromPrice(product.price),
|
|
56
|
+
[DataName.SUBSCRIPTION]: this.fromSubscription(product.subscription),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static fromPrice(price: AffiseProductPrice | null | undefined): Record<string, any> | null {
|
|
61
|
+
if (price == null) return null;
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
[DataName.VALUE]: price.value,
|
|
65
|
+
[DataName.CURRENCY_CODE]: price.currencyCode,
|
|
66
|
+
[DataName.FORMATTED_PRICE]: price.formattedPrice,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static fromSubscription(subscription: AffiseProductSubscriptionDetail | null | undefined): Record<string, any> | null {
|
|
71
|
+
if (subscription == null) return null;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
[DataName.OFFER_TOKEN]: subscription.offerToken,
|
|
75
|
+
[DataName.OFFER_ID]: subscription.offerId,
|
|
76
|
+
[DataName.TIME_UNIT]: subscription.timeUnit,
|
|
77
|
+
[DataName.NUMBER_OF_UNITS]: subscription.numberOfUnits,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static toResultAffiseProductsResult(from: any): AffiseResult<AffiseProductsResult> {
|
|
82
|
+
return this.toResult(from, this.toAffiseProductsResult);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static toResultAffisePurchasedInfo(from: any): AffiseResult<AffisePurchasedInfo> {
|
|
86
|
+
return this.toResult(from, this.toAffisePurchasedInfo);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private static toResult<T>(from: any, transformer: Transform<T | null>): AffiseResult<T> {
|
|
90
|
+
const json = tryCast<Record<string, any>>(from) || {};
|
|
91
|
+
|
|
92
|
+
const error = json[DataName.ERROR];
|
|
93
|
+
const success = json[DataName.SUCCESS];
|
|
94
|
+
|
|
95
|
+
if (error != null) {
|
|
96
|
+
return AffiseResult.Failure(error);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const data = transformer(success);
|
|
100
|
+
if (data == null) {
|
|
101
|
+
return AffiseResult.Failure(`serialization error. Data: ${from}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return AffiseResult.Success(data);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static toAffiseProductsResult(from: any): AffiseProductsResult | null {
|
|
108
|
+
const data = tryCast<Record<string, any>>(from);
|
|
109
|
+
if (data == null) return null;
|
|
110
|
+
|
|
111
|
+
const invalidIds = tryCast<string[]>(data[DataName.INVALID_IDS]) || [];
|
|
112
|
+
|
|
113
|
+
return new AffiseProductsResult({
|
|
114
|
+
products: DataMapper.toProductsList(data[DataName.PRODUCTS]),
|
|
115
|
+
invalidIds: invalidIds,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static toAffisePurchasedInfo(from: any): AffisePurchasedInfo | null {
|
|
120
|
+
const data = tryCast<Record<string, any>>(from);
|
|
121
|
+
if (data == null) return null;
|
|
122
|
+
|
|
123
|
+
return new AffisePurchasedInfo({
|
|
124
|
+
product: DataMapper.toProduct(data[DataName.PRODUCT]),
|
|
125
|
+
orderId: data[DataName.ORDER_ID],
|
|
126
|
+
originalOrderId: data[DataName.ORIGINAL_ORDER_ID],
|
|
127
|
+
purchase: data[DataName.PURCHASE],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
private static toProductsList(from: any): AffiseProduct[] {
|
|
133
|
+
const result: AffiseProduct[] = [];
|
|
134
|
+
|
|
135
|
+
const array = tryCast<Array<string>>(from) || [];
|
|
136
|
+
for (const obj of array) {
|
|
137
|
+
const product = this.toProduct(obj);
|
|
138
|
+
if (product != null) {
|
|
139
|
+
result.push(product);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static toProduct(from: any): AffiseProduct | null {
|
|
147
|
+
const data = tryCast<Record<string, any>>(from);
|
|
148
|
+
if (data == null) return null;
|
|
149
|
+
|
|
150
|
+
const productType = affiseProductTypeFrom(data[DataName.PRODUCT_TYPE]);
|
|
151
|
+
|
|
152
|
+
const productId = data[DataName.PRODUCT_ID];
|
|
153
|
+
const title = data[DataName.TITLE];
|
|
154
|
+
const description = data[DataName.DESCRIPTION];
|
|
155
|
+
|
|
156
|
+
if (productId == null) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return new AffiseProduct({
|
|
161
|
+
productId: productId,
|
|
162
|
+
title: title,
|
|
163
|
+
description: description,
|
|
164
|
+
productType: productType || AffiseProductType.CONSUMABLE,
|
|
165
|
+
price: this.toPrice(data[DataName.PRICE]),
|
|
166
|
+
subscription: this.toSubscriptionDetail(data[DataName.SUBSCRIPTION]),
|
|
167
|
+
// productDetails: data[DataName.PRODUCT_DETAILS],
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static toPrice(from: any): AffiseProductPrice | null {
|
|
172
|
+
const data = tryCast<Record<string, any>>(from);
|
|
173
|
+
if (data == null) return null;
|
|
174
|
+
|
|
175
|
+
return new AffiseProductPrice({
|
|
176
|
+
value: Number(data[DataName.VALUE]) || 0.0,
|
|
177
|
+
currencyCode: data[DataName.CURRENCY_CODE] || "",
|
|
178
|
+
formattedPrice: data[DataName.FORMATTED_PRICE] || ""
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static toSubscriptionDetail(from: any): AffiseProductSubscriptionDetail | null {
|
|
183
|
+
const data = tryCast<Record<string, any>>(from);
|
|
184
|
+
if (data == null) return null;
|
|
185
|
+
|
|
186
|
+
return new AffiseProductSubscriptionDetail({
|
|
187
|
+
offerToken: data[DataName.OFFER_TOKEN],
|
|
188
|
+
offerId: data[DataName.OFFER_ID],
|
|
189
|
+
timeUnit: timeUnitTypeFrom(data[DataName.TIME_UNIT]),
|
|
190
|
+
numberOfUnits: Number(data[DataName.NUMBER_OF_UNITS]) || null,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class DataName {
|
|
2
|
+
static FINE_VALUE = "fineValue";
|
|
3
|
+
static COARSE_VALUE = "coarseValue";
|
|
4
|
+
static TYPE = "type";
|
|
5
|
+
static REQUEST = "request";
|
|
6
|
+
static RESPONSE = "response";
|
|
7
|
+
|
|
8
|
+
static FAILED = "failed";
|
|
9
|
+
static SUCCESS = "success";
|
|
10
|
+
static ERROR = "error";
|
|
11
|
+
|
|
12
|
+
static PRODUCTS = "products";
|
|
13
|
+
static INVALID_IDS = "invalidIds";
|
|
14
|
+
static PRODUCT = "product";
|
|
15
|
+
static ORDER_ID = "orderId";
|
|
16
|
+
static ORIGINAL_ORDER_ID = "originalOrderId";
|
|
17
|
+
static PURCHASE = "purchase";
|
|
18
|
+
|
|
19
|
+
static DEEPLINK = "deeplink";
|
|
20
|
+
static SCHEME = "scheme";
|
|
21
|
+
static HOST = "host";
|
|
22
|
+
static PATH = "path";
|
|
23
|
+
static PARAMETERS = "parameters";
|
|
24
|
+
|
|
25
|
+
static METHOD = "method";
|
|
26
|
+
static URL = "url";
|
|
27
|
+
static CODE = "code";
|
|
28
|
+
static MESSAGE = "message";
|
|
29
|
+
static HEADERS = "headers";
|
|
30
|
+
static BODY = "body";
|
|
31
|
+
|
|
32
|
+
static PRODUCT_ID = "productId";
|
|
33
|
+
static TITLE = "title";
|
|
34
|
+
static DESCRIPTION = "description";
|
|
35
|
+
static PRODUCT_TYPE = "productType";
|
|
36
|
+
static PRICE = "price";
|
|
37
|
+
static VALUE = "value";
|
|
38
|
+
static CURRENCY_CODE = "currencyCode";
|
|
39
|
+
static FORMATTED_PRICE = "formattedPrice";
|
|
40
|
+
static SUBSCRIPTION = "subscription";
|
|
41
|
+
static OFFER_TOKEN = "offerToken";
|
|
42
|
+
static OFFER_ID = "offerId";
|
|
43
|
+
static TIME_UNIT = "timeUnit";
|
|
44
|
+
static NUMBER_OF_UNITS = "numberOfUnits";
|
|
45
|
+
static PRODUCT_DETAILS = "productDetails";
|
|
46
|
+
}
|
|
@@ -5,7 +5,8 @@ export enum HttpMethod {
|
|
|
5
5
|
POST = "POST",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export function httpMethodFrom(name: string): HttpMethod | null {
|
|
8
|
+
export function httpMethodFrom(name: string | null): HttpMethod | null {
|
|
9
|
+
if (name == null) return null;
|
|
9
10
|
return getEnumFromString(HttpMethod, name);
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DataMapper = void 0;
|
|
7
|
-
var _AffiseKeyValue = require("../../module/AffiseKeyValue");
|
|
8
|
-
var _TryCast = require("../../utils/TryCast");
|
|
9
|
-
var _DeeplinkValue = require("../../deeplink/DeeplinkValue");
|
|
10
|
-
class DataMapper {
|
|
11
|
-
static toNonNullString(from) {
|
|
12
|
-
return from || "";
|
|
13
|
-
}
|
|
14
|
-
static toAffiseKeyValueList(from) {
|
|
15
|
-
const data = (0, _TryCast.tryCast)(from) || [];
|
|
16
|
-
const result = [];
|
|
17
|
-
for (const item of data) {
|
|
18
|
-
const cast = item;
|
|
19
|
-
const key = cast["key"];
|
|
20
|
-
const value = cast["value"];
|
|
21
|
-
if (!(key && value)) continue;
|
|
22
|
-
result.push(new _AffiseKeyValue.AffiseKeyValue(key, value));
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
static toDeeplinkValue(from) {
|
|
27
|
-
const data = (0, _TryCast.tryCast)(from) || {};
|
|
28
|
-
const parameters = (0, _TryCast.tryCast)(data["parameters"]) || {};
|
|
29
|
-
return new _DeeplinkValue.DeeplinkValue(data["deeplink"], data["scheme"], data["host"], data["path"], parameters);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.DataMapper = DataMapper;
|
|
33
|
-
//# sourceMappingURL=DataMapper.js.map
|