@unboundcx/sdk 1.0.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.
@@ -0,0 +1,137 @@
1
+ export class NotesService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async list({
7
+ relatedId,
8
+ recordTypeId,
9
+ limit,
10
+ orderBy,
11
+ orderDirection,
12
+ }) {
13
+ this.sdk.validateParams(
14
+ { relatedId, limit, orderBy, orderDirection },
15
+ {
16
+ relatedId: { type: 'string', required: true },
17
+ recordTypeId: { type: 'string', required: false },
18
+ limit: { type: 'number', required: false },
19
+ orderBy: { type: 'string', required: false },
20
+ orderDirection: { type: 'string', required: false },
21
+ },
22
+ );
23
+
24
+ const params = {
25
+ query: {
26
+ relatedId,
27
+ recordTypeId,
28
+ limit,
29
+ orderBy,
30
+ orderDirection,
31
+ },
32
+ };
33
+
34
+ const result = await this.sdk._fetch('/notes', 'GET', params);
35
+ return result;
36
+ }
37
+
38
+ async create({
39
+ title,
40
+ relatedId,
41
+ recordTypeId,
42
+ content_html,
43
+ content_binary,
44
+ content_json,
45
+ version,
46
+ }) {
47
+ this.sdk.validateParams(
48
+ {
49
+ title,
50
+ relatedId,
51
+ recordTypeId,
52
+ content_html,
53
+ content_binary,
54
+ content_json,
55
+ version,
56
+ },
57
+ {
58
+ title: { type: 'string', required: false },
59
+ relatedId: { type: 'string', required: true },
60
+ recordTypeId: { type: 'string', required: false },
61
+ content_html: { type: 'string', required: false },
62
+ content_binary: { type: 'array', required: false },
63
+ content_json: { type: 'object', required: false },
64
+ version: { type: 'number', required: false },
65
+ },
66
+ );
67
+
68
+ const params = {
69
+ body: {
70
+ title,
71
+ relatedId,
72
+ recordTypeId,
73
+ content_html,
74
+ content_binary,
75
+ content_json,
76
+ version,
77
+ },
78
+ };
79
+
80
+ const result = await this.sdk._fetch('/notes', 'POST', params);
81
+ return result;
82
+ }
83
+
84
+ async update(
85
+ noteId,
86
+ { title, content_html, content_binary, content_json, version },
87
+ ) {
88
+ this.sdk.validateParams(
89
+ { noteId, title, content_html, content_binary, content_json, version },
90
+ {
91
+ noteId: { type: 'string', required: true },
92
+ title: { type: 'string', required: false },
93
+ content_html: { type: 'string', required: false },
94
+ content_binary: { type: 'array', required: false },
95
+ content_json: { type: 'object', required: false },
96
+ version: { type: 'number', required: false },
97
+ },
98
+ );
99
+
100
+ const params = {
101
+ body: {
102
+ title,
103
+ content_html,
104
+ content_binary,
105
+ content_json,
106
+ version,
107
+ },
108
+ };
109
+
110
+ const result = await this.sdk._fetch(`/notes/${noteId}`, 'PUT', params);
111
+ return result;
112
+ }
113
+
114
+ async delete(noteId) {
115
+ this.sdk.validateParams(
116
+ { noteId },
117
+ {
118
+ noteId: { type: 'string', required: true },
119
+ },
120
+ );
121
+
122
+ const result = await this.sdk._fetch(`/notes/${noteId}`, 'DELETE');
123
+ return result;
124
+ }
125
+
126
+ async get(noteId) {
127
+ this.sdk.validateParams(
128
+ { noteId },
129
+ {
130
+ noteId: { type: 'string', required: true },
131
+ },
132
+ );
133
+
134
+ const result = await this.sdk._fetch(`/notes/${noteId}`, 'GET');
135
+ return result;
136
+ }
137
+ }
@@ -0,0 +1,163 @@
1
+ export class ObjectsService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async byId(id, query = {}) {
7
+ this.sdk.validateParams(
8
+ { id, query },
9
+ {
10
+ id: { type: 'string', required: true },
11
+ query: { type: 'object', required: false }
12
+ },
13
+ );
14
+
15
+ const params = {
16
+ query
17
+ }
18
+
19
+ const result = await this.sdk._fetch(`/object/${id}`, 'GET', params);
20
+ return result;
21
+ }
22
+
23
+ async query(object, query = {}) {
24
+ this.sdk.validateParams(
25
+ { object, query },
26
+ {
27
+ object: { type: 'string', required: true },
28
+ query: { type: 'object', required: false }
29
+ },
30
+ );
31
+
32
+ const params = {
33
+ query,
34
+ }
35
+
36
+ const result = await this.sdk._fetch(`/object/query/${object}`, 'GET', params);
37
+ return result;
38
+ }
39
+
40
+ async updateById(object, id, update) {
41
+ this.sdk.validateParams(
42
+ { object, id, update },
43
+ {
44
+ object: { type: 'string', required: true },
45
+ id: { type: 'string', required: true },
46
+ update: { type: 'object', required: true }
47
+ },
48
+ );
49
+
50
+ const params = {
51
+ body: {
52
+ where: {
53
+ id,
54
+ },
55
+ update,
56
+ },
57
+ }
58
+
59
+ const result = await this.sdk._fetch(`/object/${object}`, 'PUT', params);
60
+ return result;
61
+ }
62
+
63
+ async update(object, where, update) {
64
+ this.sdk.validateParams(
65
+ { object, where, update },
66
+ {
67
+ object: { type: 'string', required: true },
68
+ where: { type: 'object', required: true },
69
+ update: { type: 'object', required: true }
70
+ },
71
+ );
72
+
73
+ const params = {
74
+ body: {
75
+ where,
76
+ update,
77
+ },
78
+ }
79
+
80
+ const result = await this.sdk._fetch(`/object/${object}`, 'PUT', params);
81
+ return result;
82
+ }
83
+
84
+ async create(object, body = {}) {
85
+ this.sdk.validateParams(
86
+ { object, body },
87
+ {
88
+ object: { type: 'string', required: true },
89
+ body: { type: 'object', required: true }
90
+ },
91
+ );
92
+
93
+ const params = {
94
+ body
95
+ }
96
+
97
+ const result = await this.sdk._fetch(`/object/${object}`, 'POST', params);
98
+ return result;
99
+ }
100
+
101
+ async delete(object, where) {
102
+ this.sdk.validateParams(
103
+ { object, where },
104
+ {
105
+ object: { type: 'string', required: true },
106
+ where: { type: 'object', required: true }
107
+ },
108
+ );
109
+
110
+ const params = {
111
+ body: {
112
+ where
113
+ }
114
+ }
115
+
116
+ const result = await this.sdk._fetch(`/object/${object}`, 'DELETE', params);
117
+ return result;
118
+ }
119
+
120
+ async deleteById(object, id) {
121
+ this.sdk.validateParams(
122
+ { object, id },
123
+ {
124
+ object: { type: 'string', required: true },
125
+ id: { type: 'string', required: true }
126
+ },
127
+ );
128
+
129
+ const params = {
130
+ body: {
131
+ where: {
132
+ id
133
+ }
134
+ }
135
+ }
136
+
137
+ const result = await this.sdk._fetch(`/object/${object}`, 'DELETE', params);
138
+ return result;
139
+ }
140
+
141
+ async describe(object) {
142
+ this.sdk.validateParams(
143
+ { object },
144
+ {
145
+ object: { type: 'string', required: true },
146
+ },
147
+ );
148
+
149
+ const params = {
150
+ }
151
+
152
+ const result = await this.sdk._fetch(`/object/describe/${object}`, 'GET', params);
153
+ return result;
154
+ }
155
+
156
+ async list() {
157
+ const params = {
158
+ }
159
+
160
+ const result = await this.sdk._fetch(`/object/`, 'GET', params);
161
+ return result;
162
+ }
163
+ }
@@ -0,0 +1,215 @@
1
+ export class PhoneNumbersService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ this.carrier = new PhoneNumberCarrierService(sdk);
5
+ }
6
+
7
+ async search({
8
+ type,
9
+ country,
10
+ state,
11
+ city,
12
+ startsWith,
13
+ endsWith,
14
+ contains,
15
+ limit,
16
+ minimumBlockSize,
17
+ sms,
18
+ mms,
19
+ voice
20
+ }) {
21
+ // Validate optional parameters
22
+ const validationSchema = {};
23
+ if ('type' in arguments[0]) validationSchema.type = { type: 'string' };
24
+ if ('country' in arguments[0]) validationSchema.country = { type: 'string' };
25
+ if ('state' in arguments[0]) validationSchema.state = { type: 'string' };
26
+ if ('city' in arguments[0]) validationSchema.city = { type: 'string' };
27
+ if ('startsWith' in arguments[0]) validationSchema.startsWith = { type: 'string' };
28
+ if ('endsWith' in arguments[0]) validationSchema.endsWith = { type: 'string' };
29
+ if ('contains' in arguments[0]) validationSchema.contains = { type: 'string' };
30
+ if ('limit' in arguments[0]) validationSchema.limit = { type: 'number' };
31
+ if ('minimumBlockSize' in arguments[0]) validationSchema.minimumBlockSize = { type: 'number' };
32
+ if ('sms' in arguments[0]) validationSchema.sms = { type: 'boolean' };
33
+ if ('mms' in arguments[0]) validationSchema.mms = { type: 'boolean' };
34
+ if ('voice' in arguments[0]) validationSchema.voice = { type: 'boolean' };
35
+
36
+ if (Object.keys(validationSchema).length > 0) {
37
+ this.sdk.validateParams(arguments[0], validationSchema);
38
+ }
39
+
40
+ const params = {
41
+ query: {
42
+ type,
43
+ country,
44
+ state,
45
+ city,
46
+ startsWith,
47
+ endsWith,
48
+ contains,
49
+ limit,
50
+ minimumBlockSize,
51
+ sms,
52
+ mms,
53
+ voice
54
+ },
55
+ };
56
+
57
+ const result = await this.sdk._fetch('/phoneNumbers/search', 'GET', params);
58
+ return result;
59
+ }
60
+
61
+ async order({ phoneNumbers, name }) {
62
+ this.sdk.validateParams(
63
+ { phoneNumbers },
64
+ {
65
+ phoneNumbers: { type: 'array', required: true },
66
+ name: { type: 'string', required: false },
67
+ },
68
+ );
69
+
70
+ const orderData = { phoneNumbers };
71
+ if (name) orderData.name = name;
72
+
73
+ const params = {
74
+ body: orderData,
75
+ };
76
+
77
+ const result = await this.sdk._fetch('/phoneNumbers/order', 'POST', params);
78
+ return result;
79
+ }
80
+
81
+ async remove(phoneNumber) {
82
+ this.sdk.validateParams(
83
+ { phoneNumber },
84
+ {
85
+ phoneNumber: { type: 'string', required: true },
86
+ },
87
+ );
88
+
89
+ const result = await this.sdk._fetch(`/phoneNumbers/${phoneNumber}`, 'DELETE');
90
+ return result;
91
+ }
92
+
93
+ async update(id, {
94
+ name,
95
+ messagingWebHookUrl,
96
+ voiceWebHookUrl,
97
+ voiceAppExternalUrl,
98
+ voiceAppExternalMethod,
99
+ voiceApp,
100
+ voiceAppMetaData,
101
+ voiceRecordTypeId,
102
+ messagingRecordTypeId
103
+ }) {
104
+ this.sdk.validateParams(
105
+ { id },
106
+ {
107
+ id: { type: 'string', required: true },
108
+ name: { type: 'string', required: false },
109
+ messagingWebHookUrl: { type: 'string', required: false },
110
+ voiceWebHookUrl: { type: 'string', required: false },
111
+ voiceAppExternalUrl: { type: 'string', required: false },
112
+ voiceAppExternalMethod: { type: 'string', required: false },
113
+ voiceApp: { type: 'string', required: false },
114
+ voiceAppMetaData: { type: 'object', required: false },
115
+ voiceRecordTypeId: { type: 'string', required: false },
116
+ messagingRecordTypeId: { type: 'string', required: false },
117
+ },
118
+ );
119
+
120
+ const updateData = {};
121
+ if (name) updateData.name = name;
122
+ if (messagingWebHookUrl) updateData.messagingWebHookUrl = messagingWebHookUrl;
123
+ if (voiceWebHookUrl) updateData.voiceWebHookUrl = voiceWebHookUrl;
124
+ if (voiceAppExternalUrl) updateData.voiceAppExternalUrl = voiceAppExternalUrl;
125
+ if (voiceAppExternalMethod) updateData.voiceAppExternalMethod = voiceAppExternalMethod;
126
+ if (voiceApp) updateData.voiceApp = voiceApp;
127
+ if (voiceAppMetaData) updateData.voiceAppMetaData = voiceAppMetaData;
128
+ if (voiceRecordTypeId) updateData.voiceRecordTypeId = voiceRecordTypeId;
129
+ if (messagingRecordTypeId) updateData.messagingRecordTypeId = messagingRecordTypeId;
130
+
131
+ const params = {
132
+ body: updateData,
133
+ };
134
+
135
+ const result = await this.sdk._fetch(`/phoneNumbers/${id}`, 'PUT', params);
136
+ return result;
137
+ }
138
+
139
+ async updateCnam(phoneNumber, { cnam }) {
140
+ this.sdk.validateParams(
141
+ { phoneNumber, cnam },
142
+ {
143
+ phoneNumber: { type: 'string', required: true },
144
+ cnam: { type: 'string', required: true },
145
+ },
146
+ );
147
+
148
+ const params = {
149
+ body: { cnam },
150
+ };
151
+
152
+ const result = await this.sdk._fetch(`/phoneNumbers/cnam/${phoneNumber}`, 'PUT', params);
153
+ return result;
154
+ }
155
+
156
+ async format(number) {
157
+ this.sdk.validateParams(
158
+ { number },
159
+ {
160
+ number: { type: 'string', required: true },
161
+ },
162
+ );
163
+
164
+ const result = await this.sdk._fetch(`/phoneNumbers/format/${number}`, 'GET');
165
+ return result;
166
+ }
167
+ }
168
+
169
+ export class PhoneNumberCarrierService {
170
+ constructor(sdk) {
171
+ this.sdk = sdk;
172
+ }
173
+
174
+ async sync(carrier, { updateVoiceConnection, updateMessagingConnection }) {
175
+ this.sdk.validateParams(
176
+ { carrier },
177
+ {
178
+ carrier: { type: 'string', required: true },
179
+ updateVoiceConnection: { type: 'boolean', required: false },
180
+ updateMessagingConnection: { type: 'boolean', required: false },
181
+ },
182
+ );
183
+
184
+ const params = {
185
+ query: { updateVoiceConnection, updateMessagingConnection },
186
+ };
187
+
188
+ const result = await this.sdk._fetch(`/phoneNumbers/carrier/syncPhoneNumbers/${carrier}`, 'POST', params);
189
+ return result;
190
+ }
191
+
192
+ async getDetails(phoneNumber) {
193
+ this.sdk.validateParams(
194
+ { phoneNumber },
195
+ {
196
+ phoneNumber: { type: 'string', required: true },
197
+ },
198
+ );
199
+
200
+ const result = await this.sdk._fetch(`/phoneNumbers/carrier/${phoneNumber}`, 'GET');
201
+ return result;
202
+ }
203
+
204
+ async delete(phoneNumber) {
205
+ this.sdk.validateParams(
206
+ { phoneNumber },
207
+ {
208
+ phoneNumber: { type: 'string', required: true },
209
+ },
210
+ );
211
+
212
+ const result = await this.sdk._fetch(`/phoneNumbers/carrier/${phoneNumber}`, 'DELETE');
213
+ return result;
214
+ }
215
+ }
@@ -0,0 +1,127 @@
1
+ export class PortalsService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async create({ name, domain, settings, isPublic, customCss, customJs, favicon, logo }) {
7
+ this.sdk.validateParams(
8
+ { name, domain },
9
+ {
10
+ name: { type: 'string', required: true },
11
+ domain: { type: 'string', required: true },
12
+ settings: { type: 'object', required: false },
13
+ isPublic: { type: 'boolean', required: false },
14
+ customCss: { type: 'string', required: false },
15
+ customJs: { type: 'string', required: false },
16
+ favicon: { type: 'string', required: false },
17
+ logo: { type: 'string', required: false },
18
+ },
19
+ );
20
+
21
+ const portalData = { name, domain };
22
+ if (settings) portalData.settings = settings;
23
+ if (isPublic !== undefined) portalData.isPublic = isPublic;
24
+ if (customCss) portalData.customCss = customCss;
25
+ if (customJs) portalData.customJs = customJs;
26
+ if (favicon) portalData.favicon = favicon;
27
+ if (logo) portalData.logo = logo;
28
+
29
+ const params = {
30
+ body: portalData,
31
+ };
32
+
33
+ const result = await this.sdk._fetch('/portals', 'POST', params);
34
+ return result;
35
+ }
36
+
37
+ async update(portalId, { name, domain, settings, isPublic, customCss, customJs, favicon, logo }) {
38
+ this.sdk.validateParams(
39
+ { portalId },
40
+ {
41
+ portalId: { type: 'string', required: true },
42
+ name: { type: 'string', required: false },
43
+ domain: { type: 'string', required: false },
44
+ settings: { type: 'object', required: false },
45
+ isPublic: { type: 'boolean', required: false },
46
+ customCss: { type: 'string', required: false },
47
+ customJs: { type: 'string', required: false },
48
+ favicon: { type: 'string', required: false },
49
+ logo: { type: 'string', required: false },
50
+ },
51
+ );
52
+
53
+ const updateData = {};
54
+ if (name) updateData.name = name;
55
+ if (domain) updateData.domain = domain;
56
+ if (settings) updateData.settings = settings;
57
+ if (isPublic !== undefined) updateData.isPublic = isPublic;
58
+ if (customCss) updateData.customCss = customCss;
59
+ if (customJs) updateData.customJs = customJs;
60
+ if (favicon) updateData.favicon = favicon;
61
+ if (logo) updateData.logo = logo;
62
+
63
+ const params = {
64
+ body: updateData,
65
+ };
66
+
67
+ const result = await this.sdk._fetch(`/portals/${portalId}`, 'PUT', params);
68
+ return result;
69
+ }
70
+
71
+ async delete(portalId) {
72
+ this.sdk.validateParams(
73
+ { portalId },
74
+ {
75
+ portalId: { type: 'string', required: true },
76
+ },
77
+ );
78
+
79
+ const result = await this.sdk._fetch(`/portals/${portalId}`, 'DELETE');
80
+ return result;
81
+ }
82
+
83
+ async get(portalId) {
84
+ this.sdk.validateParams(
85
+ { portalId },
86
+ {
87
+ portalId: { type: 'string', required: true },
88
+ },
89
+ );
90
+
91
+ const result = await this.sdk._fetch(`/portals/${portalId}`, 'GET');
92
+ return result;
93
+ }
94
+
95
+ async getPublic(domain) {
96
+ this.sdk.validateParams(
97
+ { domain },
98
+ {
99
+ domain: { type: 'string', required: true },
100
+ },
101
+ );
102
+
103
+ const params = {
104
+ query: { domain },
105
+ };
106
+
107
+ const result = await this.sdk._fetch('/portals/public', 'GET', params);
108
+ return result;
109
+ }
110
+
111
+ async list() {
112
+ const result = await this.sdk._fetch('/portals', 'GET');
113
+ return result;
114
+ }
115
+
116
+ async verifyDns(portalId) {
117
+ this.sdk.validateParams(
118
+ { portalId },
119
+ {
120
+ portalId: { type: 'string', required: true },
121
+ },
122
+ );
123
+
124
+ const result = await this.sdk._fetch(`/portals/${portalId}/verify-dns`, 'POST');
125
+ return result;
126
+ }
127
+ }