diff --git a/src/Iterable.ts b/src/Iterable.ts index 50fc97c0a..25313f35f 100644 --- a/src/Iterable.ts +++ b/src/Iterable.ts @@ -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; diff --git a/src/IterableAction.ts b/src/IterableAction.ts index e68995344..3b9c6857a 100644 --- a/src/IterableAction.ts +++ b/src/IterableAction.ts @@ -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). + */ export class IterableAction { type: string; data?: string; @@ -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, -} diff --git a/src/IterableInboxMessageDisplay.tsx b/src/IterableInboxMessageDisplay.tsx index 411f226d2..c89d79274 100644 --- a/src/IterableInboxMessageDisplay.tsx +++ b/src/IterableInboxMessageDisplay.tsx @@ -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, diff --git a/src/__tests__/Iterable.test.ts b/src/__tests__/Iterable.test.ts index bfc0c52f8..a257c8f0c 100644 --- a/src/__tests__/Iterable.test.ts +++ b/src/__tests__/Iterable.test.ts @@ -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(() => { diff --git a/src/index.tsx b/src/index.tsx index 63217e0e4..b40df9825 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -12,6 +12,7 @@ export { export { IterableAction, IterableActionContext, + IterableActionSource, IterableLogLevel, } from './IterableAction'; export { IterableConfig } from './IterableConfig';