@or-sdk/contacts 1.0.1-beta.511.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 +81 -0
- package/dist/cjs/Contacts.js.map +1 -0
- package/dist/cjs/constants.js +5 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/Contacts.js +60 -0
- package/dist/esm/Contacts.js.map +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/Contacts.d.ts +14 -0
- package/dist/types/Contacts.d.ts.map +1 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +30 -0
- package/src/Contacts.ts +88 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +2 -0
- package/src/types.ts +12 -0
- package/tsconfig.dev.json +8 -0
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +8 -0
- package/tsconfig.types.json +10 -0
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
+
var t = {};
|
|
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;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Contacts = void 0;
|
|
30
|
+
var base_1 = require("@or-sdk/base");
|
|
31
|
+
var constants_1 = require("./constants");
|
|
32
|
+
var Contacts = (function (_super) {
|
|
33
|
+
__extends(Contacts, _super);
|
|
34
|
+
function Contacts(params) {
|
|
35
|
+
var token = params.token, discoveryUrl = params.discoveryUrl;
|
|
36
|
+
return _super.call(this, {
|
|
37
|
+
token: token,
|
|
38
|
+
discoveryUrl: discoveryUrl,
|
|
39
|
+
serviceKey: constants_1.SERVICE_KEY,
|
|
40
|
+
}) || this;
|
|
41
|
+
}
|
|
42
|
+
Contacts.prototype.getContactsBookList = function () {
|
|
43
|
+
return this.callApi({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
route: 'contact-book',
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
Contacts.prototype.getContactsBook = function (id) {
|
|
49
|
+
return this.callApi({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
route: 'contact-book',
|
|
52
|
+
params: { id: id },
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
Contacts.prototype.updateContactsBook = function (data) {
|
|
56
|
+
var id = data.id, restData = __rest(data, ["id"]);
|
|
57
|
+
return this.callApi({
|
|
58
|
+
method: 'PATCH',
|
|
59
|
+
route: 'contact-book',
|
|
60
|
+
params: { id: id },
|
|
61
|
+
data: restData,
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
Contacts.prototype.deleteContactBook = function (id) {
|
|
65
|
+
return this.callApi({
|
|
66
|
+
method: 'DELETE',
|
|
67
|
+
route: 'contact-book',
|
|
68
|
+
params: { id: id },
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
Contacts.prototype.createContactBook = function (data) {
|
|
72
|
+
return this.callApi({
|
|
73
|
+
method: 'POST',
|
|
74
|
+
route: 'contact-book',
|
|
75
|
+
data: data,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
return Contacts;
|
|
79
|
+
}(base_1.Base));
|
|
80
|
+
exports.Contacts = Contacts;
|
|
81
|
+
//# sourceMappingURL=Contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAEpC,yCAA0C;AAU1C;IAA8B,4BAAI;IAOhC,kBAAY,MAAsB;QACxB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,YAAY,GAAK,MAAM,aAAX,CAAY;eACvC,kBAAM;YACJ,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,UAAU,EAAE,uBAAW;SACxB,CAAC;IACJ,CAAC;IAKD,sCAAmB,GAAnB;QACE,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;IACL,CAAC;IAMD,kCAAe,GAAf,UAAgB,EAAU;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,IAAA,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAMD,qCAAkB,GAAlB,UAAmB,IAA0C;QACnD,IAAA,EAAE,GAAkB,IAAI,GAAtB,EAAK,QAAQ,UAAK,IAAI,EAA1B,MAAmB,CAAF,CAAU;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,IAAA,EAAE;YACd,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAMD,oCAAiB,GAAjB,UAAkB,EAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,IAAA,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAMD,oCAAiB,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,eAAC;AAAD,CAAC,AA3ED,CAA8B,WAAI,GA2EjC;AA3EY,4BAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Contacts = void 0;
|
|
18
|
+
var Contacts_1 = require("./Contacts");
|
|
19
|
+
Object.defineProperty(exports, "Contacts", { enumerable: true, get: function () { return Contacts_1.Contacts; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import { Base } from '@or-sdk/base';
|
|
13
|
+
import { SERVICE_KEY } from './constants';
|
|
14
|
+
export class Contacts extends Base {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
const { token, discoveryUrl } = params;
|
|
17
|
+
super({
|
|
18
|
+
token,
|
|
19
|
+
discoveryUrl,
|
|
20
|
+
serviceKey: SERVICE_KEY,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
getContactsBookList() {
|
|
24
|
+
return this.callApi({
|
|
25
|
+
method: 'GET',
|
|
26
|
+
route: 'contact-book',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getContactsBook(id) {
|
|
30
|
+
return this.callApi({
|
|
31
|
+
method: 'GET',
|
|
32
|
+
route: 'contact-book',
|
|
33
|
+
params: { id },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
updateContactsBook(data) {
|
|
37
|
+
const { id } = data, restData = __rest(data, ["id"]);
|
|
38
|
+
return this.callApi({
|
|
39
|
+
method: 'PATCH',
|
|
40
|
+
route: 'contact-book',
|
|
41
|
+
params: { id },
|
|
42
|
+
data: restData,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
deleteContactBook(id) {
|
|
46
|
+
return this.callApi({
|
|
47
|
+
method: 'DELETE',
|
|
48
|
+
route: 'contact-book',
|
|
49
|
+
params: { id },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
createContactBook(data) {
|
|
53
|
+
return this.callApi({
|
|
54
|
+
method: 'POST',
|
|
55
|
+
route: 'contact-book',
|
|
56
|
+
data,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=Contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Contacts.js","sourceRoot":"","sources":["../../src/Contacts.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,MAAM,OAAO,QAAS,SAAQ,IAAI;IAOhC,YAAY,MAAsB;QAChC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QACvC,KAAK,CAAC;YACJ,KAAK;YACL,YAAY;YACZ,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IACL,CAAC;IAKD,mBAAmB;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC;IACL,CAAC;IAMD,eAAe,CAAC,EAAU;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAMD,kBAAkB,CAAC,IAA0C;QAC3D,MAAM,EAAE,EAAE,KAAkB,IAAI,EAAjB,QAAQ,UAAK,IAAI,EAA1B,MAAmB,CAAO,CAAC;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,EAAE;YACd,IAAI,EAAE,QAAQ;SACf,CAAC,CAAC;IACL,CAAC;IAMD,iBAAiB,CAAC,EAAU;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,QAAQ;YAChB,KAAK,EAAE,cAAc;YACrB,MAAM,EAAE,EAAE,EAAE,EAAE;SACf,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 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import { ContactsConfig } from './types';
|
|
3
|
+
import { ContactBookResponseDto, UpdateContactBookDto, CreateContactBookDto } from '@onereach/types-contacts-api';
|
|
4
|
+
export declare class Contacts extends Base {
|
|
5
|
+
constructor(params: ContactsConfig);
|
|
6
|
+
getContactsBookList(): Promise<ContactBookResponseDto[]>;
|
|
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
|
+
}
|
|
14
|
+
//# sourceMappingURL=Contacts.d.ts.map
|
|
@@ -0,0 +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,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AASlH,qBAAa,QAAS,SAAQ,IAAI;gBAOpB,MAAM,EAAE,cAAc;IAYlC,mBAAmB,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAWxD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IAY9D,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG;QAAC,EAAE,EAAE,MAAM,CAAC;KAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAc/F,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY5C,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAO7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,cAAc,GAAG;IAI3B,KAAK,EAAE,KAAK,CAAC;IAIb,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.1-beta.511.0",
|
|
3
|
+
"name": "@or-sdk/contacts",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
9
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
10
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
11
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
12
|
+
"build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
|
|
13
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
14
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
15
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
+
"clean": "rm -rf ./dist",
|
|
17
|
+
"dev": "pnpm build:watch:esm"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@onereach/types-contacts-api": "^0.0.3",
|
|
21
|
+
"concurrently": "^6.4.0",
|
|
22
|
+
"typescript": "^4.4.4"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@or-sdk/base": "^0.26.3"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/Contacts.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import { ContactsConfig } from './types';
|
|
3
|
+
import { SERVICE_KEY } from './constants';
|
|
4
|
+
import { ContactBookResponseDto, UpdateContactBookDto, CreateContactBookDto } from '@onereach/types-contacts-api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* OneReach Contacts service client
|
|
8
|
+
* ## Installation:
|
|
9
|
+
* ```
|
|
10
|
+
* $ npm i @or-sdk/contacts
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class Contacts extends Base {
|
|
14
|
+
/**
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { Contacts } from '@or-sdk/contacts'
|
|
17
|
+
* const contacts = new Contacts({token: 'my-account-token-string', discoveryUrl: 'http://example.tables/endpoint'});
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
constructor(params: ContactsConfig) {
|
|
21
|
+
const { token, discoveryUrl } = params;
|
|
22
|
+
super({
|
|
23
|
+
token,
|
|
24
|
+
discoveryUrl,
|
|
25
|
+
serviceKey: SERVICE_KEY,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get list for ContactsBooks
|
|
31
|
+
*/
|
|
32
|
+
getContactsBookList(): Promise<ContactBookResponseDto[]> {
|
|
33
|
+
return this.callApi({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
route: 'contact-book',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get specific ContactsBook
|
|
41
|
+
* @param id
|
|
42
|
+
*/
|
|
43
|
+
getContactsBook(id: string): Promise<ContactBookResponseDto[]> {
|
|
44
|
+
return this.callApi({
|
|
45
|
+
method: 'GET',
|
|
46
|
+
route: 'contact-book',
|
|
47
|
+
params: { id },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Update ContactsBook
|
|
53
|
+
* @param data
|
|
54
|
+
*/
|
|
55
|
+
updateContactsBook(data: UpdateContactBookDto & {id: string;}): Promise<ContactBookResponseDto> {
|
|
56
|
+
const { id, ...restData } = data;
|
|
57
|
+
return this.callApi({
|
|
58
|
+
method: 'PATCH',
|
|
59
|
+
route: 'contact-book',
|
|
60
|
+
params: { id },
|
|
61
|
+
data: restData,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Delete ContactBook
|
|
67
|
+
* @param id
|
|
68
|
+
*/
|
|
69
|
+
deleteContactBook(id: string): Promise<void> {
|
|
70
|
+
return this.callApi({
|
|
71
|
+
method: 'DELETE',
|
|
72
|
+
route: 'contact-book',
|
|
73
|
+
params: { id },
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Delete ContactBook
|
|
79
|
+
* @param data
|
|
80
|
+
*/
|
|
81
|
+
createContactBook(data: CreateContactBookDto): Promise<void> {
|
|
82
|
+
return this.callApi({
|
|
83
|
+
method: 'POST',
|
|
84
|
+
route: 'contact-book',
|
|
85
|
+
data,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SERVICE_KEY = 'contacts-api';
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
package/tsconfig.json
ADDED