Skip to content

Commit

Permalink
NC-5315: add missing fields in NamiCampaign and NamiPurchase (#338)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
cp-sumi-k and namidan authored Sep 5, 2024
1 parent ad96c01 commit 39107ba
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
18 changes: 18 additions & 0 deletions examples/Basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <App /> : <View />;
};

Expand Down
11 changes: 6 additions & 5 deletions examples/TestNamiTV/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <App /> : <View />;
Expand Down
1 change: 0 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
10 changes: 9 additions & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -158,6 +165,7 @@ export type NamiPurchase = {
sku?: NamiSKU;
skuId: string;
transactionIdentifier?: string;
purchaseToken?: string;
expires?: Date;
purchaseInitiatedTimestamp: Date;
purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
Expand Down
11 changes: 10 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -295,6 +303,7 @@ export type NamiPurchase = {
sku?: NamiSKU;
skuId: string;
transactionIdentifier?: string;
purchaseToken?: string;
expires?: Date;
purchaseInitiatedTimestamp: Date;
purchaseSource?: 'CAMPAIGN' | 'MARKETPLACE' | 'UNKNOWN';
Expand Down

0 comments on commit 39107ba

Please sign in to comment.