@or-sdk/contacts 3.0.3 → 3.0.4-beta.1139.0
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.
- package/dist/cjs/Contacts.js +6 -1
- package/dist/cjs/Contacts.js.map +1 -1
- package/dist/cjs/api/batchProcessApi.js +35 -0
- package/dist/cjs/api/batchProcessApi.js.map +1 -0
- package/dist/cjs/api/contactApi.js +87 -6
- package/dist/cjs/api/contactApi.js.map +1 -1
- package/dist/cjs/api/index.js +3 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/esm/Contacts.js +3 -1
- package/dist/esm/Contacts.js.map +1 -1
- package/dist/esm/api/batchProcessApi.js +14 -0
- package/dist/esm/api/batchProcessApi.js.map +1 -0
- package/dist/esm/api/contactApi.js +39 -6
- package/dist/esm/api/contactApi.js.map +1 -1
- package/dist/esm/api/index.js +1 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/types/Contacts.d.ts +2 -0
- package/dist/types/Contacts.d.ts.map +1 -1
- package/dist/types/api/batchProcessApi.d.ts +7 -0
- package/dist/types/api/batchProcessApi.d.ts.map +1 -0
- package/dist/types/api/contactApi.d.ts +5 -1
- package/dist/types/api/contactApi.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/Contacts.ts +4 -1
- package/src/api/batchProcessApi.ts +16 -0
- package/src/api/contactApi.ts +39 -3
- package/src/api/index.ts +1 -0
package/dist/cjs/Contacts.js
CHANGED
|
@@ -14,12 +14,16 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.Contacts = void 0;
|
|
19
22
|
var base_1 = require("@or-sdk/base");
|
|
20
23
|
var constants_1 = require("./constants");
|
|
21
24
|
var api_1 = require("./api");
|
|
22
25
|
var apiError_1 = require("./apiError");
|
|
26
|
+
var batchProcessApi_1 = __importDefault(require("./api/batchProcessApi"));
|
|
23
27
|
var Contacts = (function (_super) {
|
|
24
28
|
__extends(Contacts, _super);
|
|
25
29
|
function Contacts(params) {
|
|
@@ -32,9 +36,10 @@ var Contacts = (function (_super) {
|
|
|
32
36
|
serviceUrl: contactsApiUrl,
|
|
33
37
|
}) || this;
|
|
34
38
|
var apiCall = _this.callApiV2.bind(_this);
|
|
39
|
+
_this.batchProcessApi = new batchProcessApi_1.default(apiCall);
|
|
35
40
|
_this.contactBookApi = new api_1.ContactBookApi(apiCall);
|
|
36
41
|
_this.migrationsApi = new api_1.MigrationsApi(apiCall);
|
|
37
|
-
_this.contactApi = new api_1.ContactApi(apiCall);
|
|
42
|
+
_this.contactApi = new api_1.ContactApi(apiCall, _this.batchProcessApi);
|
|
38
43
|
_this.fieldSchemaApi = new api_1.FieldSchemaApi(apiCall);
|
|
39
44
|
_this.schemaPresetApi = new api_1.SchemaPresetApi(apiCall);
|
|
40
45
|
_this.filterApi = new api_1.FilterApi(apiCall);
|
package/dist/cjs/Contacts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,qCAAgD;AAEhD,yCAAmD;AACnD,6BASe;AACf,uCAAsC;AACtC,0EAAoD;AASpD;IAA8B,4BAAI;IAiBhC,kBAAY,MAAsB;QAAlC,iBAmBC;QAlBS,IAAA,KAAK,GAAmC,MAAM,MAAzC,EAAE,YAAY,GAAqB,MAAM,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AAC;IAC7B,CAAC;IACH,eAAC;AAAD,CAAC,AA7CD,CAA8B,WAAI,GA6CjC;AA7CY,4BAAQ"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var baseApi_1 = require("./baseApi");
|
|
19
|
+
var BatchProcessApi = (function (_super) {
|
|
20
|
+
__extends(BatchProcessApi, _super);
|
|
21
|
+
function BatchProcessApi() {
|
|
22
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
_this.apiBasePath = 'batch-process';
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
BatchProcessApi.prototype.getBatchProcess = function (id) {
|
|
27
|
+
return this.apiCall({
|
|
28
|
+
method: 'GET',
|
|
29
|
+
route: "".concat(this.apiBasePath, "/").concat(id),
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return BatchProcessApi;
|
|
33
|
+
}(baseApi_1.BaseApi));
|
|
34
|
+
exports.default = BatchProcessApi;
|
|
35
|
+
//# sourceMappingURL=batchProcessApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchProcessApi.js","sourceRoot":"","sources":["../../../src/api/batchProcessApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAMpC;IAA6C,mCAAO;IAApD;QAAA,qEASC;QARkB,iBAAW,GAAG,eAAe,CAAC;;IAQjD,CAAC;IANC,yCAAe,GAAf,UAAgB,EAAU;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,cAAI,EAAE,CAAE;SACnC,CAAC,CAAC;IACL,CAAC;IACH,sBAAC;AAAD,CAAC,AATD,CAA6C,iBAAO,GASnD"}
|
|
@@ -25,13 +25,52 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
};
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
65
|
var baseApi_1 = require("./baseApi");
|
|
66
|
+
var types_contacts_api_1 = require("@onereach/types-contacts-api");
|
|
30
67
|
var utils_1 = require("../utils");
|
|
31
68
|
var ContactApi = (function (_super) {
|
|
32
69
|
__extends(ContactApi, _super);
|
|
33
|
-
function ContactApi() {
|
|
34
|
-
var _this = _super
|
|
70
|
+
function ContactApi(apiCall, batchProcessApi) {
|
|
71
|
+
var _this = _super.call(this, apiCall) || this;
|
|
72
|
+
_this.apiCall = apiCall;
|
|
73
|
+
_this.batchProcessApi = batchProcessApi;
|
|
35
74
|
_this.apiBasePath = 'contact';
|
|
36
75
|
return _this;
|
|
37
76
|
}
|
|
@@ -78,10 +117,52 @@ var ContactApi = (function (_super) {
|
|
|
78
117
|
});
|
|
79
118
|
};
|
|
80
119
|
ContactApi.prototype.bulkCreateContacts = function (data) {
|
|
81
|
-
return this
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
var batchProcess, polling, batchProcessResult, contactIds;
|
|
122
|
+
var _this = this;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0: return [4, this.apiCall({
|
|
126
|
+
method: 'POST',
|
|
127
|
+
route: "".concat(this.apiBasePath, "/bulk"),
|
|
128
|
+
data: data,
|
|
129
|
+
})];
|
|
130
|
+
case 1:
|
|
131
|
+
batchProcess = _a.sent();
|
|
132
|
+
polling = function (ms) {
|
|
133
|
+
return new Promise(function (res, rej) {
|
|
134
|
+
var intervalId = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
135
|
+
var batchProcessState, e_1;
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0:
|
|
139
|
+
_a.trys.push([0, 2, , 3]);
|
|
140
|
+
return [4, this.batchProcessApi.getBatchProcess(batchProcess.id)];
|
|
141
|
+
case 1:
|
|
142
|
+
batchProcessState = _a.sent();
|
|
143
|
+
if (batchProcessState.status !== types_contacts_api_1.BatchProcessStatus.pending) {
|
|
144
|
+
res(batchProcessState);
|
|
145
|
+
}
|
|
146
|
+
return [3, 3];
|
|
147
|
+
case 2:
|
|
148
|
+
e_1 = _a.sent();
|
|
149
|
+
clearInterval(intervalId);
|
|
150
|
+
rej(e_1);
|
|
151
|
+
return [3, 3];
|
|
152
|
+
case 3: return [2];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}); }, ms);
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
return [4, polling(1000)];
|
|
159
|
+
case 2:
|
|
160
|
+
batchProcessResult = _a.sent();
|
|
161
|
+
contactIds = batchProcessResult.results.flat();
|
|
162
|
+
return [4, this.listContact(__assign({ contactIds: contactIds }, (data.contact_book && { contact_book: data.contact_book })))];
|
|
163
|
+
case 3: return [2, (_a.sent()).items];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
85
166
|
});
|
|
86
167
|
};
|
|
87
168
|
ContactApi.prototype.mergeContacts = function (id, data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoC;AACpC,mEAesC;AAEtC,kCAA2C;AAI3C;IAAwC,8BAAO;IAC7C,oBACqB,OAAgD,EAC3D,eAAgC;QAF1C,YAIE,kBAAM,OAAO,CAAC,SACf;QAJoB,aAAO,GAAP,OAAO,CAAyC;QAC3D,qBAAe,GAAf,eAAe,CAAiB;QAIzB,iBAAW,GAAG,SAAS,CAAC;;IADzC,CAAC;IAQD,+BAAU,GAAV,UAAW,EAAU,EAAE,MAAwB;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,cAAI,EAAE,CAAE;YAClC,MAAM,QAAA;SACP,CAAC,CAAC;IACL,CAAC;IAMD,gCAAW,GAAX,UAAY,MAA2B;QACrC,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,M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AC/C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,UAAO;YACjC,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAOD,kCAAa,GAAb,UAAc,EAAU,EAAE,IAA4B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,cAAI,EAAE,UAAO;YACvC,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAMD,wCAAmB,GAAnB,UAAoB,IAAiC;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,UAAO;YACjC,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IACH,iBAAC;AAAD,CAAC,AA5LD,CAAwC,iBAAO,GA4L9C"}
|
package/dist/cjs/api/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FieldValueApi = exports.SharedBookContactPermissionApi = exports.FilterApi = exports.SchemaPresetApi = exports.FieldSchemaApi = exports.MigrationsApi = exports.ContactBookApi = exports.ContactApi = void 0;
|
|
6
|
+
exports.BatchProcessApi = exports.FieldValueApi = exports.SharedBookContactPermissionApi = exports.FilterApi = exports.SchemaPresetApi = exports.FieldSchemaApi = exports.MigrationsApi = exports.ContactBookApi = exports.ContactApi = void 0;
|
|
7
7
|
var contactApi_1 = require("./contactApi");
|
|
8
8
|
Object.defineProperty(exports, "ContactApi", { enumerable: true, get: function () { return __importDefault(contactApi_1).default; } });
|
|
9
9
|
var contactBookApi_1 = require("./contactBookApi");
|
|
@@ -20,4 +20,6 @@ var sharedBookContactPermissionApi_1 = require("./sharedBookContactPermissionApi
|
|
|
20
20
|
Object.defineProperty(exports, "SharedBookContactPermissionApi", { enumerable: true, get: function () { return __importDefault(sharedBookContactPermissionApi_1).default; } });
|
|
21
21
|
var fieldValueApi_1 = require("./fieldValueApi");
|
|
22
22
|
Object.defineProperty(exports, "FieldValueApi", { enumerable: true, get: function () { return __importDefault(fieldValueApi_1).default; } });
|
|
23
|
+
var batchProcessApi_1 = require("./batchProcessApi");
|
|
24
|
+
Object.defineProperty(exports, "BatchProcessApi", { enumerable: true, get: function () { return __importDefault(batchProcessApi_1).default; } });
|
|
23
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAqD;AAA5C,yHAAA,OAAO,OAAc;AAC9B,mDAA6D;AAApD,iIAAA,OAAO,OAAkB;AAClC,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB;AACjC,mDAA6D;AAApD,iIAAA,OAAO,OAAkB;AAClC,qDAA+D;AAAtD,mIAAA,OAAO,OAAmB;AACnC,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,mFAA6F;AAApF,iKAAA,OAAO,OAAkC;AAClD,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAqD;AAA5C,yHAAA,OAAO,OAAc;AAC9B,mDAA6D;AAApD,iIAAA,OAAO,OAAkB;AAClC,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB;AACjC,mDAA6D;AAApD,iIAAA,OAAO,OAAkB;AAClC,qDAA+D;AAAtD,mIAAA,OAAO,OAAmB;AACnC,yCAAmD;AAA1C,uHAAA,OAAO,OAAa;AAC7B,mFAA6F;AAApF,iKAAA,OAAO,OAAkC;AAClD,iDAA2D;AAAlD,+HAAA,OAAO,OAAiB;AACjC,qDAA+D;AAAtD,mIAAA,OAAO,OAAmB"}
|
package/dist/esm/Contacts.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Base } from '@or-sdk/base';
|
|
|
2
2
|
import { CONTACTS_SERVICE_KEY } from './constants';
|
|
3
3
|
import { ContactBookApi, MigrationsApi, ContactApi, FieldSchemaApi, SchemaPresetApi, FilterApi, SharedBookContactPermissionApi, FieldValueApi, } from './api';
|
|
4
4
|
import { ApiError } from './apiError';
|
|
5
|
+
import BatchProcessApi from './api/batchProcessApi';
|
|
5
6
|
export class Contacts extends Base {
|
|
6
7
|
constructor(params) {
|
|
7
8
|
const { token, discoveryUrl, contactsApiUrl } = params;
|
|
@@ -12,9 +13,10 @@ export class Contacts extends Base {
|
|
|
12
13
|
serviceUrl: contactsApiUrl,
|
|
13
14
|
});
|
|
14
15
|
const apiCall = this.callApiV2.bind(this);
|
|
16
|
+
this.batchProcessApi = new BatchProcessApi(apiCall);
|
|
15
17
|
this.contactBookApi = new ContactBookApi(apiCall);
|
|
16
18
|
this.migrationsApi = new MigrationsApi(apiCall);
|
|
17
|
-
this.contactApi = new ContactApi(apiCall);
|
|
19
|
+
this.contactApi = new ContactApi(apiCall, this.batchProcessApi);
|
|
18
20
|
this.fieldSchemaApi = new FieldSchemaApi(apiCall);
|
|
19
21
|
this.schemaPresetApi = new SchemaPresetApi(apiCall);
|
|
20
22
|
this.filterApi = new FilterApi(apiCall);
|
package/dist/esm/Contacts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,8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AAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,CAAC,8BAA8B,GAAG,IAAI,8BAA8B,CAAC,OAAO,CAAC,CAAC;QAClF,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,UAAU,CAAC,CAAa;;QACtB,IAAI,CAAC,CAAC,YAAY,KAAI,MAAA,CAAC,CAAC,QAAQ,0CAAE,IAAI,CAAA,EAAE;YACtC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAW,CAAC;YACvD,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SACnD;QACD,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
export default class BatchProcessApi extends BaseApi {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.apiBasePath = 'batch-process';
|
|
6
|
+
}
|
|
7
|
+
getBatchProcess(id) {
|
|
8
|
+
return this.apiCall({
|
|
9
|
+
method: 'GET',
|
|
10
|
+
route: `${this.apiBasePath}/${id}`,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=batchProcessApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchProcessApi.js","sourceRoot":"","sources":["../../../src/api/batchProcessApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAApD;;QACmB,gBAAW,GAAG,eAAe,CAAC;IAQjD,CAAC;IANC,eAAe,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { BaseApi } from './baseApi';
|
|
11
|
+
import { BatchProcessStatus, } from '@onereach/types-contacts-api';
|
|
2
12
|
import { adaptListParams } from '../utils';
|
|
3
13
|
export default class ContactApi extends BaseApi {
|
|
4
|
-
constructor() {
|
|
5
|
-
super(
|
|
14
|
+
constructor(apiCall, batchProcessApi) {
|
|
15
|
+
super(apiCall);
|
|
16
|
+
this.apiCall = apiCall;
|
|
17
|
+
this.batchProcessApi = batchProcessApi;
|
|
6
18
|
this.apiBasePath = 'contact';
|
|
7
19
|
}
|
|
8
20
|
getContact(id, params) {
|
|
@@ -48,10 +60,31 @@ export default class ContactApi extends BaseApi {
|
|
|
48
60
|
});
|
|
49
61
|
}
|
|
50
62
|
bulkCreateContacts(data) {
|
|
51
|
-
return this
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const batchProcess = yield this.apiCall({
|
|
65
|
+
method: 'POST',
|
|
66
|
+
route: `${this.apiBasePath}/bulk`,
|
|
67
|
+
data,
|
|
68
|
+
});
|
|
69
|
+
const polling = (ms) => {
|
|
70
|
+
return new Promise((res, rej) => {
|
|
71
|
+
const intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
try {
|
|
73
|
+
const batchProcessState = yield this.batchProcessApi.getBatchProcess(batchProcess.id);
|
|
74
|
+
if (batchProcessState.status !== BatchProcessStatus.pending) {
|
|
75
|
+
res(batchProcessState);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
clearInterval(intervalId);
|
|
80
|
+
rej(e);
|
|
81
|
+
}
|
|
82
|
+
}), ms);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const batchProcessResult = yield polling(1000);
|
|
86
|
+
const contactIds = batchProcessResult.results.flat();
|
|
87
|
+
return (yield this.listContact(Object.assign({ contactIds }, (data.contact_book && { contact_book: data.contact_book })))).items;
|
|
55
88
|
});
|
|
56
89
|
}
|
|
57
90
|
mergeContacts(id, data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAcL,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI3C,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAC7C,YACqB,OAAgD,EAC3D,eAAgC;QAExC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHI,YAAO,GAAP,OAAO,CAAyC;QAC3D,oBAAe,GAAf,eAAe,CAAiB;QAIzB,gBAAW,GAAG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CAAC;IAOD,WAAW,CAAC,EAAU,EAAE,IAA0B;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,OAAO;YACvC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAMD,iBAAiB,CAAC,IAA+B;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,OAAO;YACjC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAOD,aAAa,CAAC,EAAU,EAAE,IAA4B;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,OAAO;YACvC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAMD,mBAAmB,CAAC,IAAiC;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,OAAO;YACjC,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/esm/api/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { default as SchemaPresetApi } from './schemaPresetApi';
|
|
|
6
6
|
export { default as FilterApi } from './filterApi';
|
|
7
7
|
export { default as SharedBookContactPermissionApi } from './sharedBookContactPermissionApi';
|
|
8
8
|
export { default as FieldValueApi } from './fieldValueApi';
|
|
9
|
+
export { default as BatchProcessApi } from './batchProcessApi';
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/types/Contacts.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AxiosError, Base } from '@or-sdk/base';
|
|
2
2
|
import { ContactsConfig } from './types';
|
|
3
3
|
import { ContactBookApi, MigrationsApi, ContactApi, FieldSchemaApi, SchemaPresetApi, FilterApi, SharedBookContactPermissionApi, FieldValueApi } from './api';
|
|
4
|
+
import BatchProcessApi from './api/batchProcessApi';
|
|
4
5
|
export declare class Contacts extends Base {
|
|
6
|
+
readonly batchProcessApi: BatchProcessApi;
|
|
5
7
|
readonly contactBookApi: ContactBookApi;
|
|
6
8
|
readonly migrationsApi: MigrationsApi;
|
|
7
9
|
readonly contactApi: ContactApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contacts.d.ts","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,8BAA8B,EAC9B,aAAa,EACd,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Contacts.d.ts","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,8BAA8B,EAC9B,aAAa,EACd,MAAM,OAAO,CAAC;AAEf,OAAO,eAAe,MAAM,uBAAuB,CAAC;AASpD,qBAAa,QAAS,SAAQ,IAAI;IAEhC,SAAgB,eAAe,EAAE,eAAe,CAAC;IACjD,SAAgB,cAAc,EAAE,cAAc,CAAC;IAC/C,SAAgB,aAAa,EAAE,aAAa,CAAC;IAC7C,SAAgB,UAAU,EAAE,UAAU,CAAC;IACvC,SAAgB,cAAc,EAAE,cAAc,CAAC;IAC/C,SAAgB,eAAe,EAAE,eAAe,CAAC;IACjD,SAAgB,SAAS,EAAE,SAAS,CAAC;IACrC,SAAgB,8BAA8B,EAAE,8BAA8B,CAAC;IAC/E,SAAgB,aAAa,EAAE,aAAa,CAAC;gBAOjC,MAAM,EAAE,cAAc;IAqBlC,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,KAAK;CAOjC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
import { BatchProcessResponseDto } from '@onereach/types-contacts-api';
|
|
3
|
+
export default class BatchProcessApi extends BaseApi {
|
|
4
|
+
private readonly apiBasePath;
|
|
5
|
+
getBatchProcess(id: string): Promise<BatchProcessResponseDto>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=batchProcessApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batchProcessApi.d.ts","sourceRoot":"","sources":["../../../src/api/batchProcessApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;IAE/C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAM9D"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { BaseApi } from './baseApi';
|
|
2
2
|
import { ContactResponseDto, CreateContactDto, CreateMultipleContactsDto, UpdateContactDto, ContactParamsDto, MergeContactParamsDto, DeleteContactParamsDto, DeleteContactMultiParamsDto, LinkContactParamsDto, LinkContactMultiParamsDto, UnlinkContactParamsDto, UnlinkContactMultiParamsDto } from '@onereach/types-contacts-api';
|
|
3
3
|
import { ContactSearchParams } from '../types';
|
|
4
|
-
import { List } from '@or-sdk/base';
|
|
4
|
+
import { CalApiParams, List } from '@or-sdk/base';
|
|
5
|
+
import BatchProcessApi from './batchProcessApi';
|
|
5
6
|
export default class ContactApi extends BaseApi {
|
|
7
|
+
protected readonly apiCall: <T>(params: CalApiParams) => Promise<T>;
|
|
8
|
+
private batchProcessApi;
|
|
9
|
+
constructor(apiCall: <T>(params: CalApiParams) => Promise<T>, batchProcessApi: BatchProcessApi);
|
|
6
10
|
private readonly apiBasePath;
|
|
7
11
|
getContact(id: string, params: ContactParamsDto): Promise<ContactResponseDto>;
|
|
8
12
|
listContact(params: ContactSearchParams): Promise<List<ContactResponseDto>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactApi.d.ts","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"contactApi.d.ts","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAG5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAE3C,SAAS,CAAC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mBAAmB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CAOtE"}
|
|
@@ -6,4 +6,5 @@ export { default as SchemaPresetApi } from './schemaPresetApi';
|
|
|
6
6
|
export { default as FilterApi } from './filterApi';
|
|
7
7
|
export { default as SharedBookContactPermissionApi } from './sharedBookContactPermissionApi';
|
|
8
8
|
export { default as FieldValueApi } from './fieldValueApi';
|
|
9
|
+
export { default as BatchProcessApi } from './batchProcessApi';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAC7F,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.0.
|
|
2
|
+
"version": "3.0.4-beta.1139.0",
|
|
3
3
|
"name": "@or-sdk/contacts",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onereach/types-contacts-api": "2.2.
|
|
27
|
+
"@onereach/types-contacts-api": "2.2.11-beta.1691.0",
|
|
28
28
|
"@or-sdk/base": "^0.28.1"
|
|
29
|
-
}
|
|
30
|
-
"gitHead": "630a5a0537532d57f25e7db98584bc64fcf85062"
|
|
29
|
+
}
|
|
31
30
|
}
|
package/src/Contacts.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
FieldValueApi,
|
|
13
13
|
} from './api';
|
|
14
14
|
import { ApiError } from './apiError';
|
|
15
|
+
import BatchProcessApi from './api/batchProcessApi';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* OneReach Contacts service client
|
|
@@ -22,6 +23,7 @@ import { ApiError } from './apiError';
|
|
|
22
23
|
*/
|
|
23
24
|
export class Contacts extends Base {
|
|
24
25
|
|
|
26
|
+
public readonly batchProcessApi: BatchProcessApi;
|
|
25
27
|
public readonly contactBookApi: ContactBookApi;
|
|
26
28
|
public readonly migrationsApi: MigrationsApi;
|
|
27
29
|
public readonly contactApi: ContactApi;
|
|
@@ -46,9 +48,10 @@ export class Contacts extends Base {
|
|
|
46
48
|
});
|
|
47
49
|
|
|
48
50
|
const apiCall = this.callApiV2.bind(this);
|
|
51
|
+
this.batchProcessApi = new BatchProcessApi(apiCall);
|
|
49
52
|
this.contactBookApi = new ContactBookApi(apiCall);
|
|
50
53
|
this.migrationsApi = new MigrationsApi(apiCall);
|
|
51
|
-
this.contactApi = new ContactApi(apiCall);
|
|
54
|
+
this.contactApi = new ContactApi(apiCall, this.batchProcessApi);
|
|
52
55
|
this.fieldSchemaApi = new FieldSchemaApi(apiCall);
|
|
53
56
|
this.schemaPresetApi = new SchemaPresetApi(apiCall);
|
|
54
57
|
this.filterApi = new FilterApi(apiCall);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BatchProcessResponseDto,
|
|
5
|
+
} from '@onereach/types-contacts-api';
|
|
6
|
+
|
|
7
|
+
export default class BatchProcessApi extends BaseApi {
|
|
8
|
+
private readonly apiBasePath = 'batch-process';
|
|
9
|
+
|
|
10
|
+
getBatchProcess(id: string): Promise<BatchProcessResponseDto> {
|
|
11
|
+
return this.apiCall({
|
|
12
|
+
method: 'GET',
|
|
13
|
+
route: `${this.apiBasePath}/${id}`,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/api/contactApi.ts
CHANGED
|
@@ -12,12 +12,21 @@ import {
|
|
|
12
12
|
LinkContactMultiParamsDto,
|
|
13
13
|
UnlinkContactParamsDto,
|
|
14
14
|
UnlinkContactMultiParamsDto,
|
|
15
|
+
BatchProcessResponseDto,
|
|
16
|
+
BatchProcessStatus,
|
|
15
17
|
} from '@onereach/types-contacts-api';
|
|
16
18
|
import { ContactSearchParams } from '../types';
|
|
17
19
|
import { adaptListParams } from '../utils';
|
|
18
|
-
import { List } from '@or-sdk/base';
|
|
20
|
+
import { CalApiParams, List } from '@or-sdk/base';
|
|
21
|
+
import BatchProcessApi from './batchProcessApi';
|
|
19
22
|
|
|
20
23
|
export default class ContactApi extends BaseApi {
|
|
24
|
+
constructor(
|
|
25
|
+
protected readonly apiCall: <T>(params: CalApiParams) => Promise<T>,
|
|
26
|
+
private batchProcessApi: BatchProcessApi
|
|
27
|
+
) {
|
|
28
|
+
super(apiCall);
|
|
29
|
+
}
|
|
21
30
|
private readonly apiBasePath = 'contact';
|
|
22
31
|
|
|
23
32
|
/**
|
|
@@ -102,12 +111,39 @@ export default class ContactApi extends BaseApi {
|
|
|
102
111
|
* @description Create Contacts
|
|
103
112
|
* @param data
|
|
104
113
|
*/
|
|
105
|
-
bulkCreateContacts(data: CreateMultipleContactsDto): Promise<ContactResponseDto[]> {
|
|
106
|
-
|
|
114
|
+
async bulkCreateContacts(data: CreateMultipleContactsDto): Promise<ContactResponseDto[]> {
|
|
115
|
+
const batchProcess = await this.apiCall<BatchProcessResponseDto>({
|
|
107
116
|
method: 'POST',
|
|
108
117
|
route: `${this.apiBasePath}/bulk`,
|
|
109
118
|
data,
|
|
110
119
|
});
|
|
120
|
+
|
|
121
|
+
const polling = (ms: number): Promise<BatchProcessResponseDto> => {
|
|
122
|
+
return new Promise((res, rej) => {
|
|
123
|
+
const intervalId = setInterval(async () => {
|
|
124
|
+
try {
|
|
125
|
+
const batchProcessState = await this.batchProcessApi.getBatchProcess(batchProcess.id);
|
|
126
|
+
if (batchProcessState.status !== BatchProcessStatus.pending) {
|
|
127
|
+
res(batchProcessState);
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
clearInterval(intervalId);
|
|
131
|
+
rej(e);
|
|
132
|
+
}
|
|
133
|
+
}, ms);
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
const batchProcessResult = await polling(1000);
|
|
139
|
+
const contactIds = batchProcessResult.results.flat();
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
await this.listContact({
|
|
143
|
+
contactIds,
|
|
144
|
+
...(data.contact_book && { contact_book: data.contact_book }),
|
|
145
|
+
})
|
|
146
|
+
).items;
|
|
111
147
|
}
|
|
112
148
|
|
|
113
149
|
/**
|
package/src/api/index.ts
CHANGED
|
@@ -6,3 +6,4 @@ export { default as SchemaPresetApi } from './schemaPresetApi';
|
|
|
6
6
|
export { default as FilterApi } from './filterApi';
|
|
7
7
|
export { default as SharedBookContactPermissionApi } from './sharedBookContactPermissionApi';
|
|
8
8
|
export { default as FieldValueApi } from './fieldValueApi';
|
|
9
|
+
export { default as BatchProcessApi } from './batchProcessApi';
|