@capawesome/capacitor-intercom 0.0.1

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 (73) hide show
  1. package/CapawesomeCapacitorIntercom.podspec +19 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +30 -0
  4. package/README.md +932 -0
  5. package/android/build.gradle +60 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/Intercom.java +441 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/IntercomHelper.java +38 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/IntercomPlugin.java +307 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/CustomException.java +20 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/CustomExceptions.java +23 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/events/UnreadConversationCountChangeEvent.java +22 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/HandlePushNotificationOptions.java +25 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/InitializeOptions.java +34 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/IsIntercomPushNotificationOptions.java +25 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/LogEventOptions.java +35 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/LoginUserOptions.java +33 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentContentOptions.java +71 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentMessageComposerOptions.java +20 -0
  20. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/PresentOptions.java +19 -0
  21. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SendPushTokenToIntercomOptions.java +24 -0
  22. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetBottomPaddingOptions.java +22 -0
  23. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetInAppMessagesVisibleOptions.java +22 -0
  24. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetLauncherVisibleOptions.java +22 -0
  25. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetUserHashOptions.java +24 -0
  26. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/SetUserJwtOptions.java +24 -0
  27. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/options/UpdateUserOptions.java +108 -0
  28. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/results/GetUnreadConversationCountResult.java +22 -0
  29. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/classes/results/IsIntercomPushNotificationResult.java +22 -0
  30. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/Callback.java +5 -0
  31. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/EmptyCallback.java +5 -0
  32. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/NonEmptyResultCallback.java +7 -0
  33. package/android/src/main/java/io/capawesome/capacitorjs/plugins/intercom/interfaces/Result.java +7 -0
  34. package/android/src/main/res/.gitkeep +0 -0
  35. package/dist/docs.json +1345 -0
  36. package/dist/esm/definitions.d.ts +549 -0
  37. package/dist/esm/definitions.js +27 -0
  38. package/dist/esm/definitions.js.map +1 -0
  39. package/dist/esm/index.d.ts +4 -0
  40. package/dist/esm/index.js +7 -0
  41. package/dist/esm/index.js.map +1 -0
  42. package/dist/esm/web.d.ts +34 -0
  43. package/dist/esm/web.js +175 -0
  44. package/dist/esm/web.js.map +1 -0
  45. package/dist/plugin.cjs.js +215 -0
  46. package/dist/plugin.cjs.js.map +1 -0
  47. package/dist/plugin.js +217 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/ios/Plugin/Classes/Events/UnreadConversationCountChangeEvent.swift +16 -0
  50. package/ios/Plugin/Classes/Options/HandlePushNotificationOptions.swift +13 -0
  51. package/ios/Plugin/Classes/Options/InitializeOptions.swift +15 -0
  52. package/ios/Plugin/Classes/Options/IsIntercomPushNotificationOptions.swift +13 -0
  53. package/ios/Plugin/Classes/Options/LogEventOptions.swift +15 -0
  54. package/ios/Plugin/Classes/Options/LoginUserOptions.swift +17 -0
  55. package/ios/Plugin/Classes/Options/PresentContentOptions.swift +29 -0
  56. package/ios/Plugin/Classes/Options/PresentMessageComposerOptions.swift +10 -0
  57. package/ios/Plugin/Classes/Options/PresentOptions.swift +10 -0
  58. package/ios/Plugin/Classes/Options/SendPushTokenToIntercomOptions.swift +13 -0
  59. package/ios/Plugin/Classes/Options/SetBottomPaddingOptions.swift +13 -0
  60. package/ios/Plugin/Classes/Options/SetInAppMessagesVisibleOptions.swift +13 -0
  61. package/ios/Plugin/Classes/Options/SetLauncherVisibleOptions.swift +13 -0
  62. package/ios/Plugin/Classes/Options/SetUserHashOptions.swift +13 -0
  63. package/ios/Plugin/Classes/Options/SetUserJwtOptions.swift +13 -0
  64. package/ios/Plugin/Classes/Options/UpdateUserOptions.swift +38 -0
  65. package/ios/Plugin/Classes/Results/GetUnreadConversationCountResult.swift +16 -0
  66. package/ios/Plugin/Classes/Results/IsIntercomPushNotificationResult.swift +16 -0
  67. package/ios/Plugin/Enums/CustomError.swift +75 -0
  68. package/ios/Plugin/Info.plist +24 -0
  69. package/ios/Plugin/Intercom.swift +323 -0
  70. package/ios/Plugin/IntercomHelper.swift +17 -0
  71. package/ios/Plugin/IntercomPlugin.swift +261 -0
  72. package/ios/Plugin/Protocols/Result.swift +5 -0
  73. package/package.json +105 -0
@@ -0,0 +1,307 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.Logger;
6
+ import com.getcapacitor.Plugin;
7
+ import com.getcapacitor.PluginCall;
8
+ import com.getcapacitor.PluginMethod;
9
+ import com.getcapacitor.annotation.CapacitorPlugin;
10
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomException;
11
+ import io.capawesome.capacitorjs.plugins.intercom.classes.events.UnreadConversationCountChangeEvent;
12
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.HandlePushNotificationOptions;
13
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.InitializeOptions;
14
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.IsIntercomPushNotificationOptions;
15
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.LogEventOptions;
16
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.LoginUserOptions;
17
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.PresentContentOptions;
18
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.PresentMessageComposerOptions;
19
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.PresentOptions;
20
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SendPushTokenToIntercomOptions;
21
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SetBottomPaddingOptions;
22
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SetInAppMessagesVisibleOptions;
23
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SetLauncherVisibleOptions;
24
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SetUserHashOptions;
25
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.SetUserJwtOptions;
26
+ import io.capawesome.capacitorjs.plugins.intercom.classes.options.UpdateUserOptions;
27
+ import io.capawesome.capacitorjs.plugins.intercom.classes.results.GetUnreadConversationCountResult;
28
+ import io.capawesome.capacitorjs.plugins.intercom.classes.results.IsIntercomPushNotificationResult;
29
+ import io.capawesome.capacitorjs.plugins.intercom.interfaces.EmptyCallback;
30
+ import io.capawesome.capacitorjs.plugins.intercom.interfaces.NonEmptyResultCallback;
31
+ import io.capawesome.capacitorjs.plugins.intercom.interfaces.Result;
32
+
33
+ @CapacitorPlugin(name = "Intercom")
34
+ public class IntercomPlugin extends Plugin {
35
+
36
+ public static final String ERROR_UNKNOWN_ERROR = "An unknown error has occurred.";
37
+ public static final String EVENT_UNREAD_CONVERSATION_COUNT_CHANGE = "unreadConversationCountChange";
38
+ public static final String TAG = "IntercomPlugin";
39
+
40
+ private Intercom implementation;
41
+
42
+ @Override
43
+ public void load() {
44
+ super.load();
45
+ this.implementation = new Intercom(this);
46
+ }
47
+
48
+ @PluginMethod
49
+ public void getUnreadConversationCount(PluginCall call) {
50
+ try {
51
+ NonEmptyResultCallback<GetUnreadConversationCountResult> callback = new NonEmptyResultCallback<>() {
52
+ @Override
53
+ public void success(@NonNull GetUnreadConversationCountResult result) {
54
+ resolveCall(call, result);
55
+ }
56
+
57
+ @Override
58
+ public void error(Exception exception) {
59
+ rejectCall(call, exception);
60
+ }
61
+ };
62
+ implementation.getUnreadConversationCount(callback);
63
+ } catch (Exception exception) {
64
+ rejectCall(call, exception);
65
+ }
66
+ }
67
+
68
+ @PluginMethod
69
+ public void handlePushNotification(PluginCall call) {
70
+ try {
71
+ HandlePushNotificationOptions options = new HandlePushNotificationOptions(call);
72
+ implementation.handlePushNotification(options, createEmptyCallback(call));
73
+ } catch (Exception exception) {
74
+ rejectCall(call, exception);
75
+ }
76
+ }
77
+
78
+ @PluginMethod
79
+ public void hide(PluginCall call) {
80
+ try {
81
+ implementation.hide(createEmptyCallback(call));
82
+ } catch (Exception exception) {
83
+ rejectCall(call, exception);
84
+ }
85
+ }
86
+
87
+ @PluginMethod
88
+ public void initialize(PluginCall call) {
89
+ try {
90
+ InitializeOptions options = new InitializeOptions(call);
91
+ implementation.initialize(options, createEmptyCallback(call));
92
+ } catch (Exception exception) {
93
+ rejectCall(call, exception);
94
+ }
95
+ }
96
+
97
+ @PluginMethod
98
+ public void isIntercomPushNotification(PluginCall call) {
99
+ try {
100
+ IsIntercomPushNotificationOptions options = new IsIntercomPushNotificationOptions(call);
101
+ NonEmptyResultCallback<IsIntercomPushNotificationResult> callback = new NonEmptyResultCallback<>() {
102
+ @Override
103
+ public void success(@NonNull IsIntercomPushNotificationResult result) {
104
+ resolveCall(call, result);
105
+ }
106
+
107
+ @Override
108
+ public void error(Exception exception) {
109
+ rejectCall(call, exception);
110
+ }
111
+ };
112
+ implementation.isIntercomPushNotification(options, callback);
113
+ } catch (Exception exception) {
114
+ rejectCall(call, exception);
115
+ }
116
+ }
117
+
118
+ @PluginMethod
119
+ public void logEvent(PluginCall call) {
120
+ try {
121
+ LogEventOptions options = new LogEventOptions(call);
122
+ implementation.logEvent(options, createEmptyCallback(call));
123
+ } catch (Exception exception) {
124
+ rejectCall(call, exception);
125
+ }
126
+ }
127
+
128
+ @PluginMethod
129
+ public void loginUnidentifiedUser(PluginCall call) {
130
+ try {
131
+ implementation.loginUnidentifiedUser(createEmptyCallback(call));
132
+ } catch (Exception exception) {
133
+ rejectCall(call, exception);
134
+ }
135
+ }
136
+
137
+ @PluginMethod
138
+ public void loginUser(PluginCall call) {
139
+ try {
140
+ LoginUserOptions options = new LoginUserOptions(call);
141
+ implementation.loginUser(options, createEmptyCallback(call));
142
+ } catch (Exception exception) {
143
+ rejectCall(call, exception);
144
+ }
145
+ }
146
+
147
+ @PluginMethod
148
+ public void logout(PluginCall call) {
149
+ try {
150
+ implementation.logout(createEmptyCallback(call));
151
+ } catch (Exception exception) {
152
+ rejectCall(call, exception);
153
+ }
154
+ }
155
+
156
+ public void notifyUnreadConversationCountChangeListeners(@NonNull UnreadConversationCountChangeEvent event) {
157
+ notifyListeners(EVENT_UNREAD_CONVERSATION_COUNT_CHANGE, event.toJSObject());
158
+ }
159
+
160
+ @PluginMethod
161
+ public void present(PluginCall call) {
162
+ try {
163
+ PresentOptions options = new PresentOptions(call);
164
+ implementation.present(options, createEmptyCallback(call));
165
+ } catch (Exception exception) {
166
+ rejectCall(call, exception);
167
+ }
168
+ }
169
+
170
+ @PluginMethod
171
+ public void presentContent(PluginCall call) {
172
+ try {
173
+ PresentContentOptions options = new PresentContentOptions(call);
174
+ implementation.presentContent(options, createEmptyCallback(call));
175
+ } catch (Exception exception) {
176
+ rejectCall(call, exception);
177
+ }
178
+ }
179
+
180
+ @PluginMethod
181
+ public void presentMessageComposer(PluginCall call) {
182
+ try {
183
+ PresentMessageComposerOptions options = new PresentMessageComposerOptions(call);
184
+ implementation.presentMessageComposer(options, createEmptyCallback(call));
185
+ } catch (Exception exception) {
186
+ rejectCall(call, exception);
187
+ }
188
+ }
189
+
190
+ @PluginMethod
191
+ public void sendPushTokenToIntercom(PluginCall call) {
192
+ try {
193
+ SendPushTokenToIntercomOptions options = new SendPushTokenToIntercomOptions(call);
194
+ implementation.sendPushTokenToIntercom(options, createEmptyCallback(call));
195
+ } catch (Exception exception) {
196
+ rejectCall(call, exception);
197
+ }
198
+ }
199
+
200
+ @PluginMethod
201
+ public void setBottomPadding(PluginCall call) {
202
+ try {
203
+ SetBottomPaddingOptions options = new SetBottomPaddingOptions(call);
204
+ implementation.setBottomPadding(options, createEmptyCallback(call));
205
+ } catch (Exception exception) {
206
+ rejectCall(call, exception);
207
+ }
208
+ }
209
+
210
+ @PluginMethod
211
+ public void setInAppMessagesVisible(PluginCall call) {
212
+ try {
213
+ SetInAppMessagesVisibleOptions options = new SetInAppMessagesVisibleOptions(call);
214
+ implementation.setInAppMessagesVisible(options, createEmptyCallback(call));
215
+ } catch (Exception exception) {
216
+ rejectCall(call, exception);
217
+ }
218
+ }
219
+
220
+ @PluginMethod
221
+ public void setLauncherVisible(PluginCall call) {
222
+ try {
223
+ SetLauncherVisibleOptions options = new SetLauncherVisibleOptions(call);
224
+ implementation.setLauncherVisible(options, createEmptyCallback(call));
225
+ } catch (Exception exception) {
226
+ rejectCall(call, exception);
227
+ }
228
+ }
229
+
230
+ @PluginMethod
231
+ public void setUserHash(PluginCall call) {
232
+ try {
233
+ SetUserHashOptions options = new SetUserHashOptions(call);
234
+ implementation.setUserHash(options, createEmptyCallback(call));
235
+ } catch (Exception exception) {
236
+ rejectCall(call, exception);
237
+ }
238
+ }
239
+
240
+ @PluginMethod
241
+ public void setUserJwt(PluginCall call) {
242
+ try {
243
+ SetUserJwtOptions options = new SetUserJwtOptions(call);
244
+ implementation.setUserJwt(options, createEmptyCallback(call));
245
+ } catch (Exception exception) {
246
+ rejectCall(call, exception);
247
+ }
248
+ }
249
+
250
+ @PluginMethod
251
+ public void updateUser(PluginCall call) {
252
+ try {
253
+ UpdateUserOptions options = new UpdateUserOptions(call);
254
+ implementation.updateUser(options, createEmptyCallback(call));
255
+ } catch (Exception exception) {
256
+ rejectCall(call, exception);
257
+ }
258
+ }
259
+
260
+ @Override
261
+ protected void handleOnDestroy() {
262
+ super.handleOnDestroy();
263
+ if (implementation != null) {
264
+ implementation.unregisterUnreadConversationCountListener();
265
+ }
266
+ }
267
+
268
+ @NonNull
269
+ private EmptyCallback createEmptyCallback(@NonNull PluginCall call) {
270
+ return new EmptyCallback() {
271
+ @Override
272
+ public void success() {
273
+ resolveCall(call);
274
+ }
275
+
276
+ @Override
277
+ public void error(Exception exception) {
278
+ rejectCall(call, exception);
279
+ }
280
+ };
281
+ }
282
+
283
+ private void rejectCall(@NonNull PluginCall call, @NonNull Exception exception) {
284
+ String message = exception.getMessage();
285
+ if (message == null) {
286
+ message = ERROR_UNKNOWN_ERROR;
287
+ }
288
+ String code = null;
289
+ if (exception instanceof CustomException) {
290
+ code = ((CustomException) exception).getCode();
291
+ }
292
+ Logger.error(TAG, message, exception);
293
+ call.reject(message, code);
294
+ }
295
+
296
+ private void resolveCall(@NonNull PluginCall call) {
297
+ call.resolve();
298
+ }
299
+
300
+ private void resolveCall(@NonNull PluginCall call, @Nullable Result result) {
301
+ if (result == null) {
302
+ call.resolve();
303
+ } else {
304
+ call.resolve(result.toJSObject());
305
+ }
306
+ }
307
+ }
@@ -0,0 +1,20 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ public class CustomException extends Exception {
7
+
8
+ @Nullable
9
+ private final String code;
10
+
11
+ public CustomException(@Nullable String code, @NonNull String message) {
12
+ super(message);
13
+ this.code = code;
14
+ }
15
+
16
+ @Nullable
17
+ public String getCode() {
18
+ return code;
19
+ }
20
+ }
@@ -0,0 +1,23 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes;
2
+
3
+ public class CustomExceptions {
4
+
5
+ public static final CustomException ANDROID_API_KEY_MISSING = new CustomException(null, "androidApiKey must be provided.");
6
+ public static final CustomException APP_ID_MISSING = new CustomException(null, "appId must be provided.");
7
+ public static final CustomException COMPANY_ID_MISSING = new CustomException(null, "company id must be provided.");
8
+ public static final CustomException DATA_MISSING = new CustomException(null, "data must be provided.");
9
+ public static final CustomException ID_MISSING = new CustomException(null, "id must be provided.");
10
+ public static final CustomException IDS_MISSING = new CustomException(null, "ids must be provided.");
11
+ public static final CustomException JWT_MISSING = new CustomException(null, "jwt must be provided.");
12
+ public static final CustomException NAME_MISSING = new CustomException(null, "name must be provided.");
13
+ public static final CustomException NOT_INITIALIZED = new CustomException(
14
+ "NOT_INITIALIZED",
15
+ "Intercom is not initialized. Call initialize() first."
16
+ );
17
+ public static final CustomException PADDING_MISSING = new CustomException(null, "padding must be provided.");
18
+ public static final CustomException TOKEN_MISSING = new CustomException(null, "token must be provided.");
19
+ public static final CustomException TYPE_INVALID = new CustomException(null, "type is invalid.");
20
+ public static final CustomException USER_HASH_MISSING = new CustomException(null, "userHash must be provided.");
21
+ public static final CustomException USER_ID_OR_EMAIL_MISSING = new CustomException(null, "userId or email must be provided.");
22
+ public static final CustomException VISIBLE_MISSING = new CustomException(null, "visible must be provided.");
23
+ }
@@ -0,0 +1,22 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.events;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.intercom.interfaces.Result;
6
+
7
+ public class UnreadConversationCountChangeEvent implements Result {
8
+
9
+ private final int count;
10
+
11
+ public UnreadConversationCountChangeEvent(int count) {
12
+ this.count = count;
13
+ }
14
+
15
+ @Override
16
+ @NonNull
17
+ public JSObject toJSObject() {
18
+ JSObject result = new JSObject();
19
+ result.put("count", count);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,25 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
7
+
8
+ public class HandlePushNotificationOptions {
9
+
10
+ @NonNull
11
+ private final JSObject data;
12
+
13
+ public HandlePushNotificationOptions(@NonNull PluginCall call) throws Exception {
14
+ JSObject data = call.getObject("data");
15
+ if (data == null) {
16
+ throw CustomExceptions.DATA_MISSING;
17
+ }
18
+ this.data = data;
19
+ }
20
+
21
+ @NonNull
22
+ public JSObject getData() {
23
+ return data;
24
+ }
25
+ }
@@ -0,0 +1,34 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
7
+
8
+ public class InitializeOptions {
9
+
10
+ @Nullable
11
+ private final String androidApiKey;
12
+
13
+ @NonNull
14
+ private final String appId;
15
+
16
+ public InitializeOptions(@NonNull PluginCall call) throws Exception {
17
+ String appId = call.getString("appId");
18
+ if (appId == null) {
19
+ throw CustomExceptions.APP_ID_MISSING;
20
+ }
21
+ this.appId = appId;
22
+ this.androidApiKey = call.getString("androidApiKey");
23
+ }
24
+
25
+ @Nullable
26
+ public String getAndroidApiKey() {
27
+ return androidApiKey;
28
+ }
29
+
30
+ @NonNull
31
+ public String getAppId() {
32
+ return appId;
33
+ }
34
+ }
@@ -0,0 +1,25 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
7
+
8
+ public class IsIntercomPushNotificationOptions {
9
+
10
+ @NonNull
11
+ private final JSObject data;
12
+
13
+ public IsIntercomPushNotificationOptions(@NonNull PluginCall call) throws Exception {
14
+ JSObject data = call.getObject("data");
15
+ if (data == null) {
16
+ throw CustomExceptions.DATA_MISSING;
17
+ }
18
+ this.data = data;
19
+ }
20
+
21
+ @NonNull
22
+ public JSObject getData() {
23
+ return data;
24
+ }
25
+ }
@@ -0,0 +1,35 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSObject;
6
+ import com.getcapacitor.PluginCall;
7
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
8
+
9
+ public class LogEventOptions {
10
+
11
+ @Nullable
12
+ private final JSObject data;
13
+
14
+ @NonNull
15
+ private final String name;
16
+
17
+ public LogEventOptions(@NonNull PluginCall call) throws Exception {
18
+ String name = call.getString("name");
19
+ if (name == null) {
20
+ throw CustomExceptions.NAME_MISSING;
21
+ }
22
+ this.name = name;
23
+ this.data = call.getObject("data");
24
+ }
25
+
26
+ @Nullable
27
+ public JSObject getData() {
28
+ return data;
29
+ }
30
+
31
+ @NonNull
32
+ public String getName() {
33
+ return name;
34
+ }
35
+ }
@@ -0,0 +1,33 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.PluginCall;
6
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
7
+
8
+ public class LoginUserOptions {
9
+
10
+ @Nullable
11
+ private final String email;
12
+
13
+ @Nullable
14
+ private final String userId;
15
+
16
+ public LoginUserOptions(@NonNull PluginCall call) throws Exception {
17
+ this.userId = call.getString("userId");
18
+ this.email = call.getString("email");
19
+ if (userId == null && email == null) {
20
+ throw CustomExceptions.USER_ID_OR_EMAIL_MISSING;
21
+ }
22
+ }
23
+
24
+ @Nullable
25
+ public String getEmail() {
26
+ return email;
27
+ }
28
+
29
+ @Nullable
30
+ public String getUserId() {
31
+ return userId;
32
+ }
33
+ }
@@ -0,0 +1,71 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSArray;
6
+ import com.getcapacitor.PluginCall;
7
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
8
+ import java.util.ArrayList;
9
+ import java.util.List;
10
+
11
+ public class PresentContentOptions {
12
+
13
+ @Nullable
14
+ private final String id;
15
+
16
+ @Nullable
17
+ private final List<String> ids;
18
+
19
+ @NonNull
20
+ private final String type;
21
+
22
+ public PresentContentOptions(@NonNull PluginCall call) throws Exception {
23
+ String type = call.getString("type");
24
+ if (type == null) {
25
+ throw CustomExceptions.TYPE_INVALID;
26
+ }
27
+ this.type = type;
28
+ this.id = call.getString("id");
29
+ JSArray ids = call.getArray("ids");
30
+ if (ids == null) {
31
+ this.ids = null;
32
+ } else {
33
+ this.ids = new ArrayList<>();
34
+ for (int i = 0; i < ids.length(); i++) {
35
+ this.ids.add(ids.getString(i));
36
+ }
37
+ }
38
+ switch (type) {
39
+ case "article":
40
+ case "carousel":
41
+ case "survey":
42
+ case "conversation":
43
+ if (id == null) {
44
+ throw CustomExceptions.ID_MISSING;
45
+ }
46
+ break;
47
+ case "help-center-collections":
48
+ if (this.ids == null || this.ids.isEmpty()) {
49
+ throw CustomExceptions.IDS_MISSING;
50
+ }
51
+ break;
52
+ default:
53
+ throw CustomExceptions.TYPE_INVALID;
54
+ }
55
+ }
56
+
57
+ @Nullable
58
+ public String getId() {
59
+ return id;
60
+ }
61
+
62
+ @Nullable
63
+ public List<String> getIds() {
64
+ return ids;
65
+ }
66
+
67
+ @NonNull
68
+ public String getType() {
69
+ return type;
70
+ }
71
+ }
@@ -0,0 +1,20 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.PluginCall;
6
+
7
+ public class PresentMessageComposerOptions {
8
+
9
+ @Nullable
10
+ private final String initialMessage;
11
+
12
+ public PresentMessageComposerOptions(@NonNull PluginCall call) {
13
+ this.initialMessage = call.getString("initialMessage");
14
+ }
15
+
16
+ @Nullable
17
+ public String getInitialMessage() {
18
+ return initialMessage;
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.PluginCall;
5
+
6
+ public class PresentOptions {
7
+
8
+ @NonNull
9
+ private final String space;
10
+
11
+ public PresentOptions(@NonNull PluginCall call) {
12
+ this.space = call.getString("space", "home");
13
+ }
14
+
15
+ @NonNull
16
+ public String getSpace() {
17
+ return space;
18
+ }
19
+ }
@@ -0,0 +1,24 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.PluginCall;
5
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
6
+
7
+ public class SendPushTokenToIntercomOptions {
8
+
9
+ @NonNull
10
+ private final String token;
11
+
12
+ public SendPushTokenToIntercomOptions(@NonNull PluginCall call) throws Exception {
13
+ String token = call.getString("token");
14
+ if (token == null) {
15
+ throw CustomExceptions.TOKEN_MISSING;
16
+ }
17
+ this.token = token;
18
+ }
19
+
20
+ @NonNull
21
+ public String getToken() {
22
+ return token;
23
+ }
24
+ }
@@ -0,0 +1,22 @@
1
+ package io.capawesome.capacitorjs.plugins.intercom.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.PluginCall;
5
+ import io.capawesome.capacitorjs.plugins.intercom.classes.CustomExceptions;
6
+
7
+ public class SetBottomPaddingOptions {
8
+
9
+ private final int padding;
10
+
11
+ public SetBottomPaddingOptions(@NonNull PluginCall call) throws Exception {
12
+ Integer padding = call.getInt("padding");
13
+ if (padding == null) {
14
+ throw CustomExceptions.PADDING_MISSING;
15
+ }
16
+ this.padding = padding;
17
+ }
18
+
19
+ public int getPadding() {
20
+ return padding;
21
+ }
22
+ }