@novu/api 0.1.0 → 0.1.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 (67) hide show
  1. package/FUNCTIONS.md +15 -8
  2. package/README.md +161 -73
  3. package/docs/sdks/credentials/README.md +44 -0
  4. package/docs/sdks/messages/README.md +8 -2
  5. package/docs/sdks/notifications/README.md +2 -32
  6. package/docs/sdks/novu/README.md +277 -47
  7. package/docs/sdks/novumessages/README.md +4 -4
  8. package/docs/sdks/novunotifications/README.md +4 -2
  9. package/docs/sdks/preferences/README.md +4 -4
  10. package/docs/sdks/properties/README.md +2 -2
  11. package/docs/sdks/subscribers/README.md +2 -4
  12. package/funcs/create.d.ts +9 -0
  13. package/funcs/create.d.ts.map +1 -0
  14. package/funcs/create.js +110 -0
  15. package/funcs/create.js.map +1 -0
  16. package/funcs/supportControllerFetchUserOrganizations.d.ts +10 -0
  17. package/funcs/supportControllerFetchUserOrganizations.d.ts.map +1 -0
  18. package/funcs/supportControllerFetchUserOrganizations.js +111 -0
  19. package/funcs/supportControllerFetchUserOrganizations.js.map +1 -0
  20. package/jsr.json +1 -1
  21. package/lib/config.d.ts +3 -3
  22. package/lib/config.js +3 -3
  23. package/lib/schemas.d.ts +1 -1
  24. package/lib/schemas.d.ts.map +1 -1
  25. package/lib/schemas.js +4 -1
  26. package/lib/schemas.js.map +1 -1
  27. package/models/components/createsupportthreaddto.d.ts +29 -0
  28. package/models/components/createsupportthreaddto.d.ts.map +1 -0
  29. package/models/components/createsupportthreaddto.js +59 -0
  30. package/models/components/createsupportthreaddto.js.map +1 -0
  31. package/models/components/index.d.ts +2 -0
  32. package/models/components/index.d.ts.map +1 -1
  33. package/models/components/index.js +2 -0
  34. package/models/components/index.js.map +1 -1
  35. package/models/components/plaincardrequestdto.d.ts +100 -0
  36. package/models/components/plaincardrequestdto.d.ts.map +1 -0
  37. package/models/components/plaincardrequestdto.js +139 -0
  38. package/models/components/plaincardrequestdto.js.map +1 -0
  39. package/models/operations/index.d.ts +2 -0
  40. package/models/operations/index.d.ts.map +1 -1
  41. package/models/operations/index.js +2 -0
  42. package/models/operations/index.js.map +1 -1
  43. package/models/operations/supportcontrollercreatethread.d.ts +35 -0
  44. package/models/operations/supportcontrollercreatethread.d.ts.map +1 -0
  45. package/models/operations/supportcontrollercreatethread.js +73 -0
  46. package/models/operations/supportcontrollercreatethread.js.map +1 -0
  47. package/models/operations/supportcontrollerfetchuserorganizations.d.ts +56 -0
  48. package/models/operations/supportcontrollerfetchuserorganizations.d.ts.map +1 -0
  49. package/models/operations/supportcontrollerfetchuserorganizations.js +96 -0
  50. package/models/operations/supportcontrollerfetchuserorganizations.js.map +1 -0
  51. package/package.json +5 -1
  52. package/sdk/sdk.d.ts +8 -0
  53. package/sdk/sdk.d.ts.map +1 -1
  54. package/sdk/sdk.js +14 -0
  55. package/sdk/sdk.js.map +1 -1
  56. package/sources/json-development.json +116 -0
  57. package/src/funcs/create.ts +148 -0
  58. package/src/funcs/supportControllerFetchUserOrganizations.ts +150 -0
  59. package/src/lib/config.ts +3 -3
  60. package/src/lib/schemas.ts +5 -0
  61. package/src/models/components/createsupportthreaddto.ts +66 -0
  62. package/src/models/components/index.ts +2 -0
  63. package/src/models/components/plaincardrequestdto.ts +223 -0
  64. package/src/models/operations/index.ts +2 -0
  65. package/src/models/operations/supportcontrollercreatethread.ts +90 -0
  66. package/src/models/operations/supportcontrollerfetchuserorganizations.ts +163 -0
  67. package/src/sdk/sdk.ts +34 -0
@@ -13,6 +13,8 @@ Novu Documentation
13
13
  * [triggerBulk](#triggerbulk) - Bulk trigger event
14
14
  * [triggerBroadcast](#triggerbroadcast) - Broadcast event to all
15
15
  * [cancel](#cancel) - Cancel triggered event
16
+ * [supportControllerFetchUserOrganizations](#supportcontrollerfetchuserorganizations)
17
+ * [create](#create)
16
18
 
17
19
  ## trigger
18
20
 
@@ -34,16 +36,23 @@ const novu = new Novu({
34
36
  async function run() {
35
37
  const result = await novu.trigger({
36
38
  name: "workflow_identifier",
37
- to: [
38
- {
39
- topicKey: "<value>",
40
- type: "Topic",
39
+ payload: {
40
+ "comment_id": "string",
41
+ "post": {
42
+ "text": "string",
41
43
  },
42
- {
43
- topicKey: "<value>",
44
- type: "Topic",
44
+ },
45
+ bridgeUrl: "https://example.com/bridge",
46
+ overrides: {
47
+ "fcm": {
48
+ "data": {
49
+ "key": "value",
50
+ },
45
51
  },
46
- ],
52
+ },
53
+ to: {
54
+ subscriberId: "<id>",
55
+ },
47
56
  });
48
57
 
49
58
  // Handle the result
@@ -70,16 +79,23 @@ const novu = new NovuCore({
70
79
  async function run() {
71
80
  const res = await trigger(novu, {
72
81
  name: "workflow_identifier",
73
- to: [
74
- {
75
- topicKey: "<value>",
76
- type: "Topic",
82
+ payload: {
83
+ "comment_id": "string",
84
+ "post": {
85
+ "text": "string",
77
86
  },
78
- {
79
- topicKey: "<value>",
80
- type: "Topic",
87
+ },
88
+ bridgeUrl: "https://example.com/bridge",
89
+ overrides: {
90
+ "fcm": {
91
+ "data": {
92
+ "key": "value",
93
+ },
81
94
  },
82
- ],
95
+ },
96
+ to: {
97
+ subscriberId: "<id>",
98
+ },
83
99
  });
84
100
 
85
101
  if (!res.ok) {
@@ -140,33 +156,66 @@ async function run() {
140
156
  events: [
141
157
  {
142
158
  name: "workflow_identifier",
143
- to: [
144
- {
145
- topicKey: "<value>",
146
- type: "Topic",
159
+ payload: {
160
+ "comment_id": "string",
161
+ "post": {
162
+ "text": "string",
147
163
  },
148
- {
149
- subscriberId: "<id>",
164
+ },
165
+ bridgeUrl: "https://example.com/bridge",
166
+ overrides: {
167
+ "fcm": {
168
+ "data": {
169
+ "key": "value",
170
+ },
150
171
  },
151
- ],
172
+ },
173
+ to: {
174
+ subscriberId: "<id>",
175
+ },
152
176
  },
153
177
  {
154
178
  name: "workflow_identifier",
179
+ payload: {
180
+ "comment_id": "string",
181
+ "post": {
182
+ "text": "string",
183
+ },
184
+ },
185
+ bridgeUrl: "https://example.com/bridge",
186
+ overrides: {
187
+ "fcm": {
188
+ "data": {
189
+ "key": "value",
190
+ },
191
+ },
192
+ },
155
193
  to: [
156
-
194
+ {
195
+ topicKey: "<value>",
196
+ type: "Subscriber",
197
+ },
157
198
  ],
158
199
  },
159
200
  {
160
201
  name: "workflow_identifier",
161
- to: [
162
- {
163
- topicKey: "<value>",
164
- type: "Topic",
202
+ payload: {
203
+ "comment_id": "string",
204
+ "post": {
205
+ "text": "string",
165
206
  },
166
- {
167
- topicKey: "<value>",
168
- type: "Topic",
207
+ },
208
+ bridgeUrl: "https://example.com/bridge",
209
+ overrides: {
210
+ "fcm": {
211
+ "data": {
212
+ "key": "value",
213
+ },
169
214
  },
215
+ },
216
+ to: [
217
+ "SUBSCRIBER_ID",
218
+ "SUBSCRIBER_ID",
170
219
  ],
171
220
  },
172
221
  ],
@@ -198,33 +247,66 @@ async function run() {
198
247
  events: [
199
248
  {
200
249
  name: "workflow_identifier",
201
- to: [
202
- {
203
- topicKey: "<value>",
204
- type: "Topic",
250
+ payload: {
251
+ "comment_id": "string",
252
+ "post": {
253
+ "text": "string",
205
254
  },
206
- {
207
- subscriberId: "<id>",
255
+ },
256
+ bridgeUrl: "https://example.com/bridge",
257
+ overrides: {
258
+ "fcm": {
259
+ "data": {
260
+ "key": "value",
261
+ },
208
262
  },
209
- ],
263
+ },
264
+ to: {
265
+ subscriberId: "<id>",
266
+ },
210
267
  },
211
268
  {
212
269
  name: "workflow_identifier",
270
+ payload: {
271
+ "comment_id": "string",
272
+ "post": {
273
+ "text": "string",
274
+ },
275
+ },
276
+ bridgeUrl: "https://example.com/bridge",
277
+ overrides: {
278
+ "fcm": {
279
+ "data": {
280
+ "key": "value",
281
+ },
282
+ },
283
+ },
213
284
  to: [
214
-
285
+ {
286
+ topicKey: "<value>",
287
+ type: "Subscriber",
288
+ },
215
289
  ],
216
290
  },
217
291
  {
218
292
  name: "workflow_identifier",
219
- to: [
220
- {
221
- topicKey: "<value>",
222
- type: "Topic",
293
+ payload: {
294
+ "comment_id": "string",
295
+ "post": {
296
+ "text": "string",
223
297
  },
224
- {
225
- topicKey: "<value>",
226
- type: "Topic",
298
+ },
299
+ bridgeUrl: "https://example.com/bridge",
300
+ overrides: {
301
+ "fcm": {
302
+ "data": {
303
+ "key": "value",
304
+ },
227
305
  },
306
+ },
307
+ to: [
308
+ "SUBSCRIBER_ID",
309
+ "SUBSCRIBER_ID",
228
310
  ],
229
311
  },
230
312
  ],
@@ -439,4 +521,152 @@ run();
439
521
  | errors.ErrorDto | 414 | application/json |
440
522
  | errors.ValidationErrorDto | 422 | application/json |
441
523
  | errors.ErrorDto | 500 | application/json |
442
- | errors.SDKError | 4XX, 5XX | \*/\* |
524
+ | errors.SDKError | 4XX, 5XX | \*/\* |
525
+
526
+ ## supportControllerFetchUserOrganizations
527
+
528
+ ### Example Usage
529
+
530
+ ```typescript
531
+ import { Novu } from "@novu/api";
532
+
533
+ const novu = new Novu({
534
+ apiKey: "<YOUR_API_KEY_HERE>",
535
+ });
536
+
537
+ async function run() {
538
+ const result = await novu.supportControllerFetchUserOrganizations({
539
+ timestamp: "<value>",
540
+ });
541
+
542
+ // Handle the result
543
+ console.log(result);
544
+ }
545
+
546
+ run();
547
+ ```
548
+
549
+ ### Standalone function
550
+
551
+ The standalone function version of this method:
552
+
553
+ ```typescript
554
+ import { NovuCore } from "@novu/api/core.js";
555
+ import { supportControllerFetchUserOrganizations } from "@novu/api/funcs/supportControllerFetchUserOrganizations.js";
556
+
557
+ // Use `NovuCore` for best tree-shaking performance.
558
+ // You can create one instance of it to use across an application.
559
+ const novu = new NovuCore({
560
+ apiKey: "<YOUR_API_KEY_HERE>",
561
+ });
562
+
563
+ async function run() {
564
+ const res = await supportControllerFetchUserOrganizations(novu, {
565
+ timestamp: "<value>",
566
+ });
567
+
568
+ if (!res.ok) {
569
+ throw res.error;
570
+ }
571
+
572
+ const { value: result } = res;
573
+
574
+ // Handle the result
575
+ console.log(result);
576
+ }
577
+
578
+ run();
579
+ ```
580
+
581
+ ### Parameters
582
+
583
+ | Parameter | Type | Required | Description |
584
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
585
+ | `plainCardRequestDto` | [components.PlainCardRequestDto](../../models/components/plaincardrequestdto.md) | :heavy_check_mark: | N/A |
586
+ | `idempotencyKey` | *string* | :heavy_minus_sign: | A header for idempotency purposes |
587
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
588
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
589
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
590
+
591
+ ### Response
592
+
593
+ **Promise\<[operations.SupportControllerFetchUserOrganizationsResponseBody](../../models/operations/supportcontrollerfetchuserorganizationsresponsebody.md)\>**
594
+
595
+ ### Errors
596
+
597
+ | Error Type | Status Code | Content Type |
598
+ | --------------- | --------------- | --------------- |
599
+ | errors.SDKError | 4XX, 5XX | \*/\* |
600
+
601
+ ## create
602
+
603
+ ### Example Usage
604
+
605
+ ```typescript
606
+ import { Novu } from "@novu/api";
607
+
608
+ const novu = new Novu({
609
+ apiKey: "<YOUR_API_KEY_HERE>",
610
+ });
611
+
612
+ async function run() {
613
+ await novu.create({
614
+ text: "<value>",
615
+ });
616
+
617
+
618
+ }
619
+
620
+ run();
621
+ ```
622
+
623
+ ### Standalone function
624
+
625
+ The standalone function version of this method:
626
+
627
+ ```typescript
628
+ import { NovuCore } from "@novu/api/core.js";
629
+ import { create } from "@novu/api/funcs/create.js";
630
+
631
+ // Use `NovuCore` for best tree-shaking performance.
632
+ // You can create one instance of it to use across an application.
633
+ const novu = new NovuCore({
634
+ apiKey: "<YOUR_API_KEY_HERE>",
635
+ });
636
+
637
+ async function run() {
638
+ const res = await create(novu, {
639
+ text: "<value>",
640
+ });
641
+
642
+ if (!res.ok) {
643
+ throw res.error;
644
+ }
645
+
646
+ const { value: result } = res;
647
+
648
+
649
+ }
650
+
651
+ run();
652
+ ```
653
+
654
+ ### Parameters
655
+
656
+ | Parameter | Type | Required | Description |
657
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
658
+ | `createSupportThreadDto` | [components.CreateSupportThreadDto](../../models/components/createsupportthreaddto.md) | :heavy_check_mark: | N/A |
659
+ | `idempotencyKey` | *string* | :heavy_minus_sign: | A header for idempotency purposes |
660
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
661
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
662
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
663
+
664
+ ### Response
665
+
666
+ **Promise\<void\>**
667
+
668
+ ### Errors
669
+
670
+ | Error Type | Status Code | Content Type |
671
+ | --------------- | --------------- | --------------- |
672
+ | errors.SDKError | 4XX, 5XX | \*/\* |
@@ -24,8 +24,8 @@ const novu = new Novu({
24
24
 
25
25
  async function run() {
26
26
  const result = await novu.subscribers.messages.markAllAs({
27
- messageId: "<value>",
28
- markAs: "read",
27
+ messageId: "<id>",
28
+ markAs: "unread",
29
29
  }, "<id>");
30
30
 
31
31
  // Handle the result
@@ -51,8 +51,8 @@ const novu = new NovuCore({
51
51
 
52
52
  async function run() {
53
53
  const res = await subscribersMessagesMarkAllAs(novu, {
54
- messageId: "<value>",
55
- markAs: "read",
54
+ messageId: "<id>",
55
+ markAs: "unread",
56
56
  }, "<id>");
57
57
 
58
58
  if (!res.ok) {
@@ -24,6 +24,7 @@ const novu = new Novu({
24
24
  async function run() {
25
25
  const result = await novu.subscribers.notifications.feed({
26
26
  subscriberId: "<id>",
27
+ limit: 10,
27
28
  payload: "btoa(JSON.stringify({ foo: 123 })) results in base64 encoded string like eyJmb28iOjEyM30=",
28
29
  });
29
30
 
@@ -51,6 +52,7 @@ const novu = new NovuCore({
51
52
  async function run() {
52
53
  const res = await subscribersNotificationsFeed(novu, {
53
54
  subscriberId: "<id>",
55
+ limit: 10,
54
56
  payload: "btoa(JSON.stringify({ foo: 123 })) results in base64 encoded string like eyJmb28iOjEyM30=",
55
57
  });
56
58
 
@@ -107,7 +109,7 @@ async function run() {
107
109
  const result = await novu.subscribers.notifications.unseenCount({
108
110
  subscriberId: "<id>",
109
111
  seen: false,
110
- limit: 2979.49,
112
+ limit: 100,
111
113
  });
112
114
 
113
115
  // Handle the result
@@ -135,7 +137,7 @@ async function run() {
135
137
  const res = await subscribersNotificationsUnseenCount(novu, {
136
138
  subscriberId: "<id>",
137
139
  seen: false,
138
- limit: 2979.49,
140
+ limit: 100,
139
141
  });
140
142
 
141
143
  if (!res.ok) {
@@ -181,7 +181,7 @@ const novu = new Novu({
181
181
 
182
182
  async function run() {
183
183
  const result = await novu.subscribers.preferences.retrieveByLevel({
184
- preferenceLevel: "global",
184
+ preferenceLevel: "template",
185
185
  subscriberId: "<id>",
186
186
  });
187
187
 
@@ -208,7 +208,7 @@ const novu = new NovuCore({
208
208
 
209
209
  async function run() {
210
210
  const res = await subscribersPreferencesRetrieveByLevel(novu, {
211
- preferenceLevel: "global",
211
+ preferenceLevel: "template",
212
212
  subscriberId: "<id>",
213
213
  });
214
214
 
@@ -264,7 +264,7 @@ const novu = new Novu({
264
264
  async function run() {
265
265
  const result = await novu.subscribers.preferences.update({
266
266
  subscriberId: "<id>",
267
- workflowId: "exampleValue",
267
+ workflowId: "<id>",
268
268
  updateSubscriberPreferenceRequestDto: {},
269
269
  });
270
270
 
@@ -292,7 +292,7 @@ const novu = new NovuCore({
292
292
  async function run() {
293
293
  const res = await subscribersPreferencesUpdate(novu, {
294
294
  subscriberId: "<id>",
295
- workflowId: "exampleValue",
295
+ workflowId: "<id>",
296
296
  updateSubscriberPreferenceRequestDto: {},
297
297
  });
298
298
 
@@ -22,7 +22,7 @@ const novu = new Novu({
22
22
 
23
23
  async function run() {
24
24
  const result = await novu.subscribers.properties.updateOnlineFlag({
25
- isOnline: true,
25
+ isOnline: false,
26
26
  }, "<id>");
27
27
 
28
28
  // Handle the result
@@ -48,7 +48,7 @@ const novu = new NovuCore({
48
48
 
49
49
  async function run() {
50
50
  const res = await subscribersPropertiesUpdateOnlineFlag(novu, {
51
- isOnline: true,
51
+ isOnline: false,
52
52
  }, "<id>");
53
53
 
54
54
  if (!res.ok) {
@@ -29,7 +29,7 @@ const novu = new Novu({
29
29
  });
30
30
 
31
31
  async function run() {
32
- const result = await novu.subscribers.list();
32
+ const result = await novu.subscribers.list(10);
33
33
 
34
34
  for await (const page of result) {
35
35
  // Handle the page
@@ -55,7 +55,7 @@ const novu = new NovuCore({
55
55
  });
56
56
 
57
57
  async function run() {
58
- const res = await subscribersList(novu);
58
+ const res = await subscribersList(novu, 10);
59
59
 
60
60
  if (!res.ok) {
61
61
  throw res.error;
@@ -466,7 +466,6 @@ async function run() {
466
466
  subscribers: [
467
467
  {
468
468
  subscriberId: "<id>",
469
- email: "example@example.com",
470
469
  },
471
470
  ],
472
471
  });
@@ -497,7 +496,6 @@ async function run() {
497
496
  subscribers: [
498
497
  {
499
498
  subscriberId: "<id>",
500
- email: "example@example.com",
501
499
  },
502
500
  ],
503
501
  });
@@ -0,0 +1,9 @@
1
+ import { NovuCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import * as components from "../models/components/index.js";
4
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
5
+ import { SDKError } from "../models/errors/sdkerror.js";
6
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
7
+ import { Result } from "../types/fp.js";
8
+ export declare function create(client: NovuCore, createSupportThreadDto: components.CreateSupportThreadDto, idempotencyKey?: string | undefined, options?: RequestOptions): Promise<Result<void, SDKError | SDKValidationError | UnexpectedClientError | InvalidRequestError | RequestAbortedError | RequestTimeoutError | ConnectionError>>;
9
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/funcs/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,wBAAsB,MAAM,CAC1B,MAAM,EAAE,QAAQ,EAChB,sBAAsB,EAAE,UAAU,CAAC,sBAAsB,EACzD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CACR,MAAM,CACJ,IAAI,EACF,QAAQ,GACR,kBAAkB,GAClB,qBAAqB,GACrB,mBAAmB,GACnB,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,CAClB,CACF,CAyGA"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /*
3
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.create = void 0;
30
+ const z = __importStar(require("zod"));
31
+ const encodings_js_1 = require("../lib/encodings.js");
32
+ const M = __importStar(require("../lib/matchers.js"));
33
+ const primitives_js_1 = require("../lib/primitives.js");
34
+ const schemas_js_1 = require("../lib/schemas.js");
35
+ const security_js_1 = require("../lib/security.js");
36
+ const url_js_1 = require("../lib/url.js");
37
+ const operations = __importStar(require("../models/operations/index.js"));
38
+ async function create(client, createSupportThreadDto, idempotencyKey, options) {
39
+ const input = {
40
+ createSupportThreadDto: createSupportThreadDto,
41
+ idempotencyKey: idempotencyKey,
42
+ };
43
+ const parsed = (0, schemas_js_1.safeParse)(input, (value) => operations.SupportControllerCreateThreadRequest$outboundSchema.parse(value), "Input validation failed");
44
+ if (!parsed.ok) {
45
+ return parsed;
46
+ }
47
+ const payload = parsed.value;
48
+ const body = (0, encodings_js_1.encodeJSON)("body", payload.CreateSupportThreadDto, {
49
+ explode: true,
50
+ });
51
+ const path = (0, url_js_1.pathToFunc)("/v1/support/create-thread")();
52
+ const headers = new Headers((0, primitives_js_1.compactMap)({
53
+ "Content-Type": "application/json",
54
+ Accept: "*/*",
55
+ "idempotency-key": (0, encodings_js_1.encodeSimple)("idempotency-key", payload["idempotency-key"], { explode: false, charEncoding: "none" }),
56
+ }));
57
+ const secConfig = await (0, security_js_1.extractSecurity)(client._options.apiKey);
58
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
59
+ const requestSecurity = (0, security_js_1.resolveGlobalSecurity)(securityInput);
60
+ const context = {
61
+ operationID: "SupportController_createThread",
62
+ oAuth2Scopes: [],
63
+ resolvedSecurity: requestSecurity,
64
+ securitySource: client._options.apiKey,
65
+ retryConfig: options?.retries
66
+ || client._options.retryConfig
67
+ || {
68
+ strategy: "backoff",
69
+ backoff: {
70
+ initialInterval: 1000,
71
+ maxInterval: 30000,
72
+ exponent: 1.5,
73
+ maxElapsedTime: 3600000,
74
+ },
75
+ retryConnectionErrors: true,
76
+ }
77
+ || { strategy: "none" },
78
+ retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"],
79
+ };
80
+ const requestRes = client._createRequest(context, {
81
+ security: requestSecurity,
82
+ method: "POST",
83
+ baseURL: options?.serverURL,
84
+ path: path,
85
+ headers: headers,
86
+ body: body,
87
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
88
+ }, options);
89
+ if (!requestRes.ok) {
90
+ return requestRes;
91
+ }
92
+ const req = requestRes.value;
93
+ const doResult = await client._do(req, {
94
+ context,
95
+ errorCodes: ["4XX", "5XX"],
96
+ retryConfig: context.retryConfig,
97
+ retryCodes: context.retryCodes,
98
+ });
99
+ if (!doResult.ok) {
100
+ return doResult;
101
+ }
102
+ const response = doResult.value;
103
+ const [result] = await M.match(M.nil(201, z.void()), M.fail("4XX"), M.fail("5XX"))(response);
104
+ if (!result.ok) {
105
+ return result;
106
+ }
107
+ return result;
108
+ }
109
+ exports.create = create;
110
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/funcs/create.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,sDAA+D;AAC/D,sDAAwC;AACxC,wDAAkD;AAClD,kDAA8C;AAE9C,oDAA4E;AAC5E,0CAA2C;AAW3C,0EAA4D;AAGrD,KAAK,UAAU,MAAM,CAC1B,MAAgB,EAChB,sBAAyD,EACzD,cAAmC,EACnC,OAAwB;IAaxB,MAAM,KAAK,GAAoD;QAC7D,sBAAsB,EAAE,sBAAsB;QAC9C,cAAc,EAAE,cAAc;KAC/B,CAAC;IAEF,MAAM,MAAM,GAAG,IAAA,sBAAS,EACtB,KAAK,EACL,CAAC,KAAK,EAAE,EAAE,CACR,UAAU,CAAC,mDAAmD,CAAC,KAAK,CAClE,KAAK,CACN,EACH,yBAAyB,CAC1B,CAAC;IACF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B,MAAM,IAAI,GAAG,IAAA,yBAAU,EAAC,MAAM,EAAE,OAAO,CAAC,sBAAsB,EAAE;QAC9D,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,2BAA2B,CAAC,EAAE,CAAC;IAEvD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAA,0BAAU,EAAC;QACrC,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,KAAK;QACb,iBAAiB,EAAE,IAAA,2BAAY,EAC7B,iBAAiB,EACjB,OAAO,CAAC,iBAAiB,CAAC,EAC1B,EAAE,OAAO,EAAE,KAAK,EAA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