Skip to content

Commit 7cae386

Browse files
authored
Merge pull request #598 from Iterable/2.0.0-alpha/MOB-10131-remove-duplicate-code
[MOB-10131] remove duplicate code
2 parents c9c0e15 + af7328b commit 7cae386

File tree

5 files changed

+45
-79
lines changed

5 files changed

+45
-79
lines changed

src/Iterable.ts

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,32 @@
33
*/
44

55
import {
6-
NativeModules,
7-
NativeEventEmitter,
86
Linking,
7+
NativeEventEmitter,
8+
NativeModules,
99
Platform,
1010
} from 'react-native';
1111

12+
import { IterableAction, IterableActionContext } from './IterableAction';
13+
import { IterableConfig, AuthResponse } from './IterableConfig';
1214
import {
13-
IterableInAppLocation,
1415
IterableInAppCloseSource,
1516
IterableInAppDeleteSource,
17+
IterableInAppLocation,
1618
} from './IterableInAppClasses';
1719

1820
import { IterableInAppManager } from './IterableInAppManager';
1921
import { IterableInAppMessage } from './IterableInAppMessage';
20-
import { AuthResponse, IterableConfig } from './IterableConfig';
2122
import { IterableLogger } from './IterableLogger';
2223

2324
const RNIterableAPI = NativeModules.RNIterableAPI;
2425
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
2526

26-
/**
27-
* Enum representing the source of IterableAction.
28-
*/
29-
export enum IterableActionSource {
30-
push = 0,
31-
appLink = 1,
32-
inApp = 2,
33-
}
34-
3527
enum AuthResponseCallback {
3628
SUCCESS,
3729
FAILURE,
3830
}
3931

40-
/**
41-
* Enum representing what level of logs will Android and iOS project be printing on their consoles respectively.
42-
*/
43-
export enum IterableLogLevel {
44-
debug = 1,
45-
info = 2,
46-
error = 3,
47-
}
48-
49-
/**
50-
* IterableAction represents an action defined as a response to user events.
51-
* It is currently used in push notification actions (open push & action buttons).
52-
*/
53-
export class IterableAction {
54-
type: string;
55-
data?: string;
56-
userInput?: string;
57-
58-
constructor(type: string, data?: string, userInput?: string) {
59-
this.type = type;
60-
this.data = data;
61-
this.userInput = userInput;
62-
}
63-
64-
static fromDict(dict: any): IterableAction {
65-
return new IterableAction(dict.type, dict.data, dict.userInput);
66-
}
67-
}
68-
69-
export class IterableActionContext {
70-
action: IterableAction;
71-
source: IterableActionSource;
72-
73-
constructor(action: IterableAction, source: IterableActionSource) {
74-
this.action = action;
75-
this.source = source;
76-
}
77-
78-
static fromDict(dict: any): IterableActionContext {
79-
const action = IterableAction.fromDict(dict.action);
80-
const source = dict.source as IterableActionSource;
81-
return new IterableActionContext(action, source);
82-
}
83-
}
84-
8532
export class IterableAttributionInfo {
8633
campaignId: number;
8734
templateId: number;

src/IterableAction.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/**
2+
* Enum representing the source of IterableAction.
3+
*/
4+
export enum IterableActionSource {
5+
push = 0,
6+
appLink = 1,
7+
inApp = 2,
8+
}
9+
10+
/**
11+
* Enum representing what level of logs will Android and iOS project be printing on their consoles respectively.
12+
*/
13+
export enum IterableLogLevel {
14+
debug = 1,
15+
info = 2,
16+
error = 3,
17+
}
18+
19+
/**
20+
* IterableAction represents an action defined as a response to user events.
21+
* It is currently used in push notification actions (open push & action buttons).
22+
*/
123
export class IterableAction {
224
type: string;
325
data?: string;
@@ -29,15 +51,3 @@ export class IterableActionContext {
2951
return new IterableActionContext(action, source);
3052
}
3153
}
32-
33-
export enum IterableActionSource {
34-
push = 0,
35-
appLink = 1,
36-
inApp = 2,
37-
}
38-
39-
export enum IterableLogLevel {
40-
debug = 1,
41-
info = 2,
42-
error = 3,
43-
}

src/IterableInboxMessageDisplay.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ import Icon from 'react-native-vector-icons/Ionicons';
1111
import { WebView } from 'react-native-webview';
1212

1313
import { type InboxRowViewModel } from './InboxRowViewModel';
14-
import { Iterable, IterableActionSource } from './Iterable';
15-
import { IterableAction, IterableActionContext } from './IterableAction';
14+
import { Iterable } from './Iterable';
15+
import {
16+
IterableAction,
17+
IterableActionContext,
18+
IterableActionSource,
19+
} from './IterableAction';
1620
import {
1721
IterableEdgeInsets,
1822
IterableHtmlInAppContent,

src/__tests__/Iterable.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import { NativeEventEmitter } from 'react-native';
22

3-
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
43
import { MockLinking } from '../__mocks__/MockLinking';
4+
import { MockRNIterableAPI } from '../__mocks__/MockRNIterableAPI';
55
import { TestHelper } from './TestHelper';
66

77
// import from the same location that consumers import from
8-
import { Iterable, IterableConfig, IterableLogLevel } from '../index';
98
import {
10-
IterableAttributionInfo,
11-
IterableCommerceItem,
12-
IterableActionContext,
13-
EventName,
9+
Iterable,
1410
IterableAction,
11+
IterableActionContext,
1512
IterableActionSource,
13+
IterableConfig,
14+
IterableLogLevel,
15+
} from '../index';
16+
import {
17+
EventName,
18+
IterableAttributionInfo,
19+
IterableCommerceItem,
1620
} from '../Iterable';
17-
import { IterableLogger } from '../IterableLogger';
1821
import { IterableDataRegion } from '../IterableDataRegion';
22+
import { IterableLogger } from '../IterableLogger';
1923

2024
describe('Iterable', () => {
2125
beforeEach(() => {

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export {
1212
export {
1313
IterableAction,
1414
IterableActionContext,
15+
IterableActionSource,
1516
IterableLogLevel,
1617
} from './IterableAction';
1718
export { IterableConfig } from './IterableConfig';

0 commit comments

Comments
 (0)