@juhuu/sdk-ts 1.2.145 → 1.2.147
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/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.js +129 -36
- package/dist/index.mjs +129 -36
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -539,6 +539,9 @@ declare class Service {
|
|
539
539
|
readonly httpBaseUrl: string;
|
540
540
|
readonly wssBaseUrl: string;
|
541
541
|
readonly clientVersion: string;
|
542
|
+
readonly apiKey: string | null;
|
543
|
+
readonly defaultRequestOptions: JUHUU.RequestOptions;
|
544
|
+
readonly authenticationMode: "jwt" | "apiKey";
|
542
545
|
onException: <T>(response: JUHUU.HttpResponse<T>) => Promise<"abort" | "retry">;
|
543
546
|
getAccessToken: () => Promise<string | null> | null;
|
544
547
|
setAccessToken: (accessToken: string) => Promise<void>;
|
@@ -893,13 +896,16 @@ declare class Juhuu {
|
|
893
896
|
}
|
894
897
|
declare namespace JUHUU {
|
895
898
|
interface SetupConfig {
|
896
|
-
environment
|
897
|
-
getAccessToken
|
898
|
-
onException
|
899
|
-
setAccessToken
|
900
|
-
getRefreshToken
|
901
|
-
setRefreshToken
|
899
|
+
environment?: Environment;
|
900
|
+
getAccessToken?: () => Promise<string | null>;
|
901
|
+
onException?: <T>(response: JUHUU.HttpResponse<T>) => Promise<"abort">;
|
902
|
+
setAccessToken?: (accessToken: string) => Promise<void>;
|
903
|
+
getRefreshToken?: () => Promise<string | null>;
|
904
|
+
setRefreshToken?: (refreshToken: string) => Promise<void>;
|
902
905
|
clientVersion: string;
|
906
|
+
apiKey?: string;
|
907
|
+
defaultRequestOptions?: JUHUU.RequestOptions;
|
908
|
+
authenticationMode?: "jwt" | "apiKey";
|
903
909
|
}
|
904
910
|
interface HttpResponse<T> {
|
905
911
|
ok: boolean;
|
@@ -925,6 +931,10 @@ declare namespace JUHUU {
|
|
925
931
|
* If this is true, a new accessToken will be requested if the current one is expired.
|
926
932
|
*/
|
927
933
|
refreshTokensIfNecessary?: boolean;
|
934
|
+
/**
|
935
|
+
* If this API key is provided, the request will be sent with this API key instead of the one passed to config.
|
936
|
+
*/
|
937
|
+
apiKey?: string | null;
|
928
938
|
};
|
929
939
|
interface LocaleString {
|
930
940
|
de?: string;
|
@@ -1488,6 +1498,7 @@ declare namespace JUHUU {
|
|
1488
1498
|
namespace Create {
|
1489
1499
|
type Params = {
|
1490
1500
|
propertyId: string;
|
1501
|
+
name?: string;
|
1491
1502
|
};
|
1492
1503
|
type Options = JUHUU.RequestOptions;
|
1493
1504
|
type Response = {
|
package/dist/index.d.ts
CHANGED
@@ -539,6 +539,9 @@ declare class Service {
|
|
539
539
|
readonly httpBaseUrl: string;
|
540
540
|
readonly wssBaseUrl: string;
|
541
541
|
readonly clientVersion: string;
|
542
|
+
readonly apiKey: string | null;
|
543
|
+
readonly defaultRequestOptions: JUHUU.RequestOptions;
|
544
|
+
readonly authenticationMode: "jwt" | "apiKey";
|
542
545
|
onException: <T>(response: JUHUU.HttpResponse<T>) => Promise<"abort" | "retry">;
|
543
546
|
getAccessToken: () => Promise<string | null> | null;
|
544
547
|
setAccessToken: (accessToken: string) => Promise<void>;
|
@@ -893,13 +896,16 @@ declare class Juhuu {
|
|
893
896
|
}
|
894
897
|
declare namespace JUHUU {
|
895
898
|
interface SetupConfig {
|
896
|
-
environment
|
897
|
-
getAccessToken
|
898
|
-
onException
|
899
|
-
setAccessToken
|
900
|
-
getRefreshToken
|
901
|
-
setRefreshToken
|
899
|
+
environment?: Environment;
|
900
|
+
getAccessToken?: () => Promise<string | null>;
|
901
|
+
onException?: <T>(response: JUHUU.HttpResponse<T>) => Promise<"abort">;
|
902
|
+
setAccessToken?: (accessToken: string) => Promise<void>;
|
903
|
+
getRefreshToken?: () => Promise<string | null>;
|
904
|
+
setRefreshToken?: (refreshToken: string) => Promise<void>;
|
902
905
|
clientVersion: string;
|
906
|
+
apiKey?: string;
|
907
|
+
defaultRequestOptions?: JUHUU.RequestOptions;
|
908
|
+
authenticationMode?: "jwt" | "apiKey";
|
903
909
|
}
|
904
910
|
interface HttpResponse<T> {
|
905
911
|
ok: boolean;
|
@@ -925,6 +931,10 @@ declare namespace JUHUU {
|
|
925
931
|
* If this is true, a new accessToken will be requested if the current one is expired.
|
926
932
|
*/
|
927
933
|
refreshTokensIfNecessary?: boolean;
|
934
|
+
/**
|
935
|
+
* If this API key is provided, the request will be sent with this API key instead of the one passed to config.
|
936
|
+
*/
|
937
|
+
apiKey?: string | null;
|
928
938
|
};
|
929
939
|
interface LocaleString {
|
930
940
|
de?: string;
|
@@ -1488,6 +1498,7 @@ declare namespace JUHUU {
|
|
1488
1498
|
namespace Create {
|
1489
1499
|
type Params = {
|
1490
1500
|
propertyId: string;
|
1501
|
+
name?: string;
|
1491
1502
|
};
|
1492
1503
|
type Options = JUHUU.RequestOptions;
|
1493
1504
|
type Response = {
|
package/dist/index.js
CHANGED
@@ -46,14 +46,17 @@ module.exports = __toCommonJS(src_exports);
|
|
46
46
|
var import_socket = __toESM(require("socket.io-client"));
|
47
47
|
var Service = class {
|
48
48
|
constructor(config) {
|
49
|
-
this.environment = config.environment;
|
50
|
-
this.getAccessToken = config.getAccessToken;
|
51
|
-
this.onException = config.onException;
|
52
|
-
this.setAccessToken = config.setAccessToken;
|
53
|
-
this.getAccessToken = config.getAccessToken;
|
54
|
-
this.setRefreshToken = config.setRefreshToken;
|
55
|
-
this.getRefreshToken = config.getRefreshToken;
|
49
|
+
this.environment = config.environment ?? "production";
|
50
|
+
this.getAccessToken = config.getAccessToken ?? (() => null);
|
51
|
+
this.onException = config.onException ?? (() => Promise.resolve("abort"));
|
52
|
+
this.setAccessToken = config.setAccessToken ?? (() => Promise.resolve());
|
53
|
+
this.getAccessToken = config.getAccessToken ?? (() => null);
|
54
|
+
this.setRefreshToken = config.setRefreshToken ?? (() => Promise.resolve());
|
55
|
+
this.getRefreshToken = config.getRefreshToken ?? (() => Promise.resolve(null));
|
56
56
|
this.clientVersion = config.clientVersion;
|
57
|
+
this.apiKey = config.apiKey ?? null;
|
58
|
+
this.defaultRequestOptions = config.defaultRequestOptions ?? {};
|
59
|
+
this.authenticationMode = config.authenticationMode ?? "jwt";
|
57
60
|
switch (config.environment) {
|
58
61
|
case "development":
|
59
62
|
this.httpBaseUrl = "https://api.juhuu.dev/v1/";
|
@@ -69,6 +72,9 @@ var Service = class {
|
|
69
72
|
httpBaseUrl;
|
70
73
|
wssBaseUrl;
|
71
74
|
clientVersion;
|
75
|
+
apiKey;
|
76
|
+
defaultRequestOptions;
|
77
|
+
authenticationMode;
|
72
78
|
onException;
|
73
79
|
getAccessToken;
|
74
80
|
setAccessToken;
|
@@ -80,49 +86,105 @@ var Service = class {
|
|
80
86
|
body = void 0,
|
81
87
|
authenticationNotOptional
|
82
88
|
}, options = {}) {
|
83
|
-
|
84
|
-
|
89
|
+
const currentOptions = {
|
90
|
+
...this.defaultRequestOptions,
|
91
|
+
...options
|
92
|
+
};
|
93
|
+
if (currentOptions.triggerOnException === void 0) {
|
94
|
+
switch (this.authenticationMode) {
|
95
|
+
case "jwt": {
|
96
|
+
currentOptions.triggerOnException = true;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
case "apiKey": {
|
100
|
+
currentOptions.triggerOnException = false;
|
101
|
+
break;
|
102
|
+
}
|
103
|
+
}
|
85
104
|
}
|
86
|
-
if (
|
87
|
-
|
105
|
+
if (currentOptions.refreshTokensIfNecessary === void 0) {
|
106
|
+
switch (this.authenticationMode) {
|
107
|
+
case "jwt": {
|
108
|
+
currentOptions.refreshTokensIfNecessary = true;
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
case "apiKey": {
|
112
|
+
currentOptions.refreshTokensIfNecessary = false;
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
}
|
88
116
|
}
|
117
|
+
console.log("currentOptions", currentOptions);
|
89
118
|
let token = null;
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
"
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
119
|
+
let apiKey = null;
|
120
|
+
switch (this.authenticationMode) {
|
121
|
+
case "jwt": {
|
122
|
+
if (currentOptions.accessToken === void 0 || currentOptions.accessToken === null) {
|
123
|
+
token = await this.getAccessToken();
|
124
|
+
} else {
|
125
|
+
token = currentOptions.accessToken;
|
126
|
+
}
|
127
|
+
console.log("accessToken:", token);
|
128
|
+
if ((token === null || token === void 0) && authenticationNotOptional === true) {
|
129
|
+
console.error(
|
130
|
+
"endpoint",
|
131
|
+
url,
|
132
|
+
"should use authentication but no token was found"
|
133
|
+
);
|
134
|
+
return {
|
135
|
+
ok: false,
|
136
|
+
data: {}
|
137
|
+
};
|
138
|
+
}
|
139
|
+
break;
|
140
|
+
}
|
141
|
+
case "apiKey": {
|
142
|
+
if (currentOptions.apiKey === void 0 || currentOptions.apiKey === null) {
|
143
|
+
apiKey = this.apiKey;
|
144
|
+
} else {
|
145
|
+
apiKey = currentOptions.apiKey;
|
146
|
+
}
|
147
|
+
if (apiKey === null) {
|
148
|
+
console.error(
|
149
|
+
"endpoint",
|
150
|
+
url,
|
151
|
+
"should use authentication but no apiKey was found"
|
152
|
+
);
|
153
|
+
return {
|
154
|
+
ok: false,
|
155
|
+
data: {}
|
156
|
+
};
|
157
|
+
}
|
158
|
+
break;
|
159
|
+
}
|
106
160
|
}
|
107
161
|
const uri = this.httpBaseUrl + url;
|
108
162
|
let response = null;
|
109
163
|
let responseObject = null;
|
164
|
+
console.log(
|
165
|
+
"sending request to",
|
166
|
+
uri,
|
167
|
+
"with apiKey",
|
168
|
+
apiKey,
|
169
|
+
"and token",
|
170
|
+
token
|
171
|
+
);
|
110
172
|
try {
|
111
173
|
switch (method) {
|
112
174
|
case "GET": {
|
113
|
-
response = await this.sendGetRequest(token, uri);
|
175
|
+
response = await this.sendGetRequest({ token, uri, apiKey });
|
114
176
|
break;
|
115
177
|
}
|
116
178
|
case "POST": {
|
117
|
-
response = await this.sendPostRequest(token, uri, body);
|
179
|
+
response = await this.sendPostRequest({ token, uri, body, apiKey });
|
118
180
|
break;
|
119
181
|
}
|
120
182
|
case "PATCH": {
|
121
|
-
response = await this.sendPatchRequest(token, uri, body);
|
183
|
+
response = await this.sendPatchRequest({ token, uri, body, apiKey });
|
122
184
|
break;
|
123
185
|
}
|
124
186
|
case "DELETE": {
|
125
|
-
response = await this.sendDeleteRequest(token, uri);
|
187
|
+
response = await this.sendDeleteRequest({ token, uri, apiKey });
|
126
188
|
break;
|
127
189
|
}
|
128
190
|
}
|
@@ -210,7 +272,11 @@ var Service = class {
|
|
210
272
|
}
|
211
273
|
return responseObject;
|
212
274
|
}
|
213
|
-
async sendGetRequest(
|
275
|
+
async sendGetRequest({
|
276
|
+
token,
|
277
|
+
apiKey,
|
278
|
+
uri
|
279
|
+
}) {
|
214
280
|
const headers = {
|
215
281
|
"Content-Type": "application/json",
|
216
282
|
"Client-Version": this.clientVersion
|
@@ -218,12 +284,20 @@ var Service = class {
|
|
218
284
|
if (token !== void 0 && token !== null) {
|
219
285
|
headers.Authorization = `Bearer ${token}`;
|
220
286
|
}
|
287
|
+
if (apiKey !== null) {
|
288
|
+
headers["X-API-KEY"] = apiKey;
|
289
|
+
}
|
221
290
|
return await fetch(uri, {
|
222
291
|
method: "GET",
|
223
292
|
headers
|
224
293
|
});
|
225
294
|
}
|
226
|
-
async sendPostRequest(
|
295
|
+
async sendPostRequest({
|
296
|
+
token,
|
297
|
+
uri,
|
298
|
+
apiKey,
|
299
|
+
body
|
300
|
+
}) {
|
227
301
|
const headers = {
|
228
302
|
"Content-Type": "application/json",
|
229
303
|
"Client-Version": this.clientVersion
|
@@ -231,13 +305,21 @@ var Service = class {
|
|
231
305
|
if (token !== void 0 && token !== null) {
|
232
306
|
headers.Authorization = `Bearer ${token}`;
|
233
307
|
}
|
308
|
+
if (apiKey !== null) {
|
309
|
+
headers["X-API-KEY"] = apiKey;
|
310
|
+
}
|
234
311
|
return await fetch(uri, {
|
235
312
|
method: "POST",
|
236
313
|
headers,
|
237
314
|
body: JSON.stringify(body)
|
238
315
|
});
|
239
316
|
}
|
240
|
-
async sendPatchRequest(
|
317
|
+
async sendPatchRequest({
|
318
|
+
token,
|
319
|
+
uri,
|
320
|
+
apiKey,
|
321
|
+
body
|
322
|
+
}) {
|
241
323
|
const headers = {
|
242
324
|
"Content-Type": "application/json",
|
243
325
|
"Client-Version": this.clientVersion
|
@@ -245,13 +327,20 @@ var Service = class {
|
|
245
327
|
if (token !== void 0 && token !== null) {
|
246
328
|
headers.Authorization = `Bearer ${token}`;
|
247
329
|
}
|
330
|
+
if (apiKey !== null) {
|
331
|
+
headers["X-API-KEY"] = apiKey;
|
332
|
+
}
|
248
333
|
return await fetch(uri, {
|
249
334
|
method: "PATCH",
|
250
335
|
headers,
|
251
336
|
body: JSON.stringify(body)
|
252
337
|
});
|
253
338
|
}
|
254
|
-
async sendDeleteRequest(
|
339
|
+
async sendDeleteRequest({
|
340
|
+
token,
|
341
|
+
uri,
|
342
|
+
apiKey
|
343
|
+
}) {
|
255
344
|
const headers = {
|
256
345
|
"Content-Type": "application/json",
|
257
346
|
"Client-Version": this.clientVersion
|
@@ -259,6 +348,9 @@ var Service = class {
|
|
259
348
|
if (token !== void 0 && token !== null) {
|
260
349
|
headers.Authorization = `Bearer ${token}`;
|
261
350
|
}
|
351
|
+
if (apiKey !== null) {
|
352
|
+
headers["X-API-KEY"] = apiKey;
|
353
|
+
}
|
262
354
|
return await fetch(uri, {
|
263
355
|
method: "DELETE",
|
264
356
|
headers
|
@@ -885,7 +977,8 @@ var PropertiesService = class extends Service {
|
|
885
977
|
primaryColor: PropertyOnboardingParams.primaryColor,
|
886
978
|
backgroundColor: PropertyOnboardingParams.backgroundColor,
|
887
979
|
logo: PropertyOnboardingParams.logo,
|
888
|
-
name: PropertyOnboardingParams.name
|
980
|
+
name: PropertyOnboardingParams.name,
|
981
|
+
eligibleToCreateOnBehalfOfBusiness: PropertyOnboardingParams.eligibleToCreateOnBehalfOfBusiness
|
889
982
|
},
|
890
983
|
authenticationNotOptional: true
|
891
984
|
},
|
package/dist/index.mjs
CHANGED
@@ -2,14 +2,17 @@
|
|
2
2
|
import io from "socket.io-client";
|
3
3
|
var Service = class {
|
4
4
|
constructor(config) {
|
5
|
-
this.environment = config.environment;
|
6
|
-
this.getAccessToken = config.getAccessToken;
|
7
|
-
this.onException = config.onException;
|
8
|
-
this.setAccessToken = config.setAccessToken;
|
9
|
-
this.getAccessToken = config.getAccessToken;
|
10
|
-
this.setRefreshToken = config.setRefreshToken;
|
11
|
-
this.getRefreshToken = config.getRefreshToken;
|
5
|
+
this.environment = config.environment ?? "production";
|
6
|
+
this.getAccessToken = config.getAccessToken ?? (() => null);
|
7
|
+
this.onException = config.onException ?? (() => Promise.resolve("abort"));
|
8
|
+
this.setAccessToken = config.setAccessToken ?? (() => Promise.resolve());
|
9
|
+
this.getAccessToken = config.getAccessToken ?? (() => null);
|
10
|
+
this.setRefreshToken = config.setRefreshToken ?? (() => Promise.resolve());
|
11
|
+
this.getRefreshToken = config.getRefreshToken ?? (() => Promise.resolve(null));
|
12
12
|
this.clientVersion = config.clientVersion;
|
13
|
+
this.apiKey = config.apiKey ?? null;
|
14
|
+
this.defaultRequestOptions = config.defaultRequestOptions ?? {};
|
15
|
+
this.authenticationMode = config.authenticationMode ?? "jwt";
|
13
16
|
switch (config.environment) {
|
14
17
|
case "development":
|
15
18
|
this.httpBaseUrl = "https://api.juhuu.dev/v1/";
|
@@ -25,6 +28,9 @@ var Service = class {
|
|
25
28
|
httpBaseUrl;
|
26
29
|
wssBaseUrl;
|
27
30
|
clientVersion;
|
31
|
+
apiKey;
|
32
|
+
defaultRequestOptions;
|
33
|
+
authenticationMode;
|
28
34
|
onException;
|
29
35
|
getAccessToken;
|
30
36
|
setAccessToken;
|
@@ -36,49 +42,105 @@ var Service = class {
|
|
36
42
|
body = void 0,
|
37
43
|
authenticationNotOptional
|
38
44
|
}, options = {}) {
|
39
|
-
|
40
|
-
|
45
|
+
const currentOptions = {
|
46
|
+
...this.defaultRequestOptions,
|
47
|
+
...options
|
48
|
+
};
|
49
|
+
if (currentOptions.triggerOnException === void 0) {
|
50
|
+
switch (this.authenticationMode) {
|
51
|
+
case "jwt": {
|
52
|
+
currentOptions.triggerOnException = true;
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
case "apiKey": {
|
56
|
+
currentOptions.triggerOnException = false;
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
}
|
41
60
|
}
|
42
|
-
if (
|
43
|
-
|
61
|
+
if (currentOptions.refreshTokensIfNecessary === void 0) {
|
62
|
+
switch (this.authenticationMode) {
|
63
|
+
case "jwt": {
|
64
|
+
currentOptions.refreshTokensIfNecessary = true;
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
case "apiKey": {
|
68
|
+
currentOptions.refreshTokensIfNecessary = false;
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
}
|
44
72
|
}
|
73
|
+
console.log("currentOptions", currentOptions);
|
45
74
|
let token = null;
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
75
|
+
let apiKey = null;
|
76
|
+
switch (this.authenticationMode) {
|
77
|
+
case "jwt": {
|
78
|
+
if (currentOptions.accessToken === void 0 || currentOptions.accessToken === null) {
|
79
|
+
token = await this.getAccessToken();
|
80
|
+
} else {
|
81
|
+
token = currentOptions.accessToken;
|
82
|
+
}
|
83
|
+
console.log("accessToken:", token);
|
84
|
+
if ((token === null || token === void 0) && authenticationNotOptional === true) {
|
85
|
+
console.error(
|
86
|
+
"endpoint",
|
87
|
+
url,
|
88
|
+
"should use authentication but no token was found"
|
89
|
+
);
|
90
|
+
return {
|
91
|
+
ok: false,
|
92
|
+
data: {}
|
93
|
+
};
|
94
|
+
}
|
95
|
+
break;
|
96
|
+
}
|
97
|
+
case "apiKey": {
|
98
|
+
if (currentOptions.apiKey === void 0 || currentOptions.apiKey === null) {
|
99
|
+
apiKey = this.apiKey;
|
100
|
+
} else {
|
101
|
+
apiKey = currentOptions.apiKey;
|
102
|
+
}
|
103
|
+
if (apiKey === null) {
|
104
|
+
console.error(
|
105
|
+
"endpoint",
|
106
|
+
url,
|
107
|
+
"should use authentication but no apiKey was found"
|
108
|
+
);
|
109
|
+
return {
|
110
|
+
ok: false,
|
111
|
+
data: {}
|
112
|
+
};
|
113
|
+
}
|
114
|
+
break;
|
115
|
+
}
|
62
116
|
}
|
63
117
|
const uri = this.httpBaseUrl + url;
|
64
118
|
let response = null;
|
65
119
|
let responseObject = null;
|
120
|
+
console.log(
|
121
|
+
"sending request to",
|
122
|
+
uri,
|
123
|
+
"with apiKey",
|
124
|
+
apiKey,
|
125
|
+
"and token",
|
126
|
+
token
|
127
|
+
);
|
66
128
|
try {
|
67
129
|
switch (method) {
|
68
130
|
case "GET": {
|
69
|
-
response = await this.sendGetRequest(token, uri);
|
131
|
+
response = await this.sendGetRequest({ token, uri, apiKey });
|
70
132
|
break;
|
71
133
|
}
|
72
134
|
case "POST": {
|
73
|
-
response = await this.sendPostRequest(token, uri, body);
|
135
|
+
response = await this.sendPostRequest({ token, uri, body, apiKey });
|
74
136
|
break;
|
75
137
|
}
|
76
138
|
case "PATCH": {
|
77
|
-
response = await this.sendPatchRequest(token, uri, body);
|
139
|
+
response = await this.sendPatchRequest({ token, uri, body, apiKey });
|
78
140
|
break;
|
79
141
|
}
|
80
142
|
case "DELETE": {
|
81
|
-
response = await this.sendDeleteRequest(token, uri);
|
143
|
+
response = await this.sendDeleteRequest({ token, uri, apiKey });
|
82
144
|
break;
|
83
145
|
}
|
84
146
|
}
|
@@ -166,7 +228,11 @@ var Service = class {
|
|
166
228
|
}
|
167
229
|
return responseObject;
|
168
230
|
}
|
169
|
-
async sendGetRequest(
|
231
|
+
async sendGetRequest({
|
232
|
+
token,
|
233
|
+
apiKey,
|
234
|
+
uri
|
235
|
+
}) {
|
170
236
|
const headers = {
|
171
237
|
"Content-Type": "application/json",
|
172
238
|
"Client-Version": this.clientVersion
|
@@ -174,12 +240,20 @@ var Service = class {
|
|
174
240
|
if (token !== void 0 && token !== null) {
|
175
241
|
headers.Authorization = `Bearer ${token}`;
|
176
242
|
}
|
243
|
+
if (apiKey !== null) {
|
244
|
+
headers["X-API-KEY"] = apiKey;
|
245
|
+
}
|
177
246
|
return await fetch(uri, {
|
178
247
|
method: "GET",
|
179
248
|
headers
|
180
249
|
});
|
181
250
|
}
|
182
|
-
async sendPostRequest(
|
251
|
+
async sendPostRequest({
|
252
|
+
token,
|
253
|
+
uri,
|
254
|
+
apiKey,
|
255
|
+
body
|
256
|
+
}) {
|
183
257
|
const headers = {
|
184
258
|
"Content-Type": "application/json",
|
185
259
|
"Client-Version": this.clientVersion
|
@@ -187,13 +261,21 @@ var Service = class {
|
|
187
261
|
if (token !== void 0 && token !== null) {
|
188
262
|
headers.Authorization = `Bearer ${token}`;
|
189
263
|
}
|
264
|
+
if (apiKey !== null) {
|
265
|
+
headers["X-API-KEY"] = apiKey;
|
266
|
+
}
|
190
267
|
return await fetch(uri, {
|
191
268
|
method: "POST",
|
192
269
|
headers,
|
193
270
|
body: JSON.stringify(body)
|
194
271
|
});
|
195
272
|
}
|
196
|
-
async sendPatchRequest(
|
273
|
+
async sendPatchRequest({
|
274
|
+
token,
|
275
|
+
uri,
|
276
|
+
apiKey,
|
277
|
+
body
|
278
|
+
}) {
|
197
279
|
const headers = {
|
198
280
|
"Content-Type": "application/json",
|
199
281
|
"Client-Version": this.clientVersion
|
@@ -201,13 +283,20 @@ var Service = class {
|
|
201
283
|
if (token !== void 0 && token !== null) {
|
202
284
|
headers.Authorization = `Bearer ${token}`;
|
203
285
|
}
|
286
|
+
if (apiKey !== null) {
|
287
|
+
headers["X-API-KEY"] = apiKey;
|
288
|
+
}
|
204
289
|
return await fetch(uri, {
|
205
290
|
method: "PATCH",
|
206
291
|
headers,
|
207
292
|
body: JSON.stringify(body)
|
208
293
|
});
|
209
294
|
}
|
210
|
-
async sendDeleteRequest(
|
295
|
+
async sendDeleteRequest({
|
296
|
+
token,
|
297
|
+
uri,
|
298
|
+
apiKey
|
299
|
+
}) {
|
211
300
|
const headers = {
|
212
301
|
"Content-Type": "application/json",
|
213
302
|
"Client-Version": this.clientVersion
|
@@ -215,6 +304,9 @@ var Service = class {
|
|
215
304
|
if (token !== void 0 && token !== null) {
|
216
305
|
headers.Authorization = `Bearer ${token}`;
|
217
306
|
}
|
307
|
+
if (apiKey !== null) {
|
308
|
+
headers["X-API-KEY"] = apiKey;
|
309
|
+
}
|
218
310
|
return await fetch(uri, {
|
219
311
|
method: "DELETE",
|
220
312
|
headers
|
@@ -841,7 +933,8 @@ var PropertiesService = class extends Service {
|
|
841
933
|
primaryColor: PropertyOnboardingParams.primaryColor,
|
842
934
|
backgroundColor: PropertyOnboardingParams.backgroundColor,
|
843
935
|
logo: PropertyOnboardingParams.logo,
|
844
|
-
name: PropertyOnboardingParams.name
|
936
|
+
name: PropertyOnboardingParams.name,
|
937
|
+
eligibleToCreateOnBehalfOfBusiness: PropertyOnboardingParams.eligibleToCreateOnBehalfOfBusiness
|
845
938
|
},
|
846
939
|
authenticationNotOptional: true
|
847
940
|
},
|