rcs-js 2.0.5 → 2.0.6

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 (105) hide show
  1. package/README.md +0 -199
  2. package/dist/cjs/Client.d.ts +3 -0
  3. package/dist/cjs/Client.js +25 -20
  4. package/dist/cjs/api/resources/audiences/client/Client.d.ts +129 -0
  5. package/dist/cjs/api/resources/audiences/client/Client.js +385 -0
  6. package/dist/cjs/api/resources/audiences/client/index.d.ts +2 -0
  7. package/dist/cjs/api/resources/audiences/client/index.js +17 -0
  8. package/dist/cjs/api/resources/audiences/client/requests/AudiencesDeleteRequest.d.ts +13 -0
  9. package/dist/cjs/api/resources/audiences/client/requests/AudiencesDeleteRequest.js +5 -0
  10. package/dist/cjs/api/resources/audiences/client/requests/AudiencesGetRequest.d.ts +22 -0
  11. package/dist/cjs/api/resources/audiences/client/requests/AudiencesGetRequest.js +5 -0
  12. package/dist/cjs/api/resources/audiences/client/requests/CreateAudienceParams.d.ts +31 -0
  13. package/dist/cjs/api/resources/audiences/client/requests/CreateAudienceParams.js +5 -0
  14. package/dist/cjs/api/resources/audiences/client/requests/UpdateAudienceParams.d.ts +19 -0
  15. package/dist/cjs/api/resources/audiences/client/requests/UpdateAudienceParams.js +5 -0
  16. package/dist/cjs/api/resources/audiences/client/requests/index.d.ts +4 -0
  17. package/dist/cjs/api/resources/audiences/client/requests/index.js +2 -0
  18. package/dist/cjs/api/resources/audiences/index.d.ts +3 -0
  19. package/dist/cjs/api/resources/audiences/index.js +19 -0
  20. package/dist/cjs/api/resources/audiences/resources/contacts/client/Client.d.ts +80 -0
  21. package/dist/cjs/api/resources/audiences/resources/contacts/client/Client.js +220 -0
  22. package/dist/cjs/api/resources/audiences/resources/contacts/client/index.d.ts +2 -0
  23. package/dist/cjs/api/resources/audiences/resources/contacts/client/index.js +17 -0
  24. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/AddContactsParams.d.ts +16 -0
  25. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/AddContactsParams.js +5 -0
  26. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/RemoveContactsParams.d.ts +16 -0
  27. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/RemoveContactsParams.js +5 -0
  28. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/index.d.ts +2 -0
  29. package/dist/cjs/api/resources/audiences/resources/contacts/client/requests/index.js +2 -0
  30. package/dist/cjs/api/resources/audiences/resources/contacts/index.d.ts +1 -0
  31. package/dist/cjs/api/resources/audiences/resources/contacts/index.js +17 -0
  32. package/dist/cjs/api/resources/audiences/resources/index.d.ts +2 -0
  33. package/dist/cjs/api/resources/audiences/resources/index.js +41 -0
  34. package/dist/cjs/api/resources/audiences/types/AudiencesGetResponse.d.ts +11 -0
  35. package/dist/cjs/api/resources/audiences/types/AudiencesGetResponse.js +5 -0
  36. package/dist/cjs/api/resources/audiences/types/index.d.ts +1 -0
  37. package/dist/cjs/api/resources/audiences/types/index.js +17 -0
  38. package/dist/cjs/api/resources/index.d.ts +3 -0
  39. package/dist/cjs/api/resources/index.js +4 -1
  40. package/dist/cjs/api/types/AudienceCountOnly.d.ts +17 -0
  41. package/dist/cjs/api/types/AudienceCountOnly.js +5 -0
  42. package/dist/cjs/api/types/AudienceWithPagination.d.ts +17 -0
  43. package/dist/cjs/api/types/AudienceWithPagination.js +5 -0
  44. package/dist/cjs/api/types/DeleteAudienceResponse.d.ts +7 -0
  45. package/dist/cjs/api/types/DeleteAudienceResponse.js +5 -0
  46. package/dist/cjs/api/types/Pagination.d.ts +13 -0
  47. package/dist/cjs/api/types/Pagination.js +5 -0
  48. package/dist/cjs/api/types/SentMmsDetails.d.ts +5 -1
  49. package/dist/cjs/api/types/index.d.ts +4 -0
  50. package/dist/cjs/api/types/index.js +4 -0
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/esm/Client.d.mts +3 -0
  54. package/dist/esm/Client.mjs +7 -2
  55. package/dist/esm/api/resources/audiences/client/Client.d.mts +129 -0
  56. package/dist/esm/api/resources/audiences/client/Client.mjs +348 -0
  57. package/dist/esm/api/resources/audiences/client/index.d.mts +2 -0
  58. package/dist/esm/api/resources/audiences/client/index.mjs +1 -0
  59. package/dist/esm/api/resources/audiences/client/requests/AudiencesDeleteRequest.d.mts +13 -0
  60. package/dist/esm/api/resources/audiences/client/requests/AudiencesDeleteRequest.mjs +4 -0
  61. package/dist/esm/api/resources/audiences/client/requests/AudiencesGetRequest.d.mts +22 -0
  62. package/dist/esm/api/resources/audiences/client/requests/AudiencesGetRequest.mjs +4 -0
  63. package/dist/esm/api/resources/audiences/client/requests/CreateAudienceParams.d.mts +31 -0
  64. package/dist/esm/api/resources/audiences/client/requests/CreateAudienceParams.mjs +4 -0
  65. package/dist/esm/api/resources/audiences/client/requests/UpdateAudienceParams.d.mts +19 -0
  66. package/dist/esm/api/resources/audiences/client/requests/UpdateAudienceParams.mjs +4 -0
  67. package/dist/esm/api/resources/audiences/client/requests/index.d.mts +4 -0
  68. package/dist/esm/api/resources/audiences/client/requests/index.mjs +1 -0
  69. package/dist/esm/api/resources/audiences/index.d.mts +3 -0
  70. package/dist/esm/api/resources/audiences/index.mjs +3 -0
  71. package/dist/esm/api/resources/audiences/resources/contacts/client/Client.d.mts +80 -0
  72. package/dist/esm/api/resources/audiences/resources/contacts/client/Client.mjs +183 -0
  73. package/dist/esm/api/resources/audiences/resources/contacts/client/index.d.mts +2 -0
  74. package/dist/esm/api/resources/audiences/resources/contacts/client/index.mjs +1 -0
  75. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/AddContactsParams.d.mts +16 -0
  76. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/AddContactsParams.mjs +4 -0
  77. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/RemoveContactsParams.d.mts +16 -0
  78. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/RemoveContactsParams.mjs +4 -0
  79. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/index.d.mts +2 -0
  80. package/dist/esm/api/resources/audiences/resources/contacts/client/requests/index.mjs +1 -0
  81. package/dist/esm/api/resources/audiences/resources/contacts/index.d.mts +1 -0
  82. package/dist/esm/api/resources/audiences/resources/contacts/index.mjs +1 -0
  83. package/dist/esm/api/resources/audiences/resources/index.d.mts +2 -0
  84. package/dist/esm/api/resources/audiences/resources/index.mjs +2 -0
  85. package/dist/esm/api/resources/audiences/types/AudiencesGetResponse.d.mts +11 -0
  86. package/dist/esm/api/resources/audiences/types/AudiencesGetResponse.mjs +4 -0
  87. package/dist/esm/api/resources/audiences/types/index.d.mts +1 -0
  88. package/dist/esm/api/resources/audiences/types/index.mjs +1 -0
  89. package/dist/esm/api/resources/index.d.mts +3 -0
  90. package/dist/esm/api/resources/index.mjs +3 -0
  91. package/dist/esm/api/types/AudienceCountOnly.d.mts +17 -0
  92. package/dist/esm/api/types/AudienceCountOnly.mjs +4 -0
  93. package/dist/esm/api/types/AudienceWithPagination.d.mts +17 -0
  94. package/dist/esm/api/types/AudienceWithPagination.mjs +4 -0
  95. package/dist/esm/api/types/DeleteAudienceResponse.d.mts +7 -0
  96. package/dist/esm/api/types/DeleteAudienceResponse.mjs +4 -0
  97. package/dist/esm/api/types/Pagination.d.mts +13 -0
  98. package/dist/esm/api/types/Pagination.mjs +4 -0
  99. package/dist/esm/api/types/SentMmsDetails.d.mts +5 -1
  100. package/dist/esm/api/types/index.d.mts +4 -0
  101. package/dist/esm/api/types/index.mjs +4 -0
  102. package/dist/esm/version.d.mts +1 -1
  103. package/dist/esm/version.mjs +1 -1
  104. package/package.json +1 -1
  105. package/reference.md +408 -0
@@ -0,0 +1,129 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as environments from "../../../../environments.mjs";
5
+ import * as core from "../../../../core/index.mjs";
6
+ import * as Pinnacle from "../../../index.mjs";
7
+ import { Contacts } from "../resources/contacts/client/Client.mjs";
8
+ export declare namespace Audiences {
9
+ interface Options {
10
+ environment?: core.Supplier<environments.PinnacleEnvironment | string>;
11
+ /** Specify a custom URL to connect the client to. */
12
+ baseUrl?: core.Supplier<string>;
13
+ apiKey?: core.Supplier<string | undefined>;
14
+ /** Additional headers to include in requests. */
15
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
16
+ }
17
+ interface RequestOptions {
18
+ /** The maximum time to wait for a response in seconds. */
19
+ timeoutInSeconds?: number;
20
+ /** The number of times to retry the request. Defaults to 2. */
21
+ maxRetries?: number;
22
+ /** A hook to abort the request. */
23
+ abortSignal?: AbortSignal;
24
+ /** Additional query string parameters to include in the request. */
25
+ queryParams?: Record<string, unknown>;
26
+ /** Additional headers to include in the request. */
27
+ headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
28
+ }
29
+ }
30
+ export declare class Audiences {
31
+ protected readonly _options: Audiences.Options;
32
+ protected _contacts: Contacts | undefined;
33
+ constructor(_options?: Audiences.Options);
34
+ get contacts(): Contacts;
35
+ /**
36
+ * Retrieve an audience by ID with optional pagination.
37
+ *
38
+ * @param {Pinnacle.AudiencesGetRequest} request
39
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
40
+ *
41
+ * @throws {@link Pinnacle.BadRequestError}
42
+ * @throws {@link Pinnacle.UnauthorizedError}
43
+ * @throws {@link Pinnacle.NotFoundError}
44
+ * @throws {@link Pinnacle.InternalServerError}
45
+ *
46
+ * @example
47
+ * await client.audiences.get({
48
+ * id: "aud_abc123"
49
+ * })
50
+ */
51
+ get(request: Pinnacle.AudiencesGetRequest, requestOptions?: Audiences.RequestOptions): core.HttpResponsePromise<Pinnacle.AudiencesGetResponse>;
52
+ private __get;
53
+ /**
54
+ * Create a new audience with optional initial contacts. Phone numbers that don't exist will be auto-created as contacts.
55
+ *
56
+ * @param {Pinnacle.CreateAudienceParams} request
57
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
58
+ *
59
+ * @throws {@link Pinnacle.BadRequestError}
60
+ * @throws {@link Pinnacle.UnauthorizedError}
61
+ * @throws {@link Pinnacle.InternalServerError}
62
+ *
63
+ * @example
64
+ * await client.audiences.create({
65
+ * name: "Marketing Campaign Q1",
66
+ * description: "Contacts for Q1 marketing push"
67
+ * })
68
+ *
69
+ * @example
70
+ * await client.audiences.create({
71
+ * name: "VIP Customers",
72
+ * description: "Our best customers",
73
+ * contacts: ["+12125551234", "+13105551234"]
74
+ * })
75
+ *
76
+ * @example
77
+ * await client.audiences.create({
78
+ * name: "Mixed Audience",
79
+ * contacts: ["+12125551234", "co_abc123", "+13105551234"]
80
+ * })
81
+ */
82
+ create(request: Pinnacle.CreateAudienceParams, requestOptions?: Audiences.RequestOptions): core.HttpResponsePromise<Pinnacle.AudienceCountOnly>;
83
+ private __create;
84
+ /**
85
+ * Permanently delete an audience and all its contact associations.
86
+ *
87
+ * Note: This will NOT delete the contacts themselves, only the audience and its memberships.
88
+ *
89
+ * @param {Pinnacle.AudiencesDeleteRequest} request
90
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
91
+ *
92
+ * @throws {@link Pinnacle.BadRequestError}
93
+ * @throws {@link Pinnacle.UnauthorizedError}
94
+ * @throws {@link Pinnacle.NotFoundError}
95
+ * @throws {@link Pinnacle.InternalServerError}
96
+ *
97
+ * @example
98
+ * await client.audiences.delete({
99
+ * id: "aud_abc123"
100
+ * })
101
+ */
102
+ delete(request: Pinnacle.AudiencesDeleteRequest, requestOptions?: Audiences.RequestOptions): core.HttpResponsePromise<Pinnacle.DeleteAudienceResponse>;
103
+ private __delete;
104
+ /**
105
+ * Update audience metadata. This endpoint does NOT modify contacts.
106
+ *
107
+ * To add or remove contacts, use the [Add Contacts](/api-reference/audiences/add-contacts) or [Remove Contacts](/api-reference/audiences/remove-contacts) endpoints.
108
+ *
109
+ * @param {Pinnacle.UpdateAudienceParams} request
110
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
111
+ *
112
+ * @throws {@link Pinnacle.BadRequestError}
113
+ * @throws {@link Pinnacle.UnauthorizedError}
114
+ * @throws {@link Pinnacle.NotFoundError}
115
+ * @throws {@link Pinnacle.InternalServerError}
116
+ *
117
+ * @example
118
+ * await client.audiences.update({
119
+ * id: "aud_abc123",
120
+ * name: "Updated Audience Name",
121
+ * description: "New description"
122
+ * })
123
+ */
124
+ update(request: Pinnacle.UpdateAudienceParams, requestOptions?: Audiences.RequestOptions): core.HttpResponsePromise<Pinnacle.AudienceCountOnly>;
125
+ private __update;
126
+ protected _getCustomAuthorizationHeaders(): Promise<{
127
+ "PINNACLE-API-KEY": string | undefined;
128
+ }>;
129
+ }
@@ -0,0 +1,348 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ import * as environments from "../../../../environments.mjs";
14
+ import * as core from "../../../../core/index.mjs";
15
+ import * as Pinnacle from "../../../index.mjs";
16
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
17
+ import * as errors from "../../../../errors/index.mjs";
18
+ import { Contacts } from "../resources/contacts/client/Client.mjs";
19
+ export class Audiences {
20
+ constructor(_options = {}) {
21
+ this._options = _options;
22
+ }
23
+ get contacts() {
24
+ var _a;
25
+ return ((_a = this._contacts) !== null && _a !== void 0 ? _a : (this._contacts = new Contacts(this._options)));
26
+ }
27
+ /**
28
+ * Retrieve an audience by ID with optional pagination.
29
+ *
30
+ * @param {Pinnacle.AudiencesGetRequest} request
31
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
32
+ *
33
+ * @throws {@link Pinnacle.BadRequestError}
34
+ * @throws {@link Pinnacle.UnauthorizedError}
35
+ * @throws {@link Pinnacle.NotFoundError}
36
+ * @throws {@link Pinnacle.InternalServerError}
37
+ *
38
+ * @example
39
+ * await client.audiences.get({
40
+ * id: "aud_abc123"
41
+ * })
42
+ */
43
+ get(request, requestOptions) {
44
+ return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions));
45
+ }
46
+ __get(request, requestOptions) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ var _a, _b, _c;
49
+ const { id, page, limit } = request;
50
+ const _queryParams = {};
51
+ _queryParams["id"] = id;
52
+ if (page != null) {
53
+ _queryParams["page"] = page.toString();
54
+ }
55
+ if (limit != null) {
56
+ _queryParams["limit"] = limit.toString();
57
+ }
58
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
59
+ const _response = yield core.fetcher({
60
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PinnacleEnvironment.Default, "audiences"),
61
+ method: "GET",
62
+ headers: _headers,
63
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
64
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
65
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
66
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
67
+ });
68
+ if (_response.ok) {
69
+ return { data: _response.body, rawResponse: _response.rawResponse };
70
+ }
71
+ if (_response.error.reason === "status-code") {
72
+ switch (_response.error.statusCode) {
73
+ case 400:
74
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
75
+ case 401:
76
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
77
+ case 404:
78
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
79
+ case 500:
80
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
81
+ default:
82
+ throw new errors.PinnacleError({
83
+ statusCode: _response.error.statusCode,
84
+ body: _response.error.body,
85
+ rawResponse: _response.rawResponse,
86
+ });
87
+ }
88
+ }
89
+ switch (_response.error.reason) {
90
+ case "non-json":
91
+ throw new errors.PinnacleError({
92
+ statusCode: _response.error.statusCode,
93
+ body: _response.error.rawBody,
94
+ rawResponse: _response.rawResponse,
95
+ });
96
+ case "timeout":
97
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling GET /audiences.");
98
+ case "unknown":
99
+ throw new errors.PinnacleError({
100
+ message: _response.error.errorMessage,
101
+ rawResponse: _response.rawResponse,
102
+ });
103
+ }
104
+ });
105
+ }
106
+ /**
107
+ * Create a new audience with optional initial contacts. Phone numbers that don't exist will be auto-created as contacts.
108
+ *
109
+ * @param {Pinnacle.CreateAudienceParams} request
110
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
111
+ *
112
+ * @throws {@link Pinnacle.BadRequestError}
113
+ * @throws {@link Pinnacle.UnauthorizedError}
114
+ * @throws {@link Pinnacle.InternalServerError}
115
+ *
116
+ * @example
117
+ * await client.audiences.create({
118
+ * name: "Marketing Campaign Q1",
119
+ * description: "Contacts for Q1 marketing push"
120
+ * })
121
+ *
122
+ * @example
123
+ * await client.audiences.create({
124
+ * name: "VIP Customers",
125
+ * description: "Our best customers",
126
+ * contacts: ["+12125551234", "+13105551234"]
127
+ * })
128
+ *
129
+ * @example
130
+ * await client.audiences.create({
131
+ * name: "Mixed Audience",
132
+ * contacts: ["+12125551234", "co_abc123", "+13105551234"]
133
+ * })
134
+ */
135
+ create(request, requestOptions) {
136
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
137
+ }
138
+ __create(request, requestOptions) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ var _a, _b, _c;
141
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
142
+ const _response = yield core.fetcher({
143
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PinnacleEnvironment.Default, "audiences"),
144
+ method: "POST",
145
+ headers: _headers,
146
+ contentType: "application/json",
147
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
148
+ requestType: "json",
149
+ body: request,
150
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
151
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
152
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
153
+ });
154
+ if (_response.ok) {
155
+ return { data: _response.body, rawResponse: _response.rawResponse };
156
+ }
157
+ if (_response.error.reason === "status-code") {
158
+ switch (_response.error.statusCode) {
159
+ case 400:
160
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
161
+ case 401:
162
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
163
+ case 500:
164
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
165
+ default:
166
+ throw new errors.PinnacleError({
167
+ statusCode: _response.error.statusCode,
168
+ body: _response.error.body,
169
+ rawResponse: _response.rawResponse,
170
+ });
171
+ }
172
+ }
173
+ switch (_response.error.reason) {
174
+ case "non-json":
175
+ throw new errors.PinnacleError({
176
+ statusCode: _response.error.statusCode,
177
+ body: _response.error.rawBody,
178
+ rawResponse: _response.rawResponse,
179
+ });
180
+ case "timeout":
181
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling POST /audiences.");
182
+ case "unknown":
183
+ throw new errors.PinnacleError({
184
+ message: _response.error.errorMessage,
185
+ rawResponse: _response.rawResponse,
186
+ });
187
+ }
188
+ });
189
+ }
190
+ /**
191
+ * Permanently delete an audience and all its contact associations.
192
+ *
193
+ * Note: This will NOT delete the contacts themselves, only the audience and its memberships.
194
+ *
195
+ * @param {Pinnacle.AudiencesDeleteRequest} request
196
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
197
+ *
198
+ * @throws {@link Pinnacle.BadRequestError}
199
+ * @throws {@link Pinnacle.UnauthorizedError}
200
+ * @throws {@link Pinnacle.NotFoundError}
201
+ * @throws {@link Pinnacle.InternalServerError}
202
+ *
203
+ * @example
204
+ * await client.audiences.delete({
205
+ * id: "aud_abc123"
206
+ * })
207
+ */
208
+ delete(request, requestOptions) {
209
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
210
+ }
211
+ __delete(request, requestOptions) {
212
+ return __awaiter(this, void 0, void 0, function* () {
213
+ var _a, _b, _c;
214
+ const { id } = request;
215
+ const _queryParams = {};
216
+ _queryParams["id"] = id;
217
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
218
+ const _response = yield core.fetcher({
219
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PinnacleEnvironment.Default, "audiences"),
220
+ method: "DELETE",
221
+ headers: _headers,
222
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
223
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
224
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
225
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
226
+ });
227
+ if (_response.ok) {
228
+ return { data: _response.body, rawResponse: _response.rawResponse };
229
+ }
230
+ if (_response.error.reason === "status-code") {
231
+ switch (_response.error.statusCode) {
232
+ case 400:
233
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
234
+ case 401:
235
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
236
+ case 404:
237
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
238
+ case 500:
239
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
240
+ default:
241
+ throw new errors.PinnacleError({
242
+ statusCode: _response.error.statusCode,
243
+ body: _response.error.body,
244
+ rawResponse: _response.rawResponse,
245
+ });
246
+ }
247
+ }
248
+ switch (_response.error.reason) {
249
+ case "non-json":
250
+ throw new errors.PinnacleError({
251
+ statusCode: _response.error.statusCode,
252
+ body: _response.error.rawBody,
253
+ rawResponse: _response.rawResponse,
254
+ });
255
+ case "timeout":
256
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling DELETE /audiences.");
257
+ case "unknown":
258
+ throw new errors.PinnacleError({
259
+ message: _response.error.errorMessage,
260
+ rawResponse: _response.rawResponse,
261
+ });
262
+ }
263
+ });
264
+ }
265
+ /**
266
+ * Update audience metadata. This endpoint does NOT modify contacts.
267
+ *
268
+ * To add or remove contacts, use the [Add Contacts](/api-reference/audiences/add-contacts) or [Remove Contacts](/api-reference/audiences/remove-contacts) endpoints.
269
+ *
270
+ * @param {Pinnacle.UpdateAudienceParams} request
271
+ * @param {Audiences.RequestOptions} requestOptions - Request-specific configuration.
272
+ *
273
+ * @throws {@link Pinnacle.BadRequestError}
274
+ * @throws {@link Pinnacle.UnauthorizedError}
275
+ * @throws {@link Pinnacle.NotFoundError}
276
+ * @throws {@link Pinnacle.InternalServerError}
277
+ *
278
+ * @example
279
+ * await client.audiences.update({
280
+ * id: "aud_abc123",
281
+ * name: "Updated Audience Name",
282
+ * description: "New description"
283
+ * })
284
+ */
285
+ update(request, requestOptions) {
286
+ return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions));
287
+ }
288
+ __update(request, requestOptions) {
289
+ return __awaiter(this, void 0, void 0, function* () {
290
+ var _a, _b, _c;
291
+ let _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({}, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
292
+ const _response = yield core.fetcher({
293
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PinnacleEnvironment.Default, "audiences"),
294
+ method: "PATCH",
295
+ headers: _headers,
296
+ contentType: "application/json",
297
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
298
+ requestType: "json",
299
+ body: request,
300
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
301
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
302
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
303
+ });
304
+ if (_response.ok) {
305
+ return { data: _response.body, rawResponse: _response.rawResponse };
306
+ }
307
+ if (_response.error.reason === "status-code") {
308
+ switch (_response.error.statusCode) {
309
+ case 400:
310
+ throw new Pinnacle.BadRequestError(_response.error.body, _response.rawResponse);
311
+ case 401:
312
+ throw new Pinnacle.UnauthorizedError(_response.error.body, _response.rawResponse);
313
+ case 404:
314
+ throw new Pinnacle.NotFoundError(_response.error.body, _response.rawResponse);
315
+ case 500:
316
+ throw new Pinnacle.InternalServerError(_response.error.body, _response.rawResponse);
317
+ default:
318
+ throw new errors.PinnacleError({
319
+ statusCode: _response.error.statusCode,
320
+ body: _response.error.body,
321
+ rawResponse: _response.rawResponse,
322
+ });
323
+ }
324
+ }
325
+ switch (_response.error.reason) {
326
+ case "non-json":
327
+ throw new errors.PinnacleError({
328
+ statusCode: _response.error.statusCode,
329
+ body: _response.error.rawBody,
330
+ rawResponse: _response.rawResponse,
331
+ });
332
+ case "timeout":
333
+ throw new errors.PinnacleTimeoutError("Timeout exceeded when calling PATCH /audiences.");
334
+ case "unknown":
335
+ throw new errors.PinnacleError({
336
+ message: _response.error.errorMessage,
337
+ rawResponse: _response.rawResponse,
338
+ });
339
+ }
340
+ });
341
+ }
342
+ _getCustomAuthorizationHeaders() {
343
+ return __awaiter(this, void 0, void 0, function* () {
344
+ const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
345
+ return { "PINNACLE-API-KEY": apiKeyValue };
346
+ });
347
+ }
348
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * id: "aud_abc123"
8
+ * }
9
+ */
10
+ export interface AudiencesDeleteRequest {
11
+ /** Audience ID. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. */
12
+ id: string;
13
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * id: "aud_abc123"
8
+ * }
9
+ *
10
+ * @example
11
+ * {
12
+ * id: "aud_abc123"
13
+ * }
14
+ */
15
+ export interface AudiencesGetRequest {
16
+ /** Audience ID. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. */
17
+ id: string;
18
+ /** Page number. If provided with or without limit, returns paginated contacts. */
19
+ page?: number;
20
+ /** Items per page. If provided with or without page, returns paginated contacts. */
21
+ limit?: number;
22
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * name: "Marketing Campaign Q1",
8
+ * description: "Contacts for Q1 marketing push"
9
+ * }
10
+ *
11
+ * @example
12
+ * {
13
+ * name: "VIP Customers",
14
+ * description: "Our best customers",
15
+ * contacts: ["+12125551234", "+13105551234"]
16
+ * }
17
+ *
18
+ * @example
19
+ * {
20
+ * name: "Mixed Audience",
21
+ * contacts: ["+12125551234", "co_abc123", "+13105551234"]
22
+ * }
23
+ */
24
+ export interface CreateAudienceParams {
25
+ /** Audience name. */
26
+ name: string;
27
+ /** Audience description. */
28
+ description?: string;
29
+ /** Optional array of phone numbers (E.164 format) or contact IDs. */
30
+ contacts?: string[];
31
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ /**
5
+ * @example
6
+ * {
7
+ * id: "aud_abc123",
8
+ * name: "Updated Audience Name",
9
+ * description: "New description"
10
+ * }
11
+ */
12
+ export interface UpdateAudienceParams {
13
+ /** Audience ID to update. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. */
14
+ id: string;
15
+ /** New audience name. */
16
+ name?: string;
17
+ /** New audience description. */
18
+ description?: string;
19
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export {};
@@ -0,0 +1,4 @@
1
+ export { type AudiencesGetRequest } from "./AudiencesGetRequest.mjs";
2
+ export { type CreateAudienceParams } from "./CreateAudienceParams.mjs";
3
+ export { type AudiencesDeleteRequest } from "./AudiencesDeleteRequest.mjs";
4
+ export { type UpdateAudienceParams } from "./UpdateAudienceParams.mjs";
@@ -0,0 +1,3 @@
1
+ export * from "./types/index.mjs";
2
+ export * from "./client/index.mjs";
3
+ export * from "./resources/index.mjs";
@@ -0,0 +1,3 @@
1
+ export * from "./types/index.mjs";
2
+ export * from "./client/index.mjs";
3
+ export * from "./resources/index.mjs";