@trycourier/courier-react-native 5.6.16 → 5.7.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 (222) hide show
  1. package/README.md +66 -135
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +1 -0
  4. package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +3 -0
  5. package/android/src/main/java/com/courierreactnative/Utils.kt +11 -1
  6. package/courier-react-native.podspec +1 -1
  7. package/ios/CourierClientModule.swift +1 -0
  8. package/ios/CourierReactNativeDelegate.m +1 -1
  9. package/ios/CourierReactNativeEventEmitter.swift +1 -1
  10. package/ios/CourierReactNativeModule.m +1 -0
  11. package/ios/CourierSharedModule.swift +10 -3
  12. package/ios/Utils.swift +10 -0
  13. package/lib/commonjs/Broadcaster.js +5 -5
  14. package/lib/commonjs/Broadcaster.js.map +1 -1
  15. package/lib/commonjs/CourierApiUrls.js +29 -0
  16. package/lib/commonjs/CourierApiUrls.js.map +1 -0
  17. package/lib/commonjs/Modules.js.map +1 -1
  18. package/lib/commonjs/client/BrandClient.js.map +1 -1
  19. package/lib/commonjs/client/ClientModule.js.map +1 -1
  20. package/lib/commonjs/client/CourierClient.js +4 -1
  21. package/lib/commonjs/client/CourierClient.js.map +1 -1
  22. package/lib/commonjs/client/InboxClient.js.map +1 -1
  23. package/lib/commonjs/client/PreferenceClient.js.map +1 -1
  24. package/lib/commonjs/client/TokenClient.js.map +1 -1
  25. package/lib/commonjs/client/TrackingClient.js.map +1 -1
  26. package/lib/commonjs/index.js +22 -2
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
  29. package/lib/commonjs/models/CourierPushListener.js.map +1 -1
  30. package/lib/commonjs/models/CourierUserPreferences.js +13 -13
  31. package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
  32. package/lib/commonjs/models/InboxAction.js.map +1 -1
  33. package/lib/commonjs/models/InboxMessage.js.map +1 -1
  34. package/lib/commonjs/utils.js.map +1 -1
  35. package/lib/commonjs/views/CourierInboxView.js +13 -13
  36. package/lib/commonjs/views/CourierInboxView.js.map +1 -1
  37. package/lib/commonjs/views/CourierPreferencesView.js +4 -4
  38. package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
  39. package/lib/module/Broadcaster.js +7 -7
  40. package/lib/module/Broadcaster.js.map +1 -1
  41. package/lib/module/CourierApiUrls.js +20 -0
  42. package/lib/module/CourierApiUrls.js.map +1 -0
  43. package/lib/module/Modules.js +1 -1
  44. package/lib/module/Modules.js.map +1 -1
  45. package/lib/module/client/BrandClient.js +1 -1
  46. package/lib/module/client/BrandClient.js.map +1 -1
  47. package/lib/module/client/ClientModule.js +1 -1
  48. package/lib/module/client/ClientModule.js.map +1 -1
  49. package/lib/module/client/CourierClient.js +10 -7
  50. package/lib/module/client/CourierClient.js.map +1 -1
  51. package/lib/module/client/InboxClient.js +1 -1
  52. package/lib/module/client/InboxClient.js.map +1 -1
  53. package/lib/module/client/PreferenceClient.js +1 -1
  54. package/lib/module/client/PreferenceClient.js.map +1 -1
  55. package/lib/module/client/TokenClient.js +1 -1
  56. package/lib/module/client/TokenClient.js.map +1 -1
  57. package/lib/module/client/TrackingClient.js +1 -1
  58. package/lib/module/client/TrackingClient.js.map +1 -1
  59. package/lib/module/index.js +5 -2
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/models/CourierAuthenticationListener.js +1 -1
  62. package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
  63. package/lib/module/models/CourierInboxListener.js +1 -1
  64. package/lib/module/models/CourierPushListener.js.map +1 -1
  65. package/lib/module/models/CourierUserPreferences.js +13 -13
  66. package/lib/module/models/CourierUserPreferences.js.map +1 -1
  67. package/lib/module/models/InboxAction.js.map +1 -1
  68. package/lib/module/models/InboxMessage.js +1 -1
  69. package/lib/module/models/InboxMessage.js.map +1 -1
  70. package/lib/module/utils.js.map +1 -1
  71. package/lib/module/views/CourierInboxView.js +18 -18
  72. package/lib/module/views/CourierInboxView.js.map +1 -1
  73. package/lib/module/views/CourierPreferencesView.js +7 -7
  74. package/lib/module/views/CourierPreferencesView.js.map +1 -1
  75. package/lib/typescript/src/Broadcaster.d.ts +7 -7
  76. package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
  77. package/lib/typescript/src/CourierApiUrls.d.ts +11 -0
  78. package/lib/typescript/src/CourierApiUrls.d.ts.map +1 -0
  79. package/lib/typescript/src/Modules.d.ts.map +1 -1
  80. package/lib/typescript/src/client/BrandClient.d.ts +1 -1
  81. package/lib/typescript/src/client/BrandClient.d.ts.map +1 -1
  82. package/lib/typescript/src/client/ClientModule.d.ts +1 -1
  83. package/lib/typescript/src/client/ClientModule.d.ts.map +1 -1
  84. package/lib/typescript/src/client/CourierClient.d.ts +9 -6
  85. package/lib/typescript/src/client/CourierClient.d.ts.map +1 -1
  86. package/lib/typescript/src/client/InboxClient.d.ts +1 -1
  87. package/lib/typescript/src/client/InboxClient.d.ts.map +1 -1
  88. package/lib/typescript/src/client/PreferenceClient.d.ts +1 -1
  89. package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -1
  90. package/lib/typescript/src/client/TokenClient.d.ts +1 -1
  91. package/lib/typescript/src/client/TokenClient.d.ts.map +1 -1
  92. package/lib/typescript/src/client/TrackingClient.d.ts +1 -1
  93. package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -1
  94. package/lib/typescript/src/index.d.ts +6 -2
  95. package/lib/typescript/src/index.d.ts.map +1 -1
  96. package/lib/typescript/src/models/Android_CourierSheet.d.ts +1 -1
  97. package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -1
  98. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
  99. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
  100. package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -1
  101. package/lib/typescript/src/models/CourierButton.d.ts +1 -1
  102. package/lib/typescript/src/models/CourierButton.d.ts.map +1 -1
  103. package/lib/typescript/src/models/CourierFont.d.ts.map +1 -1
  104. package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
  105. package/lib/typescript/src/models/CourierInboxMessages.d.ts +1 -1
  106. package/lib/typescript/src/models/CourierInboxTheme.d.ts +3 -3
  107. package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
  108. package/lib/typescript/src/models/CourierInfoViewStyle.d.ts +2 -2
  109. package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -1
  110. package/lib/typescript/src/models/CourierPreferencesTheme.d.ts +6 -6
  111. package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -1
  112. package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -1
  113. package/lib/typescript/src/models/CourierUserPreferences.d.ts +1 -1
  114. package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -1
  115. package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
  116. package/lib/typescript/src/models/InboxMessage.d.ts +1 -1
  117. package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
  118. package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -1
  119. package/lib/typescript/src/models/InboxMessageSet.d.ts +1 -1
  120. package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -1
  121. package/lib/typescript/src/models/iOS_CourierSheet.d.ts +1 -1
  122. package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -1
  123. package/lib/typescript/src/utils.d.ts.map +1 -1
  124. package/lib/typescript/src/views/CourierInboxView.d.ts +5 -5
  125. package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
  126. package/lib/typescript/src/views/CourierPreferencesView.d.ts +3 -3
  127. package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -1
  128. package/package.json +8 -4
  129. package/src/Broadcaster.tsx +21 -15
  130. package/src/CourierApiUrls.tsx +30 -0
  131. package/src/Modules.tsx +22 -13
  132. package/src/client/BrandClient.tsx +6 -6
  133. package/src/client/ClientModule.tsx +4 -6
  134. package/src/client/CourierClient.tsx +20 -13
  135. package/src/client/InboxClient.tsx +40 -13
  136. package/src/client/PreferenceClient.tsx +47 -21
  137. package/src/client/TokenClient.tsx +14 -7
  138. package/src/client/TrackingClient.tsx +7 -6
  139. package/src/index.tsx +208 -115
  140. package/src/models/Android_CourierSheet.tsx +5 -5
  141. package/src/models/CourierAuthenticationListener.tsx +5 -9
  142. package/src/models/CourierBrand.tsx +6 -6
  143. package/src/models/CourierButton.tsx +5 -5
  144. package/src/models/CourierDevice.tsx +1 -1
  145. package/src/models/CourierFont.tsx +4 -4
  146. package/src/models/CourierInboxListener.tsx +3 -3
  147. package/src/models/CourierInboxMessages.tsx +2 -2
  148. package/src/models/CourierInboxTheme.tsx +55 -42
  149. package/src/models/CourierInfoViewStyle.tsx +5 -5
  150. package/src/models/CourierPaging.tsx +1 -1
  151. package/src/models/CourierPreferencesTheme.tsx +32 -27
  152. package/src/models/CourierPushListener.tsx +9 -7
  153. package/src/models/CourierPushProvider.tsx +1 -1
  154. package/src/models/CourierTrackingEvent.tsx +6 -6
  155. package/src/models/CourierUserPreferences.tsx +32 -28
  156. package/src/models/InboxAction.tsx +2 -6
  157. package/src/models/InboxMessage.tsx +4 -5
  158. package/src/models/InboxMessageEvent.tsx +7 -1
  159. package/src/models/InboxMessageFeed.tsx +1 -1
  160. package/src/models/InboxMessageSet.tsx +1 -1
  161. package/src/models/iOS_CourierCell.tsx +10 -5
  162. package/src/models/iOS_CourierSheet.tsx +4 -4
  163. package/src/utils.tsx +4 -7
  164. package/src/views/CourierInboxView.tsx +79 -71
  165. package/src/views/CourierPreferencesView.tsx +34 -35
  166. package/lib/example/src/App.js +0 -11
  167. package/lib/example/src/Emitter.js +0 -11
  168. package/lib/example/src/Env.js +0 -6
  169. package/lib/example/src/Home.js +0 -67
  170. package/lib/example/src/Poke.js +0 -75
  171. package/lib/example/src/Tabs.js +0 -36
  172. package/lib/example/src/Utils.js +0 -71
  173. package/lib/example/src/pages/Auth.js +0 -224
  174. package/lib/example/src/pages/Inbox.js +0 -38
  175. package/lib/example/src/pages/Preferences.js +0 -13
  176. package/lib/example/src/pages/PreferencesStack.js +0 -11
  177. package/lib/example/src/pages/Push.js +0 -93
  178. package/lib/example/src/pages/Styles.js +0 -26
  179. package/lib/example/src/pages/Tests.js +0 -1068
  180. package/lib/example/src/pages/inbox/InboxCustom.js +0 -141
  181. package/lib/example/src/pages/inbox/InboxDefault.js +0 -22
  182. package/lib/example/src/pages/inbox/InboxStyled.js +0 -220
  183. package/lib/example/src/pages/preferences/PreferencesCustom.js +0 -91
  184. package/lib/example/src/pages/preferences/PreferencesDefault.js +0 -17
  185. package/lib/example/src/pages/preferences/PreferencesDetail.js +0 -127
  186. package/lib/example/src/pages/preferences/PreferencesStyled.js +0 -110
  187. package/lib/package.json +0 -171
  188. package/lib/src/Broadcaster.js +0 -24
  189. package/lib/src/Modules.js +0 -26
  190. package/lib/src/client/BrandClient.js +0 -17
  191. package/lib/src/client/ClientModule.js +0 -14
  192. package/lib/src/client/CourierClient.js +0 -31
  193. package/lib/src/client/InboxClient.js +0 -99
  194. package/lib/src/client/PreferenceClient.js +0 -63
  195. package/lib/src/client/TokenClient.js +0 -27
  196. package/lib/src/client/TrackingClient.js +0 -17
  197. package/lib/src/index.js +0 -567
  198. package/lib/src/models/Android_CourierSheet.js +0 -1
  199. package/lib/src/models/CourierAuthenticationListener.js +0 -14
  200. package/lib/src/models/CourierBrand.js +0 -1
  201. package/lib/src/models/CourierButton.js +0 -1
  202. package/lib/src/models/CourierDevice.js +0 -1
  203. package/lib/src/models/CourierFont.js +0 -1
  204. package/lib/src/models/CourierInboxListener.js +0 -20
  205. package/lib/src/models/CourierInboxMessages.js +0 -1
  206. package/lib/src/models/CourierInboxTheme.js +0 -1
  207. package/lib/src/models/CourierInfoViewStyle.js +0 -1
  208. package/lib/src/models/CourierPaging.js +0 -1
  209. package/lib/src/models/CourierPreferencesTheme.js +0 -1
  210. package/lib/src/models/CourierPushListener.js +0 -14
  211. package/lib/src/models/CourierPushProvider.js +0 -8
  212. package/lib/src/models/CourierTrackingEvent.js +0 -8
  213. package/lib/src/models/CourierUserPreferences.js +0 -51
  214. package/lib/src/models/InboxAction.js +0 -1
  215. package/lib/src/models/InboxMessage.js +0 -1
  216. package/lib/src/models/InboxMessageFeed.js +0 -1
  217. package/lib/src/models/InboxMessageSet.js +0 -1
  218. package/lib/src/models/iOS_CourierCell.js +0 -1
  219. package/lib/src/models/iOS_CourierSheet.js +0 -1
  220. package/lib/src/utils.js +0 -27
  221. package/lib/src/views/CourierInboxView.js +0 -75
  222. package/lib/src/views/CourierPreferencesView.js +0 -33
package/src/Modules.tsx CHANGED
@@ -1,28 +1,38 @@
1
- import { NativeModules, Platform, UIManager, requireNativeComponent } from "react-native";
1
+ import {
2
+ NativeModules,
3
+ Platform,
4
+ UIManager,
5
+ requireNativeComponent,
6
+ } from 'react-native';
2
7
 
3
8
  export class Modules {
4
-
5
9
  static readonly LINKING_ERROR =
6
- `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
7
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
8
- '- You rebuilt the app after installing the package\n' +
9
- '- You are not using Expo Go\n';
10
+ `The package '@trycourier/courier-react-native' doesn't seem to be linked. Make sure: \n\n` +
11
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
12
+ '- You rebuilt the app after installing the package\n' +
13
+ '- You are not using Expo Go\n';
10
14
 
11
- static readonly Client = Modules.getNativeModule(NativeModules.CourierClientModule);
12
- static readonly Shared = Modules.getNativeModule(NativeModules.CourierSharedModule);
13
- static readonly System = Modules.getNativeModule(NativeModules.CourierSystemModule);
15
+ static readonly Client = Modules.getNativeModule(
16
+ NativeModules.CourierClientModule
17
+ );
18
+ static readonly Shared = Modules.getNativeModule(
19
+ NativeModules.CourierSharedModule
20
+ );
21
+ static readonly System = Modules.getNativeModule(
22
+ NativeModules.CourierSystemModule
23
+ );
14
24
 
15
25
  static getNativeModule<T>(nativeModule: T | undefined): T {
16
26
  return nativeModule
17
27
  ? nativeModule
18
- : new Proxy(
28
+ : (new Proxy(
19
29
  {},
20
30
  {
21
31
  get() {
22
32
  throw new Error(Modules.LINKING_ERROR);
23
33
  },
24
34
  }
25
- ) as T;
35
+ ) as T);
26
36
  }
27
37
 
28
38
  static getNativeComponent(componentName: string) {
@@ -32,5 +42,4 @@ export class Modules {
32
42
  throw new Error(Modules.LINKING_ERROR);
33
43
  };
34
44
  }
35
-
36
- }
45
+ }
@@ -1,8 +1,7 @@
1
- import { Modules } from "../Modules";
2
- import { CourierBrandResponse } from "..";
1
+ import { Modules } from '../Modules';
2
+ import { CourierBrandResponse } from '..';
3
3
 
4
4
  export class BrandClient {
5
-
6
5
  readonly clientId: string;
7
6
 
8
7
  constructor(clientId: string) {
@@ -15,9 +14,10 @@ export class BrandClient {
15
14
  * @param props.brandId - The ID of the brand to retrieve.
16
15
  * @returns A promise that resolves with the CourierBrandResponse containing brand information.
17
16
  */
18
- public async getBrand(props: { brandId: string }): Promise<CourierBrandResponse> {
17
+ public async getBrand(props: {
18
+ brandId: string;
19
+ }): Promise<CourierBrandResponse> {
19
20
  const json = await Modules.Client.getBrand(this.clientId, props.brandId);
20
21
  return JSON.parse(json);
21
22
  }
22
-
23
- }
23
+ }
@@ -1,15 +1,14 @@
1
- import { Modules } from "../Modules";
2
- import { CourierClientOptions } from "./CourierClient";
1
+ import { Modules } from '../Modules';
2
+ import { CourierClientOptions } from './CourierClient';
3
3
 
4
4
  export abstract class ClientModule {
5
-
6
5
  readonly clientId: string;
7
6
 
8
7
  // Constructor to create a low level CourierClient
9
8
  constructor(options: CourierClientOptions) {
10
9
  this.clientId = this.add(options);
11
10
  }
12
-
11
+
13
12
  private add(options: CourierClientOptions): string {
14
13
  return Modules.Client.addClient(options);
15
14
  }
@@ -17,5 +16,4 @@ export abstract class ClientModule {
17
16
  public remove(): string {
18
17
  return Modules.Client.removeClient(this.clientId);
19
18
  }
20
-
21
- }
19
+ }
@@ -1,9 +1,10 @@
1
- import { BrandClient } from "..";
2
- import { ClientModule } from "./ClientModule";
3
- import { InboxClient } from "./InboxClient";
4
- import { PreferenceClient } from "./PreferenceClient";
5
- import { TokenClient } from "./TokenClient";
6
- import { TrackingClient } from "./TrackingClient";
1
+ import { BrandClient } from '..';
2
+ import { ClientModule } from './ClientModule';
3
+ import { InboxClient } from './InboxClient';
4
+ import { PreferenceClient } from './PreferenceClient';
5
+ import { TokenClient } from './TokenClient';
6
+ import { TrackingClient } from './TrackingClient';
7
+ import { CourierApiUrls } from '../CourierApiUrls';
7
8
 
8
9
  export interface CourierClientOptions {
9
10
  userId: string;
@@ -12,10 +13,10 @@ export interface CourierClientOptions {
12
13
  clientKey?: string;
13
14
  connectionId?: string;
14
15
  tenantId?: string;
16
+ apiUrls?: CourierApiUrls;
15
17
  }
16
18
 
17
19
  export class CourierClient extends ClientModule {
18
-
19
20
  public readonly options: CourierClientOptions;
20
21
  public readonly tokens: TokenClient;
21
22
  public readonly brands: BrandClient;
@@ -23,8 +24,15 @@ export class CourierClient extends ClientModule {
23
24
  public readonly preferences: PreferenceClient;
24
25
  public readonly tracking: TrackingClient;
25
26
 
26
- constructor(props: { userId: string, jwt?: string, clientKey?: string, connectionId?: string, tenantId?: string, showLogs?: boolean }) {
27
-
27
+ constructor(props: {
28
+ userId: string;
29
+ jwt?: string;
30
+ clientKey?: string;
31
+ connectionId?: string;
32
+ tenantId?: string;
33
+ apiUrls?: CourierApiUrls;
34
+ showLogs?: boolean;
35
+ }) {
28
36
  const options = {
29
37
  userId: props.userId,
30
38
  showLogs: props.showLogs ?? __DEV__,
@@ -32,18 +40,17 @@ export class CourierClient extends ClientModule {
32
40
  clientKey: props.clientKey,
33
41
  connectionId: props.clientKey,
34
42
  tenantId: props.tenantId,
43
+ apiUrls: props.apiUrls ? { ...props.apiUrls } : undefined,
35
44
  };
36
45
 
37
46
  super(options);
38
47
 
39
- this.options = options
48
+ this.options = options;
40
49
 
41
50
  this.tokens = new TokenClient(this.clientId);
42
51
  this.brands = new BrandClient(this.clientId);
43
52
  this.inbox = new InboxClient(this.clientId);
44
53
  this.preferences = new PreferenceClient(this.clientId);
45
54
  this.tracking = new TrackingClient(this.clientId);
46
-
47
55
  }
48
-
49
- }
56
+ }
@@ -1,8 +1,10 @@
1
- import { Modules } from "../Modules";
2
- import { CourierGetInboxMessageResponse, CourierGetInboxMessagesResponse } from "../models/CourierInboxMessages";
1
+ import { Modules } from '../Modules';
2
+ import {
3
+ CourierGetInboxMessageResponse,
4
+ CourierGetInboxMessagesResponse,
5
+ } from '../models/CourierInboxMessages';
3
6
 
4
7
  export class InboxClient {
5
-
6
8
  readonly clientId: string;
7
9
 
8
10
  constructor(clientId: string) {
@@ -16,8 +18,15 @@ export class InboxClient {
16
18
  * @param props.startCursor - Optional. The cursor to start retrieving messages from.
17
19
  * @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the messages.
18
20
  */
19
- public async getMessages(props: { paginationLimit?: number, startCursor?: string }): Promise<CourierGetInboxMessagesResponse> {
20
- const json = await Modules.Client.getMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
21
+ public async getMessages(props: {
22
+ paginationLimit?: number;
23
+ startCursor?: string;
24
+ }): Promise<CourierGetInboxMessagesResponse> {
25
+ const json = await Modules.Client.getMessages(
26
+ this.clientId,
27
+ props.paginationLimit ?? 24,
28
+ props.startCursor
29
+ );
21
30
  return JSON.parse(json);
22
31
  }
23
32
 
@@ -28,8 +37,15 @@ export class InboxClient {
28
37
  * @param props.startCursor - Optional. The cursor to start retrieving messages from.
29
38
  * @returns A promise that resolves with the CourierGetInboxMessagesResponse containing the archived messages.
30
39
  */
31
- public async getArchivedMessages(props: { paginationLimit?: number, startCursor?: string }): Promise<CourierGetInboxMessagesResponse> {
32
- const json = await Modules.Client.getArchivedMessages(this.clientId, props.paginationLimit ?? 24, props.startCursor);
40
+ public async getArchivedMessages(props: {
41
+ paginationLimit?: number;
42
+ startCursor?: string;
43
+ }): Promise<CourierGetInboxMessagesResponse> {
44
+ const json = await Modules.Client.getArchivedMessages(
45
+ this.clientId,
46
+ props.paginationLimit ?? 24,
47
+ props.startCursor
48
+ );
33
49
  return JSON.parse(json);
34
50
  }
35
51
 
@@ -39,8 +55,13 @@ export class InboxClient {
39
55
  * @param props.messageId - The ID of the message to retrieve.
40
56
  * @returns A promise that resolves with the CourierGetInboxMessageResponse containing the message.
41
57
  */
42
- public async getMessageById(props: { messageId: String }): Promise<CourierGetInboxMessageResponse> {
43
- const json = await Modules.Client.getMessageById(this.clientId, props.messageId);
58
+ public async getMessageById(props: {
59
+ messageId: String;
60
+ }): Promise<CourierGetInboxMessageResponse> {
61
+ const json = await Modules.Client.getMessageById(
62
+ this.clientId,
63
+ props.messageId
64
+ );
44
65
  return JSON.parse(json);
45
66
  }
46
67
 
@@ -89,8 +110,15 @@ export class InboxClient {
89
110
  * @param props.trackingId - The tracking ID associated with the click event.
90
111
  * @returns A promise that resolves with a number indicating the operation result.
91
112
  */
92
- public async click(props: { messageId: String, trackingId: string }): Promise<number> {
93
- return await Modules.Client.clickMessage(this.clientId, props.messageId, props.trackingId);
113
+ public async click(props: {
114
+ messageId: String;
115
+ trackingId: string;
116
+ }): Promise<number> {
117
+ return await Modules.Client.clickMessage(
118
+ this.clientId,
119
+ props.messageId,
120
+ props.trackingId
121
+ );
94
122
  }
95
123
 
96
124
  /**
@@ -110,5 +138,4 @@ export class InboxClient {
110
138
  public async readAll(): Promise<number> {
111
139
  return await Modules.Client.readAllMessages(this.clientId);
112
140
  }
113
-
114
- }
141
+ }
@@ -1,8 +1,12 @@
1
- import { Modules } from "../Modules";
2
- import { CourierUserPreferences, CourierUserPreferencesChannel, CourierUserPreferencesStatus, CourierUserPreferencesTopic } from "../models/CourierUserPreferences";
1
+ import { Modules } from '../Modules';
2
+ import {
3
+ CourierUserPreferences,
4
+ CourierUserPreferencesChannel,
5
+ CourierUserPreferencesStatus,
6
+ CourierUserPreferencesTopic,
7
+ } from '../models/CourierUserPreferences';
3
8
 
4
9
  export class PreferenceClient {
5
-
6
10
  readonly clientId: string;
7
11
 
8
12
  constructor(clientId: string) {
@@ -15,26 +19,31 @@ export class PreferenceClient {
15
19
  * @param props.paginationCursor - Optional cursor for pagination.
16
20
  * @returns A promise that resolves with CourierUserPreferences containing user preference items and paging information.
17
21
  */
18
- public async getUserPreferences(props?: { paginationCursor?: string }): Promise<CourierUserPreferences> {
22
+ public async getUserPreferences(props?: {
23
+ paginationCursor?: string;
24
+ }): Promise<CourierUserPreferences> {
25
+ const json = await Modules.Client.getUserPreferences(
26
+ this.clientId,
27
+ props?.paginationCursor
28
+ );
19
29
 
20
- const json = await Modules.Client.getUserPreferences(this.clientId, props?.paginationCursor);
21
-
22
30
  const rawData = JSON.parse(json);
23
-
31
+
24
32
  return {
25
33
  items: rawData.items.map((item: any) => ({
26
34
  defaultStatus: item.default_status as CourierUserPreferencesStatus,
27
35
  hasCustomRouting: item.has_custom_routing,
28
- customRouting: item.custom_routing.map((channel: string) => channel as CourierUserPreferencesChannel),
36
+ customRouting: item.custom_routing.map(
37
+ (channel: string) => channel as CourierUserPreferencesChannel
38
+ ),
29
39
  status: item.status as CourierUserPreferencesStatus,
30
40
  topicId: item.topic_id,
31
41
  topicName: item.topic_name,
32
42
  sectionName: item.section_name,
33
- sectionId: item.section_id
43
+ sectionId: item.section_id,
34
44
  })),
35
- paging: rawData.paging
45
+ paging: rawData.paging,
36
46
  };
37
-
38
47
  }
39
48
 
40
49
  /**
@@ -43,21 +52,28 @@ export class PreferenceClient {
43
52
  * @param props.topicId - The ID of the topic to retrieve preferences for.
44
53
  * @returns A promise that resolves with CourierUserPreferencesTopic containing the topic preference details.
45
54
  */
46
- public async getUserPreferenceTopic(props: { topicId: string }): Promise<CourierUserPreferencesTopic> {
47
- const json = await Modules.Client.getUserPreferenceTopic(this.clientId, props.topicId);
55
+ public async getUserPreferenceTopic(props: {
56
+ topicId: string;
57
+ }): Promise<CourierUserPreferencesTopic> {
58
+ const json = await Modules.Client.getUserPreferenceTopic(
59
+ this.clientId,
60
+ props.topicId
61
+ );
48
62
  const rawData = JSON.parse(json);
49
-
63
+
50
64
  const convertedTopic: CourierUserPreferencesTopic = {
51
65
  defaultStatus: rawData.default_status as CourierUserPreferencesStatus,
52
66
  hasCustomRouting: rawData.has_custom_routing,
53
- customRouting: rawData.custom_routing.map((channel: string) => channel as CourierUserPreferencesChannel),
67
+ customRouting: rawData.custom_routing.map(
68
+ (channel: string) => channel as CourierUserPreferencesChannel
69
+ ),
54
70
  status: rawData.status as CourierUserPreferencesStatus,
55
71
  topicId: rawData.topic_id,
56
72
  topicName: rawData.topic_name,
57
73
  sectionName: rawData.section_name,
58
- sectionId: rawData.section_id
74
+ sectionId: rawData.section_id,
59
75
  };
60
-
76
+
61
77
  return convertedTopic;
62
78
  }
63
79
 
@@ -70,8 +86,18 @@ export class PreferenceClient {
70
86
  * @param props.customRouting - Array of custom routing channels.
71
87
  * @returns A promise that resolves when the update is complete.
72
88
  */
73
- public async putUserPreferenceTopic(props: { topicId: string, status: CourierUserPreferencesStatus, hasCustomRouting: boolean, customRouting: CourierUserPreferencesChannel[] }): Promise<void> {
74
- await Modules.Client.putUserPreferenceTopic(this.clientId, props.topicId, props.status, props.hasCustomRouting, props.customRouting);
89
+ public async putUserPreferenceTopic(props: {
90
+ topicId: string;
91
+ status: CourierUserPreferencesStatus;
92
+ hasCustomRouting: boolean;
93
+ customRouting: CourierUserPreferencesChannel[];
94
+ }): Promise<void> {
95
+ await Modules.Client.putUserPreferenceTopic(
96
+ this.clientId,
97
+ props.topicId,
98
+ props.status,
99
+ props.hasCustomRouting,
100
+ props.customRouting
101
+ );
75
102
  }
76
-
77
- }
103
+ }
@@ -1,8 +1,7 @@
1
- import { CourierDevice } from "..";
2
- import { Modules } from "../Modules";
1
+ import { CourierDevice } from '..';
2
+ import { Modules } from '../Modules';
3
3
 
4
4
  export class TokenClient {
5
-
6
5
  readonly clientId: string;
7
6
 
8
7
  constructor(clientId: string) {
@@ -17,8 +16,17 @@ export class TokenClient {
17
16
  * @param props.device - Optional device information.
18
17
  * @returns A promise that resolves when the token is successfully stored.
19
18
  */
20
- public async putUserToken(props: { token: string, provider: string, device?: CourierDevice }): Promise<void> {
21
- await Modules.Client.putUserToken(this.clientId, props.token, props.provider, props.device);
19
+ public async putUserToken(props: {
20
+ token: string;
21
+ provider: string;
22
+ device?: CourierDevice;
23
+ }): Promise<void> {
24
+ await Modules.Client.putUserToken(
25
+ this.clientId,
26
+ props.token,
27
+ props.provider,
28
+ props.device
29
+ );
22
30
  }
23
31
 
24
32
  /**
@@ -30,5 +38,4 @@ export class TokenClient {
30
38
  public async deleteUserToken(props: { token: string }): Promise<void> {
31
39
  await Modules.Client.deleteUserToken(this.clientId, props.token);
32
40
  }
33
-
34
- }
41
+ }
@@ -1,8 +1,7 @@
1
- import { CourierTrackingEvent } from "..";
2
- import { Modules } from "../Modules";
1
+ import { CourierTrackingEvent } from '..';
2
+ import { Modules } from '../Modules';
3
3
 
4
4
  export class TrackingClient {
5
-
6
5
  readonly clientId: string;
7
6
 
8
7
  constructor(clientId: string) {
@@ -16,8 +15,10 @@ export class TrackingClient {
16
15
  * @param props.event - The CourierTrackingEvent associated with the URL.
17
16
  * @returns A promise that resolves when the tracking URL is successfully posted.
18
17
  */
19
- public async postTrackingUrl(props: { url: string, event: CourierTrackingEvent }): Promise<void> {
18
+ public async postTrackingUrl(props: {
19
+ url: string;
20
+ event: CourierTrackingEvent;
21
+ }): Promise<void> {
20
22
  await Modules.Client.postTrackingUrl(this.clientId, props.url, props.event);
21
23
  }
22
-
23
- }
24
+ }