@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,238 @@
1
+ export class EnrollService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async checkNamespace(namespace) {
7
+ this.sdk.validateParams(
8
+ { namespace },
9
+ {
10
+ namespace: { type: 'string', required: true },
11
+ },
12
+ );
13
+
14
+ const params = {
15
+ query: { namespace },
16
+ };
17
+
18
+ const result = await this.sdk._fetch('/enroll/checkNamespace', 'GET', params);
19
+ return result;
20
+ }
21
+
22
+ async collectCompanyInfo(companyInfo) {
23
+ this.sdk.validateParams(
24
+ { companyInfo },
25
+ {
26
+ companyInfo: { type: 'object', required: true },
27
+ },
28
+ );
29
+
30
+ const params = {
31
+ body: companyInfo,
32
+ };
33
+
34
+ const result = await this.sdk._fetch('/enroll/companyInfo', 'POST', params);
35
+ return result;
36
+ }
37
+
38
+ async updateEnrollmentInfo(enrollmentId, updateData) {
39
+ this.sdk.validateParams(
40
+ { enrollmentId, updateData },
41
+ {
42
+ enrollmentId: { type: 'string', required: true },
43
+ updateData: { type: 'object', required: true },
44
+ },
45
+ );
46
+
47
+ const params = {
48
+ body: updateData,
49
+ };
50
+
51
+ const result = await this.sdk._fetch(`/enroll/enrollment/${enrollmentId}`, 'PUT', params);
52
+ return result;
53
+ }
54
+
55
+ async validateEnrollment(enrollmentData) {
56
+ this.sdk.validateParams(
57
+ { enrollmentData },
58
+ {
59
+ enrollmentData: { type: 'object', required: true },
60
+ },
61
+ );
62
+
63
+ const params = {
64
+ body: enrollmentData,
65
+ };
66
+
67
+ const result = await this.sdk._fetch('/enroll/validate', 'POST', params);
68
+ return result;
69
+ }
70
+
71
+ async verifyEmail(email, code) {
72
+ this.sdk.validateParams(
73
+ { email, code },
74
+ {
75
+ email: { type: 'string', required: true },
76
+ code: { type: 'string', required: true },
77
+ },
78
+ );
79
+
80
+ const params = {
81
+ body: { email, code },
82
+ };
83
+
84
+ const result = await this.sdk._fetch('/enroll/verifyEmail', 'POST', params);
85
+ return result;
86
+ }
87
+
88
+ async verifySms(phoneNumber, code) {
89
+ this.sdk.validateParams(
90
+ { phoneNumber, code },
91
+ {
92
+ phoneNumber: { type: 'string', required: true },
93
+ code: { type: 'string', required: true },
94
+ },
95
+ );
96
+
97
+ const params = {
98
+ body: { phoneNumber, code },
99
+ };
100
+
101
+ const result = await this.sdk._fetch('/enroll/verifySms', 'POST', params);
102
+ return result;
103
+ }
104
+
105
+ async verifyPayment(paymentData) {
106
+ this.sdk.validateParams(
107
+ { paymentData },
108
+ {
109
+ paymentData: { type: 'object', required: true },
110
+ },
111
+ );
112
+
113
+ const params = {
114
+ body: paymentData,
115
+ };
116
+
117
+ const result = await this.sdk._fetch('/enroll/verifyPayment', 'POST', params);
118
+ return result;
119
+ }
120
+
121
+ async createStripeVerificationSession(sessionData) {
122
+ this.sdk.validateParams(
123
+ { sessionData },
124
+ {
125
+ sessionData: { type: 'object', required: true },
126
+ },
127
+ );
128
+
129
+ const params = {
130
+ body: sessionData,
131
+ };
132
+
133
+ const result = await this.sdk._fetch('/enroll/stripeVerification', 'POST', params);
134
+ return result;
135
+ }
136
+
137
+ async getStripeVerificationStatus(sessionId) {
138
+ this.sdk.validateParams(
139
+ { sessionId },
140
+ {
141
+ sessionId: { type: 'string', required: true },
142
+ },
143
+ );
144
+
145
+ const params = {
146
+ query: { sessionId },
147
+ };
148
+
149
+ const result = await this.sdk._fetch('/enroll/stripeVerification/status', 'GET', params);
150
+ return result;
151
+ }
152
+
153
+ async signAgreement(agreementData) {
154
+ this.sdk.validateParams(
155
+ { agreementData },
156
+ {
157
+ agreementData: { type: 'object', required: true },
158
+ },
159
+ );
160
+
161
+ const params = {
162
+ body: agreementData,
163
+ };
164
+
165
+ const result = await this.sdk._fetch('/enroll/signAgreement', 'POST', params);
166
+ return result;
167
+ }
168
+
169
+ async getAgreement(agreementType, version) {
170
+ this.sdk.validateParams(
171
+ { agreementType },
172
+ {
173
+ agreementType: { type: 'string', required: true },
174
+ version: { type: 'string', required: false },
175
+ },
176
+ );
177
+
178
+ const params = {
179
+ query: { type: agreementType, version },
180
+ };
181
+
182
+ const result = await this.sdk._fetch('/enroll/agreement', 'GET', params);
183
+ return result;
184
+ }
185
+
186
+ async getBrandForEnrollment(enrollmentId) {
187
+ this.sdk.validateParams(
188
+ { enrollmentId },
189
+ {
190
+ enrollmentId: { type: 'string', required: true },
191
+ },
192
+ );
193
+
194
+ const result = await this.sdk._fetch(`/enroll/brand/${enrollmentId}`, 'GET');
195
+ return result;
196
+ }
197
+
198
+ async getBuildStatus(enrollmentId) {
199
+ this.sdk.validateParams(
200
+ { enrollmentId },
201
+ {
202
+ enrollmentId: { type: 'string', required: true },
203
+ },
204
+ );
205
+
206
+ const result = await this.sdk._fetch(`/enroll/buildStatus/${enrollmentId}`, 'GET');
207
+ return result;
208
+ }
209
+
210
+ async completeEnrollment(enrollmentId, completionData) {
211
+ this.sdk.validateParams(
212
+ { enrollmentId, completionData },
213
+ {
214
+ enrollmentId: { type: 'string', required: true },
215
+ completionData: { type: 'object', required: true },
216
+ },
217
+ );
218
+
219
+ const params = {
220
+ body: completionData,
221
+ };
222
+
223
+ const result = await this.sdk._fetch(`/enroll/complete/${enrollmentId}`, 'POST', params);
224
+ return result;
225
+ }
226
+
227
+ async createAccountDatabase(enrollmentId) {
228
+ this.sdk.validateParams(
229
+ { enrollmentId },
230
+ {
231
+ enrollmentId: { type: 'string', required: true },
232
+ },
233
+ );
234
+
235
+ const result = await this.sdk._fetch(`/enroll/createDatabase/${enrollmentId}`, 'POST');
236
+ return result;
237
+ }
238
+ }
@@ -0,0 +1,117 @@
1
+ export class ExternalOAuthService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async create({ name, provider, scopes, credentials, configuration }) {
7
+ this.sdk.validateParams(
8
+ { name, provider, scopes },
9
+ {
10
+ name: { type: 'string', required: true },
11
+ provider: { type: 'string', required: true },
12
+ scopes: { type: 'array', required: true },
13
+ credentials: { type: 'object', required: false },
14
+ configuration: { type: 'object', required: false },
15
+ },
16
+ );
17
+
18
+ const oauthData = { name, provider, scopes };
19
+ if (credentials) oauthData.credentials = credentials;
20
+ if (configuration) oauthData.configuration = configuration;
21
+
22
+ const params = {
23
+ body: oauthData,
24
+ };
25
+
26
+ const result = await this.sdk._fetch('/externalOAuth', 'POST', params);
27
+ return result;
28
+ }
29
+
30
+ async update(id, { name, scopes, credentials, configuration }) {
31
+ this.sdk.validateParams(
32
+ { id },
33
+ {
34
+ id: { type: 'string', required: true },
35
+ name: { type: 'string', required: false },
36
+ scopes: { type: 'array', required: false },
37
+ credentials: { type: 'object', required: false },
38
+ configuration: { type: 'object', required: false },
39
+ },
40
+ );
41
+
42
+ const updateData = {};
43
+ if (name) updateData.name = name;
44
+ if (scopes) updateData.scopes = scopes;
45
+ if (credentials) updateData.credentials = credentials;
46
+ if (configuration) updateData.configuration = configuration;
47
+
48
+ const params = {
49
+ body: updateData,
50
+ };
51
+
52
+ const result = await this.sdk._fetch(`/externalOAuth/${id}`, 'PUT', params);
53
+ return result;
54
+ }
55
+
56
+ async delete(id) {
57
+ this.sdk.validateParams(
58
+ { id },
59
+ {
60
+ id: { type: 'string', required: true },
61
+ },
62
+ );
63
+
64
+ const result = await this.sdk._fetch(`/externalOAuth/${id}`, 'DELETE');
65
+ return result;
66
+ }
67
+
68
+ async get(id) {
69
+ this.sdk.validateParams(
70
+ { id },
71
+ {
72
+ id: { type: 'string', required: true },
73
+ },
74
+ );
75
+
76
+ const result = await this.sdk._fetch(`/externalOAuth/${id}`, 'GET');
77
+ return result;
78
+ }
79
+
80
+ async getByName(name) {
81
+ this.sdk.validateParams(
82
+ { name },
83
+ {
84
+ name: { type: 'string', required: true },
85
+ },
86
+ );
87
+
88
+ const params = {
89
+ query: { name },
90
+ };
91
+
92
+ const result = await this.sdk._fetch('/externalOAuth/byName', 'GET', params);
93
+ return result;
94
+ }
95
+
96
+ async getByScopeAndProvider(scope, provider) {
97
+ this.sdk.validateParams(
98
+ { scope, provider },
99
+ {
100
+ scope: { type: 'string', required: true },
101
+ provider: { type: 'string', required: true },
102
+ },
103
+ );
104
+
105
+ const params = {
106
+ query: { scope, provider },
107
+ };
108
+
109
+ const result = await this.sdk._fetch('/externalOAuth/byScopeAndProvider', 'GET', params);
110
+ return result;
111
+ }
112
+
113
+ async list() {
114
+ const result = await this.sdk._fetch('/externalOAuth', 'GET');
115
+ return result;
116
+ }
117
+ }
@@ -0,0 +1,39 @@
1
+ export class GenerateIdService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async createId({ service, serviceCode }) {
7
+ // Either service or serviceCode is required
8
+ if (!service && !serviceCode) {
9
+ throw new Error('Either service or serviceCode parameter is required');
10
+ }
11
+
12
+ this.sdk.validateParams(
13
+ { service, serviceCode },
14
+ {
15
+ service: { type: 'string', required: false },
16
+ serviceCode: { type: 'string', required: false },
17
+ },
18
+ );
19
+
20
+ const params = {
21
+ query: { service, serviceCode },
22
+ };
23
+
24
+ const result = await this.sdk._fetch('/generateId/', 'POST', params);
25
+ return result;
26
+ }
27
+
28
+ async validateId(input) {
29
+ this.sdk.validateParams(
30
+ { input },
31
+ {
32
+ input: { type: 'string', required: true },
33
+ },
34
+ );
35
+
36
+ const result = await this.sdk._fetch(`/generateId/${input}`, 'GET');
37
+ return result;
38
+ }
39
+ }
@@ -0,0 +1,92 @@
1
+ export class GoogleCalendarService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async setupWebhook({ calendarId, eventTypes, webhookUrl, expirationTime }) {
7
+ this.sdk.validateParams(
8
+ { calendarId, eventTypes, webhookUrl },
9
+ {
10
+ calendarId: { type: 'string', required: true },
11
+ eventTypes: { type: 'array', required: true },
12
+ webhookUrl: { type: 'string', required: true },
13
+ expirationTime: { type: 'number', required: false },
14
+ },
15
+ );
16
+
17
+ const webhookData = { calendarId, eventTypes, webhookUrl };
18
+ if (expirationTime) webhookData.expirationTime = expirationTime;
19
+
20
+ const params = {
21
+ body: webhookData,
22
+ };
23
+
24
+ const result = await this.sdk._fetch('/googleCalendar/webhook', 'POST', params);
25
+ return result;
26
+ }
27
+
28
+ async removeWebhook(webhookId) {
29
+ this.sdk.validateParams(
30
+ { webhookId },
31
+ {
32
+ webhookId: { type: 'string', required: true },
33
+ },
34
+ );
35
+
36
+ const result = await this.sdk._fetch(`/googleCalendar/webhook/${webhookId}`, 'DELETE');
37
+ return result;
38
+ }
39
+
40
+ async listWebhooks() {
41
+ const result = await this.sdk._fetch('/googleCalendar/webhooks', 'GET');
42
+ return result;
43
+ }
44
+
45
+ async getCalendarList() {
46
+ const result = await this.sdk._fetch('/googleCalendar/calendars', 'GET');
47
+ return result;
48
+ }
49
+
50
+ async getCalendarEvents(calendarId, options = {}) {
51
+ this.sdk.validateParams(
52
+ { calendarId },
53
+ {
54
+ calendarId: { type: 'string', required: true },
55
+ },
56
+ );
57
+
58
+ // Validate optional parameters
59
+ const validationSchema = {};
60
+ if ('timeMin' in options) validationSchema.timeMin = { type: 'string' };
61
+ if ('timeMax' in options) validationSchema.timeMax = { type: 'string' };
62
+ if ('maxResults' in options) validationSchema.maxResults = { type: 'number' };
63
+ if ('orderBy' in options) validationSchema.orderBy = { type: 'string' };
64
+
65
+ if (Object.keys(validationSchema).length > 0) {
66
+ this.sdk.validateParams(options, validationSchema);
67
+ }
68
+
69
+ const params = {
70
+ query: { calendarId, ...options },
71
+ };
72
+
73
+ const result = await this.sdk._fetch('/googleCalendar/events', 'GET', params);
74
+ return result;
75
+ }
76
+
77
+ async processCalendarChange(changeData) {
78
+ this.sdk.validateParams(
79
+ { changeData },
80
+ {
81
+ changeData: { type: 'object', required: true },
82
+ },
83
+ );
84
+
85
+ const params = {
86
+ body: changeData,
87
+ };
88
+
89
+ const result = await this.sdk._fetch('/googleCalendar/processChange', 'POST', params);
90
+ return result;
91
+ }
92
+ }
@@ -0,0 +1,91 @@
1
+ export class LayoutsService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async get(objectName, id, query = {}) {
7
+ this.sdk.validateParams(
8
+ { objectName, id, query },
9
+ {
10
+ objectName: { type: 'string', required: false },
11
+ id: { type: 'string', required: false },
12
+ query: { type: 'object', required: false },
13
+ },
14
+ );
15
+
16
+ const params = {
17
+ query,
18
+ }
19
+
20
+ let uri = `/layouts/${objectName}`;
21
+ if (id) {
22
+ uri = `${uri}/${id}`
23
+ }
24
+
25
+ const result = await this.sdk._fetch(uri, 'GET', params);
26
+ return result;
27
+ }
28
+
29
+ async create(layout) {
30
+ this.sdk.validateParams(
31
+ { layout },
32
+ {
33
+ layout: { type: 'object', required: true },
34
+ },
35
+ );
36
+
37
+ const params = {
38
+ body: layout,
39
+ }
40
+
41
+ const result = await this.sdk._fetch('/layouts/', 'POST', params);
42
+ return result;
43
+ }
44
+
45
+ async update(id, layout) {
46
+ this.sdk.validateParams(
47
+ { id, layout },
48
+ {
49
+ id: { type: 'string', required: true },
50
+ layout: { type: 'object', required: true },
51
+ },
52
+ );
53
+
54
+ const params = {
55
+ body: layout,
56
+ }
57
+
58
+ const result = await this.sdk._fetch(`/layouts/${id}`, 'PUT', params);
59
+ return result;
60
+ }
61
+
62
+ async delete(id) {
63
+ this.sdk.validateParams(
64
+ { id },
65
+ {
66
+ id: { type: 'string', required: true },
67
+ },
68
+ );
69
+
70
+ const params = {}
71
+
72
+ const result = await this.sdk._fetch(`/layouts/${id}`, 'DELETE', params);
73
+ return result;
74
+ }
75
+
76
+ async dynamicSelectSearch(query) {
77
+ this.sdk.validateParams(
78
+ { query },
79
+ {
80
+ query: { type: 'object', required: true },
81
+ },
82
+ );
83
+
84
+ const params = {
85
+ query,
86
+ }
87
+
88
+ const result = await this.sdk._fetch('/layouts/dynamic-select-search', 'GET', params);
89
+ return result;
90
+ }
91
+ }
@@ -0,0 +1,76 @@
1
+ export class LoginService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async login(username, password, namespace) {
7
+ this.sdk.validateParams(
8
+ { username, password },
9
+ {
10
+ username: { type: 'string', required: true },
11
+ password: { type: 'string', required: true },
12
+ namespace: { type: 'string', required: false },
13
+ },
14
+ );
15
+
16
+ const options = {
17
+ body: { username, password, tokenType: 'cookie', namespace },
18
+ };
19
+
20
+ const login = await this.sdk._fetch('/login', 'POST', options, true);
21
+
22
+ if (typeof window !== 'undefined') {
23
+ const canUseLocalStorage = typeof localStorage !== 'undefined';
24
+ if (login?.namespace && canUseLocalStorage) {
25
+ localStorage.setItem('unbound_url', login.url);
26
+ localStorage.setItem('unbound_userId', login.userId);
27
+ localStorage.setItem('unbound_namespace', login.namespace);
28
+ }
29
+ }
30
+
31
+ return {
32
+ valid: true,
33
+ userId: login.userId,
34
+ namespace: login.namespace,
35
+ url: login.url,
36
+ };
37
+ }
38
+
39
+ async logout() {
40
+ const logout = await this.sdk._fetch('/login', 'DELETE', {}, true);
41
+
42
+ if (typeof window !== 'undefined') {
43
+ const canUseLocalStorage = typeof localStorage !== 'undefined';
44
+ if (canUseLocalStorage) {
45
+ localStorage.removeItem('unbound_url');
46
+ localStorage.removeItem('unbound_userId');
47
+ localStorage.removeItem('unbound_namespace');
48
+ }
49
+ }
50
+
51
+ return true;
52
+ }
53
+
54
+ async validate() {
55
+ const options = {};
56
+ const validation = await this.sdk._fetch('/login/validate', 'POST', options, true);
57
+ return validation;
58
+ }
59
+
60
+ async changePassword(currentPassword, newPassword) {
61
+ this.sdk.validateParams(
62
+ { currentPassword, newPassword },
63
+ {
64
+ currentPassword: { type: 'string', required: true },
65
+ newPassword: { type: 'string', required: true },
66
+ },
67
+ );
68
+
69
+ const options = {
70
+ body: { currentPassword, newPassword },
71
+ };
72
+
73
+ const result = await this.sdk._fetch('/login/changePassword', 'POST', options);
74
+ return result;
75
+ }
76
+ }
@@ -0,0 +1,53 @@
1
+ export class LookupService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ async cnam(phoneNumber) {
7
+ this.sdk.validateParams(
8
+ { phoneNumber },
9
+ {
10
+ phoneNumber: { type: 'string', required: true },
11
+ },
12
+ );
13
+
14
+ const params = {
15
+ query: { phoneNumber },
16
+ };
17
+
18
+ const result = await this.sdk._fetch('/lookup/cnam', 'GET', params);
19
+ return result;
20
+ }
21
+
22
+ async lrn(phoneNumber) {
23
+ this.sdk.validateParams(
24
+ { phoneNumber },
25
+ {
26
+ phoneNumber: { type: 'string', required: true },
27
+ },
28
+ );
29
+
30
+ const params = {
31
+ query: { phoneNumber },
32
+ };
33
+
34
+ const result = await this.sdk._fetch('/lookup/lrn', 'GET', params);
35
+ return result;
36
+ }
37
+
38
+ async number(phoneNumber) {
39
+ this.sdk.validateParams(
40
+ { phoneNumber },
41
+ {
42
+ phoneNumber: { type: 'string', required: true },
43
+ },
44
+ );
45
+
46
+ const params = {
47
+ query: { phoneNumber },
48
+ };
49
+
50
+ const result = await this.sdk._fetch('/lookup/number', 'GET', params);
51
+ return result;
52
+ }
53
+ }