-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontacts.ts
More file actions
293 lines (245 loc) · 6.42 KB
/
Copy pathcontacts.ts
File metadata and controls
293 lines (245 loc) · 6.42 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as IDAPI from './id';
import {
ID,
IDRetrieveIDResponse,
IDUpdateIDParams,
IDUpdateIDResponse,
IDUpdateMetadataParams,
IDUpdateMetadataResponse,
} from './id';
import * as OrganizationsAPI from './organizations/organizations';
import {
OrganizationCreateParams,
OrganizationCreateResponse,
Organizations,
} from './organizations/organizations';
import { APIPromise } from '../../core/api-promise';
import { RequestOptions } from '../../internal/request-options';
export class Contacts extends APIResource {
organizations: OrganizationsAPI.Organizations = new OrganizationsAPI.Organizations(this._client);
id: IDAPI.ID = new IDAPI.ID(this._client);
/**
* Creates a new contact for the website. If externalId is provided and already
* exists for the website, the contact is updated and returned.
*
* @example
* ```ts
* const contact = await client.contacts.create();
* ```
*/
create(
body: ContactCreateParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<ContactCreateResponse> {
return this._client.post('/v1/contacts', { body, ...options, __security: {} });
}
/**
* Creates or updates a contact for a visitor. If a contact with the same
* externalId or email exists, it will be updated. The visitor will be linked to
* the contact.
*
* @example
* ```ts
* const response = await client.contacts.identify({
* visitorId: '01JG000000000000000000000',
* });
* ```
*/
identify(body: ContactIdentifyParams, options?: RequestOptions): APIPromise<ContactIdentifyResponse> {
return this._client.post('/v1/contacts/identify', { body, ...options, __security: {} });
}
}
export interface ContactCreateResponse {
/**
* The contact's unique identifier (ULID).
*/
id: string;
/**
* The contact organization ID this contact belongs to.
*/
contactOrganizationId: string | null;
/**
* When the contact was first created.
*/
createdAt: string;
/**
* The contact's email address.
*/
email: string | null;
/**
* External identifier for the contact.
*/
externalId: string | null;
/**
* The contact's avatar/image URL.
*/
image: string | null;
/**
* Additional custom metadata for the contact.
*/
metadata: { [key: string]: string | number | boolean | null } | null;
/**
* The contact's name.
*/
name: string | null;
/**
* The organization's unique identifier that the contact belongs to.
*/
organizationId: string;
/**
* When the contact record was last updated.
*/
updatedAt: string;
/**
* The user ID if the contact is linked to a registered user.
*/
userId: string | null;
/**
* The website's unique identifier that the contact belongs to.
*/
websiteId: string;
}
export interface ContactIdentifyResponse {
contact: ContactIdentifyResponse.Contact;
/**
* The visitor ID that was linked to the contact.
*/
visitorId: string;
}
export namespace ContactIdentifyResponse {
export interface Contact {
/**
* The contact's unique identifier (ULID).
*/
id: string;
/**
* The contact organization ID this contact belongs to.
*/
contactOrganizationId: string | null;
/**
* When the contact was first created.
*/
createdAt: string;
/**
* The contact's email address.
*/
email: string | null;
/**
* External identifier for the contact.
*/
externalId: string | null;
/**
* The contact's avatar/image URL.
*/
image: string | null;
/**
* Additional custom metadata for the contact.
*/
metadata: { [key: string]: string | number | boolean | null } | null;
/**
* The contact's name.
*/
name: string | null;
/**
* The organization's unique identifier that the contact belongs to.
*/
organizationId: string;
/**
* When the contact record was last updated.
*/
updatedAt: string;
/**
* The user ID if the contact is linked to a registered user.
*/
userId: string | null;
/**
* The website's unique identifier that the contact belongs to.
*/
websiteId: string;
}
}
export interface ContactCreateParams {
/**
* The contact organization ID this contact belongs to.
*/
contactOrganizationId?: string;
/**
* The contact's email address.
*/
email?: string;
/**
* External identifier for the contact (e.g. from your CRM).
*/
externalId?: string;
/**
* The contact's avatar/image URL.
*/
image?: string;
/**
* Additional custom metadata for the contact.
*/
metadata?: { [key: string]: string | number | boolean | null };
/**
* The contact's name.
*/
name?: string;
}
export interface ContactIdentifyParams {
/**
* The visitor ID to link to the contact.
*/
visitorId: string;
/**
* Optional contact ID to update when linking the visitor to an existing contact.
*/
id?: string;
/**
* The contact organization ID this contact belongs to.
*/
contactOrganizationId?: string;
/**
* The contact's email address. Used to find existing contacts.
*/
email?: string;
/**
* External identifier for the contact. Used to find existing contacts.
*/
externalId?: string;
/**
* The contact's avatar/image URL.
*/
image?: string;
/**
* Additional custom metadata for the contact.
*/
metadata?: { [key: string]: string | number | boolean | null };
/**
* The contact's name.
*/
name?: string;
}
Contacts.Organizations = Organizations;
Contacts.ID = ID;
export declare namespace Contacts {
export {
type ContactCreateResponse as ContactCreateResponse,
type ContactIdentifyResponse as ContactIdentifyResponse,
type ContactCreateParams as ContactCreateParams,
type ContactIdentifyParams as ContactIdentifyParams,
};
export {
Organizations as Organizations,
type OrganizationCreateResponse as OrganizationCreateResponse,
type OrganizationCreateParams as OrganizationCreateParams,
};
export {
ID as ID,
type IDRetrieveIDResponse as IDRetrieveIDResponse,
type IDUpdateIDResponse as IDUpdateIDResponse,
type IDUpdateMetadataResponse as IDUpdateMetadataResponse,
type IDUpdateIDParams as IDUpdateIDParams,
type IDUpdateMetadataParams as IDUpdateMetadataParams,
};
}