@trycourier/courier-react-native 5.6.17 → 5.7.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.
- package/README.md +66 -135
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +1 -0
- package/android/src/main/java/com/courierreactnative/CourierInboxViewManager.kt +2 -0
- package/android/src/main/java/com/courierreactnative/CourierPreferencesViewManager.kt +2 -0
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +3 -0
- package/android/src/main/java/com/courierreactnative/Utils.kt +11 -1
- package/courier-react-native.podspec +1 -1
- package/ios/CourierClientModule.swift +1 -0
- package/ios/CourierInboxReactNativeManager.swift +8 -0
- package/ios/CourierPreferencesReactNativeManager.swift +8 -0
- package/ios/CourierReactNativeDelegate.m +1 -1
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +1 -0
- package/ios/CourierSharedModule.swift +10 -3
- package/ios/Utils.swift +10 -0
- package/lib/commonjs/Broadcaster.js +5 -5
- package/lib/commonjs/Broadcaster.js.map +1 -1
- package/lib/commonjs/CourierApiUrls.js +29 -0
- package/lib/commonjs/CourierApiUrls.js.map +1 -0
- package/lib/commonjs/Modules.js.map +1 -1
- package/lib/commonjs/client/BrandClient.js.map +1 -1
- package/lib/commonjs/client/ClientModule.js.map +1 -1
- package/lib/commonjs/client/CourierClient.js +4 -1
- package/lib/commonjs/client/CourierClient.js.map +1 -1
- package/lib/commonjs/client/InboxClient.js.map +1 -1
- package/lib/commonjs/client/PreferenceClient.js.map +1 -1
- package/lib/commonjs/client/TokenClient.js.map +1 -1
- package/lib/commonjs/client/TrackingClient.js.map +1 -1
- package/lib/commonjs/index.js +22 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/commonjs/models/CourierPushListener.js.map +1 -1
- package/lib/commonjs/models/CourierUserPreferences.js +13 -13
- package/lib/commonjs/models/CourierUserPreferences.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/views/CourierInboxView.js +13 -13
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/commonjs/views/CourierPreferencesView.js +4 -4
- package/lib/commonjs/views/CourierPreferencesView.js.map +1 -1
- package/lib/module/Broadcaster.js +7 -7
- package/lib/module/Broadcaster.js.map +1 -1
- package/lib/module/CourierApiUrls.js +20 -0
- package/lib/module/CourierApiUrls.js.map +1 -0
- package/lib/module/Modules.js +1 -1
- package/lib/module/Modules.js.map +1 -1
- package/lib/module/client/BrandClient.js +1 -1
- package/lib/module/client/BrandClient.js.map +1 -1
- package/lib/module/client/ClientModule.js +1 -1
- package/lib/module/client/ClientModule.js.map +1 -1
- package/lib/module/client/CourierClient.js +10 -7
- package/lib/module/client/CourierClient.js.map +1 -1
- package/lib/module/client/InboxClient.js +1 -1
- package/lib/module/client/InboxClient.js.map +1 -1
- package/lib/module/client/PreferenceClient.js +1 -1
- package/lib/module/client/PreferenceClient.js.map +1 -1
- package/lib/module/client/TokenClient.js +1 -1
- package/lib/module/client/TokenClient.js.map +1 -1
- package/lib/module/client/TrackingClient.js +1 -1
- package/lib/module/client/TrackingClient.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierAuthenticationListener.js +1 -1
- package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -1
- package/lib/module/models/CourierPushListener.js.map +1 -1
- package/lib/module/models/CourierUserPreferences.js +13 -13
- package/lib/module/models/CourierUserPreferences.js.map +1 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js +1 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/views/CourierInboxView.js +18 -18
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/module/views/CourierPreferencesView.js +7 -7
- package/lib/module/views/CourierPreferencesView.js.map +1 -1
- package/lib/typescript/src/Broadcaster.d.ts +7 -7
- package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
- package/lib/typescript/src/CourierApiUrls.d.ts +11 -0
- package/lib/typescript/src/CourierApiUrls.d.ts.map +1 -0
- package/lib/typescript/src/Modules.d.ts.map +1 -1
- package/lib/typescript/src/client/BrandClient.d.ts +1 -1
- package/lib/typescript/src/client/BrandClient.d.ts.map +1 -1
- package/lib/typescript/src/client/ClientModule.d.ts +1 -1
- package/lib/typescript/src/client/ClientModule.d.ts.map +1 -1
- package/lib/typescript/src/client/CourierClient.d.ts +9 -6
- package/lib/typescript/src/client/CourierClient.d.ts.map +1 -1
- package/lib/typescript/src/client/InboxClient.d.ts +1 -1
- package/lib/typescript/src/client/InboxClient.d.ts.map +1 -1
- package/lib/typescript/src/client/PreferenceClient.d.ts +1 -1
- package/lib/typescript/src/client/PreferenceClient.d.ts.map +1 -1
- package/lib/typescript/src/client/TokenClient.d.ts +1 -1
- package/lib/typescript/src/client/TokenClient.d.ts.map +1 -1
- package/lib/typescript/src/client/TrackingClient.d.ts +1 -1
- package/lib/typescript/src/client/TrackingClient.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/Android_CourierSheet.d.ts +1 -1
- package/lib/typescript/src/models/Android_CourierSheet.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierBrand.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierButton.d.ts +1 -1
- package/lib/typescript/src/models/CourierButton.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierFont.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierInboxMessages.d.ts +1 -1
- package/lib/typescript/src/models/CourierInboxTheme.d.ts +4 -3
- package/lib/typescript/src/models/CourierInboxTheme.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts +2 -2
- package/lib/typescript/src/models/CourierInfoViewStyle.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts +7 -6
- package/lib/typescript/src/models/CourierPreferencesTheme.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierPushListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierUserPreferences.d.ts +1 -1
- package/lib/typescript/src/models/CourierUserPreferences.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageSet.d.ts +1 -1
- package/lib/typescript/src/models/iOS_CourierCell.d.ts.map +1 -1
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts +1 -1
- package/lib/typescript/src/models/iOS_CourierSheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/views/CourierInboxView.d.ts +5 -5
- package/lib/typescript/src/views/CourierInboxView.d.ts.map +1 -1
- package/lib/typescript/src/views/CourierPreferencesView.d.ts +3 -3
- package/lib/typescript/src/views/CourierPreferencesView.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/Broadcaster.tsx +21 -15
- package/src/CourierApiUrls.tsx +30 -0
- package/src/Modules.tsx +22 -13
- package/src/client/BrandClient.tsx +6 -6
- package/src/client/ClientModule.tsx +4 -6
- package/src/client/CourierClient.tsx +20 -13
- package/src/client/InboxClient.tsx +40 -13
- package/src/client/PreferenceClient.tsx +47 -21
- package/src/client/TokenClient.tsx +14 -7
- package/src/client/TrackingClient.tsx +7 -6
- package/src/index.tsx +208 -115
- package/src/models/Android_CourierSheet.tsx +5 -5
- package/src/models/CourierAuthenticationListener.tsx +5 -9
- package/src/models/CourierBrand.tsx +6 -6
- package/src/models/CourierButton.tsx +5 -5
- package/src/models/CourierDevice.tsx +1 -1
- package/src/models/CourierFont.tsx +4 -4
- package/src/models/CourierInboxListener.tsx +3 -3
- package/src/models/CourierInboxMessages.tsx +2 -2
- package/src/models/CourierInboxTheme.tsx +56 -42
- package/src/models/CourierInfoViewStyle.tsx +5 -5
- package/src/models/CourierPaging.tsx +1 -1
- package/src/models/CourierPreferencesTheme.tsx +33 -27
- package/src/models/CourierPushListener.tsx +9 -7
- package/src/models/CourierPushProvider.tsx +1 -1
- package/src/models/CourierTrackingEvent.tsx +6 -6
- package/src/models/CourierUserPreferences.tsx +32 -28
- package/src/models/InboxAction.tsx +2 -6
- package/src/models/InboxMessage.tsx +4 -5
- package/src/models/InboxMessageEvent.tsx +7 -1
- package/src/models/InboxMessageFeed.tsx +1 -1
- package/src/models/InboxMessageSet.tsx +1 -1
- package/src/models/iOS_CourierCell.tsx +10 -5
- package/src/models/iOS_CourierSheet.tsx +4 -4
- package/src/utils.tsx +4 -7
- package/src/views/CourierInboxView.tsx +79 -71
- package/src/views/CourierPreferencesView.tsx +34 -35
- package/lib/example/src/App.js +0 -11
- package/lib/example/src/Emitter.js +0 -11
- package/lib/example/src/Env.js +0 -6
- package/lib/example/src/Home.js +0 -67
- package/lib/example/src/Poke.js +0 -75
- package/lib/example/src/Tabs.js +0 -36
- package/lib/example/src/Utils.js +0 -71
- package/lib/example/src/pages/Auth.js +0 -224
- package/lib/example/src/pages/Inbox.js +0 -38
- package/lib/example/src/pages/Preferences.js +0 -13
- package/lib/example/src/pages/PreferencesStack.js +0 -11
- package/lib/example/src/pages/Push.js +0 -93
- package/lib/example/src/pages/Styles.js +0 -26
- package/lib/example/src/pages/Tests.js +0 -1068
- package/lib/example/src/pages/inbox/InboxCustom.js +0 -141
- package/lib/example/src/pages/inbox/InboxDefault.js +0 -22
- package/lib/example/src/pages/inbox/InboxStyled.js +0 -220
- package/lib/example/src/pages/preferences/PreferencesCustom.js +0 -91
- package/lib/example/src/pages/preferences/PreferencesDefault.js +0 -17
- package/lib/example/src/pages/preferences/PreferencesDetail.js +0 -127
- package/lib/example/src/pages/preferences/PreferencesStyled.js +0 -110
- package/lib/package.json +0 -171
- package/lib/src/Broadcaster.js +0 -24
- package/lib/src/Modules.js +0 -26
- package/lib/src/client/BrandClient.js +0 -17
- package/lib/src/client/ClientModule.js +0 -14
- package/lib/src/client/CourierClient.js +0 -31
- package/lib/src/client/InboxClient.js +0 -99
- package/lib/src/client/PreferenceClient.js +0 -63
- package/lib/src/client/TokenClient.js +0 -27
- package/lib/src/client/TrackingClient.js +0 -17
- package/lib/src/index.js +0 -567
- package/lib/src/models/Android_CourierSheet.js +0 -1
- package/lib/src/models/CourierAuthenticationListener.js +0 -14
- package/lib/src/models/CourierBrand.js +0 -1
- package/lib/src/models/CourierButton.js +0 -1
- package/lib/src/models/CourierDevice.js +0 -1
- package/lib/src/models/CourierFont.js +0 -1
- package/lib/src/models/CourierInboxListener.js +0 -20
- package/lib/src/models/CourierInboxMessages.js +0 -1
- package/lib/src/models/CourierInboxTheme.js +0 -1
- package/lib/src/models/CourierInfoViewStyle.js +0 -1
- package/lib/src/models/CourierPaging.js +0 -1
- package/lib/src/models/CourierPreferencesTheme.js +0 -1
- package/lib/src/models/CourierPushListener.js +0 -14
- package/lib/src/models/CourierPushProvider.js +0 -8
- package/lib/src/models/CourierTrackingEvent.js +0 -8
- package/lib/src/models/CourierUserPreferences.js +0 -51
- package/lib/src/models/InboxAction.js +0 -1
- package/lib/src/models/InboxMessage.js +0 -1
- package/lib/src/models/InboxMessageFeed.js +0 -1
- package/lib/src/models/InboxMessageSet.js +0 -1
- package/lib/src/models/iOS_CourierCell.js +0 -1
- package/lib/src/models/iOS_CourierSheet.js +0 -1
- package/lib/src/utils.js +0 -27
- package/lib/src/views/CourierInboxView.js +0 -75
- package/lib/src/views/CourierPreferencesView.js +0 -33
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface CourierApiUrls {
|
|
2
|
+
rest: string;
|
|
3
|
+
graphql: string;
|
|
4
|
+
inboxGraphql: string;
|
|
5
|
+
inboxWebSocket: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type CourierApiRegion = 'us' | 'eu';
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_COURIER_API_URLS: CourierApiUrls = {
|
|
11
|
+
rest: 'https://api.courier.com',
|
|
12
|
+
graphql: 'https://api.courier.com/client/q',
|
|
13
|
+
inboxGraphql: 'https://inbox.courier.io/q',
|
|
14
|
+
inboxWebSocket: 'wss://realtime.courier.io',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const EU_COURIER_API_URLS: CourierApiUrls = {
|
|
18
|
+
rest: 'https://api.eu.courier.com',
|
|
19
|
+
graphql: 'https://api.eu.courier.com/client/q',
|
|
20
|
+
inboxGraphql: 'https://inbox.eu.courier.io/q',
|
|
21
|
+
inboxWebSocket: 'wss://realtime.eu.courier.io',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export function getCourierApiUrlsForRegion(
|
|
25
|
+
region: CourierApiRegion
|
|
26
|
+
): CourierApiUrls {
|
|
27
|
+
return region === 'eu'
|
|
28
|
+
? { ...EU_COURIER_API_URLS }
|
|
29
|
+
: { ...DEFAULT_COURIER_API_URLS };
|
|
30
|
+
}
|
package/src/Modules.tsx
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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(
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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: {
|
|
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
|
|
2
|
-
import { CourierClientOptions } from
|
|
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
|
|
3
|
-
import { InboxClient } from
|
|
4
|
-
import { PreferenceClient } from
|
|
5
|
-
import { TokenClient } from
|
|
6
|
-
import { TrackingClient } from
|
|
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: {
|
|
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
|
|
2
|
-
import {
|
|
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: {
|
|
20
|
-
|
|
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: {
|
|
32
|
-
|
|
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: {
|
|
43
|
-
|
|
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: {
|
|
93
|
-
|
|
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
|
|
2
|
-
import {
|
|
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?: {
|
|
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(
|
|
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: {
|
|
47
|
-
|
|
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(
|
|
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: {
|
|
74
|
-
|
|
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
|
|
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: {
|
|
21
|
-
|
|
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
|
|
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: {
|
|
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
|
+
}
|