@or-sdk/contacts 1.0.1 → 1.0.2-beta.541.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/README.md +17 -0
- package/dist/cjs/Contacts.js +12 -44
- package/dist/cjs/Contacts.js.map +1 -1
- package/dist/cjs/api/baseApi.js +11 -0
- package/dist/cjs/api/baseApi.js.map +1 -0
- package/dist/cjs/api/contactApi.js +53 -0
- package/dist/cjs/api/contactApi.js.map +1 -0
- package/dist/cjs/api/contactBookApi.js +59 -0
- package/dist/cjs/api/contactBookApi.js.map +1 -0
- package/dist/cjs/api/migrationsApi.js +39 -0
- package/dist/cjs/api/migrationsApi.js.map +1 -0
- package/dist/esm/Contacts.js +7 -44
- package/dist/esm/Contacts.js.map +1 -1
- package/dist/esm/api/baseApi.js +6 -0
- package/dist/esm/api/baseApi.js.map +1 -0
- package/dist/esm/api/contactApi.js +30 -0
- package/dist/esm/api/contactApi.js.map +1 -0
- package/dist/esm/api/contactBookApi.js +36 -0
- package/dist/esm/api/contactBookApi.js.map +1 -0
- package/dist/esm/api/migrationsApi.js +16 -0
- package/dist/esm/api/migrationsApi.js.map +1 -0
- package/dist/types/Contacts.d.ts +6 -8
- package/dist/types/Contacts.d.ts.map +1 -1
- package/dist/types/api/baseApi.d.ts +6 -0
- package/dist/types/api/baseApi.d.ts.map +1 -0
- package/dist/types/api/contactApi.d.ts +9 -0
- package/dist/types/api/contactApi.d.ts.map +1 -0
- package/dist/types/api/contactBookApi.d.ts +10 -0
- package/dist/types/api/contactBookApi.d.ts.map +1 -0
- package/dist/types/api/migrationsApi.d.ts +6 -0
- package/dist/types/api/migrationsApi.d.ts.map +1 -0
- package/package.json +3 -4
- package/src/Contacts.ts +11 -62
- package/src/api/baseApi.ts +8 -0
- package/src/api/contactApi.ts +51 -0
- package/src/api/contactBookApi.ts +67 -0
- package/src/api/migrationsApi.ts +24 -0
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
$ npm i @or-sdk/contacts
|
|
4
4
|
```
|
|
5
5
|
|
|
6
|
+
Contacts is a composition of separate Api entities.
|
|
6
7
|
## Usage:
|
|
7
8
|
```typescript
|
|
8
9
|
import { Contacts } from '@or-sdk/contacts'
|
|
@@ -19,5 +20,21 @@ const accountSettings = new Contacts({
|
|
|
19
20
|
discoveryUrl: 'http://example.account-settings/endpoint'
|
|
20
21
|
});
|
|
21
22
|
```
|
|
23
|
+
After when you initialize the Contacts Api,
|
|
24
|
+
various entities are available at your service with which you can work
|
|
25
|
+
(all entities presented in `api` folder )
|
|
22
26
|
|
|
27
|
+
## Example
|
|
28
|
+
Let's say you want to perform some CRUD operation on the contactBook entity
|
|
29
|
+
All you need to do, it's just refer to contactBookApi(entity)
|
|
30
|
+
```typescript
|
|
31
|
+
import { Contacts } from '@or-sdk/contacts'
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const {contactBookApi, migrationsApi, ...rest} = new Contacts(...);
|
|
35
|
+
const migrationsStatus = migrationsApi.migrationsStatus()
|
|
36
|
+
const book = contactBookApi.getContactsBook(id)
|
|
37
|
+
const newContactBook = contactBookApi.createContactBook(...)
|
|
38
|
+
|
|
39
|
+
```
|
|
23
40
|
[[include:contacts/CHANGELOG.md]]
|
package/dist/cjs/Contacts.js
CHANGED
|
@@ -14,65 +14,33 @@ 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
|
|
18
|
-
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
-
t[p[i]] = s[p[i]];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
19
|
};
|
|
28
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
21
|
exports.Contacts = void 0;
|
|
30
22
|
var base_1 = require("@or-sdk/base");
|
|
31
23
|
var constants_1 = require("./constants");
|
|
24
|
+
var contactBookApi_1 = __importDefault(require("./api/contactBookApi"));
|
|
25
|
+
var migrationsApi_1 = __importDefault(require("./api/migrationsApi"));
|
|
26
|
+
var contactApi_1 = __importDefault(require("./api/contactApi"));
|
|
32
27
|
var Contacts = (function (_super) {
|
|
33
28
|
__extends(Contacts, _super);
|
|
34
29
|
function Contacts(params) {
|
|
30
|
+
var _this = this;
|
|
35
31
|
var token = params.token, discoveryUrl = params.discoveryUrl, contactsApiUrl = params.contactsApiUrl;
|
|
36
|
-
|
|
32
|
+
_this = _super.call(this, {
|
|
37
33
|
token: token,
|
|
38
34
|
discoveryUrl: discoveryUrl,
|
|
39
35
|
serviceKey: constants_1.CONTACTS_SERVICE_KEY,
|
|
40
36
|
serviceUrl: contactsApiUrl,
|
|
41
37
|
}) || this;
|
|
38
|
+
var apiCall = _this.callApiV2.bind(_this);
|
|
39
|
+
_this.contactBookApi = new contactBookApi_1.default(apiCall);
|
|
40
|
+
_this.migrationsApi = new migrationsApi_1.default(apiCall);
|
|
41
|
+
_this.contactApi = new contactApi_1.default(apiCall);
|
|
42
|
+
return _this;
|
|
42
43
|
}
|
|
43
|
-
Contacts.prototype.getContactsBookList = function () {
|
|
44
|
-
return this.callApiV2({
|
|
45
|
-
method: 'GET',
|
|
46
|
-
route: 'contact-book',
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
Contacts.prototype.getContactsBook = function (id) {
|
|
50
|
-
return this.callApiV2({
|
|
51
|
-
method: 'GET',
|
|
52
|
-
route: "contact-book/".concat(id),
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
Contacts.prototype.updateContactsBook = function (data) {
|
|
56
|
-
var id = data.id, restData = __rest(data, ["id"]);
|
|
57
|
-
return this.callApiV2({
|
|
58
|
-
method: 'PATCH',
|
|
59
|
-
route: "contact-book/".concat(id),
|
|
60
|
-
data: restData,
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
Contacts.prototype.deleteContactBook = function (id) {
|
|
64
|
-
return this.callApiV2({
|
|
65
|
-
method: 'DELETE',
|
|
66
|
-
route: "contact-book/".concat(id),
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
Contacts.prototype.createContactBook = function (data) {
|
|
70
|
-
return this.callApiV2({
|
|
71
|
-
method: 'POST',
|
|
72
|
-
route: 'contact-book',
|
|
73
|
-
data: data,
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
44
|
return Contacts;
|
|
77
45
|
}(base_1.Base));
|
|
78
46
|
exports.Contacts = Contacts;
|
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,qCAAoC;AAEpC,yCAAmD;AACnD,wEAAkD;AAClD,sEAAgD;AAChD,gEAA0C;AAS1C;IAA8B,4BAAI;IAWhC,kBAAY,MAAsB;QAAlC,iBAaC;QAZS,IAAA,KAAK,GAAmC,MAAM,MAAzC,EAAE,YAAY,GAAqB,MAAM,aAA3B,EAAE,cAAc,GAAK,MAAM,eAAX,CAAY;gBACvD,kBAAM;YACJ,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,UAAU,EAAE,gCAAoB;YAChC,UAAU,EAAE,cAAc;SAC3B,CAAC;QAEF,IAAM,OAAO,GAAG,KAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;QAC1C,KAAI,CAAC,cAAc,GAAG,IAAI,wBAAc,CAAC,OAAO,CAAC,CAAC;QAClD,KAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,CAAC,OAAO,CAAC,CAAC;QAChD,KAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,OAAO,CAAC,CAAC;;IAC5C,CAAC;IACH,eAAC;AAAD,CAAC,AAzBD,CAA8B,WAAI,GAyBjC;AAzBY,4BAAQ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseApi = void 0;
|
|
4
|
+
var BaseApi = (function () {
|
|
5
|
+
function BaseApi(apiCall) {
|
|
6
|
+
this.apiCall = apiCall;
|
|
7
|
+
}
|
|
8
|
+
return BaseApi;
|
|
9
|
+
}());
|
|
10
|
+
exports.BaseApi = BaseApi;
|
|
11
|
+
//# sourceMappingURL=baseApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseApi.js","sourceRoot":"","sources":["../../../src/api/baseApi.ts"],"names":[],"mappings":";;;AAEA;IAEE,iBAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACH,cAAC;AAAD,CAAC,AALD,IAKC;AALqB,0BAAO"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 ContactApi = (function (_super) {
|
|
20
|
+
__extends(ContactApi, _super);
|
|
21
|
+
function ContactApi() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
ContactApi.prototype.getContact = function (id) {
|
|
25
|
+
return this.apiCall({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
route: "contact/".concat(id),
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
ContactApi.prototype.updateContact = function (id, data) {
|
|
31
|
+
return this.apiCall({
|
|
32
|
+
method: 'PATCH',
|
|
33
|
+
route: "contact/".concat(id),
|
|
34
|
+
data: data,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
ContactApi.prototype.deleteContact = function (id) {
|
|
38
|
+
return this.apiCall({
|
|
39
|
+
method: 'DELETE',
|
|
40
|
+
route: "contact/".concat(id),
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
ContactApi.prototype.createContact = function (data) {
|
|
44
|
+
return this.apiCall({
|
|
45
|
+
method: 'POST',
|
|
46
|
+
route: 'contact',
|
|
47
|
+
data: data,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
return ContactApi;
|
|
51
|
+
}(baseApi_1.BaseApi));
|
|
52
|
+
exports.default = ContactApi;
|
|
53
|
+
//# sourceMappingURL=contactApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAGpC;IAAwC,8BAAO;IAA/C;;IA+CA,CAAC;IA1CC,+BAAU,GAAV,UAAW,EAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,kBAAW,EAAE,CAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAOD,kCAAa,GAAb,UAAc,EAAU,EAAE,IAAsB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,kBAAW,EAAE,CAAE;YACtB,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAMD,kCAAa,GAAb,UAAc,EAAU;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,kBAAW,EAAE,CAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAMD,kCAAa,GAAb,UAAc,IAAsB;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IACH,iBAAC;AAAD,CAAC,AA/CD,CAAwC,iBAAO,GA+C9C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 ContactBookApi = (function (_super) {
|
|
20
|
+
__extends(ContactBookApi, _super);
|
|
21
|
+
function ContactBookApi() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
ContactBookApi.prototype.getContactBookList = function () {
|
|
25
|
+
return this.apiCall({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
route: 'contact-book',
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
ContactBookApi.prototype.getContactBook = function (id) {
|
|
31
|
+
return this.apiCall({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
route: "contact-book/".concat(id),
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
ContactBookApi.prototype.updateContactBook = function (id, data) {
|
|
37
|
+
return this.apiCall({
|
|
38
|
+
method: 'PATCH',
|
|
39
|
+
route: "contact-book/".concat(id),
|
|
40
|
+
data: data,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
ContactBookApi.prototype.deleteContactBook = function (id) {
|
|
44
|
+
return this.apiCall({
|
|
45
|
+
method: 'DELETE',
|
|
46
|
+
route: "contact-book/".concat(id),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
ContactBookApi.prototype.createContactBook = function (data) {
|
|
50
|
+
return this.apiCall({
|
|
51
|
+
method: 'POST',
|
|
52
|
+
route: 'contact-book',
|
|
53
|
+
data: data,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
return ContactBookApi;
|
|
57
|
+
}(baseApi_1.BaseApi));
|
|
58
|
+
exports.default = ContactBookApi;
|
|
59
|
+
//# sourceMappingURL=contactBookApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactBookApi.js","sourceRoot":"","sources":["../../../src/api/contactBookApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,qCAAoC;AAEpC;IAA4C,kCAAO;IAAnD;;IA0DA,CAAC;IArDC,2CAAkB,GAAlB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;IACL,CAAC;IAMD,uCAAc,GAAd,UAAe,EAAU;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,uBAAgB,EAAE,CAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAOD,0CAAiB,GAAjB,UAAkB,EAAU,EAAE,IAA0B;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,uBAAgB,EAAE,CAAE;YAC3B,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IAMD,0CAAiB,GAAjB,UAAkB,EAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,uBAAgB,EAAE,CAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAMD,0CAAiB,GAAjB,UAAkB,IAA0B;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,cAAc;YACrB,IAAI,MAAA;SACL,CAAC,CAAC;IACL,CAAC;IACH,qBAAC;AAAD,CAAC,AA1DD,CAA4C,iBAAO,GA0DlD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 MigrationsApi = (function (_super) {
|
|
20
|
+
__extends(MigrationsApi, _super);
|
|
21
|
+
function MigrationsApi() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
MigrationsApi.prototype.migrationsStatus = function () {
|
|
25
|
+
return this.apiCall({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
route: 'migrations/status',
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
MigrationsApi.prototype.migrationsRun = function () {
|
|
31
|
+
return this.apiCall({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
route: 'migrations/run',
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return MigrationsApi;
|
|
37
|
+
}(baseApi_1.BaseApi));
|
|
38
|
+
exports.default = MigrationsApi;
|
|
39
|
+
//# sourceMappingURL=migrationsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationsApi.js","sourceRoot":"","sources":["../../../src/api/migrationsApi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAEpC;IAA2C,iCAAO;IAAlD;;IAqBA,CAAC;IAhBC,wCAAgB,GAAhB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,mBAAmB;SAC3B,CAAC,CAAC;IACL,CAAC;IAKD,qCAAa,GAAb;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,gBAAgB;SACxB,CAAC,CAAC;IACL,CAAC;IACH,oBAAC;AAAD,CAAC,AArBD,CAA2C,iBAAO,GAqBjD"}
|
package/dist/esm/Contacts.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { Base } from '@or-sdk/base';
|
|
13
2
|
import { CONTACTS_SERVICE_KEY } from './constants';
|
|
3
|
+
import ContactBookApi from './api/contactBookApi';
|
|
4
|
+
import MigrationsApi from './api/migrationsApi';
|
|
5
|
+
import ContactApi from './api/contactApi';
|
|
14
6
|
export class Contacts extends Base {
|
|
15
7
|
constructor(params) {
|
|
16
8
|
const { token, discoveryUrl, contactsApiUrl } = params;
|
|
@@ -20,39 +12,10 @@ export class Contacts extends Base {
|
|
|
20
12
|
serviceKey: CONTACTS_SERVICE_KEY,
|
|
21
13
|
serviceUrl: contactsApiUrl,
|
|
22
14
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
route: 'contact-book',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
getContactsBook(id) {
|
|
31
|
-
return this.callApiV2({
|
|
32
|
-
method: 'GET',
|
|
33
|
-
route: `contact-book/${id}`,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
updateContactsBook(data) {
|
|
37
|
-
const { id } = data, restData = __rest(data, ["id"]);
|
|
38
|
-
return this.callApiV2({
|
|
39
|
-
method: 'PATCH',
|
|
40
|
-
route: `contact-book/${id}`,
|
|
41
|
-
data: restData,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
deleteContactBook(id) {
|
|
45
|
-
return this.callApiV2({
|
|
46
|
-
method: 'DELETE',
|
|
47
|
-
route: `contact-book/${id}`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
createContactBook(data) {
|
|
51
|
-
return this.callApiV2({
|
|
52
|
-
method: 'POST',
|
|
53
|
-
route: 'contact-book',
|
|
54
|
-
data,
|
|
55
|
-
});
|
|
15
|
+
const apiCall = this.callApiV2.bind(this);
|
|
16
|
+
this.contactBookApi = new ContactBookApi(apiCall);
|
|
17
|
+
this.migrationsApi = new MigrationsApi(apiCall);
|
|
18
|
+
this.contactApi = new ContactApi(apiCall);
|
|
56
19
|
}
|
|
57
20
|
}
|
|
58
21
|
//# sourceMappingURL=Contacts.js.map
|
package/dist/esm/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,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAS1C,MAAM,OAAO,QAAS,SAAQ,IAAI;IAWhC,YAAY,MAAsB;QAChC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;QACvD,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,oBAAoB;YAChC,UAAU,EAAE,cAAc;SAC3B,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseApi.js","sourceRoot":"","sources":["../../../src/api/baseApi.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,OAAO;IAE3B,YAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
export default class ContactApi extends BaseApi {
|
|
3
|
+
getContact(id) {
|
|
4
|
+
return this.apiCall({
|
|
5
|
+
method: 'GET',
|
|
6
|
+
route: `contact/${id}`,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
updateContact(id, data) {
|
|
10
|
+
return this.apiCall({
|
|
11
|
+
method: 'PATCH',
|
|
12
|
+
route: `contact/${id}`,
|
|
13
|
+
data,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
deleteContact(id) {
|
|
17
|
+
return this.apiCall({
|
|
18
|
+
method: 'DELETE',
|
|
19
|
+
route: `contact/${id}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
createContact(data) {
|
|
23
|
+
return this.apiCall({
|
|
24
|
+
method: 'POST',
|
|
25
|
+
route: 'contact',
|
|
26
|
+
data,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=contactApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactApi.js","sourceRoot":"","sources":["../../../src/api/contactApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAK7C,UAAU,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,WAAW,EAAE,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAOD,aAAa,CAAC,EAAU,EAAE,IAAsB;QAC9C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,WAAW,EAAE,EAAE;YACtB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAMD,aAAa,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,WAAW,EAAE,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAMD,aAAa,CAAC,IAAsB;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,SAAS;YAChB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
export default class ContactBookApi extends BaseApi {
|
|
3
|
+
getContactBookList() {
|
|
4
|
+
return this.apiCall({
|
|
5
|
+
method: 'GET',
|
|
6
|
+
route: 'contact-book',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
getContactBook(id) {
|
|
10
|
+
return this.apiCall({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
route: `contact-book/${id}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
updateContactBook(id, data) {
|
|
16
|
+
return this.apiCall({
|
|
17
|
+
method: 'PATCH',
|
|
18
|
+
route: `contact-book/${id}`,
|
|
19
|
+
data,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
deleteContactBook(id) {
|
|
23
|
+
return this.apiCall({
|
|
24
|
+
method: 'DELETE',
|
|
25
|
+
route: `contact-book/${id}`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
createContactBook(data) {
|
|
29
|
+
return this.apiCall({
|
|
30
|
+
method: 'POST',
|
|
31
|
+
route: 'contact-book',
|
|
32
|
+
data,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=contactBookApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactBookApi.js","sourceRoot":"","sources":["../../../src/api/contactBookApi.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAKjD,kBAAkB;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;IACL,CAAC;IAMD,cAAc,CAAC,EAAU;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,gBAAgB,EAAE,EAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAOD,iBAAiB,CAAC,EAAU,EAAE,IAA0B;QACtD,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,gBAAgB,EAAE,EAAE;YAC3B,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAMD,iBAAiB,CAAC,EAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,gBAAgB,EAAE,EAAE;SAC5B,CAAC,CAAC;IACL,CAAC;IAMD,iBAAiB,CAAC,IAA0B;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,cAAc;YACrB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
export default class MigrationsApi extends BaseApi {
|
|
3
|
+
migrationsStatus() {
|
|
4
|
+
return this.apiCall({
|
|
5
|
+
method: 'GET',
|
|
6
|
+
route: 'migrations/status',
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
migrationsRun() {
|
|
10
|
+
return this.apiCall({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
route: 'migrations/run',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=migrationsApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationsApi.js","sourceRoot":"","sources":["../../../src/api/migrationsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAKhD,gBAAgB;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,mBAAmB;SAC3B,CAAC,CAAC;IACL,CAAC;IAKD,aAAa;QACX,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,gBAAgB;SACxB,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/types/Contacts.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Base } from '@or-sdk/base';
|
|
2
2
|
import { ContactsConfig } from './types';
|
|
3
|
-
import
|
|
3
|
+
import ContactBookApi from './api/contactBookApi';
|
|
4
|
+
import MigrationsApi from './api/migrationsApi';
|
|
5
|
+
import ContactApi from './api/contactApi';
|
|
4
6
|
export declare class Contacts extends Base {
|
|
7
|
+
readonly contactBookApi: ContactBookApi;
|
|
8
|
+
readonly migrationsApi: MigrationsApi;
|
|
9
|
+
readonly contactApi: ContactApi;
|
|
5
10
|
constructor(params: ContactsConfig);
|
|
6
|
-
getContactsBookList(): Promise<ContactBookListDto>;
|
|
7
|
-
getContactsBook(id: string): Promise<ContactBookResponseDto[]>;
|
|
8
|
-
updateContactsBook(data: UpdateContactBookDto & {
|
|
9
|
-
id: string;
|
|
10
|
-
}): Promise<ContactBookResponseDto>;
|
|
11
|
-
deleteContactBook(id: string): Promise<void>;
|
|
12
|
-
createContactBook(data: CreateContactBookDto): Promise<void>;
|
|
13
11
|
}
|
|
14
12
|
//# sourceMappingURL=Contacts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contacts.d.ts","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,
|
|
1
|
+
{"version":3,"file":"Contacts.d.ts","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAS1C,qBAAa,QAAS,SAAQ,IAAI;IAEhC,SAAgB,cAAc,EAAE,cAAc,CAAC;IAC/C,SAAgB,aAAa,EAAE,aAAa,CAAC;IAC7C,SAAgB,UAAU,EAAE,UAAU,CAAC;gBAO3B,MAAM,EAAE,cAAc;CAcnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseApi.d.ts","sourceRoot":"","sources":["../../../src/api/baseApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,8BAAsB,OAAO;IAC3B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;gBACxD,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC;CAG7D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
import { ContactResponseDto, CreateContactDto, UpdateContactDto } from '@onereach/types-contacts-api';
|
|
3
|
+
export default class ContactApi extends BaseApi {
|
|
4
|
+
getContact(id: string): Promise<ContactResponseDto>;
|
|
5
|
+
updateContact(id: string, data: UpdateContactDto): Promise<ContactResponseDto>;
|
|
6
|
+
deleteContact(id: string): Promise<void>;
|
|
7
|
+
createContact(data: CreateContactDto): Promise<ContactResponseDto>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=contactApi.d.ts.map
|
|
@@ -0,0 +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,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEtG,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,OAAO;IAK7C,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAYnD,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAY9E,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWxC,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAOnE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ContactBookListDto, ContactBookResponseDto, CreateContactBookDto, UpdateContactBookDto } from '@onereach/types-contacts-api';
|
|
2
|
+
import { BaseApi } from './baseApi';
|
|
3
|
+
export default class ContactBookApi extends BaseApi {
|
|
4
|
+
getContactBookList(): Promise<ContactBookListDto>;
|
|
5
|
+
getContactBook(id: string): Promise<ContactBookResponseDto>;
|
|
6
|
+
updateContactBook(id: string, data: UpdateContactBookDto): Promise<ContactBookResponseDto>;
|
|
7
|
+
deleteContactBook(id: string): Promise<void>;
|
|
8
|
+
createContactBook(data: CreateContactBookDto): Promise<ContactBookResponseDto>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=contactBookApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contactBookApi.d.ts","sourceRoot":"","sources":["../../../src/api/contactBookApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAKjD,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAWjD,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAY3D,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAY1F,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5C,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC;CAO/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationsApi.d.ts","sourceRoot":"","sources":["../../../src/api/migrationsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IAKhD,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAUpC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.2-beta.541.0",
|
|
3
3
|
"name": "@or-sdk/contacts",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dev": "pnpm build:watch:esm"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@onereach/types-contacts-api": "^0.0.
|
|
20
|
+
"@onereach/types-contacts-api": "^0.0.8",
|
|
21
21
|
"concurrently": "^6.4.0",
|
|
22
22
|
"typescript": "^4.4.4"
|
|
23
23
|
},
|
|
@@ -26,6 +26,5 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@or-sdk/base": "^0.26.3"
|
|
29
|
-
}
|
|
30
|
-
"gitHead": "655aa3e9224d65590532003f0b39cc9a78b1f293"
|
|
29
|
+
}
|
|
31
30
|
}
|
package/src/Contacts.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Base } from '@or-sdk/base';
|
|
2
2
|
import { ContactsConfig } from './types';
|
|
3
3
|
import { CONTACTS_SERVICE_KEY } from './constants';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
CreateContactBookDto,
|
|
8
|
-
ContactBookListDto,
|
|
9
|
-
} from '@onereach/types-contacts-api';
|
|
4
|
+
import ContactBookApi from './api/contactBookApi';
|
|
5
|
+
import MigrationsApi from './api/migrationsApi';
|
|
6
|
+
import ContactApi from './api/contactApi';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* OneReach Contacts service client
|
|
@@ -16,6 +13,10 @@ import {
|
|
|
16
13
|
* ```
|
|
17
14
|
*/
|
|
18
15
|
export class Contacts extends Base {
|
|
16
|
+
|
|
17
|
+
public readonly contactBookApi: ContactBookApi;
|
|
18
|
+
public readonly migrationsApi: MigrationsApi;
|
|
19
|
+
public readonly contactApi: ContactApi;
|
|
19
20
|
/**
|
|
20
21
|
* ```typescript
|
|
21
22
|
* import { Contacts } from '@or-sdk/contacts'
|
|
@@ -30,62 +31,10 @@ export class Contacts extends Base {
|
|
|
30
31
|
serviceKey: CONTACTS_SERVICE_KEY,
|
|
31
32
|
serviceUrl: contactsApiUrl,
|
|
32
33
|
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get list for ContactsBooks
|
|
37
|
-
*/
|
|
38
|
-
getContactsBookList(): Promise<ContactBookListDto> {
|
|
39
|
-
return this.callApiV2({
|
|
40
|
-
method: 'GET',
|
|
41
|
-
route: 'contact-book',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
getContactsBook(id: string): Promise<ContactBookResponseDto[]> {
|
|
50
|
-
return this.callApiV2({
|
|
51
|
-
method: 'GET',
|
|
52
|
-
route: `contact-book/${id}`,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Update ContactsBook
|
|
58
|
-
* @param data
|
|
59
|
-
*/
|
|
60
|
-
updateContactsBook(data: UpdateContactBookDto & {id: string;}): Promise<ContactBookResponseDto> {
|
|
61
|
-
const { id, ...restData } = data;
|
|
62
|
-
return this.callApiV2({
|
|
63
|
-
method: 'PATCH',
|
|
64
|
-
route: `contact-book/${id}`,
|
|
65
|
-
data: restData,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Delete ContactBook
|
|
71
|
-
* @param id
|
|
72
|
-
*/
|
|
73
|
-
deleteContactBook(id: string): Promise<void> {
|
|
74
|
-
return this.callApiV2({
|
|
75
|
-
method: 'DELETE',
|
|
76
|
-
route: `contact-book/${id}`,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Delete ContactBook
|
|
82
|
-
* @param data
|
|
83
|
-
*/
|
|
84
|
-
createContactBook(data: CreateContactBookDto): Promise<void> {
|
|
85
|
-
return this.callApiV2({
|
|
86
|
-
method: 'POST',
|
|
87
|
-
route: 'contact-book',
|
|
88
|
-
data,
|
|
89
|
-
});
|
|
35
|
+
const apiCall = this.callApiV2.bind(this);
|
|
36
|
+
this.contactBookApi = new ContactBookApi(apiCall);
|
|
37
|
+
this.migrationsApi = new MigrationsApi(apiCall);
|
|
38
|
+
this.contactApi = new ContactApi(apiCall);
|
|
90
39
|
}
|
|
91
40
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
import { ContactResponseDto, CreateContactDto, UpdateContactDto } from '@onereach/types-contacts-api';
|
|
3
|
+
|
|
4
|
+
export default class ContactApi extends BaseApi {
|
|
5
|
+
/**
|
|
6
|
+
* @description Get specific Contact
|
|
7
|
+
* @param id
|
|
8
|
+
*/
|
|
9
|
+
getContact(id: string): Promise<ContactResponseDto> {
|
|
10
|
+
return this.apiCall({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
route: `contact/${id}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @description Update Contact
|
|
18
|
+
* @param data
|
|
19
|
+
* @param id
|
|
20
|
+
*/
|
|
21
|
+
updateContact(id: string, data: UpdateContactDto): Promise<ContactResponseDto> {
|
|
22
|
+
return this.apiCall({
|
|
23
|
+
method: 'PATCH',
|
|
24
|
+
route: `contact/${id}`,
|
|
25
|
+
data,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @description Delete Contact
|
|
31
|
+
* @param id
|
|
32
|
+
*/
|
|
33
|
+
deleteContact(id: string): Promise<void> {
|
|
34
|
+
return this.apiCall({
|
|
35
|
+
method: 'DELETE',
|
|
36
|
+
route: `contact/${id}`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description Create Contact
|
|
42
|
+
* @param data
|
|
43
|
+
*/
|
|
44
|
+
createContact(data: CreateContactDto): Promise<ContactResponseDto> {
|
|
45
|
+
return this.apiCall({
|
|
46
|
+
method: 'POST',
|
|
47
|
+
route: 'contact',
|
|
48
|
+
data,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContactBookListDto,
|
|
3
|
+
ContactBookResponseDto,
|
|
4
|
+
CreateContactBookDto,
|
|
5
|
+
UpdateContactBookDto,
|
|
6
|
+
} from '@onereach/types-contacts-api';
|
|
7
|
+
import { BaseApi } from './baseApi';
|
|
8
|
+
|
|
9
|
+
export default class ContactBookApi extends BaseApi {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description Get list for ContactsBooks
|
|
13
|
+
*/
|
|
14
|
+
getContactBookList(): Promise<ContactBookListDto> {
|
|
15
|
+
return this.apiCall({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
route: 'contact-book',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description Get specific ContactsBook
|
|
23
|
+
* @param id
|
|
24
|
+
*/
|
|
25
|
+
getContactBook(id: string): Promise<ContactBookResponseDto> {
|
|
26
|
+
return this.apiCall({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
route: `contact-book/${id}`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description Update ContactsBook
|
|
34
|
+
* @param data
|
|
35
|
+
* @param id
|
|
36
|
+
*/
|
|
37
|
+
updateContactBook(id: string, data: UpdateContactBookDto): Promise<ContactBookResponseDto> {
|
|
38
|
+
return this.apiCall({
|
|
39
|
+
method: 'PATCH',
|
|
40
|
+
route: `contact-book/${id}`,
|
|
41
|
+
data,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @description Delete ContactBook
|
|
47
|
+
* @param id
|
|
48
|
+
*/
|
|
49
|
+
deleteContactBook(id: string): Promise<void> {
|
|
50
|
+
return this.apiCall({
|
|
51
|
+
method: 'DELETE',
|
|
52
|
+
route: `contact-book/${id}`,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @description Create ContactBook
|
|
58
|
+
* @param data
|
|
59
|
+
*/
|
|
60
|
+
createContactBook(data: CreateContactBookDto): Promise<ContactBookResponseDto> {
|
|
61
|
+
return this.apiCall({
|
|
62
|
+
method: 'POST',
|
|
63
|
+
route: 'contact-book',
|
|
64
|
+
data,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseApi } from './baseApi';
|
|
2
|
+
|
|
3
|
+
export default class MigrationsApi extends BaseApi {
|
|
4
|
+
/**
|
|
5
|
+
* Migrations status.
|
|
6
|
+
* @description Returns true if there are pending migrations
|
|
7
|
+
*/
|
|
8
|
+
migrationsStatus(): Promise<boolean> {
|
|
9
|
+
return this.apiCall({
|
|
10
|
+
method: 'GET',
|
|
11
|
+
route: 'migrations/status',
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description Run all pending migrations
|
|
17
|
+
*/
|
|
18
|
+
migrationsRun(): Promise<void> {
|
|
19
|
+
return this.apiCall({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
route: 'migrations/run',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|