Repository navigation
Expand file tree
/
Copy pathme.ts
More file actions
400 lines (350 loc) · 12 KB
/
Copy pathme.ts
File metadata and controls
400 lines (350 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import * as MeAPI from './me';
import * as WebhooksAPI from './webhooks';
import { APIPromise } from '../core/api-promise';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
/**
* Who the current key is.
*
* `GET /v3/me` answers with the account the key authenticates as, which is the quickest way to tell a live key from a test one, an organization key from a sender profile's, and to confirm `x-profile-id` resolved to the profile you meant.
*/
export class Me extends APIResource {
/**
* Returns the account associated with the provided API key. The response includes
* account identity, contact information, messaging channel configuration, and —
* depending on the account type — either a list of child profiles or the profile's
* own settings.
*
* **Account types:**
*
* - `organization` — Has child profiles. The `profiles` array is populated.
* - `user` — Standalone account with no profiles.
* - `profile` — Child of an organization. Includes `organization_id`,
* `short_name`, `status`, and `settings`.
*
* **Channels:** The `channels` object always includes `sms`, `whatsapp`, and
* `rcs`. Each channel has a `configured` boolean. Configured channels expose
* additional details such as `phone_number`.
*
* **Sending number:** `sending_phone_number` is the account's US SMS sender. It is
* intentionally the same value as `channels.sms.phone_number` — the two are kept
* in step, and it is published under both names because `sending_phone_number` is
* what this value is called on `GET /v3/profiles`. Read either. One difference:
* `sending_phone_number` is always present, including as `null`, while
* `channels.sms.phone_number` is omitted when there is no sender.
*
* `sending_phone_number_profile_id` names the account that holds that number in
* inventory — normally this account, and a different one where a number is shared.
* Both are `null` when the account has no US SMS sender.
*
* **Template auto-creation:** `enable_template_auto_creation_for_sp` reports
* whether this account may mark a template for automatic creation on its sender
* profiles. It is granted by Sent and off by default. A `profile` reports `false`,
* having no sender profiles of its own to create anything on.
*/
retrieve(
params: MeRetrieveParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<MeRetrieveResponse> {
const { 'x-profile-id': xProfileID } = params ?? {};
return this._client.get('/v3/me', {
...options,
headers: buildHeaders([
{ ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
options?.headers,
]),
});
}
}
/**
* Profile configuration settings
*/
export interface ProfileSettings {
/**
* @deprecated Always false. A profile no longer shares contacts with sibling
* profiles — it sees only what it owns. Retained so existing v3 clients reading
* allow_contact_sharing keep deserializing; it carries no information.
*/
allow_contact_sharing?: boolean | null;
/**
* @deprecated Always false. A profile no longer shares templates with sibling
* profiles. Retained so existing v3 clients reading allow_template_sharing keep
* deserializing; it carries no information.
*/
allow_template_sharing?: boolean | null;
/**
* Billing model: profile, organization, or profile_and_organization
*/
billing_model?: string | null;
/**
* @deprecated Always false. A profile no longer inherits its organization's
* contacts. Retained so existing v3 clients reading inherit_contacts keep
* deserializing; it carries no information.
*/
inherit_contacts?: boolean | null;
/**
* Whether this profile inherits TCR brand from the organization
*/
inherit_tcr_brand?: boolean | null;
/**
* Whether this profile inherits TCR campaign from the organization
*/
inherit_tcr_campaign?: boolean | null;
/**
* @deprecated Always false. A profile no longer inherits its organization's
* templates. Retained so existing v3 clients reading inherit_templates keep
* deserializing; it carries no information.
*/
inherit_templates?: boolean | null;
}
/**
* Standard API response envelope for all v3 endpoints
*/
export interface MeRetrieveResponse {
/**
* Account response for GET /v3/me endpoint. Returns organization (with profiles),
* user (standalone), or profile (child of an organization) data depending on the
* API key type. Always includes messaging channel configuration.
*/
data?: MeRetrieveResponse.Data | null;
/**
* Error information
*/
error?: WebhooksAPI.ErrorDetail | null;
/**
* Request and response metadata
*/
meta?: WebhooksAPI.APIMeta;
/**
* Indicates whether the request was successful
*/
success?: boolean;
}
export namespace MeRetrieveResponse {
/**
* Account response for GET /v3/me endpoint. Returns organization (with profiles),
* user (standalone), or profile (child of an organization) data depending on the
* API key type. Always includes messaging channel configuration.
*/
export interface Data {
/**
* Customer ID (organization, account, or profile)
*/
id?: string;
/**
* Messaging channel configuration. All three channels are always present. Each
* channel has a "configured" flag; configured channels expose additional details.
*/
channels?: Data.Channels;
/**
* When the account was created
*/
created_at?: string;
/**
* Account description
*/
description?: string | null;
/**
* Contact email address
*/
email?: string | null;
/**
* Whether this account may mark a template for automatic creation on its sender
* profiles. Granted by Sent per account and off by default, so it is what a
* template-create form reads to decide whether to offer the option at all —
* marking a template without it does nothing.
*
* Top-level rather than inside settings, which is written for type: "profile" only
* and so would never carry it to the account type that can act on it.
*
* This is the capability, not the stored flag: a profile reports false whatever
* its own row holds. A sender profile owns no sender profiles, so a template it
* marked would have nothing to be created on and the fan-out would never read the
* flag. The admin GET /customers/{id} reports the stored value instead, because
* that is the one an operator granted.
*/
enable_template_auto_creation_for_sp?: boolean;
/**
* Account icon URL
*/
icon?: string | null;
/**
* Account name
*/
name?: string;
/**
* Organization ID (only for profile type — the parent organization)
*/
organization_id?: string | null;
/**
* List of profiles (populated for organization type, empty for user and profile
* types)
*/
profiles?: Array<Data.Profile>;
/**
* The SMS sender this account sends from in the United States, in E.164 form. Null
* when the account has no US SMS sender.
*
* The same value as channels.sms.phone_number, published under both names on
* purpose: sending_phone_number is what this value is already called on GET
* /v3/profiles, so the same key answers the same question whichever of the two
* endpoints you ask. Neither name is preferred over the other and neither is
* deprecated.
*
* The same value, not the same presence: this key is always written, including as
* null, whereas channels.sms.phone_number is left out entirely when there is no
* sender.
*/
sending_phone_number?: string | null;
/**
* The account that holds sending_phone_number in number inventory: normally this
* account itself, and a different account when the number is held elsewhere. Null
* when there is no US sender, or when the sender is not a number drawn from
* inventory — an alphanumeric sender ID or a short code.
*/
sending_phone_number_profile_id?: string | null;
/**
* Profile configuration settings
*/
settings?: MeAPI.ProfileSettings | null;
/**
* Short name / abbreviation (only for profile type)
*/
short_name?: string | null;
/**
* Profile status (only for profile type): incomplete, pending_review, approved,
* etc.
*/
status?: string | null;
/**
* Account type: "organization" (has profiles), "user" (no profiles), or "profile"
* (child of an organization)
*/
type?: string;
}
export namespace Data {
/**
* Messaging channel configuration. All three channels are always present. Each
* channel has a "configured" flag; configured channels expose additional details.
*/
export interface Channels {
/**
* RCS channel configuration. When configured, includes the RCS phone number.
*/
rcs?: Channels.Rcs;
/**
* SMS channel configuration. When configured, includes the sending phone number.
*/
sms?: Channels.SMS;
/**
* WhatsApp Business channel configuration. When configured, includes the WhatsApp
* phone number and business name.
*/
whatsapp?: Channels.Whatsapp;
}
export namespace Channels {
/**
* RCS channel configuration. When configured, includes the RCS phone number.
*/
export interface Rcs {
/**
* Whether RCS is configured for this account
*/
configured?: boolean;
/**
* RCS-enabled phone number in E.164 format
*/
phone_number?: string | null;
}
/**
* SMS channel configuration. When configured, includes the sending phone number.
*/
export interface SMS {
/**
* Whether SMS is configured for this account
*/
configured?: boolean;
/**
* Sending phone number in E.164 format
*/
phone_number?: string | null;
}
/**
* WhatsApp Business channel configuration. When configured, includes the WhatsApp
* phone number and business name.
*/
export interface Whatsapp {
/**
* WhatsApp Business display name
*/
business_name?: string | null;
/**
* Whether WhatsApp is configured for this account
*/
configured?: boolean;
/**
* WhatsApp phone number in E.164 format
*/
phone_number?: string | null;
}
}
/**
* Profile (sender profile) response for v3 API
*/
export interface Profile {
/**
* Profile unique identifier
*/
id?: string;
/**
* When the profile was created
*/
created_at?: string;
/**
* Profile description
*/
description?: string | null;
/**
* Profile icon URL
*/
icon?: string | null;
/**
* Profile name
*/
name?: string;
/**
* User's role in this profile: admin, billing, developer (inherited from
* organization if not explicitly set)
*/
role?: string | null;
/**
* Profile configuration settings
*/
settings?: MeAPI.ProfileSettings;
/**
* Profile short name (abbreviation)
*/
short_name?: string | null;
/**
* Profile setup status: incomplete, pending_review, approved, rejected
*/
status?: string | null;
}
}
}
export interface MeRetrieveParams {
/**
* Profile UUID to scope the request to a child profile. Only organization API keys
* can use this header. The profile must belong to the calling organization.
*/
'x-profile-id'?: string;
}
export declare namespace Me {
export {
type ProfileSettings as ProfileSettings,
type MeRetrieveResponse as MeRetrieveResponse,
type MeRetrieveParams as MeRetrieveParams,
};
}