From 39107ba5990cc60e9e546d552e54996cb2023cbc Mon Sep 17 00:00:00 2001 From: Sumita Canopas <69897605+cp-sumi-k@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:24:33 +0530 Subject: [PATCH] NC-5315: add missing fields in NamiCampaign and NamiPurchase (#338) * NC-5315: add missing fields in NamiCampaign and NamiPurchase * Update NamiCampaign and NamiPurchase * Fix eslint * Replace external_segment_id to external_segment --------- Co-authored-by: Dan Burcaw <92536821+namidan@users.noreply.github.com> --- examples/Basic/index.js | 18 ++++++++++++++++++ examples/TestNamiTV/index.js | 11 ++++++----- index.ts | 1 - src/types.d.ts | 10 +++++++++- src/types.ts | 11 ++++++++++- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/examples/Basic/index.js b/examples/Basic/index.js index 901393b5..25d36445 100644 --- a/examples/Basic/index.js +++ b/examples/Basic/index.js @@ -56,6 +56,24 @@ const Root = () => { return () => {}; }, []); + useEffect(() => { + async function configureNami() { + checkSdkConfigured(); + + const result = await Nami.configure(configDict); + if(result.success){ + setIsConfigurationComplete(true); + checkSdkConfigured(); + } + + initStoreConnection(); + + // eslint-disable-next-line @typescript-eslint/no-empty-function + return () => {}; + } + configureNami(); + }, []); + return isConfigurationComplete ? : ; }; diff --git a/examples/TestNamiTV/index.js b/examples/TestNamiTV/index.js index 6a76e4d2..b071dcf6 100644 --- a/examples/TestNamiTV/index.js +++ b/examples/TestNamiTV/index.js @@ -23,18 +23,19 @@ const Root = () => { useEffect(() => { async function configureNami() { const result = await Nami.configure(configDict); - if (result.success) { + if(result.success){ setIsConfigurationComplete(true); - + if (Platform.constants.Manufacturer === 'Amazon') { NamiPaywallManager.setProductDetails(getAmazonProducts(), false); } } + + // eslint-disable-next-line @typescript-eslint/no-empty-function + return () => {}; + } configureNami(); - - // eslint-disable-next-line @typescript-eslint/no-empty-function - return () => {}; }, []); return isConfigurationComplete ? : ; diff --git a/index.ts b/index.ts index 041416f8..2123350f 100644 --- a/index.ts +++ b/index.ts @@ -6,5 +6,4 @@ export { NamiEntitlementManager } from './src/NamiEntitlementManager'; export { NamiManager } from './src/NamiManager'; export { NamiPurchaseManager } from './src/NamiPurchaseManager'; export { NamiPaywallManager } from './src/NamiPaywallManager'; -export { NamiSKU } from './src/types'; export * from './src/types'; diff --git a/src/types.d.ts b/src/types.d.ts index 1e091d47..9d604bbb 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -47,13 +47,20 @@ export type AppleProduct = { export type GoogleProduct = {}; export type AmazonProduct = {}; export type NamiCampaign = { - id: string; + name: string; rule: string; segment: string; paywall: string; type: NamiCampaignRuleType; value?: string | null; + form_factors: NamiFormFactor[]; + external_segment: string | null; }; +type NamiFormFactor = { + form_factor: string; + supports_portrait?: boolean; + supports_landscape?: boolean; +} export declare enum NamiCampaignRuleType { DEFAULT = "default", LABEL = "label", @@ -158,6 +165,7 @@ export type NamiPurchase = { sku?: NamiSKU; skuId: string; transactionIdentifier?: string; + purchaseToken?: string; expires?: Date; purchaseInitiatedTimestamp: Date; purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN'; diff --git a/src/types.ts b/src/types.ts index 5f241dc9..9f04973f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -153,12 +153,14 @@ export type AmazonProduct = {}; // NamiCampaignManager export type NamiCampaign = { - id: string; + name: string; rule: string; segment: string; paywall: string; type: NamiCampaignRuleType; value?: string | null; + form_factors: NamiFormFactor[]; + external_segment: string | null; }; export enum NamiCampaignRuleType { @@ -168,6 +170,12 @@ export enum NamiCampaignRuleType { URL = 'url', } +type NamiFormFactor = { + form_factor?: string; + supports_portrait?: boolean; + supports_landscape?: boolean; +}; + export enum LaunchCampaignError { DEFAULT_CAMPAIGN_NOT_FOUND = 0, LABELED_CAMPAIGN_NOT_FOUND = 1, @@ -295,6 +303,7 @@ export type NamiPurchase = { sku?: NamiSKU; skuId: string; transactionIdentifier?: string; + purchaseToken?: string; expires?: Date; purchaseInitiatedTimestamp: Date; purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';