affise-attribution-lib 1.6.19 → 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 +103 -17
- 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 +19 -0
- 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 +3 -0
- package/lib/commonjs/native/AffiseApiMethod.js.map +1 -1
- package/lib/commonjs/native/AffiseNative.js +31 -20
- 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 +19 -0
- 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 +3 -0
- package/lib/module/native/AffiseApiMethod.js.map +1 -1
- package/lib/module/native/AffiseNative.js +31 -20
- 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 +15 -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 +4 -2
- package/lib/typescript/native/AffiseApiMethod.d.ts.map +1 -1
- package/lib/typescript/native/AffiseNative.d.ts +7 -6
- 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 +21 -1
- 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 +5 -1
- package/src/native/AffiseNative.ts +47 -16
- 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,42 @@
|
|
|
1
|
+
export declare class DataName {
|
|
2
|
+
static FINE_VALUE: string;
|
|
3
|
+
static COARSE_VALUE: string;
|
|
4
|
+
static TYPE: string;
|
|
5
|
+
static REQUEST: string;
|
|
6
|
+
static RESPONSE: string;
|
|
7
|
+
static FAILED: string;
|
|
8
|
+
static SUCCESS: string;
|
|
9
|
+
static ERROR: string;
|
|
10
|
+
static PRODUCTS: string;
|
|
11
|
+
static INVALID_IDS: string;
|
|
12
|
+
static PRODUCT: string;
|
|
13
|
+
static ORDER_ID: string;
|
|
14
|
+
static ORIGINAL_ORDER_ID: string;
|
|
15
|
+
static PURCHASE: string;
|
|
16
|
+
static DEEPLINK: string;
|
|
17
|
+
static SCHEME: string;
|
|
18
|
+
static HOST: string;
|
|
19
|
+
static PATH: string;
|
|
20
|
+
static PARAMETERS: string;
|
|
21
|
+
static METHOD: string;
|
|
22
|
+
static URL: string;
|
|
23
|
+
static CODE: string;
|
|
24
|
+
static MESSAGE: string;
|
|
25
|
+
static HEADERS: string;
|
|
26
|
+
static BODY: string;
|
|
27
|
+
static PRODUCT_ID: string;
|
|
28
|
+
static TITLE: string;
|
|
29
|
+
static DESCRIPTION: string;
|
|
30
|
+
static PRODUCT_TYPE: string;
|
|
31
|
+
static PRICE: string;
|
|
32
|
+
static VALUE: string;
|
|
33
|
+
static CURRENCY_CODE: string;
|
|
34
|
+
static FORMATTED_PRICE: string;
|
|
35
|
+
static SUBSCRIPTION: string;
|
|
36
|
+
static OFFER_TOKEN: string;
|
|
37
|
+
static OFFER_ID: string;
|
|
38
|
+
static TIME_UNIT: string;
|
|
39
|
+
static NUMBER_OF_UNITS: string;
|
|
40
|
+
static PRODUCT_DETAILS: string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=DataName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataName.d.ts","sourceRoot":"","sources":["../../../../src/native/data/DataName.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACjB,MAAM,CAAC,UAAU,SAAe;IAChC,MAAM,CAAC,YAAY,SAAiB;IACpC,MAAM,CAAC,IAAI,SAAU;IACrB,MAAM,CAAC,OAAO,SAAa;IAC3B,MAAM,CAAC,QAAQ,SAAc;IAE7B,MAAM,CAAC,MAAM,SAAY;IACzB,MAAM,CAAC,OAAO,SAAa;IAC3B,MAAM,CAAC,KAAK,SAAW;IAEvB,MAAM,CAAC,QAAQ,SAAc;IAC7B,MAAM,CAAC,WAAW,SAAgB;IAClC,MAAM,CAAC,OAAO,SAAa;IAC3B,MAAM,CAAC,QAAQ,SAAa;IAC5B,MAAM,CAAC,iBAAiB,SAAqB;IAC7C,MAAM,CAAC,QAAQ,SAAc;IAE7B,MAAM,CAAC,QAAQ,SAAc;IAC7B,MAAM,CAAC,MAAM,SAAY;IACzB,MAAM,CAAC,IAAI,SAAU;IACrB,MAAM,CAAC,IAAI,SAAU;IACrB,MAAM,CAAC,UAAU,SAAgB;IAEjC,MAAM,CAAC,MAAM,SAAY;IACzB,MAAM,CAAC,GAAG,SAAS;IACnB,MAAM,CAAC,IAAI,SAAU;IACrB,MAAM,CAAC,OAAO,SAAa;IAC3B,MAAM,CAAC,OAAO,SAAa;IAC3B,MAAM,CAAC,IAAI,SAAU;IAErB,MAAM,CAAC,UAAU,SAAe;IAChC,MAAM,CAAC,KAAK,SAAW;IACvB,MAAM,CAAC,WAAW,SAAiB;IACnC,MAAM,CAAC,YAAY,SAAiB;IACpC,MAAM,CAAC,KAAK,SAAW;IACvB,MAAM,CAAC,KAAK,SAAW;IACvB,MAAM,CAAC,aAAa,SAAkB;IACtC,MAAM,CAAC,eAAe,SAAoB;IAC1C,MAAM,CAAC,YAAY,SAAkB;IACrC,MAAM,CAAC,WAAW,SAAgB;IAClC,MAAM,CAAC,QAAQ,SAAa;IAC5B,MAAM,CAAC,SAAS,SAAc;IAC9B,MAAM,CAAC,eAAe,SAAmB;IACzC,MAAM,CAAC,eAAe,SAAoB;CAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpMethod.d.ts","sourceRoot":"","sources":["../../../src/network/HttpMethod.ts"],"names":[],"mappings":"AAEA,oBAAY,UAAU;IAClB,GAAG,QAAQ;IACX,IAAI,SAAS;CAChB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"HttpMethod.d.ts","sourceRoot":"","sources":["../../../src/network/HttpMethod.ts"],"names":[],"mappings":"AAEA,oBAAY,UAAU;IAClB,GAAG,QAAQ;IACX,IAAI,SAAS;CAChB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,GAAG,IAAI,CAGrE"}
|
package/package.json
CHANGED
package/src/Export.ts
CHANGED
|
@@ -25,8 +25,17 @@ export * from './skad/CoarseValue';
|
|
|
25
25
|
|
|
26
26
|
export * from './module/AffiseModules';
|
|
27
27
|
export * from './module/AffiseKeyValue';
|
|
28
|
+
export * from './module/AffiseResult';
|
|
28
29
|
export * from './module/OnKeyValueCallback';
|
|
29
30
|
export * from './module/link/AffiseLinkCallback';
|
|
31
|
+
export * from './module/subscription/AffiseProduct';
|
|
32
|
+
export * from './module/subscription/AffiseProductPrice';
|
|
33
|
+
export * from './module/subscription/AffiseProductsResult';
|
|
34
|
+
export * from './module/subscription/AffiseProductSubscriptionDetail';
|
|
35
|
+
export * from './module/subscription/AffiseProductType';
|
|
36
|
+
export * from './module/subscription/AffisePurchasedInfo';
|
|
37
|
+
export * from './module/subscription/AffiseResultCallback';
|
|
38
|
+
export * from './module/subscription/TimeUnitType';
|
|
30
39
|
|
|
31
40
|
export * from './ad/AffiseAdRevenue';
|
|
32
41
|
export * from './ad/AffiseAdSource';
|
|
@@ -10,6 +10,7 @@ export enum ValidationStatus {
|
|
|
10
10
|
UNKNOWN_ERROR = "unknown_error",
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function validationStatusFrom(name: string): ValidationStatus | null {
|
|
13
|
+
export function validationStatusFrom(name: string | null): ValidationStatus | null {
|
|
14
|
+
if (name == null) return null;
|
|
14
15
|
return getEnumFromString(ValidationStatus, name);
|
|
15
16
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,10 +15,11 @@ import type {
|
|
|
15
15
|
OnSendSuccessCallback,
|
|
16
16
|
OnSendFailedCallback,
|
|
17
17
|
AffiseLinkCallback,
|
|
18
|
+
AffiseResultCallback,
|
|
18
19
|
} from "./Export";
|
|
19
20
|
import {AffiseNative} from "./native/AffiseNative";
|
|
20
21
|
import {Platform} from "react-native";
|
|
21
|
-
import {AffiseSettings} from "./Export";
|
|
22
|
+
import {AffiseProduct, AffiseProductsResult, AffiseProductType, AffisePurchasedInfo, AffiseSettings} from "./Export";
|
|
22
23
|
|
|
23
24
|
export * from "./Export";
|
|
24
25
|
|
|
@@ -320,6 +321,25 @@ export class Affise {
|
|
|
320
321
|
static linkResolve(url: string, callback: AffiseLinkCallback) {
|
|
321
322
|
Affise.native.linkResolve(url, callback);
|
|
322
323
|
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Module subscription fetchProducts
|
|
327
|
+
* @param ids list of product ids
|
|
328
|
+
* @param callback result callback
|
|
329
|
+
*/
|
|
330
|
+
static fetchProducts(ids: string[], callback: AffiseResultCallback<AffiseProductsResult>) {
|
|
331
|
+
Affise.native.fetchProducts(ids, callback);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Module subscription purchase
|
|
336
|
+
* @param product product
|
|
337
|
+
* @param type product type
|
|
338
|
+
* @param callback result callback
|
|
339
|
+
*/
|
|
340
|
+
static purchase(product: AffiseProduct, type: AffiseProductType, callback: AffiseResultCallback<AffisePurchasedInfo>) {
|
|
341
|
+
Affise.native.purchase(product, type, callback);
|
|
342
|
+
}
|
|
323
343
|
};
|
|
324
344
|
|
|
325
345
|
static debug = class {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class AffiseResult<T> {
|
|
2
|
+
|
|
3
|
+
static Success<T>(value: T): AffiseResult<T> {
|
|
4
|
+
return new AffiseSuccess<T>(value);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
static Failure<T>(error: string): AffiseResult<T> {
|
|
8
|
+
return new AffiseFailure<T>(error);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public get asSuccess(): T {
|
|
12
|
+
return (this as unknown as AffiseSuccess<T>).value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public get asFailure(): string {
|
|
16
|
+
return (this as unknown as AffiseFailure<T>).error;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public get isSuccess(): boolean {
|
|
20
|
+
return this instanceof AffiseSuccess<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public get isFailure(): boolean {
|
|
24
|
+
return !this.isSuccess;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AffiseSuccess<T> extends AffiseResult<T> {
|
|
30
|
+
public value: T;
|
|
31
|
+
|
|
32
|
+
constructor(value: T) {
|
|
33
|
+
super();
|
|
34
|
+
this.value = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class AffiseFailure<T> extends AffiseResult<T> {
|
|
39
|
+
public error: string;
|
|
40
|
+
|
|
41
|
+
constructor(error: string) {
|
|
42
|
+
super();
|
|
43
|
+
this.error = error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -45,11 +45,15 @@ export enum AffiseApiMethod {
|
|
|
45
45
|
GET_STATUS_CALLBACK = "get_status_callback",
|
|
46
46
|
// Link Module
|
|
47
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",
|
|
48
51
|
////////////////////////////////////////
|
|
49
52
|
// modules
|
|
50
53
|
////////////////////////////////////////
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
export function apiMethodFrom(name: string): AffiseApiMethod | null {
|
|
56
|
+
export function apiMethodFrom(name: string | null): AffiseApiMethod | null {
|
|
57
|
+
if (name == null) return null;
|
|
54
58
|
return getEnumFromString(AffiseApiMethod, name);
|
|
55
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
|
);
|
|
@@ -150,8 +149,8 @@ export class AffiseNative extends NativeBase {
|
|
|
150
149
|
|
|
151
150
|
updatePostbackConversionValue(fineValue: bigint, coarseValue: CoarseValue, completionHandler: ErrorCallback) {
|
|
152
151
|
const value: Record<string, any> = {};
|
|
153
|
-
value[
|
|
154
|
-
value[
|
|
152
|
+
value[DataName.FINE_VALUE] = Number(fineValue);
|
|
153
|
+
value[DataName.COARSE_VALUE] = coarseValue.value;
|
|
155
154
|
this.nativeCallbackOnce(AffiseApiMethod.SKAD_POSTBACK_ERROR_CALLBACK, completionHandler, value);
|
|
156
155
|
}
|
|
157
156
|
|
|
@@ -178,6 +177,7 @@ export class AffiseNative extends NativeBase {
|
|
|
178
177
|
return this.nativeResult(AffiseApiMethod.GET_MODULES_INSTALLED);
|
|
179
178
|
}
|
|
180
179
|
|
|
180
|
+
// Link Module
|
|
181
181
|
linkResolve(url: string, callback: AffiseLinkCallback) {
|
|
182
182
|
this.nativeCallbackOnce(
|
|
183
183
|
AffiseApiMethod.MODULE_LINK_LINK_RESOLVE_CALLBACK,
|
|
@@ -185,6 +185,28 @@ export class AffiseNative extends NativeBase {
|
|
|
185
185
|
url
|
|
186
186
|
);
|
|
187
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
|
+
}
|
|
188
210
|
////////////////////////////////////////
|
|
189
211
|
// modules
|
|
190
212
|
////////////////////////////////////////
|
|
@@ -193,10 +215,10 @@ export class AffiseNative extends NativeBase {
|
|
|
193
215
|
switch (api) {
|
|
194
216
|
case AffiseApiMethod.SEND_EVENT_NOW:
|
|
195
217
|
switch (tag) {
|
|
196
|
-
case
|
|
218
|
+
case DataName.SUCCESS:
|
|
197
219
|
tryCast<OnSendSuccessCallback>(callback)?.();
|
|
198
220
|
break;
|
|
199
|
-
case
|
|
221
|
+
case DataName.FAILED:
|
|
200
222
|
tryCast<OnSendFailedCallback>(callback)?.(DebugUtils.toResponse(data));
|
|
201
223
|
break;
|
|
202
224
|
default:
|
|
@@ -229,8 +251,8 @@ export class AffiseNative extends NativeBase {
|
|
|
229
251
|
break;
|
|
230
252
|
case AffiseApiMethod.DEBUG_NETWORK_CALLBACK:
|
|
231
253
|
tryCast<DebugOnNetworkCallback>(callback)?.(
|
|
232
|
-
DebugUtils.toRequestWithKey(data,
|
|
233
|
-
DebugUtils.toResponseWithKey(data,
|
|
254
|
+
DebugUtils.toRequestWithKey(data, DataName.REQUEST),
|
|
255
|
+
DebugUtils.toResponseWithKey(data, DataName.RESPONSE)
|
|
234
256
|
);
|
|
235
257
|
break;
|
|
236
258
|
////////////////////////////////////////
|
|
@@ -242,6 +264,15 @@ export class AffiseNative extends NativeBase {
|
|
|
242
264
|
case AffiseApiMethod.MODULE_LINK_LINK_RESOLVE_CALLBACK:
|
|
243
265
|
tryCast<AffiseLinkCallback>(callback)?.(DataMapper.toNonNullString(data));
|
|
244
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;
|
|
245
276
|
////////////////////////////////////////
|
|
246
277
|
// modules
|
|
247
278
|
////////////////////////////////////////
|