react-native-moengage-cards 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +10 -0
  2. package/ReactNativeMoEngageCards.podspec +25 -0
  3. package/android/.editorconfig +8 -0
  4. package/android/build.gradle +58 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +18 -0
  7. package/android/gradle.properties +14 -0
  8. package/android/gradlew +234 -0
  9. package/android/gradlew.bat +89 -0
  10. package/android/src/main/AndroidManifest.xml +16 -0
  11. package/android/src/main/java/com/moengage/react/cards/Constants.kt +12 -0
  12. package/android/src/main/java/com/moengage/react/cards/EventEmitterImpl.kt +62 -0
  13. package/android/src/main/java/com/moengage/react/cards/MoEngageCardsBridge.kt +228 -0
  14. package/android/src/main/java/com/moengage/react/cards/MoEngageCardsPackage.kt +35 -0
  15. package/android/src/main/java/com/moengage/react/cards/PayloadGenerator.kt +26 -0
  16. package/ios/Cards.xcodeproj/project.pbxproj +302 -0
  17. package/ios/Cards.xcworkspace/contents.xcworkspacedata +7 -0
  18. package/ios/Cards.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  19. package/ios/MoEngageCardsBridge.h +9 -0
  20. package/ios/MoEngageCardsBridge.m +149 -0
  21. package/ios/MoEngageCardsReactConstants.h +14 -0
  22. package/ios/MoEngageCardsReactConstants.m +15 -0
  23. package/ios/MoEngageCardsReactUtil.h +15 -0
  24. package/ios/MoEngageCardsReactUtil.m +44 -0
  25. package/package.json +42 -0
  26. package/src/ReactMoEngageCards.ts +212 -0
  27. package/src/index.ts +58 -0
  28. package/src/internal/Constants.ts +86 -0
  29. package/src/internal/MoEngageCardHandler.ts +265 -0
  30. package/src/internal/MoEngageCardsCache.ts +31 -0
  31. package/src/internal/utils/JsonToModelMapper.ts +267 -0
  32. package/src/internal/utils/ModelToJsonMapper.ts +250 -0
  33. package/src/internal/utils/PayloadBuilder.ts +68 -0
  34. package/src/internal/utils/PayloadParser.ts +53 -0
  35. package/src/internal/utils/PlatformPayloadBuilder.ts +81 -0
  36. package/src/internal/utils/Util.ts +16 -0
  37. package/src/model/CampaignState.ts +54 -0
  38. package/src/model/Card.ts +51 -0
  39. package/src/model/CardInfo.ts +36 -0
  40. package/src/model/CardsData.ts +29 -0
  41. package/src/model/Container.ts +59 -0
  42. package/src/model/DisplayControl.ts +70 -0
  43. package/src/model/MetaData.ts +90 -0
  44. package/src/model/ShowTime.ts +27 -0
  45. package/src/model/SyncData.ts +30 -0
  46. package/src/model/Template.ts +37 -0
  47. package/src/model/Widget.ts +59 -0
  48. package/src/model/action/Action.ts +22 -0
  49. package/src/model/action/NavigationAction.ts +39 -0
  50. package/src/model/enums/ActionType.ts +16 -0
  51. package/src/model/enums/NavigationType.ts +28 -0
  52. package/src/model/enums/SyncType.ts +28 -0
  53. package/src/model/enums/TemplateType.ts +22 -0
  54. package/src/model/enums/WidgetType.ts +28 -0
  55. package/src/model/styles/ButtonStyle.ts +23 -0
  56. package/src/model/styles/ContainerStyle.ts +20 -0
  57. package/src/model/styles/ImageStyle.ts +16 -0
  58. package/src/model/styles/TextStyle.ts +19 -0
  59. package/src/model/styles/WidgetStyle.ts +19 -0
@@ -0,0 +1,250 @@
1
+ /**
2
+ * @file contains the function to convert the model to json
3
+ * @author Abhishek Kumar
4
+ * @since 1.0.0
5
+ */
6
+
7
+ import CampaignState from "../../model/CampaignState";
8
+ import Card from "../../model/Card";
9
+ import CardInfo from "../../model/CardInfo";
10
+ import CardsData from "../../model/CardsData";
11
+ import Container from "../../model/Container";
12
+ import DisplayControl from "../../model/DisplayControl";
13
+ import MetaData from "../../model/MetaData";
14
+ import ShowTime from "../../model/ShowTime";
15
+ import SyncCompleteData from "../../model/SyncData";
16
+ import Template from "../../model/Template";
17
+ import Widget from "../../model/Widget";
18
+ import Action from "../../model/action/Action";
19
+ import NavigationAction from "../../model/action/NavigationAction";
20
+ import SyncType from "../../model/enums/SyncType";
21
+ import TemplateType from "../../model/enums/TemplateType";
22
+ import WidgetType from "../../model/enums/WidgetType";
23
+ import ButtonStyle from "../../model/styles/ButtonStyle";
24
+ import ContainerStyle from "../../model/styles/ContainerStyle";
25
+ import ImageStyle from "../../model/styles/ImageStyle";
26
+ import TextStyle from "../../model/styles/TextStyle";
27
+ import WidgetStyle from "../../model/styles/WidgetStyle";
28
+ import {
29
+ keyActionType,
30
+ keyActionValue,
31
+ keyActions,
32
+ keyAdditionalMetaData,
33
+ keyBackgroundColor,
34
+ keyCampaignPayload,
35
+ keyCampaignState,
36
+ keyCardId,
37
+ keyCards,
38
+ keyCategories,
39
+ keyCategory,
40
+ keyContainerId,
41
+ keyContainerStyle,
42
+ keyContainers,
43
+ keyCreatedAt,
44
+ keyDeletionTime,
45
+ keyDisplayControl,
46
+ keyEndTime,
47
+ keyExpireAfterDelivered,
48
+ keyExpireAfterSeen,
49
+ keyExpireAt,
50
+ keyFirstReceived,
51
+ keyFirstSeen,
52
+ keyFontSize,
53
+ keyHasUpdates,
54
+ keyId,
55
+ keyIsClicked,
56
+ keyIsNewCard,
57
+ keyIsPinned,
58
+ keyKVPairs,
59
+ keyLocalShowCount,
60
+ keyMaxCount,
61
+ keyMetaData,
62
+ keyNavigationType,
63
+ keyShouldShowAllTab,
64
+ keyShowTime,
65
+ keyStartTime,
66
+ keySyncType,
67
+ keyTemplateData,
68
+ keyTemplateType,
69
+ keyTotalShowCount,
70
+ keyUpdatedAt,
71
+ keyWidgetContent,
72
+ keyWidgetId,
73
+ keyWidgetStyle,
74
+ keyWidgetType,
75
+ keyWidgets
76
+ } from "../Constants";
77
+ import { assertUnsupportedError } from "../utils/Util";
78
+
79
+ export function actionToJson(action: Action): { [k: string]: any } {
80
+ if (action instanceof NavigationAction) {
81
+ return navigationActionToJson(action);
82
+ }
83
+
84
+ assertUnsupportedError("Action Instance Not Supported");
85
+ }
86
+
87
+ export function navigationActionToJson(navigationAction: NavigationAction): { [k: string]: any } {
88
+ return {
89
+ [keyActionType]: navigationAction.actionType,
90
+ [keyNavigationType]: navigationAction.navigationType,
91
+ [keyActionValue]: navigationAction.value,
92
+ [keyKVPairs]: navigationAction.kvPairs
93
+ };
94
+ }
95
+
96
+ export function buttonStyleToJson(buttonStyle: ButtonStyle): { [k: string]: any } {
97
+ return {
98
+ [keyBackgroundColor]: buttonStyle.backgroundColor,
99
+ [keyFontSize]: buttonStyle.fontSize
100
+ };
101
+ }
102
+
103
+ export function containerStyleToJson(containerStyle: ContainerStyle | undefined): { [k: string]: any } | undefined {
104
+ if (containerStyle === undefined) return undefined;
105
+ return {
106
+ [keyBackgroundColor]: containerStyle.backgroundColor
107
+ };
108
+ }
109
+
110
+ export function imageStyleToJson(imageStyle: ImageStyle): { [k: string]: any } {
111
+ return {
112
+ [keyBackgroundColor]: imageStyle.backgroundColor,
113
+ };
114
+ }
115
+
116
+ export function textStyleToJson(textStyle: TextStyle): { [k: string]: any } {
117
+ return {
118
+ [keyBackgroundColor]: textStyle.backgroundColor,
119
+ [keyFontSize]: textStyle.fontSize
120
+ };
121
+ }
122
+
123
+ export function widgetStyleToJson(widgetStyle: WidgetStyle | undefined): { [k: string]: any } | undefined {
124
+ if (widgetStyle === undefined) return undefined;
125
+ if (widgetStyle instanceof ButtonStyle) {
126
+ return buttonStyleToJson(widgetStyle);
127
+ } else if (widgetStyle instanceof ContainerStyle) {
128
+ return containerStyleToJson(widgetStyle);
129
+ } else if (widgetStyle instanceof ImageStyle) {
130
+ return imageStyleToJson(widgetStyle);
131
+ } else if (widgetStyle instanceof TextStyle) {
132
+ return textStyleToJson(widgetStyle);
133
+ }
134
+
135
+ assertUnsupportedError("WidgetStyle Instance Not Supported");
136
+ }
137
+
138
+ export function campaignStateToJson(campaignState: CampaignState): { [k: string]: any } {
139
+ return {
140
+ [keyLocalShowCount]: campaignState.localShowCount,
141
+ [keyIsClicked]: campaignState.isClicked,
142
+ [keyFirstReceived]: campaignState.firstReceived,
143
+ [keyFirstSeen]: campaignState.firstSeen,
144
+ [keyTotalShowCount]: campaignState.totalShowCount
145
+ };
146
+ }
147
+
148
+ export function cardToJson(card: Card): { [k: string]: any } {
149
+ return {
150
+ [keyId]: card.id,
151
+ [keyCardId]: card.cardId,
152
+ [keyCategory]: card.category,
153
+ [keyTemplateData]: templateToJson(card.template),
154
+ [keyMetaData]: metaDataToJson(card.metaData)
155
+ };
156
+ }
157
+
158
+ export function cardInfoToJson(cardInfo: CardInfo): { [k: string]: any } {
159
+ return {
160
+ [keyShouldShowAllTab]: cardInfo.shouldShowAllTab,
161
+ [keyCategories]: cardInfo.categories,
162
+ [keyCards]: cardInfo.cards.map((card) => {
163
+ return cardToJson(card);
164
+ })
165
+ };
166
+ }
167
+
168
+ export function cardsDataToJson(cardsData: CardsData): { [k: string]: any } {
169
+ return {
170
+ [keyCategory]: cardsData.category,
171
+ [keyCards]: cardsData.cards.map((card) => {
172
+ return cardToJson(card);
173
+ })
174
+ };
175
+ }
176
+
177
+ export function containerToJson(container: Container): { [k: string]: any } {
178
+ return {
179
+ [keyContainerId]: container.id,
180
+ [keyTemplateType]: TemplateType[container.templateType],
181
+ [keyContainerStyle]: containerStyleToJson(container.style),
182
+ [keyWidgets]: container.widgets.map((widget) => {
183
+ return widgetToJson(widget);
184
+ }),
185
+ [keyActions]: container.actionList.map((action) => {
186
+ return actionToJson(action);
187
+ })
188
+ };
189
+ }
190
+
191
+ export function displayControlToJson(displayControl: DisplayControl): { [k: string]: any } {
192
+ return {
193
+ [keyExpireAt]: displayControl.expireAt,
194
+ [keyExpireAfterSeen]: displayControl.expireAfterSeen,
195
+ [keyExpireAfterDelivered]: displayControl.expireAfterDelivered,
196
+ [keyMaxCount]: displayControl.maxCount,
197
+ [keyIsPinned]: displayControl.isPinned,
198
+ [keyShowTime]: showTimeToJson(displayControl.showTime)
199
+ };
200
+ }
201
+
202
+ export function metaDataToJson(metaData: MetaData): { [k: string]: any } {
203
+ return {
204
+ [keyIsPinned]: metaData.isPinned,
205
+ [keyIsNewCard]: metaData.isNewCard,
206
+ [keyCampaignState]: campaignStateToJson(metaData.campaignState),
207
+ [keyDeletionTime]: metaData.deletionTime,
208
+ [keyDisplayControl]: displayControlToJson(metaData.displayControl),
209
+ [keyAdditionalMetaData]: metaData.metaData,
210
+ [keyUpdatedAt]: metaData.updatedTime,
211
+ [keyCreatedAt]: metaData.createdAt,
212
+ [keyCampaignPayload]: metaData.campaignPayload
213
+ };
214
+ }
215
+
216
+ export function showTimeToJson(showTime: ShowTime): { [k: string]: any } {
217
+ return {
218
+ [keyStartTime]: showTime.startTime,
219
+ [keyEndTime]: showTime.endTime
220
+ };
221
+ }
222
+
223
+ export function syncDataToJson(syncData: SyncCompleteData): { [k: string]: any } {
224
+ return {
225
+ [keyHasUpdates]: syncData.hasUpdates,
226
+ [keySyncType]: SyncType[syncData.syncType]
227
+ };
228
+ }
229
+
230
+ export function templateToJson(template: Template): { [k: string]: any } {
231
+ return {
232
+ [keyTemplateType]: TemplateType[template.templateType],
233
+ [keyContainers]: template.containers.map((container) => {
234
+ return containerToJson(container);
235
+ }),
236
+ [keyKVPairs]: template.kvPairs
237
+ };
238
+ }
239
+
240
+ export function widgetToJson(widget: Widget): { [k: string]: any } {
241
+ return {
242
+ [keyWidgetId]: widget.id,
243
+ [keyWidgetContent]: widget.content,
244
+ [keyWidgetType]: WidgetType[widget.widgetType],
245
+ [keyWidgetStyle]: widgetStyleToJson(widget.style),
246
+ [keyActions]: widget.actionList.map((action) => {
247
+ return actionToJson(action);
248
+ })
249
+ };
250
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @file contains the function to build the payload to communicate with native bridge
3
+ * @author Abhishek Kumar
4
+ * @since 1.0.0
5
+ */
6
+
7
+ import Card from "../../model/Card";
8
+ import {
9
+ keyAccountMeta,
10
+ keyAppId,
11
+ keyCard,
12
+ keyCards,
13
+ keyCategory,
14
+ keyData,
15
+ keyWidgetIdentifier
16
+ } from "../Constants";
17
+ import { cardToJson } from "./ModelToJsonMapper";
18
+
19
+ export function getAccountMetaPayload(appId: string): { [k: string]: any } {
20
+ return {
21
+ [keyAccountMeta]: getAppIdPayload(appId)
22
+ };
23
+ }
24
+
25
+ export function getCardClickedPayload(card: Card, widgetId: number, appId: string): { [k: string]: any } {
26
+ return {
27
+ [keyAccountMeta]: getAppIdPayload(appId),
28
+ [keyData]: {
29
+ [keyCard]: cardToJson(card),
30
+ [keyWidgetIdentifier]: widgetId
31
+ }
32
+ };
33
+ }
34
+
35
+ export function getCardShownPayload(card: Card, appId: string): { [k: string]: any } {
36
+ return {
37
+ [keyAccountMeta]: getAppIdPayload(appId),
38
+ [keyData]: {
39
+ [keyCard]: cardToJson(card)
40
+ }
41
+ };
42
+ }
43
+
44
+ export function getCardsForCategoriesPayload(category: string, appId: string): { [k: string]: any } {
45
+ return {
46
+ [keyAccountMeta]: getAppIdPayload(appId),
47
+ [keyData]: {
48
+ [keyCategory]: category
49
+ }
50
+ };
51
+ }
52
+
53
+ export function getDeleteCardsPayload(cards: Array<Card>, appId: string): { [k: string]: any } {
54
+ return {
55
+ [keyAccountMeta]: getAppIdPayload(appId),
56
+ [keyData]: {
57
+ [keyCards]: cards.map((card) => {
58
+ return cardToJson(card);
59
+ })
60
+ }
61
+ };
62
+ }
63
+
64
+ function getAppIdPayload(appId: string): { [k: string]: any } {
65
+ return {
66
+ [keyAppId]: appId
67
+ };
68
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file contains the function to build the object from json
3
+ * @author Abhishek Kumar
4
+ * @since 1.0.0
5
+ */
6
+
7
+ import CardInfo from "../../model/CardInfo";
8
+ import CardsData from "../../model/CardsData";
9
+ import {
10
+ keyCategories,
11
+ keyCategory,
12
+ keyData,
13
+ keyIsAllCategoryEnabled,
14
+ keyNewCardsCount,
15
+ keyUnClickedCardsCount
16
+ } from "../Constants";
17
+ import { cardInfoFromJson, cardsDataFromJson } from "./JsonToModelMapper";
18
+
19
+ export function getCardsCategoriesFromPayload(payload: string): Array<string> {
20
+ const categoriesJson = JSON.parse(payload)[keyData];
21
+ return categoriesJson[keyCategories];
22
+ }
23
+
24
+ export function getCardInfoFromPayload(payload: string): CardInfo {
25
+ const cardsInfoJson = JSON.parse(payload)[keyData];
26
+ return cardInfoFromJson(cardsInfoJson);
27
+ }
28
+
29
+ export function getCardsDataFromPayload(payload: string): CardsData {
30
+ const cardsDataJson = JSON.parse(payload)[keyData];
31
+ return cardsDataFromJson(cardsDataJson);
32
+ }
33
+
34
+ export function getCardsDataFromPayloadWithDefaultCategory(payload: string): CardsData {
35
+ const cardsDataJson = JSON.parse(payload)[keyData];
36
+ cardsDataJson[keyCategory] = "All";
37
+ return cardsDataFromJson(cardsDataJson);
38
+ }
39
+
40
+ export function getAllCategoryStatusFromPayload(payload: string): boolean {
41
+ const statusJson = JSON.parse(payload)[keyData];
42
+ return statusJson[keyIsAllCategoryEnabled];
43
+ }
44
+
45
+ export function getNewCardCountFromPayload(payload: string): number {
46
+ const cardCountJson = JSON.parse(payload)[keyData];
47
+ return cardCountJson[keyNewCardsCount];
48
+ }
49
+
50
+ export function getUnclickedCountFromPayload(payload: string): number {
51
+ const unclickedCountJson = JSON.parse(payload)[keyData];
52
+ return unclickedCountJson[keyUnClickedCardsCount];
53
+ }
@@ -0,0 +1,81 @@
1
+ import Card from "../../model/Card";
2
+ import {
3
+ getAccountMetaPayload,
4
+ getCardClickedPayload,
5
+ getCardShownPayload,
6
+ getCardsForCategoriesPayload,
7
+ getDeleteCardsPayload
8
+ } from "./PayloadBuilder";
9
+
10
+ const PLATFORM_ANDROID = "android";
11
+ const PLATFORM_iOS = "ios";
12
+
13
+ /**
14
+ * Class to build the Platform specific payload to communicate with the bridge
15
+ *
16
+ * @author Abhishek Kumar
17
+ * @since 1.0.0
18
+ */
19
+ class PlatformPayloadBuilder {
20
+
21
+ private platform: string;
22
+ private appId: string;
23
+
24
+ constructor(platform: string, appId: string) {
25
+ this.platform = platform;
26
+ this.appId = appId;
27
+ }
28
+
29
+ getAccountMetaPayload(): string | { [k: string]: any } {
30
+ if (this.platform === PLATFORM_ANDROID) {
31
+ return JSON.stringify(getAccountMetaPayload(this.appId));
32
+ } else if (this.platform === PLATFORM_iOS) {
33
+ return getAccountMetaPayload(this.appId);
34
+ } else {
35
+ throw new Error("Platform Not Supported");
36
+ }
37
+ }
38
+
39
+ getCardClickedPayload(card: Card, widgetId: number): string | { [k: string]: any } {
40
+ if (this.platform === PLATFORM_ANDROID) {
41
+ return JSON.stringify(getCardClickedPayload(card, widgetId, this.appId));
42
+ } else if (this.platform === PLATFORM_iOS) {
43
+ return getCardClickedPayload(card, widgetId, this.appId);
44
+ } else {
45
+ throw new Error("Platform Not Supported");
46
+ }
47
+ }
48
+
49
+ getCardShowPayload(card: Card): string | { [k: string]: any } {
50
+ if (this.platform === PLATFORM_ANDROID) {
51
+ return JSON.stringify(getCardShownPayload(card, this.appId));
52
+ } else if (this.platform === PLATFORM_iOS) {
53
+ return getCardShownPayload(card, this.appId);
54
+ } else {
55
+ throw new Error("Platform Not Supported");
56
+ }
57
+ }
58
+
59
+ getCardsForCategoriesPayload(category: string): string | { [k: string]: any } {
60
+ if (this.platform === PLATFORM_ANDROID) {
61
+ return JSON.stringify(getCardsForCategoriesPayload(category, this.appId));
62
+ } else if (this.platform === PLATFORM_iOS) {
63
+ return getCardsForCategoriesPayload(category, this.appId);
64
+ } else {
65
+ throw new Error("Platform Not Supported");
66
+ }
67
+
68
+ }
69
+
70
+ getDeleteCardsPayload(cards: Array<Card>): string | { [k: string]: any } {
71
+ if (this.platform === PLATFORM_ANDROID) {
72
+ return JSON.stringify(getDeleteCardsPayload(cards, this.appId));
73
+ } else if (this.platform === PLATFORM_iOS) {
74
+ return getDeleteCardsPayload(cards, this.appId);
75
+ } else {
76
+ throw new Error("Platform Not Supported");
77
+ }
78
+ }
79
+ }
80
+
81
+ export default PlatformPayloadBuilder;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file contains the utility function
3
+ * @author Abhishek Kumar
4
+ * @since 1.0.0
5
+ */
6
+
7
+ export function getEnumByName<T>(enumType: any, enumValue: string): T {
8
+ enumValue = enumValue.toUpperCase();
9
+ const typedEnumValue = enumValue as unknown as T;
10
+ const enumIndex = enumType[typedEnumValue]
11
+ return enumType[enumIndex];
12
+ }
13
+
14
+ export function assertUnsupportedError(errorMessage: string): never {
15
+ throw new Error(errorMessage);
16
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * State of the card.
3
+ *
4
+ * @author Abhishek Kumar
5
+ * @since 1.0.0
6
+ */
7
+ class CampaignState {
8
+
9
+ /**
10
+ * Number of times card shown on the current device
11
+ * @since 1.0.0
12
+ */
13
+ localShowCount: number;
14
+
15
+ /**
16
+ * True if the user has clicked the card, else false.
17
+ * @since 1.0.0
18
+ */
19
+ isClicked: boolean;
20
+
21
+ /**
22
+ * First Time the card was received.
23
+ * @since 1.0.0
24
+ */
25
+ firstReceived: number;
26
+
27
+ /**
28
+ * First Time the card was seen by the user.
29
+ * @since 1.0.0
30
+ */
31
+ firstSeen: number;
32
+
33
+ /**
34
+ * Total number of times campaign has been seen by the user across devices.
35
+ * @since 1.0.0
36
+ */
37
+ totalShowCount: number;
38
+
39
+ constructor(
40
+ localShowCount: number,
41
+ isClicked: boolean,
42
+ firstReceived: number,
43
+ firstSeen: number,
44
+ totalShowCount: number
45
+ ) {
46
+ this.localShowCount = localShowCount;
47
+ this.isClicked = isClicked;
48
+ this.firstReceived = firstReceived;
49
+ this.firstSeen = firstSeen;
50
+ this.totalShowCount = totalShowCount;
51
+ }
52
+ }
53
+
54
+ export default CampaignState;
@@ -0,0 +1,51 @@
1
+ import MetaData from "./MetaData";
2
+ import Template from "./Template";
3
+
4
+ /**
5
+ * Card data
6
+ *
7
+ * @author Abhishek Kumar
8
+ * @since 1.0.0
9
+ */
10
+ class Card {
11
+
12
+ /**
13
+ * Internal SDK identifier.
14
+ * @since 1.0.0
15
+ */
16
+ id: number;
17
+
18
+ /**
19
+ * Unique identifier for the campaign
20
+ * @since 1.0.0
21
+ */
22
+ cardId: string;
23
+
24
+ /**
25
+ * Category to which the campaign belongs.
26
+ * @since 1.0.0
27
+ */
28
+ category: string;
29
+
30
+ /**
31
+ * Template payload for the campaign.
32
+ * @since 1.0.0
33
+ */
34
+ template: Template;
35
+
36
+ /**
37
+ * Meta data related to the campaign like status, delivery control etc.
38
+ * @since 1.0.0
39
+ */
40
+ metaData: MetaData;
41
+
42
+ constructor(id: number, cardId: string, category: string, template: Template, metaData: MetaData) {
43
+ this.id = id;
44
+ this.cardId = cardId;
45
+ this.category = category;
46
+ this.template = template;
47
+ this.metaData = metaData;
48
+ }
49
+ }
50
+
51
+ export default Card;
@@ -0,0 +1,36 @@
1
+ import Card from "./Card";
2
+
3
+ /**
4
+ * All data for cards.
5
+ *
6
+ * @author Abhishek Kumar
7
+ * @since 1.0.0
8
+ */
9
+ class CardInfo {
10
+
11
+ /**
12
+ * True is showing ALL tabs is enabled else false.
13
+ * @since 1.0.0
14
+ */
15
+ shouldShowAllTab: boolean;
16
+
17
+ /**
18
+ * All configured categories for cards.
19
+ * @since 1.0.0
20
+ */
21
+ categories: Array<string>;
22
+
23
+ /**
24
+ * All cards which are eligible for display currently.
25
+ * @since 1.0.0
26
+ */
27
+ cards: Array<Card>;
28
+
29
+ constructor(shouldShowAllTab: boolean, categories: Array<string>, cards: Array<Card>) {
30
+ this.shouldShowAllTab = shouldShowAllTab;
31
+ this.categories = categories;
32
+ this.cards = cards;
33
+ }
34
+ }
35
+
36
+ export default CardInfo;
@@ -0,0 +1,29 @@
1
+ import Card from "./Card";
2
+
3
+ /**
4
+ * Data for cards
5
+ *
6
+ * @author Abhishek Kumar
7
+ * @since 1.0.0
8
+ */
9
+ class CardsData {
10
+
11
+ /**
12
+ * Category for the cards
13
+ * @since 1.0.0
14
+ */
15
+ category: string;
16
+
17
+ /**
18
+ * [List] of [Card]
19
+ * @since 1.0.0
20
+ */
21
+ cards: Array<Card>;
22
+
23
+ constructor(category: string, cards: Array<Card>) {
24
+ this.category = category;
25
+ this.cards = cards;
26
+ }
27
+ }
28
+
29
+ export default CardsData;
@@ -0,0 +1,59 @@
1
+ import Widget from "./Widget";
2
+ import Action from "./action/Action";
3
+ import TemplateType from "./enums/TemplateType";
4
+ import ContainerStyle from "./styles/ContainerStyle";
5
+
6
+ /**
7
+ * Container to hold UI widget
8
+ *
9
+ * @author Abhishek Kumar
10
+ * @since 1.0.0
11
+ */
12
+ class Container {
13
+
14
+ /**
15
+ * Unique identifier for a template
16
+ * @since 1.0.0
17
+ */
18
+ id: number;
19
+
20
+ /**
21
+ * Type of container.
22
+ * @since 1.0.0
23
+ */
24
+ templateType: TemplateType;
25
+
26
+ /**
27
+ * Style associated to the Container
28
+ * @since 1.0.0
29
+ */
30
+ style: ContainerStyle | undefined;
31
+
32
+ /**
33
+ * Widget list associated to the Container
34
+ * @since 1.0.0
35
+ */
36
+ widgets: Array<Widget>;
37
+
38
+ /**
39
+ * Actions to be performed on widget click
40
+ * @since 1.0.0
41
+ */
42
+ actionList: Array<Action>;
43
+
44
+ constructor(
45
+ id: number,
46
+ templateType: TemplateType,
47
+ style: ContainerStyle | undefined,
48
+ widgets: Array<Widget>,
49
+ actionList: Array<Action>
50
+ ) {
51
+ this.id = id;
52
+ this.templateType = templateType;
53
+ this.style = style;
54
+ this.widgets = widgets;
55
+ this.actionList = actionList;
56
+ }
57
+ }
58
+
59
+ export default Container;