Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 5 additions & 58 deletions src/Iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,32 @@
*/

import {
NativeModules,
NativeEventEmitter,
Linking,
NativeEventEmitter,
NativeModules,
Platform,
} from 'react-native';

import { IterableAction, IterableActionContext } from './IterableAction';
import { IterableConfig, AuthResponse } from './IterableConfig';
import {
IterableInAppLocation,
IterableInAppCloseSource,
IterableInAppDeleteSource,
IterableInAppLocation,
} from './IterableInAppClasses';

import { IterableInAppManager } from './IterableInAppManager';
import { IterableInAppMessage } from './IterableInAppMessage';
import { AuthResponse, IterableConfig } from './IterableConfig';
import { IterableLogger } from './IterableLogger';

const RNIterableAPI = NativeModules.RNIterableAPI;
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);

/**
* Enum representing the source of IterableAction.
*/
export enum IterableActionSource {
push = 0,
appLink = 1,
inApp = 2,
}

enum AuthResponseCallback {
SUCCESS,
FAILURE,
}

/**
* Enum representing what level of logs will Android and iOS project be printing on their consoles respectively.
*/
export enum IterableLogLevel {
debug = 1,
info = 2,
error = 3,
}

/**
* IterableAction represents an action defined as a response to user events.
* It is currently used in push notification actions (open push & action buttons).
*/
export class IterableAction {
type: string;
data?: string;
userInput?: string;

constructor(type: string, data?: string, userInput?: string) {
this.type = type;
this.data = data;
this.userInput = userInput;
}

static fromDict(dict: any): IterableAction {
return new IterableAction(dict.type, dict.data, dict.userInput);
}
}

export class IterableActionContext {
action: IterableAction;
source: IterableActionSource;

constructor(action: IterableAction, source: IterableActionSource) {
this.action = action;
this.source = source;
}

static fromDict(dict: any): IterableActionContext {
const action = IterableAction.fromDict(dict.action);
const source = dict.source as IterableActionSource;
return new IterableActionContext(action, source);
}
}

export class IterableAttributionInfo {
campaignId: number;
templateId: number;
Expand Down
34 changes: 22 additions & 12 deletions src/IterableAction.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/**
* Enum representing the source of IterableAction.
*/
export enum IterableActionSource {
push = 0,
appLink = 1,
inApp = 2,
}

/**
* Enum representing what level of logs will Android and iOS project be printing on their consoles respectively.
*/
export enum IterableLogLevel {
debug = 1,
info = 2,
error = 3,
}

/**
* IterableAction represents an action defined as a response to user events.
* It is currently used in push notification actions (open push & action buttons).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also used for action buttons for in-app and embedded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a description for IterableActionContext

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done in a future PR

*/
export class IterableAction {
type: string;
data?: string;
Expand Down Expand Up @@ -29,15 +51,3 @@ export class IterableActionContext {
return new IterableActionContext(action, source);
}
}

export enum IterableActionSource {
push = 0,
appLink = 1,
inApp = 2,
}

export enum IterableLogLevel {
debug = 1,
info = 2,
error = 3,
}
8 changes: 6 additions & 2 deletions src/IterableInboxMessageDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import Icon from 'react-native-vector-icons/Ionicons';
import { WebView } from 'react-native-webview';

import { type InboxRowViewModel } from './InboxRowViewModel';
import { Iterable, IterableActionSource } from './Iterable';
import { IterableAction, IterableActionContext } from './IterableAction';
import { Iterable } from './Iterable';
import {
IterableAction,
IterableActionContext,
IterableActionSource,
} from './IterableAction';
import {
IterableEdgeInsets,
IterableHtmlInAppContent,
Expand Down
18 changes: 11 additions & 7 deletions src/__tests__/Iterable.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { NativeEventEmitter } from 'react-native';

import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
import { MockLinking } from '../__mocks__/MockLinking';
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
import { TestHelper } from './TestHelper';

// import from the same location that consumers import from
import { Iterable, IterableConfig, IterableLogLevel } from '../index';
import {
IterableAttributionInfo,
IterableCommerceItem,
IterableActionContext,
EventName,
Iterable,
IterableAction,
IterableActionContext,
IterableActionSource,
IterableConfig,
IterableLogLevel,
} from '../index';
import {
EventName,
IterableAttributionInfo,
IterableCommerceItem,
} from '../Iterable';
import { IterableLogger } from '../IterableLogger';
import { IterableDataRegion } from '../IterableDataRegion';
import { IterableLogger } from '../IterableLogger';

describe('Iterable', () => {
beforeEach(() => {
Expand Down
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export {
export {
IterableAction,
IterableActionContext,
IterableActionSource,
IterableLogLevel,
} from './IterableAction';
export { IterableConfig } from './IterableConfig';
Expand Down
Loading