@compassdigital/sdk.typescript 4.132.0 → 4.134.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.
@@ -35,6 +35,14 @@ export interface PushNotificationBody {
35
35
  data?: Record<string, any>;
36
36
  }
37
37
 
38
+ export interface BatchPushNotificationBody {
39
+ title: string;
40
+ text: string;
41
+ // Recipients of the notification. Example: user ids
42
+ targets: string[];
43
+ data?: Record<string, any>;
44
+ }
45
+
38
46
  export interface NotificationStatus {
39
47
  read?: boolean;
40
48
  released?: boolean;
@@ -126,6 +134,16 @@ export interface PostNotificationDevicePushRequest extends BaseRequest {
126
134
  body: PostNotificationDevicePushBody;
127
135
  }
128
136
 
137
+ // POST /notification/batch/device/push - Send a push notification to many user devices
138
+
139
+ export type PostNotificationBatchDevicePushBody = BatchPushNotificationBody;
140
+
141
+ export type PostNotificationBatchDevicePushResponse = Success;
142
+
143
+ export interface PostNotificationBatchDevicePushRequest extends BaseRequest {
144
+ body: PostNotificationBatchDevicePushBody;
145
+ }
146
+
129
147
  // GET /notification/swagger.json - Get a swagger for notification service
130
148
 
131
149
  export interface GetNotificationSwaggerQuery {
@@ -31,7 +31,7 @@ describe('ServiceClient', () => {
31
31
  url: 'https://dev.api.compassdigital.org/task/some_id',
32
32
  method: 'GET',
33
33
  headers: {
34
- 'User-Agent': 'CDL/ServiceClient',
34
+ 'user-agent': 'CDL/ServiceClient',
35
35
  },
36
36
  });
37
37
  });
@@ -42,7 +42,7 @@ describe('ServiceClient', () => {
42
42
  const api = new ServiceClient({ stage: 'dev', intercept });
43
43
  await api.get_task('', { token });
44
44
  const req = intercept.mock.calls[0][0];
45
- expect(req.headers).toHaveProperty('Authorization', `Bearer ${token}`);
45
+ expect(req.headers).toHaveProperty('authorization', `Bearer ${token}`);
46
46
  });
47
47
 
48
48
  test('headers get merged', async () => {
@@ -63,7 +63,7 @@ describe('ServiceClient', () => {
63
63
  });
64
64
  const req = intercept.mock.calls[0][0];
65
65
  expect(req.headers).toEqual({
66
- 'User-Agent': 'CDL/ServiceClient',
66
+ 'user-agent': 'CDL/ServiceClient',
67
67
  a: 'a from constructor',
68
68
  b: 'b from method',
69
69
  c: 'c from method',
@@ -79,11 +79,26 @@ describe('ServiceClient', () => {
79
79
  await api.post_discount({ name: 'test', createdBy: 'test' }, {});
80
80
  const req = intercept.mock.calls[0][0];
81
81
  expect(req.headers).toEqual({
82
- 'User-Agent': 'CDL/ServiceClient',
83
- 'Content-Type': 'application/json',
82
+ 'user-agent': 'CDL/ServiceClient',
83
+ 'content-type': 'application/json',
84
84
  });
85
85
  });
86
86
 
87
+ test('user specified headers take priority', async () => {
88
+ const intercept = jest.fn(interceptor(200));
89
+ const api = new ServiceClient({
90
+ stage: 'dev',
91
+ token: 'token',
92
+ intercept,
93
+ });
94
+ await api.post_discount(
95
+ { name: 'test', createdBy: 'test' },
96
+ { headers: { Authorization: 'user-specified' } },
97
+ );
98
+ const req = intercept.mock.calls[0][0];
99
+ expect(req.headers).toMatchObject({ authorization: 'user-specified' });
100
+ });
101
+
87
102
  test('client retries on bad status codes', async () => {
88
103
  const intercept = jest.fn(async () => {
89
104
  if (intercept.mock.calls.length === 3) {