@wix/crm 1.0.0 → 1.0.2

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 (79) hide show
  1. package/build/cjs/index.d.ts +4 -1
  2. package/build/cjs/index.js +5 -2
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/src/contacts-v4-contact.http.d.ts +192 -0
  5. package/build/cjs/src/contacts-v4-contact.http.js +522 -0
  6. package/build/cjs/src/contacts-v4-contact.http.js.map +1 -0
  7. package/build/cjs/src/contacts-v4-contact.public.d.ts +14 -0
  8. package/build/cjs/src/contacts-v4-contact.public.js +64 -0
  9. package/build/cjs/src/contacts-v4-contact.public.js.map +1 -0
  10. package/build/cjs/src/contacts-v4-contact.types.d.ts +1310 -0
  11. package/build/cjs/src/contacts-v4-contact.types.js +202 -0
  12. package/build/cjs/src/contacts-v4-contact.types.js.map +1 -0
  13. package/build/cjs/src/contacts-v4-contact.universal.d.ts +1663 -0
  14. package/build/cjs/src/contacts-v4-contact.universal.js +903 -0
  15. package/build/cjs/src/contacts-v4-contact.universal.js.map +1 -0
  16. package/build/cjs/src/contacts-v4-extended-field.http.d.ts +31 -0
  17. package/build/cjs/src/contacts-v4-extended-field.http.js +215 -0
  18. package/build/cjs/src/contacts-v4-extended-field.http.js.map +1 -0
  19. package/build/cjs/src/contacts-v4-extended-field.public.d.ts +12 -0
  20. package/build/cjs/src/contacts-v4-extended-field.public.js +40 -0
  21. package/build/cjs/src/contacts-v4-extended-field.public.js.map +1 -0
  22. package/build/cjs/src/contacts-v4-extended-field.types.d.ts +257 -0
  23. package/build/cjs/src/contacts-v4-extended-field.types.js +23 -0
  24. package/build/cjs/src/contacts-v4-extended-field.types.js.map +1 -0
  25. package/build/cjs/src/contacts-v4-extended-field.universal.d.ts +476 -0
  26. package/build/cjs/src/contacts-v4-extended-field.universal.js +393 -0
  27. package/build/cjs/src/contacts-v4-extended-field.universal.js.map +1 -0
  28. package/build/cjs/src/contacts-v4-label.http.d.ts +31 -0
  29. package/build/cjs/src/contacts-v4-label.http.js +191 -0
  30. package/build/cjs/src/contacts-v4-label.http.js.map +1 -0
  31. package/build/cjs/src/contacts-v4-label.public.d.ts +11 -0
  32. package/build/cjs/src/contacts-v4-label.public.js +33 -0
  33. package/build/cjs/src/contacts-v4-label.public.js.map +1 -0
  34. package/build/cjs/src/contacts-v4-label.types.d.ts +253 -0
  35. package/build/cjs/src/contacts-v4-label.types.js +17 -0
  36. package/build/cjs/src/contacts-v4-label.types.js.map +1 -0
  37. package/build/cjs/src/contacts-v4-label.universal.d.ts +442 -0
  38. package/build/cjs/src/contacts-v4-label.universal.js +326 -0
  39. package/build/cjs/src/contacts-v4-label.universal.js.map +1 -0
  40. package/build/es/index.d.ts +4 -1
  41. package/build/es/index.js +4 -1
  42. package/build/es/index.js.map +1 -1
  43. package/build/es/src/contacts-v4-contact.http.d.ts +192 -0
  44. package/build/es/src/contacts-v4-contact.http.js +512 -0
  45. package/build/es/src/contacts-v4-contact.http.js.map +1 -0
  46. package/build/es/src/contacts-v4-contact.public.d.ts +14 -0
  47. package/build/es/src/contacts-v4-contact.public.js +39 -0
  48. package/build/es/src/contacts-v4-contact.public.js.map +1 -0
  49. package/build/es/src/contacts-v4-contact.types.d.ts +1310 -0
  50. package/build/es/src/contacts-v4-contact.types.js +199 -0
  51. package/build/es/src/contacts-v4-contact.types.js.map +1 -0
  52. package/build/es/src/contacts-v4-contact.universal.d.ts +1663 -0
  53. package/build/es/src/contacts-v4-contact.universal.js +874 -0
  54. package/build/es/src/contacts-v4-contact.universal.js.map +1 -0
  55. package/build/es/src/contacts-v4-extended-field.http.d.ts +31 -0
  56. package/build/es/src/contacts-v4-extended-field.http.js +207 -0
  57. package/build/es/src/contacts-v4-extended-field.http.js.map +1 -0
  58. package/build/es/src/contacts-v4-extended-field.public.d.ts +12 -0
  59. package/build/es/src/contacts-v4-extended-field.public.js +29 -0
  60. package/build/es/src/contacts-v4-extended-field.public.js.map +1 -0
  61. package/build/es/src/contacts-v4-extended-field.types.d.ts +257 -0
  62. package/build/es/src/contacts-v4-extended-field.types.js +20 -0
  63. package/build/es/src/contacts-v4-extended-field.types.js.map +1 -0
  64. package/build/es/src/contacts-v4-extended-field.universal.d.ts +476 -0
  65. package/build/es/src/contacts-v4-extended-field.universal.js +366 -0
  66. package/build/es/src/contacts-v4-extended-field.universal.js.map +1 -0
  67. package/build/es/src/contacts-v4-label.http.d.ts +31 -0
  68. package/build/es/src/contacts-v4-label.http.js +184 -0
  69. package/build/es/src/contacts-v4-label.http.js.map +1 -0
  70. package/build/es/src/contacts-v4-label.public.d.ts +11 -0
  71. package/build/es/src/contacts-v4-label.public.js +24 -0
  72. package/build/es/src/contacts-v4-label.public.js.map +1 -0
  73. package/build/es/src/contacts-v4-label.types.d.ts +253 -0
  74. package/build/es/src/contacts-v4-label.types.js +14 -0
  75. package/build/es/src/contacts-v4-label.types.js.map +1 -0
  76. package/build/es/src/contacts-v4-label.universal.d.ts +442 -0
  77. package/build/es/src/contacts-v4-label.universal.js +300 -0
  78. package/build/es/src/contacts-v4-label.universal.js.map +1 -0
  79. package/package.json +2 -2
@@ -0,0 +1,903 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.getContact = exports.unlabelContact = exports.labelContact = exports.deleteContact = exports.mergeContacts = exports.updateContact = exports.createContact = exports.Mode = exports.SubmitOperation = exports.GetContactResponseType = exports.UpsertContactResponseAction = exports.Action = exports.ContactsFacetType = exports.ContactFieldSet = exports.SortOrder = exports.ImageProvider = exports.SubdivisionType = exports.AddressTag = exports.PhoneTag = exports.EmailTag = exports.ContactActivityType = exports.ContactSourceType = exports.__debug = void 0;
32
+ const velo_1 = require("@wix/metro-runtime/velo");
33
+ const ambassadorWixContactsV4Contact = __importStar(require("./contacts-v4-contact.http"));
34
+ let __verbose = false;
35
+ function __log(...args) {
36
+ __verbose && console.log(...args);
37
+ }
38
+ function __inspect(obj) {
39
+ return obj;
40
+ }
41
+ exports.__debug = {
42
+ verboseLogging: {
43
+ on: () => (__verbose = true),
44
+ off: () => (__verbose = false),
45
+ },
46
+ };
47
+ const _toVeloEntity = '$';
48
+ const _fromVeloEntity = '$';
49
+ var ContactSourceType;
50
+ (function (ContactSourceType) {
51
+ ContactSourceType["OTHER"] = "OTHER";
52
+ ContactSourceType["ADMIN"] = "ADMIN";
53
+ ContactSourceType["WIX_APP"] = "WIX_APP";
54
+ ContactSourceType["IMPORT"] = "IMPORT";
55
+ ContactSourceType["THIRD_PARTY"] = "THIRD_PARTY";
56
+ ContactSourceType["WIX_BOOKINGS"] = "WIX_BOOKINGS";
57
+ ContactSourceType["WIX_CHAT"] = "WIX_CHAT";
58
+ ContactSourceType["WIX_EMAIL_MARKETING"] = "WIX_EMAIL_MARKETING";
59
+ ContactSourceType["WIX_EVENTS"] = "WIX_EVENTS";
60
+ ContactSourceType["WIX_FORMS"] = "WIX_FORMS";
61
+ ContactSourceType["WIX_GROUPS"] = "WIX_GROUPS";
62
+ ContactSourceType["WIX_HOTELS"] = "WIX_HOTELS";
63
+ ContactSourceType["WIX_MARKET_PLACE"] = "WIX_MARKET_PLACE";
64
+ ContactSourceType["WIX_MUSIC"] = "WIX_MUSIC";
65
+ ContactSourceType["WIX_RESTAURANTS"] = "WIX_RESTAURANTS";
66
+ ContactSourceType["WIX_SITE_MEMBERS"] = "WIX_SITE_MEMBERS";
67
+ ContactSourceType["WIX_STORES"] = "WIX_STORES";
68
+ ContactSourceType["WIX_CODE"] = "WIX_CODE";
69
+ })(ContactSourceType = exports.ContactSourceType || (exports.ContactSourceType = {}));
70
+ var ContactActivityType;
71
+ (function (ContactActivityType) {
72
+ /** Last visit to your site (any unknown activity) */
73
+ ContactActivityType["GENERAL"] = "GENERAL";
74
+ /** This cannot be reported, used when contact created, will throw exception */
75
+ ContactActivityType["CONTACT_CREATED"] = "CONTACT_CREATED";
76
+ /** "auth/login" */
77
+ ContactActivityType["MEMBER_LOGIN"] = "MEMBER_LOGIN";
78
+ /** "auth/register" */
79
+ ContactActivityType["MEMBER_REGISTER"] = "MEMBER_REGISTER";
80
+ /** "auth/status-change" */
81
+ ContactActivityType["MEMBER_STATUS_CHANGED"] = "MEMBER_STATUS_CHANGED";
82
+ /** "contact/contact-form", (but also "form/contact-form", "form/form") */
83
+ ContactActivityType["FORM_SUBMITTED"] = "FORM_SUBMITTED";
84
+ /** "form/lead-capture-form" */
85
+ ContactActivityType["INBOX_FORM_SUBMITTED"] = "INBOX_FORM_SUBMITTED";
86
+ /** "chat/payment-request-paid" */
87
+ ContactActivityType["INBOX_PAYMENT_REQUEST_PAID"] = "INBOX_PAYMENT_REQUEST_PAID";
88
+ /** "messaging/email" - Direction BUSINESS_TO_CUSTOMER */
89
+ ContactActivityType["INBOX_MESSAGE_TO_CUSTOMER"] = "INBOX_MESSAGE_TO_CUSTOMER";
90
+ /** "messaging/email" - Direction CUSTOMER_TO_BUSINESS */
91
+ ContactActivityType["INBOX_MESSAGE_FROM_CUSTOMER"] = "INBOX_MESSAGE_FROM_CUSTOMER";
92
+ /** "contact/subscription-form" (but also "form/subscription-form") */
93
+ ContactActivityType["NEWSLETTER_SUBSCRIPTION_FORM_SUBMITTED"] = "NEWSLETTER_SUBSCRIPTION_FORM_SUBMITTED";
94
+ /** "contact/unsubscribe" */
95
+ ContactActivityType["NEWSLETTER_SUBSCRIPTION_UNSUBSCRIBE"] = "NEWSLETTER_SUBSCRIPTION_UNSUBSCRIBE";
96
+ /** "e_commerce/purchase" */
97
+ ContactActivityType["ECOM_PURCHASE"] = "ECOM_PURCHASE";
98
+ /** "e_commerce/cart-abandon" */
99
+ ContactActivityType["ECOM_CART_ABANDON"] = "ECOM_CART_ABANDON";
100
+ /** "e_commerce/checkout-buyer" */
101
+ ContactActivityType["ECOM_CHECKOUT_BUYER"] = "ECOM_CHECKOUT_BUYER";
102
+ /** "scheduler/appointment" */
103
+ ContactActivityType["BOOKINGS_APPOINTMENT"] = "BOOKINGS_APPOINTMENT";
104
+ /** "hotels/reservation" */
105
+ ContactActivityType["HOTELS_RESERVATION"] = "HOTELS_RESERVATION";
106
+ /** "hotels/purchase" */
107
+ ContactActivityType["HOTELS_PURCHASE"] = "HOTELS_PURCHASE";
108
+ /** "hotels/confirmation" */
109
+ ContactActivityType["HOTELS_CONFIRMATION"] = "HOTELS_CONFIRMATION";
110
+ /** "hotels/cancel" */
111
+ ContactActivityType["HOTELS_CANCEL"] = "HOTELS_CANCEL";
112
+ /** "video/purchase" */
113
+ ContactActivityType["VIDEO_PURCHASE"] = "VIDEO_PURCHASE";
114
+ /** "video/rent" */
115
+ ContactActivityType["VIDEO_RENT"] = "VIDEO_RENT";
116
+ /** "cashier/button_purchase" */
117
+ ContactActivityType["CASHIER_BUTTON_PURCHASE"] = "CASHIER_BUTTON_PURCHASE";
118
+ /** "arena/new-lead" */
119
+ ContactActivityType["ARENA_NEW_LEAD"] = "ARENA_NEW_LEAD";
120
+ /** "events/rsvp" */
121
+ ContactActivityType["EVENTS_RSVP"] = "EVENTS_RSVP";
122
+ /** "invoice/pay" */
123
+ ContactActivityType["INVOICE_PAY"] = "INVOICE_PAY";
124
+ /** "invoice/overdue" */
125
+ ContactActivityType["INVOICE_OVERDUE"] = "INVOICE_OVERDUE";
126
+ /** "price-quote/accept" */
127
+ ContactActivityType["PRICE_QUOTE_ACCEPT"] = "PRICE_QUOTE_ACCEPT";
128
+ /** "price-quote/expire" */
129
+ ContactActivityType["PRICE_QUOTE_EXPIRE"] = "PRICE_QUOTE_EXPIRE";
130
+ /** "restaurants/order" */
131
+ ContactActivityType["RESTAURANTS_ORDER"] = "RESTAURANTS_ORDER";
132
+ /** "restaurants/reservation" */
133
+ ContactActivityType["RESTAURANTS_RESERVATION"] = "RESTAURANTS_RESERVATION";
134
+ /** "shoutout/open" */
135
+ ContactActivityType["SHOUTOUT_OPEN"] = "SHOUTOUT_OPEN";
136
+ /** "shoutout/click" */
137
+ ContactActivityType["SHOUTOUT_CLICK"] = "SHOUTOUT_CLICK";
138
+ ContactActivityType["CONTACT_MERGED"] = "CONTACT_MERGED";
139
+ })(ContactActivityType = exports.ContactActivityType || (exports.ContactActivityType = {}));
140
+ var EmailTag;
141
+ (function (EmailTag) {
142
+ EmailTag["UNTAGGED"] = "UNTAGGED";
143
+ EmailTag["MAIN"] = "MAIN";
144
+ EmailTag["HOME"] = "HOME";
145
+ EmailTag["WORK"] = "WORK";
146
+ })(EmailTag = exports.EmailTag || (exports.EmailTag = {}));
147
+ var PhoneTag;
148
+ (function (PhoneTag) {
149
+ PhoneTag["UNTAGGED"] = "UNTAGGED";
150
+ PhoneTag["MAIN"] = "MAIN";
151
+ PhoneTag["HOME"] = "HOME";
152
+ PhoneTag["MOBILE"] = "MOBILE";
153
+ PhoneTag["WORK"] = "WORK";
154
+ PhoneTag["FAX"] = "FAX";
155
+ })(PhoneTag = exports.PhoneTag || (exports.PhoneTag = {}));
156
+ var AddressTag;
157
+ (function (AddressTag) {
158
+ AddressTag["UNTAGGED"] = "UNTAGGED";
159
+ AddressTag["HOME"] = "HOME";
160
+ AddressTag["WORK"] = "WORK";
161
+ AddressTag["BILLING"] = "BILLING";
162
+ AddressTag["SHIPPING"] = "SHIPPING";
163
+ })(AddressTag = exports.AddressTag || (exports.AddressTag = {}));
164
+ var SubdivisionType;
165
+ (function (SubdivisionType) {
166
+ SubdivisionType["UNKNOWN_SUBDIVISION_TYPE"] = "UNKNOWN_SUBDIVISION_TYPE";
167
+ /** state */
168
+ SubdivisionType["ADMINISTRATIVE_AREA_LEVEL_1"] = "ADMINISTRATIVE_AREA_LEVEL_1";
169
+ /** county */
170
+ SubdivisionType["ADMINISTRATIVE_AREA_LEVEL_2"] = "ADMINISTRATIVE_AREA_LEVEL_2";
171
+ /** cities/towns */
172
+ SubdivisionType["ADMINISTRATIVE_AREA_LEVEL_3"] = "ADMINISTRATIVE_AREA_LEVEL_3";
173
+ /** neighborhood/quarter */
174
+ SubdivisionType["ADMINISTRATIVE_AREA_LEVEL_4"] = "ADMINISTRATIVE_AREA_LEVEL_4";
175
+ /** street/block */
176
+ SubdivisionType["ADMINISTRATIVE_AREA_LEVEL_5"] = "ADMINISTRATIVE_AREA_LEVEL_5";
177
+ /** (ADMINISTRATIVE_AREA_LEVEL_0) indicates the national political entity, and is typically the highest order type returned by the Geocoder. */
178
+ SubdivisionType["COUNTRY"] = "COUNTRY";
179
+ })(SubdivisionType = exports.SubdivisionType || (exports.SubdivisionType = {}));
180
+ var ImageProvider;
181
+ (function (ImageProvider) {
182
+ ImageProvider["UNKNOWN"] = "UNKNOWN";
183
+ /** Image stored outside Wix */
184
+ ImageProvider["EXTERNAL"] = "EXTERNAL";
185
+ /** Stored in wix media platform, Must be uploaded by using `GeneratePictureUploadUrl` */
186
+ ImageProvider["WIX_MEDIA"] = "WIX_MEDIA";
187
+ })(ImageProvider = exports.ImageProvider || (exports.ImageProvider = {}));
188
+ var SortOrder;
189
+ (function (SortOrder) {
190
+ SortOrder["ASC"] = "ASC";
191
+ SortOrder["DESC"] = "DESC";
192
+ })(SortOrder = exports.SortOrder || (exports.SortOrder = {}));
193
+ var ContactFieldSet;
194
+ (function (ContactFieldSet) {
195
+ /** name, primaryEmail, primaryPhone */
196
+ ContactFieldSet["BASIC"] = "BASIC";
197
+ /** name, phones, emails, addressses */
198
+ ContactFieldSet["COMMUNICATION_DETAILS"] = "COMMUNICATION_DETAILS";
199
+ /** name, primaryInfo(email, phone), extendedFields */
200
+ ContactFieldSet["EXTENDED"] = "EXTENDED";
201
+ /** Full contact object */
202
+ ContactFieldSet["FULL"] = "FULL";
203
+ })(ContactFieldSet = exports.ContactFieldSet || (exports.ContactFieldSet = {}));
204
+ var ContactsFacetType;
205
+ (function (ContactsFacetType) {
206
+ ContactsFacetType["UNKNOWN"] = "UNKNOWN";
207
+ ContactsFacetType["ALL_CONTACTS"] = "ALL_CONTACTS";
208
+ ContactsFacetType["NOT_LABELED"] = "NOT_LABELED";
209
+ ContactsFacetType["LABEL"] = "LABEL";
210
+ ContactsFacetType["SUBSCRIPTION_STATUS"] = "SUBSCRIPTION_STATUS";
211
+ ContactsFacetType["MEMBERSHIP_STATUS"] = "MEMBERSHIP_STATUS";
212
+ })(ContactsFacetType = exports.ContactsFacetType || (exports.ContactsFacetType = {}));
213
+ var Action;
214
+ (function (Action) {
215
+ Action["UNKNOWN"] = "UNKNOWN";
216
+ Action["UPDATED"] = "UPDATED";
217
+ Action["CREATED"] = "CREATED";
218
+ })(Action = exports.Action || (exports.Action = {}));
219
+ var UpsertContactResponseAction;
220
+ (function (UpsertContactResponseAction) {
221
+ UpsertContactResponseAction["UNKNOWN"] = "UNKNOWN";
222
+ UpsertContactResponseAction["UPDATED"] = "UPDATED";
223
+ UpsertContactResponseAction["CREATED"] = "CREATED";
224
+ })(UpsertContactResponseAction = exports.UpsertContactResponseAction || (exports.UpsertContactResponseAction = {}));
225
+ var GetContactResponseType;
226
+ (function (GetContactResponseType) {
227
+ /** Normal contact */
228
+ GetContactResponseType["REGULAR"] = "REGULAR";
229
+ /** Contact that id was already allocated for it, but the contact not yet created. */
230
+ GetContactResponseType["IMPLICIT"] = "IMPLICIT";
231
+ /** Contact was merged into another contact */
232
+ GetContactResponseType["MERGED"] = "MERGED";
233
+ })(GetContactResponseType = exports.GetContactResponseType || (exports.GetContactResponseType = {}));
234
+ var SubmitOperation;
235
+ (function (SubmitOperation) {
236
+ SubmitOperation["UNKNOWN"] = "UNKNOWN";
237
+ SubmitOperation["CREATE"] = "CREATE";
238
+ SubmitOperation["UPDATE"] = "UPDATE";
239
+ })(SubmitOperation = exports.SubmitOperation || (exports.SubmitOperation = {}));
240
+ var Mode;
241
+ (function (Mode) {
242
+ /** any */
243
+ Mode["OR"] = "OR";
244
+ /** all */
245
+ Mode["AND"] = "AND";
246
+ })(Mode = exports.Mode || (exports.Mode = {}));
247
+ const _contact = { picture: 'wix.common.Image', info: '_contactInfo' };
248
+ const _contactAddress = { address: 'wix.common.Address' };
249
+ const _contactAddressesWrapper = { items: '_contactAddress' };
250
+ const _contactInfo = {
251
+ addresses: '_contactAddressesWrapper',
252
+ picture: '_contactPicture',
253
+ };
254
+ const _contactPicture = { image: 'wix.common.Image' };
255
+ const _createContactRequest = { info: '_contactInfo' };
256
+ const _createContactResponse = { contact: '_contact' };
257
+ const _deleteContactRequest = {};
258
+ const _deleteContactResponse = {};
259
+ const _getContactRequest = {};
260
+ const _getContactResponse = { contact: '_contact' };
261
+ const _labelContactRequest = {};
262
+ const _labelContactResponse = { contact: '_contact' };
263
+ const _mergeContactsRequest = {};
264
+ const _mergeContactsResponse = { contact: '_contact' };
265
+ const _unlabelContactRequest = {};
266
+ const _unlabelContactResponse = { contact: '_contact' };
267
+ const _updateContactRequest = { info: '_contactInfo' };
268
+ const _updateContactResponse = { contact: '_contact' };
269
+ /**
270
+ * Creates a new contact.
271
+ *
272
+ *
273
+ * The `createContact()` function returns a Promise
274
+ * that resolves to the new contact when it is created.
275
+ * > **Note:**
276
+ * > This function replaces the deprecated
277
+ * > `wixCrmBackend.createContact()`.
278
+ * > The deprecated function will continue to work, but it will not receive updates.
279
+ * > To keep any existing code compatible with future changes, see the
280
+ * > [migration instructions](wix-crm-backend/createcontact#migration-instructions).
281
+ *
282
+ * The `contactInfo` parameter object must include a name, phone number, or email address.
283
+ * If all 3 of these parameters are missing,
284
+ * the contact won't be created.
285
+ *
286
+ * <!--
287
+ * > **Note:**
288
+ * > Only visitors with
289
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
290
+ * > can create contacts.
291
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
292
+ * -->
293
+ * By default,
294
+ * if the call contains an email already in use by another contact,
295
+ * the new contact won't be created.
296
+ * To override this behavior,
297
+ * set `allowDuplicates` in the `options` object to `true`.
298
+ *
299
+ * This function is not a universal function and runs only on the backend.
300
+ * @param info - Contact info.
301
+ * @public
302
+ * @documentationMaturity preview
303
+ * @requiredField info
304
+ * @param options - Create contact options.
305
+ * @returns Contact.
306
+ */
307
+ function createContact(info, options) {
308
+ var _a, _b, _c;
309
+ return __awaiter(this, arguments, void 0, function* () {
310
+ const requestTransformation = {
311
+ info: '$[0]',
312
+ allowDuplicates: '$[1].allowDuplicates',
313
+ };
314
+ const responseTransformation = '$';
315
+ // @ts-ignore
316
+ const { httpClient, sideEffects } = arguments[2];
317
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
318
+ rootSchema: _createContactRequest,
319
+ depSchemas: {
320
+ _contactAddress,
321
+ _contactAddressesWrapper,
322
+ _contactInfo,
323
+ _contactPicture,
324
+ },
325
+ fqdnTransformation: {
326
+ paths: [],
327
+ transformation: _fromVeloEntity,
328
+ },
329
+ customTransformation: requestTransformation,
330
+ });
331
+ const { fromJSON } = (0, velo_1.serializer)({
332
+ rootSchema: _createContactResponse,
333
+ depSchemas: {
334
+ _contact,
335
+ _contactAddress,
336
+ _contactAddressesWrapper,
337
+ _contactInfo,
338
+ _contactPicture,
339
+ },
340
+ fqdnTransformation: {
341
+ paths: [...['contact']],
342
+ transformation: _toVeloEntity,
343
+ },
344
+ customTransformation: responseTransformation,
345
+ });
346
+ const payload = toAmbassadorRequest([info, options]);
347
+ const reqOpts = ambassadorWixContactsV4Contact.createContact(payload);
348
+ __log(`"CreateContact" sending request with: ${__inspect(reqOpts)}`);
349
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
350
+ try {
351
+ const result = yield httpClient.request(reqOpts);
352
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
353
+ return fromJSON(result.data);
354
+ }
355
+ catch (err) {
356
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
357
+ 'info',
358
+ 'options',
359
+ ]);
360
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
361
+ throw transformedError;
362
+ }
363
+ });
364
+ }
365
+ exports.createContact = createContact;
366
+ /**
367
+ * Updates a contact's properties.
368
+ *
369
+ * The `updateContact()` function returns a Promise that resolves
370
+ * when the specified contact's information is updated.
371
+ *
372
+ * > **Note:**
373
+ * > This function replaces the deprecated
374
+ * > `wixCrmBackend.updateContact()`.
375
+ * > The deprecated function will continue to work, but it will not receive updates.
376
+ * > To keep any existing code compatible with future changes, see the
377
+ * > [migration instructions](wix-crm-backend/updatecontact#migration-instructions).
378
+ *
379
+ * Each time the contact is updated,
380
+ * `revision` increments by 1.
381
+ * The existing `revision` must be included when updating the contact.
382
+ * This ensures you're working with the latest contact information,
383
+ * and it prevents unintended overwrites.
384
+ *
385
+ * <!--
386
+ * > **Note:**
387
+ * > Only visitors with
388
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
389
+ * > can update contacts.
390
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
391
+ * -->
392
+ *
393
+ * This function is not a universal function and runs only on the backend.
394
+ * @param contactId - ID of the contact to update.
395
+ * @param info - Contact info.
396
+ * @public
397
+ * @documentationMaturity preview
398
+ * @requiredField contactId
399
+ * @requiredField info
400
+ * @requiredField options
401
+ * @requiredField options.revision
402
+ * @param options - Contact update options.
403
+ * @returns Updated contact.
404
+ */
405
+ function updateContact(contactId, info, options) {
406
+ var _a, _b, _c;
407
+ return __awaiter(this, arguments, void 0, function* () {
408
+ const requestTransformation = {
409
+ contactId: '$[0]',
410
+ info: '$[1]',
411
+ revision: '$[2].revision',
412
+ allowDuplicates: '$[2].allowDuplicates',
413
+ };
414
+ const responseTransformation = '$';
415
+ // @ts-ignore
416
+ const { httpClient, sideEffects } = arguments[3];
417
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
418
+ rootSchema: _updateContactRequest,
419
+ depSchemas: {
420
+ _contactAddress,
421
+ _contactAddressesWrapper,
422
+ _contactInfo,
423
+ _contactPicture,
424
+ },
425
+ fqdnTransformation: {
426
+ paths: [],
427
+ transformation: _fromVeloEntity,
428
+ },
429
+ customTransformation: requestTransformation,
430
+ });
431
+ const { fromJSON } = (0, velo_1.serializer)({
432
+ rootSchema: _updateContactResponse,
433
+ depSchemas: {
434
+ _contact,
435
+ _contactAddress,
436
+ _contactAddressesWrapper,
437
+ _contactInfo,
438
+ _contactPicture,
439
+ },
440
+ fqdnTransformation: {
441
+ paths: [...['contact']],
442
+ transformation: _toVeloEntity,
443
+ },
444
+ customTransformation: responseTransformation,
445
+ });
446
+ const payload = toAmbassadorRequest([contactId, info, options]);
447
+ const reqOpts = ambassadorWixContactsV4Contact.updateContact(payload);
448
+ __log(`"UpdateContact" sending request with: ${__inspect(reqOpts)}`);
449
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
450
+ try {
451
+ const result = yield httpClient.request(reqOpts);
452
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
453
+ return fromJSON(result.data);
454
+ }
455
+ catch (err) {
456
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
457
+ 'contactId',
458
+ 'info',
459
+ 'options',
460
+ ]);
461
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
462
+ throw transformedError;
463
+ }
464
+ });
465
+ }
466
+ exports.updateContact = updateContact;
467
+ /**
468
+ * Merges source contacts into a target contact.
469
+ *
470
+ * Merging contacts has these effects on the target contact:
471
+ *
472
+ * - No target contact data is overwritten or deleted.
473
+ * - Arrays (emails, phones, addresses, and labels) are merged from the source contacts.
474
+ * - If merging more than one source contact, the 1st source is given precedence, then the 2nd, and so on.
475
+ *
476
+ * <blockquote class="important">
477
+ *
478
+ * __Important:__
479
+ * Merges cannot be undone.
480
+ * Use [Preview Merge Contacts](#preview-merge-contacts)
481
+ * to test before merging.
482
+ *
483
+ * </blockquote>
484
+ *
485
+ * Source contacts are deleted when merging.
486
+ * However, if a source contact is a site member or contributor,
487
+ * the merge fails because site contributors and members can't be deleted.
488
+ * Site members and contributors can be target contacts only.
489
+ *
490
+ * After merging,
491
+ * if you call [Get Contact](#get-contact) with a deleted source contact ID,
492
+ * the target contact ID is returned.
493
+ * This is supported when calling Get Contact only.
494
+ * Deleted source contact IDs are not supported on any other endpoint.
495
+ *
496
+ * Merging contacts triggers these webhooks:
497
+ *
498
+ * - [Contact Merged](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/contact-merged-webhook) is triggered.
499
+ * - [Contact Updated](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/contact-updated-webhook) is triggered for the target contact. `originatedFrom` is set to `merge`.
500
+ * - [Contact Deleted](https://dev.wix.com/api/rest/contacts/contacts/contacts-v4/contact-deleted-webhook) is triggered for each source contact. `originatedFrom` is set to `merge`.
501
+ *
502
+ * This function is not a universal function and runs only on the backend.
503
+ * @param targetContactId - Target contact ID.
504
+ * @param targetContactRevision - Target contact revision number, which increments by 1 each time the contact is updated.
505
+ * To prevent conflicting changes,
506
+ * the target contact's current revision must be passed.
507
+ * @public
508
+ * @documentationMaturity preview
509
+ * @requiredField targetContactId
510
+ * @requiredField targetContactRevision
511
+ * @param options - Merge contacts options.
512
+ */
513
+ function mergeContacts(targetContactId, targetContactRevision, options) {
514
+ var _a, _b, _c;
515
+ return __awaiter(this, arguments, void 0, function* () {
516
+ const requestTransformation = {
517
+ targetContactId: '$[0]',
518
+ targetContactRevision: '$[1]',
519
+ sourceContactIds: '$[2].sourceContactIds',
520
+ };
521
+ const responseTransformation = '$';
522
+ // @ts-ignore
523
+ const { httpClient, sideEffects } = arguments[3];
524
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
525
+ rootSchema: _mergeContactsRequest,
526
+ depSchemas: {},
527
+ fqdnTransformation: {
528
+ paths: [],
529
+ transformation: _fromVeloEntity,
530
+ },
531
+ customTransformation: requestTransformation,
532
+ });
533
+ const { fromJSON } = (0, velo_1.serializer)({
534
+ rootSchema: _mergeContactsResponse,
535
+ depSchemas: {
536
+ _contact,
537
+ _contactAddress,
538
+ _contactAddressesWrapper,
539
+ _contactInfo,
540
+ _contactPicture,
541
+ },
542
+ fqdnTransformation: {
543
+ paths: [...['contact']],
544
+ transformation: _toVeloEntity,
545
+ },
546
+ customTransformation: responseTransformation,
547
+ });
548
+ const payload = toAmbassadorRequest([
549
+ targetContactId,
550
+ targetContactRevision,
551
+ options,
552
+ ]);
553
+ const reqOpts = ambassadorWixContactsV4Contact.mergeContacts(payload);
554
+ __log(`"MergeContacts" sending request with: ${__inspect(reqOpts)}`);
555
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
556
+ try {
557
+ const result = yield httpClient.request(reqOpts);
558
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
559
+ return fromJSON(result.data);
560
+ }
561
+ catch (err) {
562
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
563
+ 'targetContactId',
564
+ 'targetContactRevision',
565
+ 'options',
566
+ ]);
567
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
568
+ throw transformedError;
569
+ }
570
+ });
571
+ }
572
+ exports.mergeContacts = mergeContacts;
573
+ /**
574
+ * Deletes a contact who is not a site member or contributor.
575
+ *
576
+ * The `deleteContact()` function returns a Promise
577
+ * that resolves when the specified contact is deleted.
578
+ * > **Note:**
579
+ * > This function replaces the deprecated
580
+ * > `wixCrmBackend.deleteContact()`.
581
+ * > The deprecated function will continue to work, but it will not receive updates.
582
+ * > To keep any existing code compatible with future changes, see the
583
+ * > [migration instructions](wix-crm-backend/deletecontact#migration-instructions).
584
+ *
585
+ * Deleting a contact permanently removes them from your Contact List.
586
+ *
587
+ * If the contact is also a site member,
588
+ * the member must be deleted first,
589
+ * and then the contact can be deleted.
590
+ *
591
+ * <!--
592
+ * > **Note:**
593
+ * > Only visitors with
594
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
595
+ * > can delete contacts.
596
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
597
+ * -->
598
+ *
599
+ * This function is not a universal function and runs only on the backend.
600
+ * @param contactId - ID of the contact to delete.
601
+ * @public
602
+ * @documentationMaturity preview
603
+ * @requiredField contactId
604
+ */
605
+ function deleteContact(contactId) {
606
+ var _a, _b, _c;
607
+ return __awaiter(this, arguments, void 0, function* () {
608
+ const requestTransformation = { contactId: '$[0]' };
609
+ const responseTransformation = '$';
610
+ // @ts-ignore
611
+ const { httpClient, sideEffects } = arguments[1];
612
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
613
+ rootSchema: _deleteContactRequest,
614
+ depSchemas: {},
615
+ fqdnTransformation: {
616
+ paths: [],
617
+ transformation: _fromVeloEntity,
618
+ },
619
+ customTransformation: requestTransformation,
620
+ });
621
+ const { fromJSON } = (0, velo_1.serializer)({
622
+ rootSchema: _deleteContactResponse,
623
+ depSchemas: {},
624
+ fqdnTransformation: {
625
+ paths: [],
626
+ transformation: _toVeloEntity,
627
+ },
628
+ customTransformation: responseTransformation,
629
+ });
630
+ const payload = toAmbassadorRequest([contactId]);
631
+ const reqOpts = ambassadorWixContactsV4Contact.deleteContact(payload);
632
+ __log(`"DeleteContact" sending request with: ${__inspect(reqOpts)}`);
633
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
634
+ try {
635
+ const result = yield httpClient.request(reqOpts);
636
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
637
+ return fromJSON(result.data);
638
+ }
639
+ catch (err) {
640
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
641
+ 'contactId',
642
+ ]);
643
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
644
+ throw transformedError;
645
+ }
646
+ });
647
+ }
648
+ exports.deleteContact = deleteContact;
649
+ /**
650
+ * Adds labels to a contact.
651
+ *
652
+ *
653
+ * The `labelContact()` function returns a Promise
654
+ * that resolves when the specified labels are added to the contact.
655
+ * - **To create new labels:** Use [`findOrCreateLabel()`](wix-crm-backend/contacts/findorcreatelabel).
656
+ * - **To find labels:** Use [`findOrCreateLabel()`](wix-crm-backend/contacts/findorcreatelabel), [`getLabel()`](wix-crm-backend/contacts/getlabel), or [`queryLabels()`](wix-crm-backend/contacts/queryLabels).
657
+ *
658
+ * <!--
659
+ * > **Note:**
660
+ * > Only visitors with
661
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
662
+ * > can label contacts.
663
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
664
+ * -->
665
+ *
666
+ * This function is not a universal function and runs only on the backend.
667
+ * @param contactId - ID of the contact to add labels to.
668
+ * @param labelKeys - List of label keys to add to the contact.
669
+ *
670
+ * Label keys must exist to be added to the contact.
671
+ * Contact labels can be created or retrieved with
672
+ * [`findOrCreateLabel()`](wix-crm-backend/contacts/findorcreatelabel)
673
+ * or
674
+ * [`queryLabels()`](wix-crm-backend/contacts/queryLabels).
675
+ * @public
676
+ * @documentationMaturity preview
677
+ * @requiredField contactId
678
+ * @requiredField labelKeys
679
+ * @returns Updated contact.
680
+ */
681
+ function labelContact(contactId, labelKeys) {
682
+ var _a, _b, _c;
683
+ return __awaiter(this, arguments, void 0, function* () {
684
+ const requestTransformation = { contactId: '$[0]', labelKeys: '$[1]' };
685
+ const responseTransformation = '$';
686
+ // @ts-ignore
687
+ const { httpClient, sideEffects } = arguments[2];
688
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
689
+ rootSchema: _labelContactRequest,
690
+ depSchemas: {},
691
+ fqdnTransformation: {
692
+ paths: [],
693
+ transformation: _fromVeloEntity,
694
+ },
695
+ customTransformation: requestTransformation,
696
+ });
697
+ const { fromJSON } = (0, velo_1.serializer)({
698
+ rootSchema: _labelContactResponse,
699
+ depSchemas: {
700
+ _contact,
701
+ _contactAddress,
702
+ _contactAddressesWrapper,
703
+ _contactInfo,
704
+ _contactPicture,
705
+ },
706
+ fqdnTransformation: {
707
+ paths: [...['contact']],
708
+ transformation: _toVeloEntity,
709
+ },
710
+ customTransformation: responseTransformation,
711
+ });
712
+ const payload = toAmbassadorRequest([contactId, labelKeys]);
713
+ const reqOpts = ambassadorWixContactsV4Contact.labelContact(payload);
714
+ __log(`"LabelContact" sending request with: ${__inspect(reqOpts)}`);
715
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
716
+ try {
717
+ const result = yield httpClient.request(reqOpts);
718
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
719
+ return fromJSON(result.data);
720
+ }
721
+ catch (err) {
722
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
723
+ 'contactId',
724
+ 'labelKeys',
725
+ ]);
726
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
727
+ throw transformedError;
728
+ }
729
+ });
730
+ }
731
+ exports.labelContact = labelContact;
732
+ /**
733
+ * Removes labels from a contact.
734
+ *
735
+ * The `unlabelContact()` function returns a Promise
736
+ * that resolves when the specified labels are removed from the contact.
737
+ *
738
+ * If a label is no longer needed
739
+ * and you want to remove it from all contacts,
740
+ * you can delete it with
741
+ * [`deleteLabel()`](wix-crm-backend/contacts/deletelabel).
742
+ *
743
+ * <!--
744
+ * > **Note:**
745
+ * > Only visitors with
746
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
747
+ * > can unlabel contacts.
748
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
749
+ * -->
750
+ *
751
+ * This function is not a universal function and runs only on the backend.
752
+ * @param contactId - ID of the contact to remove labels from.
753
+ * @param labelKeys - List of label keys to remove from the contact.
754
+ * @public
755
+ * @documentationMaturity preview
756
+ * @requiredField contactId
757
+ * @requiredField labelKeys
758
+ * @returns Updated contact.
759
+ */
760
+ function unlabelContact(contactId, labelKeys) {
761
+ var _a, _b, _c;
762
+ return __awaiter(this, arguments, void 0, function* () {
763
+ const requestTransformation = { contactId: '$[0]', labelKeys: '$[1]' };
764
+ const responseTransformation = '$';
765
+ // @ts-ignore
766
+ const { httpClient, sideEffects } = arguments[2];
767
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
768
+ rootSchema: _unlabelContactRequest,
769
+ depSchemas: {},
770
+ fqdnTransformation: {
771
+ paths: [],
772
+ transformation: _fromVeloEntity,
773
+ },
774
+ customTransformation: requestTransformation,
775
+ });
776
+ const { fromJSON } = (0, velo_1.serializer)({
777
+ rootSchema: _unlabelContactResponse,
778
+ depSchemas: {
779
+ _contact,
780
+ _contactAddress,
781
+ _contactAddressesWrapper,
782
+ _contactInfo,
783
+ _contactPicture,
784
+ },
785
+ fqdnTransformation: {
786
+ paths: [...['contact']],
787
+ transformation: _toVeloEntity,
788
+ },
789
+ customTransformation: responseTransformation,
790
+ });
791
+ const payload = toAmbassadorRequest([contactId, labelKeys]);
792
+ const reqOpts = ambassadorWixContactsV4Contact.unlabelContact(payload);
793
+ __log(`"UnlabelContact" sending request with: ${__inspect(reqOpts)}`);
794
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
795
+ try {
796
+ const result = yield httpClient.request(reqOpts);
797
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
798
+ return fromJSON(result.data);
799
+ }
800
+ catch (err) {
801
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
802
+ 'contactId',
803
+ 'labelKeys',
804
+ ]);
805
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
806
+ throw transformedError;
807
+ }
808
+ });
809
+ }
810
+ exports.unlabelContact = unlabelContact;
811
+ /**
812
+ * Retrieves a contact.
813
+ *
814
+ *
815
+ * The `getContact()` function returns a Promise
816
+ * that resolves when the contact is found.
817
+ * #### Getting Merged Contacts
818
+ * When a source contact is merged
819
+ * with a target contact, the source contact is deleted.
820
+ * When calling `getContact()` for a merged contact,
821
+ * you can use the source or target contact ID.
822
+ * In both cases, the target contact is returned.
823
+ *
824
+ * This is supported only when calling `getContact()`,
825
+ * and only for merged contacts.
826
+ * Deleted source contact IDs are not supported on any other function.
827
+ * > **Notes:**
828
+ * >
829
+ * > - This function replaces the deprecated
830
+ * > `wixCrmBackend.getContactById()`.
831
+ * > The deprecated function will continue to work, but it will not receive updates.
832
+ * > To keep any existing code compatible with future changes, see the
833
+ * > [migration instructions](wix-crm-backend/getcontactbyid#migration-instructions).
834
+ * <!-- > - Only visitors with
835
+ * > **Manage Contacts** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions)
836
+ * > can retrieve contacts.
837
+ * > You can override the permissions by setting the `suppressAuth` option to `true`.
838
+ * -->
839
+ *
840
+ * This function is not a universal function and runs only on the backend.
841
+ * @param _id - ID of the contact to retrieve.
842
+ * @public
843
+ * @documentationMaturity preview
844
+ * @requiredField _id
845
+ * @param options - Get contact options.
846
+ * @returns The requested contact.
847
+ */
848
+ function getContact(_id, options) {
849
+ var _a, _b, _c;
850
+ return __awaiter(this, arguments, void 0, function* () {
851
+ const requestTransformation = {
852
+ id: '$[0]',
853
+ fields: '$[1].fields',
854
+ fieldsets: '$[1].fieldsets',
855
+ };
856
+ const responseTransformation = '$.contact';
857
+ // @ts-ignore
858
+ const { httpClient, sideEffects } = arguments[2];
859
+ const { toAmbassadorRequest } = (0, velo_1.serializer)({
860
+ rootSchema: _getContactRequest,
861
+ depSchemas: {},
862
+ fqdnTransformation: {
863
+ paths: [],
864
+ transformation: _fromVeloEntity,
865
+ },
866
+ customTransformation: requestTransformation,
867
+ });
868
+ const { fromJSON } = (0, velo_1.serializer)({
869
+ rootSchema: _getContactResponse,
870
+ depSchemas: {
871
+ _contact,
872
+ _contactAddress,
873
+ _contactAddressesWrapper,
874
+ _contactInfo,
875
+ _contactPicture,
876
+ },
877
+ fqdnTransformation: {
878
+ paths: [...['contact']],
879
+ transformation: _toVeloEntity,
880
+ },
881
+ customTransformation: responseTransformation,
882
+ });
883
+ const payload = toAmbassadorRequest([_id, options]);
884
+ const reqOpts = ambassadorWixContactsV4Contact.getContact(payload);
885
+ __log(`"GetContact" sending request with: ${__inspect(reqOpts)}`);
886
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
887
+ try {
888
+ const result = yield httpClient.request(reqOpts);
889
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
890
+ return fromJSON(result.data);
891
+ }
892
+ catch (err) {
893
+ const transformedError = (0, velo_1.transformError)(err, requestTransformation, [
894
+ '_id',
895
+ 'options',
896
+ ]);
897
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
898
+ throw transformedError;
899
+ }
900
+ });
901
+ }
902
+ exports.getContact = getContact;
903
+ //# sourceMappingURL=contacts-v4-contact.universal.js.map