@izak0s/spacebring-api 0.1.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/LICENSE +21 -0
- package/README.md +116 -0
- package/dist/index.cjs +2098 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +27384 -0
- package/dist/index.d.ts +27384 -0
- package/dist/index.js +2070 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2070 @@
|
|
|
1
|
+
// node_modules/openapi-fetch/dist/index.mjs
|
|
2
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
3
|
+
var supportsRequestInitExt = () => {
|
|
4
|
+
return typeof process === "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
|
|
5
|
+
};
|
|
6
|
+
function randomID() {
|
|
7
|
+
return Math.random().toString(36).slice(2, 11);
|
|
8
|
+
}
|
|
9
|
+
function createClient(clientOptions) {
|
|
10
|
+
let {
|
|
11
|
+
baseUrl = "",
|
|
12
|
+
Request: CustomRequest = globalThis.Request,
|
|
13
|
+
fetch: baseFetch = globalThis.fetch,
|
|
14
|
+
querySerializer: globalQuerySerializer,
|
|
15
|
+
bodySerializer: globalBodySerializer,
|
|
16
|
+
headers: baseHeaders,
|
|
17
|
+
requestInitExt = void 0,
|
|
18
|
+
...baseOptions
|
|
19
|
+
} = { ...clientOptions };
|
|
20
|
+
requestInitExt = supportsRequestInitExt() ? requestInitExt : void 0;
|
|
21
|
+
baseUrl = removeTrailingSlash(baseUrl);
|
|
22
|
+
const middlewares = [];
|
|
23
|
+
async function coreFetch(schemaPath, fetchOptions) {
|
|
24
|
+
const {
|
|
25
|
+
baseUrl: localBaseUrl,
|
|
26
|
+
fetch = baseFetch,
|
|
27
|
+
Request = CustomRequest,
|
|
28
|
+
headers,
|
|
29
|
+
params = {},
|
|
30
|
+
parseAs = "json",
|
|
31
|
+
querySerializer: requestQuerySerializer,
|
|
32
|
+
bodySerializer = globalBodySerializer ?? defaultBodySerializer,
|
|
33
|
+
body,
|
|
34
|
+
...init
|
|
35
|
+
} = fetchOptions || {};
|
|
36
|
+
let finalBaseUrl = baseUrl;
|
|
37
|
+
if (localBaseUrl) {
|
|
38
|
+
finalBaseUrl = removeTrailingSlash(localBaseUrl) ?? baseUrl;
|
|
39
|
+
}
|
|
40
|
+
let querySerializer = typeof globalQuerySerializer === "function" ? globalQuerySerializer : createQuerySerializer(globalQuerySerializer);
|
|
41
|
+
if (requestQuerySerializer) {
|
|
42
|
+
querySerializer = typeof requestQuerySerializer === "function" ? requestQuerySerializer : createQuerySerializer({
|
|
43
|
+
...typeof globalQuerySerializer === "object" ? globalQuerySerializer : {},
|
|
44
|
+
...requestQuerySerializer
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const serializedBody = body === void 0 ? void 0 : bodySerializer(
|
|
48
|
+
body,
|
|
49
|
+
// Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
|
|
50
|
+
// bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
|
|
51
|
+
// the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
|
|
52
|
+
// setting the content-type at the very beginning to be overwritten.
|
|
53
|
+
// Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
|
|
54
|
+
mergeHeaders(baseHeaders, headers, params.header)
|
|
55
|
+
);
|
|
56
|
+
const finalHeaders = mergeHeaders(
|
|
57
|
+
// with no body, we should not to set Content-Type
|
|
58
|
+
serializedBody === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
|
|
59
|
+
serializedBody instanceof FormData ? {} : {
|
|
60
|
+
"Content-Type": "application/json"
|
|
61
|
+
},
|
|
62
|
+
baseHeaders,
|
|
63
|
+
headers,
|
|
64
|
+
params.header
|
|
65
|
+
);
|
|
66
|
+
const requestInit = {
|
|
67
|
+
redirect: "follow",
|
|
68
|
+
...baseOptions,
|
|
69
|
+
...init,
|
|
70
|
+
body: serializedBody,
|
|
71
|
+
headers: finalHeaders
|
|
72
|
+
};
|
|
73
|
+
let id;
|
|
74
|
+
let options;
|
|
75
|
+
let request = new Request(
|
|
76
|
+
createFinalURL(schemaPath, { baseUrl: finalBaseUrl, params, querySerializer }),
|
|
77
|
+
requestInit
|
|
78
|
+
);
|
|
79
|
+
let response;
|
|
80
|
+
for (const key in init) {
|
|
81
|
+
if (!(key in request)) {
|
|
82
|
+
request[key] = init[key];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (middlewares.length) {
|
|
86
|
+
id = randomID();
|
|
87
|
+
options = Object.freeze({
|
|
88
|
+
baseUrl: finalBaseUrl,
|
|
89
|
+
fetch,
|
|
90
|
+
parseAs,
|
|
91
|
+
querySerializer,
|
|
92
|
+
bodySerializer
|
|
93
|
+
});
|
|
94
|
+
for (const m of middlewares) {
|
|
95
|
+
if (m && typeof m === "object" && typeof m.onRequest === "function") {
|
|
96
|
+
const result = await m.onRequest({
|
|
97
|
+
request,
|
|
98
|
+
schemaPath,
|
|
99
|
+
params,
|
|
100
|
+
options,
|
|
101
|
+
id
|
|
102
|
+
});
|
|
103
|
+
if (result) {
|
|
104
|
+
if (result instanceof Request) {
|
|
105
|
+
request = result;
|
|
106
|
+
} else if (result instanceof Response) {
|
|
107
|
+
response = result;
|
|
108
|
+
break;
|
|
109
|
+
} else {
|
|
110
|
+
throw new Error("onRequest: must return new Request() or Response() when modifying the request");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (!response) {
|
|
117
|
+
try {
|
|
118
|
+
response = await fetch(request, requestInitExt);
|
|
119
|
+
} catch (error2) {
|
|
120
|
+
let errorAfterMiddleware = error2;
|
|
121
|
+
if (middlewares.length) {
|
|
122
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
123
|
+
const m = middlewares[i];
|
|
124
|
+
if (m && typeof m === "object" && typeof m.onError === "function") {
|
|
125
|
+
const result = await m.onError({
|
|
126
|
+
request,
|
|
127
|
+
error: errorAfterMiddleware,
|
|
128
|
+
schemaPath,
|
|
129
|
+
params,
|
|
130
|
+
options,
|
|
131
|
+
id
|
|
132
|
+
});
|
|
133
|
+
if (result) {
|
|
134
|
+
if (result instanceof Response) {
|
|
135
|
+
errorAfterMiddleware = void 0;
|
|
136
|
+
response = result;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (result instanceof Error) {
|
|
140
|
+
errorAfterMiddleware = result;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
throw new Error("onError: must return new Response() or instance of Error");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (errorAfterMiddleware) {
|
|
149
|
+
throw errorAfterMiddleware;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (middlewares.length) {
|
|
153
|
+
for (let i = middlewares.length - 1; i >= 0; i--) {
|
|
154
|
+
const m = middlewares[i];
|
|
155
|
+
if (m && typeof m === "object" && typeof m.onResponse === "function") {
|
|
156
|
+
const result = await m.onResponse({
|
|
157
|
+
request,
|
|
158
|
+
response,
|
|
159
|
+
schemaPath,
|
|
160
|
+
params,
|
|
161
|
+
options,
|
|
162
|
+
id
|
|
163
|
+
});
|
|
164
|
+
if (result) {
|
|
165
|
+
if (!(result instanceof Response)) {
|
|
166
|
+
throw new Error("onResponse: must return new Response() when modifying the response");
|
|
167
|
+
}
|
|
168
|
+
response = result;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (response.status === 204 || request.method === "HEAD" || response.headers.get("Content-Length") === "0") {
|
|
175
|
+
return response.ok ? { data: void 0, response } : { error: void 0, response };
|
|
176
|
+
}
|
|
177
|
+
if (response.ok) {
|
|
178
|
+
if (parseAs === "stream") {
|
|
179
|
+
return { data: response.body, response };
|
|
180
|
+
}
|
|
181
|
+
return { data: await response[parseAs](), response };
|
|
182
|
+
}
|
|
183
|
+
let error = await response.text();
|
|
184
|
+
try {
|
|
185
|
+
error = JSON.parse(error);
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
return { error, response };
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
request(method, url, init) {
|
|
192
|
+
return coreFetch(url, { ...init, method: method.toUpperCase() });
|
|
193
|
+
},
|
|
194
|
+
/** Call a GET endpoint */
|
|
195
|
+
GET(url, init) {
|
|
196
|
+
return coreFetch(url, { ...init, method: "GET" });
|
|
197
|
+
},
|
|
198
|
+
/** Call a PUT endpoint */
|
|
199
|
+
PUT(url, init) {
|
|
200
|
+
return coreFetch(url, { ...init, method: "PUT" });
|
|
201
|
+
},
|
|
202
|
+
/** Call a POST endpoint */
|
|
203
|
+
POST(url, init) {
|
|
204
|
+
return coreFetch(url, { ...init, method: "POST" });
|
|
205
|
+
},
|
|
206
|
+
/** Call a DELETE endpoint */
|
|
207
|
+
DELETE(url, init) {
|
|
208
|
+
return coreFetch(url, { ...init, method: "DELETE" });
|
|
209
|
+
},
|
|
210
|
+
/** Call a OPTIONS endpoint */
|
|
211
|
+
OPTIONS(url, init) {
|
|
212
|
+
return coreFetch(url, { ...init, method: "OPTIONS" });
|
|
213
|
+
},
|
|
214
|
+
/** Call a HEAD endpoint */
|
|
215
|
+
HEAD(url, init) {
|
|
216
|
+
return coreFetch(url, { ...init, method: "HEAD" });
|
|
217
|
+
},
|
|
218
|
+
/** Call a PATCH endpoint */
|
|
219
|
+
PATCH(url, init) {
|
|
220
|
+
return coreFetch(url, { ...init, method: "PATCH" });
|
|
221
|
+
},
|
|
222
|
+
/** Call a TRACE endpoint */
|
|
223
|
+
TRACE(url, init) {
|
|
224
|
+
return coreFetch(url, { ...init, method: "TRACE" });
|
|
225
|
+
},
|
|
226
|
+
/** Register middleware */
|
|
227
|
+
use(...middleware) {
|
|
228
|
+
for (const m of middleware) {
|
|
229
|
+
if (!m) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (typeof m !== "object" || !("onRequest" in m || "onResponse" in m || "onError" in m)) {
|
|
233
|
+
throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
|
|
234
|
+
}
|
|
235
|
+
middlewares.push(m);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
/** Unregister middleware */
|
|
239
|
+
eject(...middleware) {
|
|
240
|
+
for (const m of middleware) {
|
|
241
|
+
const i = middlewares.indexOf(m);
|
|
242
|
+
if (i !== -1) {
|
|
243
|
+
middlewares.splice(i, 1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function serializePrimitiveParam(name, value, options) {
|
|
250
|
+
if (value === void 0 || value === null) {
|
|
251
|
+
return "";
|
|
252
|
+
}
|
|
253
|
+
if (typeof value === "object") {
|
|
254
|
+
throw new Error(
|
|
255
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
return `${name}=${options?.allowReserved === true ? value : encodeURIComponent(value)}`;
|
|
259
|
+
}
|
|
260
|
+
function serializeObjectParam(name, value, options) {
|
|
261
|
+
if (!value || typeof value !== "object") {
|
|
262
|
+
return "";
|
|
263
|
+
}
|
|
264
|
+
const values = [];
|
|
265
|
+
const joiner = {
|
|
266
|
+
simple: ",",
|
|
267
|
+
label: ".",
|
|
268
|
+
matrix: ";"
|
|
269
|
+
}[options.style] || "&";
|
|
270
|
+
if (options.style !== "deepObject" && options.explode === false) {
|
|
271
|
+
for (const k in value) {
|
|
272
|
+
values.push(k, options.allowReserved === true ? value[k] : encodeURIComponent(value[k]));
|
|
273
|
+
}
|
|
274
|
+
const final2 = values.join(",");
|
|
275
|
+
switch (options.style) {
|
|
276
|
+
case "form": {
|
|
277
|
+
return `${name}=${final2}`;
|
|
278
|
+
}
|
|
279
|
+
case "label": {
|
|
280
|
+
return `.${final2}`;
|
|
281
|
+
}
|
|
282
|
+
case "matrix": {
|
|
283
|
+
return `;${name}=${final2}`;
|
|
284
|
+
}
|
|
285
|
+
default: {
|
|
286
|
+
return final2;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
for (const k in value) {
|
|
291
|
+
const finalName = options.style === "deepObject" ? `${name}[${k}]` : k;
|
|
292
|
+
values.push(serializePrimitiveParam(finalName, value[k], options));
|
|
293
|
+
}
|
|
294
|
+
const final = values.join(joiner);
|
|
295
|
+
return options.style === "label" || options.style === "matrix" ? `${joiner}${final}` : final;
|
|
296
|
+
}
|
|
297
|
+
function serializeArrayParam(name, value, options) {
|
|
298
|
+
if (!Array.isArray(value)) {
|
|
299
|
+
return "";
|
|
300
|
+
}
|
|
301
|
+
if (options.explode === false) {
|
|
302
|
+
const joiner2 = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[options.style] || ",";
|
|
303
|
+
const final = (options.allowReserved === true ? value : value.map((v) => encodeURIComponent(v))).join(joiner2);
|
|
304
|
+
switch (options.style) {
|
|
305
|
+
case "simple": {
|
|
306
|
+
return final;
|
|
307
|
+
}
|
|
308
|
+
case "label": {
|
|
309
|
+
return `.${final}`;
|
|
310
|
+
}
|
|
311
|
+
case "matrix": {
|
|
312
|
+
return `;${name}=${final}`;
|
|
313
|
+
}
|
|
314
|
+
// case "spaceDelimited":
|
|
315
|
+
// case "pipeDelimited":
|
|
316
|
+
default: {
|
|
317
|
+
return `${name}=${final}`;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const joiner = { simple: ",", label: ".", matrix: ";" }[options.style] || "&";
|
|
322
|
+
const values = [];
|
|
323
|
+
for (const v of value) {
|
|
324
|
+
if (options.style === "simple" || options.style === "label") {
|
|
325
|
+
values.push(options.allowReserved === true ? v : encodeURIComponent(v));
|
|
326
|
+
} else {
|
|
327
|
+
values.push(serializePrimitiveParam(name, v, options));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return options.style === "label" || options.style === "matrix" ? `${joiner}${values.join(joiner)}` : values.join(joiner);
|
|
331
|
+
}
|
|
332
|
+
function createQuerySerializer(options) {
|
|
333
|
+
return function querySerializer(queryParams) {
|
|
334
|
+
const search = [];
|
|
335
|
+
if (queryParams && typeof queryParams === "object") {
|
|
336
|
+
for (const name in queryParams) {
|
|
337
|
+
const value = queryParams[name];
|
|
338
|
+
if (value === void 0 || value === null) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (Array.isArray(value)) {
|
|
342
|
+
if (value.length === 0) {
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
search.push(
|
|
346
|
+
serializeArrayParam(name, value, {
|
|
347
|
+
style: "form",
|
|
348
|
+
explode: true,
|
|
349
|
+
...options?.array,
|
|
350
|
+
allowReserved: options?.allowReserved || false
|
|
351
|
+
})
|
|
352
|
+
);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (typeof value === "object") {
|
|
356
|
+
search.push(
|
|
357
|
+
serializeObjectParam(name, value, {
|
|
358
|
+
style: "deepObject",
|
|
359
|
+
explode: true,
|
|
360
|
+
...options?.object,
|
|
361
|
+
allowReserved: options?.allowReserved || false
|
|
362
|
+
})
|
|
363
|
+
);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
search.push(serializePrimitiveParam(name, value, options));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return search.join("&");
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function defaultPathSerializer(pathname, pathParams) {
|
|
373
|
+
let nextURL = pathname;
|
|
374
|
+
for (const match of pathname.match(PATH_PARAM_RE) ?? []) {
|
|
375
|
+
let name = match.substring(1, match.length - 1);
|
|
376
|
+
let explode = false;
|
|
377
|
+
let style = "simple";
|
|
378
|
+
if (name.endsWith("*")) {
|
|
379
|
+
explode = true;
|
|
380
|
+
name = name.substring(0, name.length - 1);
|
|
381
|
+
}
|
|
382
|
+
if (name.startsWith(".")) {
|
|
383
|
+
style = "label";
|
|
384
|
+
name = name.substring(1);
|
|
385
|
+
} else if (name.startsWith(";")) {
|
|
386
|
+
style = "matrix";
|
|
387
|
+
name = name.substring(1);
|
|
388
|
+
}
|
|
389
|
+
if (!pathParams || pathParams[name] === void 0 || pathParams[name] === null) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const value = pathParams[name];
|
|
393
|
+
if (Array.isArray(value)) {
|
|
394
|
+
nextURL = nextURL.replace(match, serializeArrayParam(name, value, { style, explode }));
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (typeof value === "object") {
|
|
398
|
+
nextURL = nextURL.replace(match, serializeObjectParam(name, value, { style, explode }));
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (style === "matrix") {
|
|
402
|
+
nextURL = nextURL.replace(match, `;${serializePrimitiveParam(name, value)}`);
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
nextURL = nextURL.replace(match, style === "label" ? `.${encodeURIComponent(value)}` : encodeURIComponent(value));
|
|
406
|
+
}
|
|
407
|
+
return nextURL;
|
|
408
|
+
}
|
|
409
|
+
function defaultBodySerializer(body, headers) {
|
|
410
|
+
if (body instanceof FormData) {
|
|
411
|
+
return body;
|
|
412
|
+
}
|
|
413
|
+
if (headers) {
|
|
414
|
+
const contentType = headers.get instanceof Function ? headers.get("Content-Type") ?? headers.get("content-type") : headers["Content-Type"] ?? headers["content-type"];
|
|
415
|
+
if (contentType === "application/x-www-form-urlencoded") {
|
|
416
|
+
return new URLSearchParams(body).toString();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return JSON.stringify(body);
|
|
420
|
+
}
|
|
421
|
+
function createFinalURL(pathname, options) {
|
|
422
|
+
let finalURL = `${options.baseUrl}${pathname}`;
|
|
423
|
+
if (options.params?.path) {
|
|
424
|
+
finalURL = defaultPathSerializer(finalURL, options.params.path);
|
|
425
|
+
}
|
|
426
|
+
let search = options.querySerializer(options.params.query ?? {});
|
|
427
|
+
if (search.startsWith("?")) {
|
|
428
|
+
search = search.substring(1);
|
|
429
|
+
}
|
|
430
|
+
if (search) {
|
|
431
|
+
finalURL += `?${search}`;
|
|
432
|
+
}
|
|
433
|
+
return finalURL;
|
|
434
|
+
}
|
|
435
|
+
function mergeHeaders(...allHeaders) {
|
|
436
|
+
const finalHeaders = new Headers();
|
|
437
|
+
for (const h of allHeaders) {
|
|
438
|
+
if (!h || typeof h !== "object") {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const iterator = h instanceof Headers ? h.entries() : Object.entries(h);
|
|
442
|
+
for (const [k, v] of iterator) {
|
|
443
|
+
if (v === null) {
|
|
444
|
+
finalHeaders.delete(k);
|
|
445
|
+
} else if (Array.isArray(v)) {
|
|
446
|
+
for (const v2 of v) {
|
|
447
|
+
finalHeaders.append(k, v2);
|
|
448
|
+
}
|
|
449
|
+
} else if (v !== void 0) {
|
|
450
|
+
finalHeaders.set(k, v);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return finalHeaders;
|
|
455
|
+
}
|
|
456
|
+
function removeTrailingSlash(url) {
|
|
457
|
+
if (url.endsWith("/")) {
|
|
458
|
+
return url.substring(0, url.length - 1);
|
|
459
|
+
}
|
|
460
|
+
return url;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/error.ts
|
|
464
|
+
var SpacebringError = class extends Error {
|
|
465
|
+
/** HTTP status code of the failed response. */
|
|
466
|
+
status;
|
|
467
|
+
/** Parsed error body returned by the API, if any. */
|
|
468
|
+
body;
|
|
469
|
+
constructor(status, body) {
|
|
470
|
+
const parsed = isErrorBody(body) ? body : void 0;
|
|
471
|
+
super(parsed?.message ?? `Spacebring API request failed with status ${status}`);
|
|
472
|
+
this.name = "SpacebringError";
|
|
473
|
+
this.status = status;
|
|
474
|
+
this.body = parsed;
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
function isErrorBody(body) {
|
|
478
|
+
return typeof body === "object" && body !== null;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/core.ts
|
|
482
|
+
function unwrap(result) {
|
|
483
|
+
if (result.error !== void 0 || !result.response.ok) {
|
|
484
|
+
throw new SpacebringError(result.response.status, result.error);
|
|
485
|
+
}
|
|
486
|
+
return result.data;
|
|
487
|
+
}
|
|
488
|
+
function unwrapProp(result, key) {
|
|
489
|
+
const value = unwrap(result)?.[key];
|
|
490
|
+
if (value === void 0 || value === null) {
|
|
491
|
+
throw new SpacebringError(result.response.status, {
|
|
492
|
+
message: `Response is missing the "${String(key)}" property`
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
return value;
|
|
496
|
+
}
|
|
497
|
+
async function* paginate(fetchPage, itemsKey) {
|
|
498
|
+
let token;
|
|
499
|
+
do {
|
|
500
|
+
const page = await fetchPage(token);
|
|
501
|
+
const items = page[itemsKey] ?? [];
|
|
502
|
+
yield* items;
|
|
503
|
+
const next = page.nextPageToken;
|
|
504
|
+
if (next !== void 0 && next === token) {
|
|
505
|
+
throw new Error("Pagination did not advance: the API returned the same nextPageToken twice");
|
|
506
|
+
}
|
|
507
|
+
token = next;
|
|
508
|
+
} while (token);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/generated/resources/altCurrencies.ts
|
|
512
|
+
function createAltcurrencies(client, defaults) {
|
|
513
|
+
return {
|
|
514
|
+
/**
|
|
515
|
+
* Retrieve alt currencies
|
|
516
|
+
*
|
|
517
|
+
* Retrieve all alt currencies in the location.
|
|
518
|
+
*/
|
|
519
|
+
async list(query) {
|
|
520
|
+
return unwrap(await client.GET("/alt_currencies/v1", { params: { query } }));
|
|
521
|
+
},
|
|
522
|
+
/**
|
|
523
|
+
* Retrieve alt currencies — iterates every item across all pages.
|
|
524
|
+
*
|
|
525
|
+
* Retrieve all alt currencies in the location.
|
|
526
|
+
*/
|
|
527
|
+
iterate(query) {
|
|
528
|
+
return paginate(
|
|
529
|
+
async (nextPageToken) => unwrap(await client.GET("/alt_currencies/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
530
|
+
"altCurrencies"
|
|
531
|
+
);
|
|
532
|
+
},
|
|
533
|
+
/** Create an alt currency */
|
|
534
|
+
async create(body) {
|
|
535
|
+
return unwrapProp(await client.POST("/alt_currencies/v1", { body }), "altCurrency");
|
|
536
|
+
},
|
|
537
|
+
/** Update an alt currency */
|
|
538
|
+
async update(id, body) {
|
|
539
|
+
return unwrap(await client.PATCH("/alt_currencies/v1/{id}", { params: { path: { id } }, body }));
|
|
540
|
+
},
|
|
541
|
+
/** Delete an alt currency */
|
|
542
|
+
async delete(id) {
|
|
543
|
+
return unwrap(await client.DELETE("/alt_currencies/v1/{id}", { params: { path: { id } } }));
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// src/generated/resources/benefits.ts
|
|
549
|
+
function createBenefits(client, defaults) {
|
|
550
|
+
return {
|
|
551
|
+
/**
|
|
552
|
+
* Retrieve benefits
|
|
553
|
+
*
|
|
554
|
+
* Retrieve all benefits in the location.
|
|
555
|
+
*/
|
|
556
|
+
async list(query) {
|
|
557
|
+
return unwrap(await client.GET("/benefits/v1", { params: { query } }));
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Retrieve benefits — iterates every item across all pages.
|
|
561
|
+
*
|
|
562
|
+
* Retrieve all benefits in the location.
|
|
563
|
+
*/
|
|
564
|
+
iterate(query) {
|
|
565
|
+
return paginate(
|
|
566
|
+
async (nextPageToken) => unwrap(await client.GET("/benefits/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
567
|
+
"benefits"
|
|
568
|
+
);
|
|
569
|
+
},
|
|
570
|
+
/** Retrieve a benefit */
|
|
571
|
+
async get(benefitId) {
|
|
572
|
+
return unwrapProp(await client.GET("/benefits/v1/{benefitId}", { params: { path: { benefitId } } }), "benefit");
|
|
573
|
+
},
|
|
574
|
+
/** Create a benefit */
|
|
575
|
+
async create(body) {
|
|
576
|
+
return unwrap(await client.POST("/benefits/v1", { body }));
|
|
577
|
+
},
|
|
578
|
+
/** Update a benefit */
|
|
579
|
+
async update(benefitId, body) {
|
|
580
|
+
return unwrapProp(await client.PUT("/benefits/v1/{benefitId}", { params: { path: { benefitId } }, body }), "benefit");
|
|
581
|
+
},
|
|
582
|
+
/** Delete a benefit */
|
|
583
|
+
async delete(benefitId) {
|
|
584
|
+
return unwrap(await client.DELETE("/benefits/v1/{benefitId}", { params: { path: { benefitId } } }));
|
|
585
|
+
},
|
|
586
|
+
applications: {
|
|
587
|
+
/**
|
|
588
|
+
* Retrieve applications
|
|
589
|
+
*
|
|
590
|
+
* Retrieve all benefit applications in the location or for certain benefit.
|
|
591
|
+
*/
|
|
592
|
+
async list(query) {
|
|
593
|
+
return unwrap(await client.GET("/benefits/applications/v1", { params: { query } }));
|
|
594
|
+
},
|
|
595
|
+
/**
|
|
596
|
+
* Retrieve applications — iterates every item across all pages.
|
|
597
|
+
*
|
|
598
|
+
* Retrieve all benefit applications in the location or for certain benefit.
|
|
599
|
+
*/
|
|
600
|
+
iterate(query) {
|
|
601
|
+
return paginate(
|
|
602
|
+
async (nextPageToken) => unwrap(await client.GET("/benefits/applications/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
603
|
+
"applications"
|
|
604
|
+
);
|
|
605
|
+
},
|
|
606
|
+
/**
|
|
607
|
+
* Retrieve an application
|
|
608
|
+
*
|
|
609
|
+
* Retrieve a benefit application by id.
|
|
610
|
+
*/
|
|
611
|
+
async get(benefitApplicationId) {
|
|
612
|
+
return unwrapProp(await client.GET("/benefits/applications/v1/{benefitApplicationId}", { params: { path: { benefitApplicationId } } }), "application");
|
|
613
|
+
},
|
|
614
|
+
/** Apply for a benefit */
|
|
615
|
+
async create(body) {
|
|
616
|
+
return unwrapProp(await client.POST("/benefits/applications/v1", { body }), "application");
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
categories: {
|
|
620
|
+
/**
|
|
621
|
+
* Retrieve categories
|
|
622
|
+
*
|
|
623
|
+
* Retrieve all benefit categories in the location.
|
|
624
|
+
*/
|
|
625
|
+
async list(query) {
|
|
626
|
+
return unwrapProp(await client.GET("/benefits/categories/v1", { params: { query } }), "categories");
|
|
627
|
+
},
|
|
628
|
+
/**
|
|
629
|
+
* Get a category
|
|
630
|
+
*
|
|
631
|
+
* Get a benefit category.
|
|
632
|
+
*/
|
|
633
|
+
async get(categoryId) {
|
|
634
|
+
return unwrapProp(await client.GET("/benefits/categories/v1/{categoryId}", { params: { path: { categoryId } } }), "category");
|
|
635
|
+
},
|
|
636
|
+
/**
|
|
637
|
+
* Create a category
|
|
638
|
+
*
|
|
639
|
+
* Create a benefit category.
|
|
640
|
+
*/
|
|
641
|
+
async create(body) {
|
|
642
|
+
return unwrapProp(await client.POST("/benefits/categories/v1", { body }), "category");
|
|
643
|
+
},
|
|
644
|
+
/**
|
|
645
|
+
* Update a category
|
|
646
|
+
*
|
|
647
|
+
* Update a benefit category.
|
|
648
|
+
*/
|
|
649
|
+
async update(categoryId, body) {
|
|
650
|
+
return unwrapProp(await client.PUT("/benefits/categories/v1/{categoryId}", { params: { path: { categoryId } }, body }), "category");
|
|
651
|
+
},
|
|
652
|
+
/**
|
|
653
|
+
* Delete a category
|
|
654
|
+
*
|
|
655
|
+
* Delete a benefit category.
|
|
656
|
+
*/
|
|
657
|
+
async delete(categoryId) {
|
|
658
|
+
return unwrap(await client.DELETE("/benefits/categories/v1/{categoryId}", { params: { path: { categoryId } } }));
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/generated/resources/billing.ts
|
|
665
|
+
function createBilling(client, defaults) {
|
|
666
|
+
return {
|
|
667
|
+
creditNotes: {
|
|
668
|
+
/**
|
|
669
|
+
* Retrieve credit notes
|
|
670
|
+
*
|
|
671
|
+
* Retrieve all credit notes for a specific invoice or location. One of invoiceRef or locationRef is required.
|
|
672
|
+
*/
|
|
673
|
+
async list(query) {
|
|
674
|
+
return unwrap(await client.GET("/billing/credit_notes/v1", { params: { query } }));
|
|
675
|
+
},
|
|
676
|
+
/**
|
|
677
|
+
* Retrieve credit notes — iterates every item across all pages.
|
|
678
|
+
*
|
|
679
|
+
* Retrieve all credit notes for a specific invoice or location. One of invoiceRef or locationRef is required.
|
|
680
|
+
*/
|
|
681
|
+
iterate(query) {
|
|
682
|
+
return paginate(
|
|
683
|
+
async (nextPageToken) => unwrap(await client.GET("/billing/credit_notes/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
684
|
+
"creditNotes"
|
|
685
|
+
);
|
|
686
|
+
},
|
|
687
|
+
/**
|
|
688
|
+
* Retrieve a credit note
|
|
689
|
+
*
|
|
690
|
+
* Retrieve a specific credit note.
|
|
691
|
+
*/
|
|
692
|
+
async get(id) {
|
|
693
|
+
return unwrapProp(await client.GET("/billing/credit_notes/v1/{id}", { params: { path: { id } } }), "creditNote");
|
|
694
|
+
},
|
|
695
|
+
/**
|
|
696
|
+
* Create a credit note
|
|
697
|
+
*
|
|
698
|
+
* Create a credit note for an invoice.
|
|
699
|
+
*/
|
|
700
|
+
async create(body) {
|
|
701
|
+
return unwrapProp(await client.POST("/billing/credit_notes/v1", { body }), "creditNote");
|
|
702
|
+
},
|
|
703
|
+
/** Update a credit note */
|
|
704
|
+
async update(id, body) {
|
|
705
|
+
return unwrap(await client.PATCH("/billing/credit_notes/v1/{id}", { params: { path: { id } }, body }));
|
|
706
|
+
},
|
|
707
|
+
/**
|
|
708
|
+
* Preview a credit note
|
|
709
|
+
*
|
|
710
|
+
* Preview a credit note for an invoice without creating it.
|
|
711
|
+
*/
|
|
712
|
+
async preview(body) {
|
|
713
|
+
return unwrapProp(await client.POST("/billing/credit_notes/v1/preview", { body }), "creditNote");
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
invoices: {
|
|
717
|
+
/**
|
|
718
|
+
* Retrieve invoices
|
|
719
|
+
*
|
|
720
|
+
* Retrieve all invoices based on certain parameters.
|
|
721
|
+
*/
|
|
722
|
+
async list(query) {
|
|
723
|
+
return unwrap(await client.GET("/billing/invoices/v1", { params: { query } }));
|
|
724
|
+
},
|
|
725
|
+
/**
|
|
726
|
+
* Retrieve invoices — iterates every item across all pages.
|
|
727
|
+
*
|
|
728
|
+
* Retrieve all invoices based on certain parameters.
|
|
729
|
+
*/
|
|
730
|
+
iterate(query) {
|
|
731
|
+
return paginate(
|
|
732
|
+
async (nextPageToken) => unwrap(await client.GET("/billing/invoices/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
733
|
+
"invoices"
|
|
734
|
+
);
|
|
735
|
+
},
|
|
736
|
+
/**
|
|
737
|
+
* Retrieve an invoice
|
|
738
|
+
*
|
|
739
|
+
* Retrieve a certain invoice.
|
|
740
|
+
*/
|
|
741
|
+
async get(invoiceId) {
|
|
742
|
+
return unwrapProp(await client.GET("/billing/invoices/v1/{invoiceId}", { params: { path: { invoiceId } } }), "invoice");
|
|
743
|
+
},
|
|
744
|
+
/**
|
|
745
|
+
* Create an invoice
|
|
746
|
+
*
|
|
747
|
+
* Create an invoice for a member or a company.
|
|
748
|
+
*/
|
|
749
|
+
async create(body) {
|
|
750
|
+
return unwrapProp(await client.POST("/billing/invoices/v1", { body }), "invoice");
|
|
751
|
+
},
|
|
752
|
+
/**
|
|
753
|
+
* Update an invoice
|
|
754
|
+
*
|
|
755
|
+
* Update a draft invoice.
|
|
756
|
+
*/
|
|
757
|
+
async update(invoiceId, body) {
|
|
758
|
+
return unwrap(await client.PATCH("/billing/invoices/v1/{invoiceId}", { params: { path: { invoiceId } }, body }));
|
|
759
|
+
},
|
|
760
|
+
/**
|
|
761
|
+
* Delete an invoice
|
|
762
|
+
*
|
|
763
|
+
* Delete a draft invoice.
|
|
764
|
+
*/
|
|
765
|
+
async delete(invoiceId) {
|
|
766
|
+
return unwrap(await client.DELETE("/billing/invoices/v1/{invoiceId}", { params: { path: { invoiceId } } }));
|
|
767
|
+
},
|
|
768
|
+
/**
|
|
769
|
+
* Cancel a payment
|
|
770
|
+
*
|
|
771
|
+
* Cancel a payment on an invoice.
|
|
772
|
+
*/
|
|
773
|
+
async cancelPayment(invoiceId) {
|
|
774
|
+
return unwrap(await client.POST("/billing/invoices/v1/{invoiceId}/cancel_payment", { params: { path: { invoiceId } } }));
|
|
775
|
+
},
|
|
776
|
+
/**
|
|
777
|
+
* Duplicate an invoice
|
|
778
|
+
*
|
|
779
|
+
* Duplicate an invoice, creating a new draft invoice with the same items.
|
|
780
|
+
*/
|
|
781
|
+
async duplicate(invoiceId) {
|
|
782
|
+
return unwrapProp(await client.POST("/billing/invoices/v1/{invoiceId}/duplicate", { params: { path: { invoiceId } } }), "invoice");
|
|
783
|
+
},
|
|
784
|
+
/**
|
|
785
|
+
* List invoice items
|
|
786
|
+
*
|
|
787
|
+
* List all items for a specific invoice.
|
|
788
|
+
*/
|
|
789
|
+
async getItems(invoiceId) {
|
|
790
|
+
return unwrap(await client.GET("/billing/invoices/v1/{invoiceId}/items", { params: { path: { invoiceId } } }));
|
|
791
|
+
},
|
|
792
|
+
/**
|
|
793
|
+
* Retrieve the upcoming invoice
|
|
794
|
+
*
|
|
795
|
+
* Retrieve the upcoming invoice preview for a membership or subscription.
|
|
796
|
+
*/
|
|
797
|
+
async getUpcoming(query) {
|
|
798
|
+
return unwrap(await client.GET("/billing/invoices/v1/upcoming", { params: { query } }));
|
|
799
|
+
},
|
|
800
|
+
/**
|
|
801
|
+
* Issue an invoice
|
|
802
|
+
*
|
|
803
|
+
* Issue (finalize) a draft invoice, making it ready for payment.
|
|
804
|
+
*/
|
|
805
|
+
async issue(invoiceId, body) {
|
|
806
|
+
return unwrap(await client.POST("/billing/invoices/v1/{invoiceId}/issue", { params: { path: { invoiceId } }, body }));
|
|
807
|
+
},
|
|
808
|
+
/**
|
|
809
|
+
* Pay an invoice
|
|
810
|
+
*
|
|
811
|
+
* Mark an invoice as paid by `External Payment`.
|
|
812
|
+
*/
|
|
813
|
+
async pay(invoiceId, body) {
|
|
814
|
+
return unwrap(await client.POST("/billing/invoices/v1/{invoiceId}/pay", { params: { path: { invoiceId } }, body }));
|
|
815
|
+
},
|
|
816
|
+
/**
|
|
817
|
+
* Resend an invoice
|
|
818
|
+
*
|
|
819
|
+
* Resend an issued invoice notification to the customer.
|
|
820
|
+
*/
|
|
821
|
+
async resend(invoiceId) {
|
|
822
|
+
return unwrap(await client.POST("/billing/invoices/v1/{invoiceId}/resend", { params: { path: { invoiceId } } }));
|
|
823
|
+
},
|
|
824
|
+
/**
|
|
825
|
+
* Void an invoice
|
|
826
|
+
*
|
|
827
|
+
* Void an issued invoice.
|
|
828
|
+
*/
|
|
829
|
+
async void(invoiceId) {
|
|
830
|
+
return unwrap(await client.PATCH("/billing/invoices/v1/{invoiceId}/void", { params: { path: { invoiceId } } }));
|
|
831
|
+
},
|
|
832
|
+
items: {
|
|
833
|
+
/**
|
|
834
|
+
* Retrieve an invoice item
|
|
835
|
+
*
|
|
836
|
+
* Retrieve a specific invoice item.
|
|
837
|
+
*/
|
|
838
|
+
async get(id) {
|
|
839
|
+
return unwrapProp(await client.GET("/billing/invoices/v1/items/{id}", { params: { path: { id } } }), "invoiceItem");
|
|
840
|
+
},
|
|
841
|
+
/**
|
|
842
|
+
* Create an invoice item
|
|
843
|
+
*
|
|
844
|
+
* Create an item in an invoice.
|
|
845
|
+
*/
|
|
846
|
+
async create(body) {
|
|
847
|
+
return unwrapProp(await client.POST("/billing/invoices/v1/items", { body }), "invoiceItem");
|
|
848
|
+
},
|
|
849
|
+
/**
|
|
850
|
+
* Update an invoice item
|
|
851
|
+
*
|
|
852
|
+
* Update an invoice item on a draft invoice.
|
|
853
|
+
*/
|
|
854
|
+
async update(id, body) {
|
|
855
|
+
return unwrap(await client.PATCH("/billing/invoices/v1/items/{id}", { params: { path: { id } }, body }));
|
|
856
|
+
},
|
|
857
|
+
/**
|
|
858
|
+
* Delete an invoice item
|
|
859
|
+
*
|
|
860
|
+
* Delete an invoice item from a draft invoice.
|
|
861
|
+
*/
|
|
862
|
+
async delete(id) {
|
|
863
|
+
return unwrap(await client.DELETE("/billing/invoices/v1/items/{id}", { params: { path: { id } } }));
|
|
864
|
+
},
|
|
865
|
+
/** List upcoming invoice items */
|
|
866
|
+
async getUpcoming(query) {
|
|
867
|
+
return unwrapProp(await client.GET("/billing/invoices/v1/items/upcoming", { params: { query } }), "invoiceItems");
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
// src/generated/resources/community.ts
|
|
875
|
+
function createCommunity(client, defaults) {
|
|
876
|
+
return {
|
|
877
|
+
companies: {
|
|
878
|
+
/**
|
|
879
|
+
* Retrieve companies
|
|
880
|
+
*
|
|
881
|
+
* Retrieve all companies.
|
|
882
|
+
*/
|
|
883
|
+
async list(query) {
|
|
884
|
+
return unwrap(await client.GET("/community/companies/v1", { params: { query } }));
|
|
885
|
+
},
|
|
886
|
+
/**
|
|
887
|
+
* Retrieve companies — iterates every item across all pages.
|
|
888
|
+
*
|
|
889
|
+
* Retrieve all companies.
|
|
890
|
+
*/
|
|
891
|
+
iterate(query) {
|
|
892
|
+
return paginate(
|
|
893
|
+
async (nextPageToken) => unwrap(await client.GET("/community/companies/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
894
|
+
"companies"
|
|
895
|
+
);
|
|
896
|
+
},
|
|
897
|
+
/**
|
|
898
|
+
* Retrieve a company
|
|
899
|
+
*
|
|
900
|
+
* Retrieve a certain company.
|
|
901
|
+
*/
|
|
902
|
+
async get(id) {
|
|
903
|
+
return unwrapProp(await client.GET("/community/companies/v1/{id}", { params: { path: { id } } }), "company");
|
|
904
|
+
},
|
|
905
|
+
/** Create a company */
|
|
906
|
+
async create(body) {
|
|
907
|
+
return unwrapProp(await client.POST("/community/companies/v1", { body }), "company");
|
|
908
|
+
},
|
|
909
|
+
/**
|
|
910
|
+
* Update a company
|
|
911
|
+
*
|
|
912
|
+
* Update a certain company.
|
|
913
|
+
*/
|
|
914
|
+
async update(id, body) {
|
|
915
|
+
return unwrapProp(await client.PUT("/community/companies/v1/{id}", { params: { path: { id } }, body }), "company");
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
memberships: {
|
|
919
|
+
/**
|
|
920
|
+
* Retrieve memberships
|
|
921
|
+
*
|
|
922
|
+
* Retrieve all memberships.
|
|
923
|
+
*/
|
|
924
|
+
async list(query) {
|
|
925
|
+
return unwrap(await client.GET("/community/memberships/v1", { params: { query } }));
|
|
926
|
+
},
|
|
927
|
+
/**
|
|
928
|
+
* Retrieve memberships — iterates every item across all pages.
|
|
929
|
+
*
|
|
930
|
+
* Retrieve all memberships.
|
|
931
|
+
*/
|
|
932
|
+
iterate(query) {
|
|
933
|
+
return paginate(
|
|
934
|
+
async (nextPageToken) => unwrap(await client.GET("/community/memberships/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
935
|
+
"memberships"
|
|
936
|
+
);
|
|
937
|
+
},
|
|
938
|
+
/**
|
|
939
|
+
* Retrieve a membership
|
|
940
|
+
*
|
|
941
|
+
* Retrieve a certain membership.
|
|
942
|
+
*/
|
|
943
|
+
async get(id) {
|
|
944
|
+
return unwrapProp(await client.GET("/community/memberships/v1/{id}", { params: { path: { id } } }), "membership");
|
|
945
|
+
},
|
|
946
|
+
/**
|
|
947
|
+
* Create a membership
|
|
948
|
+
*
|
|
949
|
+
* Create a membership and send an email invitation to join if type is member.
|
|
950
|
+
*/
|
|
951
|
+
async create(body) {
|
|
952
|
+
return unwrapProp(await client.POST("/community/memberships/v1", { body }), "membership");
|
|
953
|
+
},
|
|
954
|
+
/**
|
|
955
|
+
* Update a membership
|
|
956
|
+
*
|
|
957
|
+
* Update a certain membership.
|
|
958
|
+
*/
|
|
959
|
+
async update(id, body) {
|
|
960
|
+
return unwrapProp(await client.PUT("/community/memberships/v1/{id}", { params: { path: { id } }, body }), "membership");
|
|
961
|
+
},
|
|
962
|
+
/**
|
|
963
|
+
* Delete a membership
|
|
964
|
+
*
|
|
965
|
+
* Delete a certain membership.
|
|
966
|
+
*/
|
|
967
|
+
async delete(id) {
|
|
968
|
+
return unwrap(await client.DELETE("/community/memberships/v1/{id}", { params: { path: { id } } }));
|
|
969
|
+
},
|
|
970
|
+
/**
|
|
971
|
+
* Retrieve deleted memberships — iterates every item across all pages.
|
|
972
|
+
*
|
|
973
|
+
* Retrieve all deleted memberships.
|
|
974
|
+
*/
|
|
975
|
+
iterateDeleted(query) {
|
|
976
|
+
return paginate(
|
|
977
|
+
async (nextPageToken) => unwrap(await client.GET("/community/memberships/v1/deleted", { params: { query: { ...query, nextPageToken } } })),
|
|
978
|
+
"memberships"
|
|
979
|
+
);
|
|
980
|
+
},
|
|
981
|
+
/**
|
|
982
|
+
* Retrieve deleted memberships
|
|
983
|
+
*
|
|
984
|
+
* Retrieve all deleted memberships.
|
|
985
|
+
*/
|
|
986
|
+
async listDeleted(query) {
|
|
987
|
+
return unwrap(await client.GET("/community/memberships/v1/deleted", { params: { query } }));
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
// src/generated/resources/contracts.ts
|
|
994
|
+
function createContracts(client, defaults) {
|
|
995
|
+
return {
|
|
996
|
+
/**
|
|
997
|
+
* Retrieve contracts
|
|
998
|
+
*
|
|
999
|
+
* Retrieve all contracts in the location.
|
|
1000
|
+
*/
|
|
1001
|
+
async list(query) {
|
|
1002
|
+
return unwrap(await client.GET("/contracts/v1", { params: { query } }));
|
|
1003
|
+
},
|
|
1004
|
+
/**
|
|
1005
|
+
* Retrieve contracts — iterates every item across all pages.
|
|
1006
|
+
*
|
|
1007
|
+
* Retrieve all contracts in the location.
|
|
1008
|
+
*/
|
|
1009
|
+
iterate(query) {
|
|
1010
|
+
return paginate(
|
|
1011
|
+
async (nextPageToken) => unwrap(await client.GET("/contracts/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1012
|
+
"contracts"
|
|
1013
|
+
);
|
|
1014
|
+
},
|
|
1015
|
+
/** Get a contract */
|
|
1016
|
+
async get(contractId) {
|
|
1017
|
+
return unwrapProp(await client.GET("/contracts/v1/{contractId}", { params: { path: { contractId } } }), "contract");
|
|
1018
|
+
},
|
|
1019
|
+
/** Create a contract */
|
|
1020
|
+
async create(body) {
|
|
1021
|
+
return unwrapProp(await client.POST("/contracts/v1", { body }), "contract");
|
|
1022
|
+
},
|
|
1023
|
+
/** Delete a contract */
|
|
1024
|
+
async delete(contractId) {
|
|
1025
|
+
return unwrap(await client.DELETE("/contracts/v1/{contractId}", { params: { path: { contractId } } }));
|
|
1026
|
+
},
|
|
1027
|
+
/** Issue a contract */
|
|
1028
|
+
async issue(contractId, body) {
|
|
1029
|
+
return unwrapProp(await client.POST("/contracts/v1/{contractId}/issue", { params: { path: { contractId } }, body }), "contract");
|
|
1030
|
+
},
|
|
1031
|
+
/** Terminate a contract */
|
|
1032
|
+
async terminate(contractId, body) {
|
|
1033
|
+
return unwrap(await client.PATCH("/contracts/v1/{contractId}/terminate", { params: { path: { contractId } }, body }));
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// src/generated/resources/discounts.ts
|
|
1039
|
+
function createDiscounts(client, defaults) {
|
|
1040
|
+
return {
|
|
1041
|
+
coupons: {
|
|
1042
|
+
/**
|
|
1043
|
+
* Retrieve coupons
|
|
1044
|
+
*
|
|
1045
|
+
* Retrieve all coupons in the location.
|
|
1046
|
+
*/
|
|
1047
|
+
async list(query) {
|
|
1048
|
+
return unwrap(await client.GET("/discounts/coupons/v1", { params: { query } }));
|
|
1049
|
+
},
|
|
1050
|
+
/**
|
|
1051
|
+
* Retrieve coupons — iterates every item across all pages.
|
|
1052
|
+
*
|
|
1053
|
+
* Retrieve all coupons in the location.
|
|
1054
|
+
*/
|
|
1055
|
+
iterate(query) {
|
|
1056
|
+
return paginate(
|
|
1057
|
+
async (nextPageToken) => unwrap(await client.GET("/discounts/coupons/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1058
|
+
"coupons"
|
|
1059
|
+
);
|
|
1060
|
+
},
|
|
1061
|
+
/** Get a coupon */
|
|
1062
|
+
async get(id) {
|
|
1063
|
+
return unwrapProp(await client.GET("/discounts/coupons/v1/{id}", { params: { path: { id } } }), "coupon");
|
|
1064
|
+
},
|
|
1065
|
+
/** Create a coupon */
|
|
1066
|
+
async create(body) {
|
|
1067
|
+
return unwrapProp(await client.POST("/discounts/coupons/v1", { body }), "coupon");
|
|
1068
|
+
},
|
|
1069
|
+
/** Update a coupon */
|
|
1070
|
+
async update(id, body) {
|
|
1071
|
+
return unwrap(await client.PATCH("/discounts/coupons/v1/{id}", { params: { path: { id } }, body }));
|
|
1072
|
+
},
|
|
1073
|
+
/** Delete a coupon */
|
|
1074
|
+
async delete(id) {
|
|
1075
|
+
return unwrap(await client.DELETE("/discounts/coupons/v1/{id}", { params: { path: { id } } }));
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
promocodes: {
|
|
1079
|
+
/**
|
|
1080
|
+
* Retrieve promocodes
|
|
1081
|
+
*
|
|
1082
|
+
* Retrieve all promocodes.
|
|
1083
|
+
*/
|
|
1084
|
+
async list(query) {
|
|
1085
|
+
return unwrapProp(await client.GET("/discounts/promocodes/v1", { params: { query } }), "promocodes");
|
|
1086
|
+
},
|
|
1087
|
+
/** Get a promocode */
|
|
1088
|
+
async get(id) {
|
|
1089
|
+
return unwrapProp(await client.GET("/discounts/promocodes/v1/{id}", { params: { path: { id } } }), "promocode");
|
|
1090
|
+
},
|
|
1091
|
+
/** Create a promocode */
|
|
1092
|
+
async create(body) {
|
|
1093
|
+
return unwrapProp(await client.POST("/discounts/promocodes/v1", { body }), "promocode");
|
|
1094
|
+
},
|
|
1095
|
+
/** Archive a promocode */
|
|
1096
|
+
async archive(id) {
|
|
1097
|
+
return unwrapProp(await client.PUT("/discounts/promocodes/v1/{id}/archive", { params: { path: { id } } }), "promocode");
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
redemptions: {
|
|
1101
|
+
/**
|
|
1102
|
+
* Retrieve redemptions
|
|
1103
|
+
*
|
|
1104
|
+
* Retrieve all discount redemptions. Either couponRef or promocodeRef is required.
|
|
1105
|
+
*/
|
|
1106
|
+
async list(query) {
|
|
1107
|
+
return unwrap(await client.GET("/discounts/redemptions/v1", { params: { query } }));
|
|
1108
|
+
},
|
|
1109
|
+
/**
|
|
1110
|
+
* Retrieve redemptions — iterates every item across all pages.
|
|
1111
|
+
*
|
|
1112
|
+
* Retrieve all discount redemptions. Either couponRef or promocodeRef is required.
|
|
1113
|
+
*/
|
|
1114
|
+
iterate(query) {
|
|
1115
|
+
return paginate(
|
|
1116
|
+
async (nextPageToken) => unwrap(await client.GET("/discounts/redemptions/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1117
|
+
"redemptions"
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// src/generated/resources/events.ts
|
|
1125
|
+
function createEvents(client, defaults) {
|
|
1126
|
+
return {
|
|
1127
|
+
/** Retrieve events */
|
|
1128
|
+
async list(query) {
|
|
1129
|
+
return unwrap(await client.GET("/events/v1", { params: { query } }));
|
|
1130
|
+
},
|
|
1131
|
+
/** Retrieve an event */
|
|
1132
|
+
async get(id) {
|
|
1133
|
+
return unwrapProp(await client.GET("/events/v1/{id}", { params: { header: { "spacebring-network-id": defaults.networkId }, path: { id } } }), "event");
|
|
1134
|
+
},
|
|
1135
|
+
/** Create an event */
|
|
1136
|
+
async create(body) {
|
|
1137
|
+
return unwrapProp(await client.POST("/events/v1", { body }), "event");
|
|
1138
|
+
},
|
|
1139
|
+
/** Delete an event */
|
|
1140
|
+
async delete(id) {
|
|
1141
|
+
return unwrap(await client.DELETE("/events/v1/{id}", { params: { path: { id } } }));
|
|
1142
|
+
},
|
|
1143
|
+
/** Cancel an event */
|
|
1144
|
+
async cancel(id) {
|
|
1145
|
+
return unwrapProp(await client.PUT("/events/v1/{id}/cancel", { params: { path: { id } } }), "event");
|
|
1146
|
+
},
|
|
1147
|
+
/** Copy an event */
|
|
1148
|
+
async copy(id) {
|
|
1149
|
+
return unwrapProp(await client.POST("/events/v1/{id}/copy", { params: { path: { id } } }), "event");
|
|
1150
|
+
},
|
|
1151
|
+
tickets: {
|
|
1152
|
+
/**
|
|
1153
|
+
* Retrieve tickets
|
|
1154
|
+
*
|
|
1155
|
+
* Retrieve all event tickets.
|
|
1156
|
+
*/
|
|
1157
|
+
async list(query) {
|
|
1158
|
+
return unwrap(await client.GET("/events/tickets/v1", { params: { query } }));
|
|
1159
|
+
},
|
|
1160
|
+
/**
|
|
1161
|
+
* Retrieve tickets — iterates every item across all pages.
|
|
1162
|
+
*
|
|
1163
|
+
* Retrieve all event tickets.
|
|
1164
|
+
*/
|
|
1165
|
+
iterate(query) {
|
|
1166
|
+
return paginate(
|
|
1167
|
+
async (nextPageToken) => unwrap(await client.GET("/events/tickets/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1168
|
+
"tickets"
|
|
1169
|
+
);
|
|
1170
|
+
},
|
|
1171
|
+
/**
|
|
1172
|
+
* Retrieve a ticket
|
|
1173
|
+
*
|
|
1174
|
+
* Retrieve an event ticket.
|
|
1175
|
+
*/
|
|
1176
|
+
async get(id) {
|
|
1177
|
+
return unwrapProp(await client.GET("/events/tickets/v1/{id}", { params: { path: { id } } }), "ticket");
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// src/generated/resources/feed.ts
|
|
1184
|
+
function createFeed(client, defaults) {
|
|
1185
|
+
return {
|
|
1186
|
+
comments: {
|
|
1187
|
+
/**
|
|
1188
|
+
* Create a post comment
|
|
1189
|
+
*
|
|
1190
|
+
* Create a feed post comment.
|
|
1191
|
+
*/
|
|
1192
|
+
async create(body) {
|
|
1193
|
+
return unwrapProp(await client.POST("/feed/comments/v1", { body }), "comment");
|
|
1194
|
+
},
|
|
1195
|
+
/** Delete a post comment */
|
|
1196
|
+
async delete(id) {
|
|
1197
|
+
return unwrap(await client.DELETE("/feed/comments/v1/{id}", { params: { path: { id } } }));
|
|
1198
|
+
},
|
|
1199
|
+
/** Create a like for a post comment */
|
|
1200
|
+
async createLike(id) {
|
|
1201
|
+
return unwrapProp(await client.POST("/feed/comments/v1/{id}/likes", { params: { path: { id } } }), "like");
|
|
1202
|
+
},
|
|
1203
|
+
/** Delete a like for a post comment */
|
|
1204
|
+
async deleteLike(id) {
|
|
1205
|
+
return unwrap(await client.DELETE("/feed/comments/v1/{id}/likes", { params: { path: { id } } }));
|
|
1206
|
+
}
|
|
1207
|
+
},
|
|
1208
|
+
posts: {
|
|
1209
|
+
/**
|
|
1210
|
+
* Get posts
|
|
1211
|
+
*
|
|
1212
|
+
* Get feed posts.
|
|
1213
|
+
*/
|
|
1214
|
+
async list(query) {
|
|
1215
|
+
return unwrap(await client.GET("/feed/posts/v1", { params: { query } }));
|
|
1216
|
+
},
|
|
1217
|
+
/**
|
|
1218
|
+
* Get posts — iterates every item across all pages.
|
|
1219
|
+
*
|
|
1220
|
+
* Get feed posts.
|
|
1221
|
+
*/
|
|
1222
|
+
iterate(query) {
|
|
1223
|
+
return paginate(
|
|
1224
|
+
async (nextPageToken) => unwrap(await client.GET("/feed/posts/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1225
|
+
"posts"
|
|
1226
|
+
);
|
|
1227
|
+
},
|
|
1228
|
+
/**
|
|
1229
|
+
* Get a post
|
|
1230
|
+
*
|
|
1231
|
+
* Get a feed post.
|
|
1232
|
+
*/
|
|
1233
|
+
async get(id) {
|
|
1234
|
+
return unwrapProp(await client.GET("/feed/posts/v1/{id}", { params: { path: { id } } }), "post");
|
|
1235
|
+
},
|
|
1236
|
+
/**
|
|
1237
|
+
* Create a post
|
|
1238
|
+
*
|
|
1239
|
+
* Create a feed post.
|
|
1240
|
+
*/
|
|
1241
|
+
async create(body) {
|
|
1242
|
+
return unwrapProp(await client.POST("/feed/posts/v1", { body }), "post");
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Update a post
|
|
1246
|
+
*
|
|
1247
|
+
* Update a feed post.
|
|
1248
|
+
*/
|
|
1249
|
+
async update(id, body) {
|
|
1250
|
+
return unwrapProp(await client.PUT("/feed/posts/v1/{id}", { params: { path: { id } }, body }), "post");
|
|
1251
|
+
},
|
|
1252
|
+
/**
|
|
1253
|
+
* Delete a post
|
|
1254
|
+
*
|
|
1255
|
+
* Delete a feed post.
|
|
1256
|
+
*/
|
|
1257
|
+
async delete(id) {
|
|
1258
|
+
return unwrap(await client.DELETE("/feed/posts/v1/{id}", { params: { path: { id } } }));
|
|
1259
|
+
},
|
|
1260
|
+
/** Create a like for a post */
|
|
1261
|
+
async createLike(id) {
|
|
1262
|
+
return unwrapProp(await client.POST("/feed/posts/v1/{id}/likes", { params: { path: { id } } }), "like");
|
|
1263
|
+
},
|
|
1264
|
+
/** Delete a like for a post */
|
|
1265
|
+
async deleteLike(id) {
|
|
1266
|
+
return unwrap(await client.DELETE("/feed/posts/v1/{id}/likes", { params: { path: { id } } }));
|
|
1267
|
+
},
|
|
1268
|
+
/** Get comments for a post */
|
|
1269
|
+
async getComments(id) {
|
|
1270
|
+
return unwrapProp(await client.GET("/feed/posts/v1/{id}/comments", { params: { path: { id } } }), "comments");
|
|
1271
|
+
},
|
|
1272
|
+
/** Get likes for a post */
|
|
1273
|
+
async getLikes(id) {
|
|
1274
|
+
return unwrapProp(await client.GET("/feed/posts/v1/{id}/likes", { params: { path: { id } } }), "likes");
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// src/generated/resources/floors.ts
|
|
1281
|
+
function createFloors(client, defaults) {
|
|
1282
|
+
return {
|
|
1283
|
+
/** Get floors */
|
|
1284
|
+
async list(query) {
|
|
1285
|
+
return unwrap(await client.GET("/floors/v1", { params: { query } }));
|
|
1286
|
+
},
|
|
1287
|
+
/** Delete a floor */
|
|
1288
|
+
async delete(id) {
|
|
1289
|
+
return unwrap(await client.DELETE("/floors/v1/{id}", { params: { path: { id } } }));
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// src/generated/resources/guides.ts
|
|
1295
|
+
function createGuides(client, defaults) {
|
|
1296
|
+
return {
|
|
1297
|
+
/**
|
|
1298
|
+
* Retrieve guides
|
|
1299
|
+
*
|
|
1300
|
+
* Retrieve all guides for an organization. Requires locationRef. When using bearer token (non-basic auth), results are filtered by the user's access.
|
|
1301
|
+
*/
|
|
1302
|
+
async list(query) {
|
|
1303
|
+
return unwrap(await client.GET("/guides/v1", { params: { query } }));
|
|
1304
|
+
},
|
|
1305
|
+
/**
|
|
1306
|
+
* Retrieve guides — iterates every item across all pages.
|
|
1307
|
+
*
|
|
1308
|
+
* Retrieve all guides for an organization. Requires locationRef. When using bearer token (non-basic auth), results are filtered by the user's access.
|
|
1309
|
+
*/
|
|
1310
|
+
iterate(query) {
|
|
1311
|
+
return paginate(
|
|
1312
|
+
async (nextPageToken) => unwrap(await client.GET("/guides/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1313
|
+
"guides"
|
|
1314
|
+
);
|
|
1315
|
+
},
|
|
1316
|
+
/**
|
|
1317
|
+
* Retrieve a guide
|
|
1318
|
+
*
|
|
1319
|
+
* Retrieve a guide by id.
|
|
1320
|
+
*/
|
|
1321
|
+
async get(guideId) {
|
|
1322
|
+
return unwrapProp(await client.GET("/guides/v1/{guideId}", { params: { path: { guideId } } }), "guide");
|
|
1323
|
+
},
|
|
1324
|
+
/**
|
|
1325
|
+
* Create a guide
|
|
1326
|
+
*
|
|
1327
|
+
* Create a guide in an organization.
|
|
1328
|
+
*/
|
|
1329
|
+
async create(body) {
|
|
1330
|
+
return unwrapProp(await client.POST("/guides/v1", { body }), "guide");
|
|
1331
|
+
},
|
|
1332
|
+
/**
|
|
1333
|
+
* Update a guide
|
|
1334
|
+
*
|
|
1335
|
+
* Update a guide. At least one guide property must be provided.
|
|
1336
|
+
*/
|
|
1337
|
+
async update(guideId, body) {
|
|
1338
|
+
return unwrapProp(await client.PATCH("/guides/v1/{guideId}", { params: { path: { guideId } }, body }), "guide");
|
|
1339
|
+
},
|
|
1340
|
+
/** Delete a guide */
|
|
1341
|
+
async delete(guideId) {
|
|
1342
|
+
return unwrap(await client.DELETE("/guides/v1/{guideId}", { params: { path: { guideId } } }));
|
|
1343
|
+
}
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
// src/generated/resources/locations.ts
|
|
1348
|
+
function createLocations(client, defaults) {
|
|
1349
|
+
return {
|
|
1350
|
+
/** Retrieve all locations */
|
|
1351
|
+
async list() {
|
|
1352
|
+
return unwrapProp(await client.GET("/locations/v1", {}), "locations");
|
|
1353
|
+
},
|
|
1354
|
+
/** Get a location */
|
|
1355
|
+
async get(locationId) {
|
|
1356
|
+
return unwrapProp(await client.GET("/locations/v1/{locationId}", { params: { path: { locationId } } }), "location");
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// src/generated/resources/networks.ts
|
|
1362
|
+
function createNetworks(client, defaults) {
|
|
1363
|
+
return {
|
|
1364
|
+
/**
|
|
1365
|
+
* Retrieve networks
|
|
1366
|
+
*
|
|
1367
|
+
* Retrieve all networks you are in.
|
|
1368
|
+
*/
|
|
1369
|
+
async list() {
|
|
1370
|
+
return unwrapProp(await client.GET("/networks/v1", {}), "networks");
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// src/generated/resources/plans.ts
|
|
1376
|
+
function createPlans(client, defaults) {
|
|
1377
|
+
return {
|
|
1378
|
+
/**
|
|
1379
|
+
* Retrieve plans
|
|
1380
|
+
*
|
|
1381
|
+
* Retrieve all plans.
|
|
1382
|
+
*/
|
|
1383
|
+
async list(query) {
|
|
1384
|
+
return unwrap(await client.GET("/plans/v1", { params: { query } }));
|
|
1385
|
+
},
|
|
1386
|
+
/**
|
|
1387
|
+
* Retrieve plans — iterates every item across all pages.
|
|
1388
|
+
*
|
|
1389
|
+
* Retrieve all plans.
|
|
1390
|
+
*/
|
|
1391
|
+
iterate(query) {
|
|
1392
|
+
return paginate(
|
|
1393
|
+
async (nextPageToken) => unwrap(await client.GET("/plans/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1394
|
+
"plans"
|
|
1395
|
+
);
|
|
1396
|
+
},
|
|
1397
|
+
/**
|
|
1398
|
+
* Retrieve a plan
|
|
1399
|
+
*
|
|
1400
|
+
* Retrieve a certain plan.
|
|
1401
|
+
*/
|
|
1402
|
+
async get(planId) {
|
|
1403
|
+
return unwrapProp(await client.GET("/plans/v1/{planId}", { params: { path: { planId } } }), "plan");
|
|
1404
|
+
},
|
|
1405
|
+
/** Create a plan */
|
|
1406
|
+
async create(body) {
|
|
1407
|
+
return unwrapProp(await client.POST("/plans/v1", { body }), "plan");
|
|
1408
|
+
},
|
|
1409
|
+
/**
|
|
1410
|
+
* Update a plan
|
|
1411
|
+
*
|
|
1412
|
+
* Update a certain plan.
|
|
1413
|
+
*/
|
|
1414
|
+
async update(planId, body) {
|
|
1415
|
+
return unwrap(await client.PATCH("/plans/v1/{planId}", { params: { path: { planId } }, body }));
|
|
1416
|
+
},
|
|
1417
|
+
/**
|
|
1418
|
+
* Delete a plan
|
|
1419
|
+
*
|
|
1420
|
+
* Delete a certain plan.
|
|
1421
|
+
*/
|
|
1422
|
+
async delete(planId) {
|
|
1423
|
+
return unwrap(await client.DELETE("/plans/v1/{planId}", { params: { path: { planId } } }));
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// src/generated/resources/registrations.ts
|
|
1429
|
+
function createRegistrations(client, defaults) {
|
|
1430
|
+
return {
|
|
1431
|
+
/**
|
|
1432
|
+
* Retrieve registrations
|
|
1433
|
+
*
|
|
1434
|
+
* Retrieve all registrations in network.
|
|
1435
|
+
*/
|
|
1436
|
+
async list(query) {
|
|
1437
|
+
return unwrap(await client.GET("/registrations/v1", { params: { query } }));
|
|
1438
|
+
},
|
|
1439
|
+
/**
|
|
1440
|
+
* Retrieve registrations — iterates every item across all pages.
|
|
1441
|
+
*
|
|
1442
|
+
* Retrieve all registrations in network.
|
|
1443
|
+
*/
|
|
1444
|
+
iterate(query) {
|
|
1445
|
+
return paginate(
|
|
1446
|
+
async (nextPageToken) => unwrap(await client.GET("/registrations/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1447
|
+
"registrations"
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
// src/generated/resources/resources.ts
|
|
1454
|
+
function createResources(client, defaults) {
|
|
1455
|
+
return {
|
|
1456
|
+
/**
|
|
1457
|
+
* Retrieve resources
|
|
1458
|
+
*
|
|
1459
|
+
* Retrieve resources in the location. Resources represent all kind of bookable items like rooms, hot desks, dedicated desks, parking lots.
|
|
1460
|
+
*/
|
|
1461
|
+
async list(query) {
|
|
1462
|
+
return unwrap(await client.GET("/resources/v1", { params: { query } }));
|
|
1463
|
+
},
|
|
1464
|
+
/**
|
|
1465
|
+
* Retrieve resources — iterates every item across all pages.
|
|
1466
|
+
*
|
|
1467
|
+
* Retrieve resources in the location. Resources represent all kind of bookable items like rooms, hot desks, dedicated desks, parking lots.
|
|
1468
|
+
*/
|
|
1469
|
+
iterate(query) {
|
|
1470
|
+
return paginate(
|
|
1471
|
+
async (nextPageToken) => unwrap(await client.GET("/resources/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1472
|
+
"resources"
|
|
1473
|
+
);
|
|
1474
|
+
},
|
|
1475
|
+
/**
|
|
1476
|
+
* Get a resource
|
|
1477
|
+
*
|
|
1478
|
+
* Get a certain resource.
|
|
1479
|
+
*/
|
|
1480
|
+
async get(id) {
|
|
1481
|
+
return unwrapProp(await client.GET("/resources/v1/{id}", { params: { path: { id } } }), "resource");
|
|
1482
|
+
},
|
|
1483
|
+
/**
|
|
1484
|
+
* Create a resource
|
|
1485
|
+
*
|
|
1486
|
+
* Create a new resource in a location. The request body must match the schema exactly—unknown properties are rejected.
|
|
1487
|
+
*/
|
|
1488
|
+
async create(body) {
|
|
1489
|
+
return unwrapProp(await client.POST("/resources/v1", { body }), "resource");
|
|
1490
|
+
},
|
|
1491
|
+
/**
|
|
1492
|
+
* Patch a resource
|
|
1493
|
+
*
|
|
1494
|
+
* Patch a certain resource.
|
|
1495
|
+
*/
|
|
1496
|
+
async update(id, body) {
|
|
1497
|
+
return unwrap(await client.PATCH("/resources/v1/{id}", { params: { path: { id } }, body }));
|
|
1498
|
+
},
|
|
1499
|
+
bookings: {
|
|
1500
|
+
/**
|
|
1501
|
+
* Retrieve bookings
|
|
1502
|
+
*
|
|
1503
|
+
* Retrieve all bookings of resources.
|
|
1504
|
+
*/
|
|
1505
|
+
async list(query) {
|
|
1506
|
+
return unwrap(await client.GET("/resources/bookings/v1", { params: { query } }));
|
|
1507
|
+
},
|
|
1508
|
+
/**
|
|
1509
|
+
* Retrieve bookings — iterates every item across all pages.
|
|
1510
|
+
*
|
|
1511
|
+
* Retrieve all bookings of resources.
|
|
1512
|
+
*/
|
|
1513
|
+
iterate(query) {
|
|
1514
|
+
return paginate(
|
|
1515
|
+
async (nextPageToken) => unwrap(await client.GET("/resources/bookings/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1516
|
+
"bookings"
|
|
1517
|
+
);
|
|
1518
|
+
},
|
|
1519
|
+
/** Get a booking */
|
|
1520
|
+
async get(id) {
|
|
1521
|
+
return unwrapProp(await client.GET("/resources/bookings/v1/{id}", { params: { path: { id } } }), "booking");
|
|
1522
|
+
},
|
|
1523
|
+
/** Create a booking */
|
|
1524
|
+
async create(body) {
|
|
1525
|
+
return unwrapProp(await client.POST("/resources/bookings/v1", { body }), "booking");
|
|
1526
|
+
},
|
|
1527
|
+
/** Delete a booking */
|
|
1528
|
+
async delete(id) {
|
|
1529
|
+
return unwrap(await client.DELETE("/resources/bookings/v1/{id}", { params: { path: { id } } }));
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// src/generated/resources/shop.ts
|
|
1536
|
+
function createShop(client, defaults) {
|
|
1537
|
+
return {
|
|
1538
|
+
categories: {
|
|
1539
|
+
/**
|
|
1540
|
+
* Retrieve categories
|
|
1541
|
+
*
|
|
1542
|
+
* Retrieve all shop categories in the location.
|
|
1543
|
+
*/
|
|
1544
|
+
async list(query) {
|
|
1545
|
+
return unwrapProp(await client.GET("/shop/categories/v1", { params: { query } }), "categories");
|
|
1546
|
+
},
|
|
1547
|
+
/**
|
|
1548
|
+
* Get a category
|
|
1549
|
+
*
|
|
1550
|
+
* Get a shop category.
|
|
1551
|
+
*/
|
|
1552
|
+
async get(categoryId) {
|
|
1553
|
+
return unwrapProp(await client.GET("/shop/categories/v1/{categoryId}", { params: { path: { categoryId } } }), "category");
|
|
1554
|
+
},
|
|
1555
|
+
/**
|
|
1556
|
+
* Create a category
|
|
1557
|
+
*
|
|
1558
|
+
* Create a shop category.
|
|
1559
|
+
*/
|
|
1560
|
+
async create(body) {
|
|
1561
|
+
return unwrapProp(await client.POST("/shop/categories/v1", { body }), "category");
|
|
1562
|
+
},
|
|
1563
|
+
/**
|
|
1564
|
+
* Update a category
|
|
1565
|
+
*
|
|
1566
|
+
* Update a shop category.
|
|
1567
|
+
*/
|
|
1568
|
+
async update(categoryId, body) {
|
|
1569
|
+
return unwrapProp(await client.PUT("/shop/categories/v1/{categoryId}", { params: { path: { categoryId } }, body }), "category");
|
|
1570
|
+
},
|
|
1571
|
+
/**
|
|
1572
|
+
* Delete a category
|
|
1573
|
+
*
|
|
1574
|
+
* Delete a shop category.
|
|
1575
|
+
*/
|
|
1576
|
+
async delete(categoryId) {
|
|
1577
|
+
return unwrap(await client.DELETE("/shop/categories/v1/{categoryId}", { params: { path: { categoryId } } }));
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
orders: {
|
|
1581
|
+
/**
|
|
1582
|
+
* Retrieve orders
|
|
1583
|
+
*
|
|
1584
|
+
* Retrieve all orders of products from shop.
|
|
1585
|
+
*/
|
|
1586
|
+
async list(query) {
|
|
1587
|
+
return unwrap(await client.GET("/shop/orders/v1", { params: { query } }));
|
|
1588
|
+
},
|
|
1589
|
+
/**
|
|
1590
|
+
* Retrieve orders — iterates every item across all pages.
|
|
1591
|
+
*
|
|
1592
|
+
* Retrieve all orders of products from shop.
|
|
1593
|
+
*/
|
|
1594
|
+
iterate(query) {
|
|
1595
|
+
return paginate(
|
|
1596
|
+
async (nextPageToken) => unwrap(await client.GET("/shop/orders/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1597
|
+
"orders"
|
|
1598
|
+
);
|
|
1599
|
+
},
|
|
1600
|
+
/**
|
|
1601
|
+
* Get an order
|
|
1602
|
+
*
|
|
1603
|
+
* Get a certain order.
|
|
1604
|
+
*/
|
|
1605
|
+
async get(orderId) {
|
|
1606
|
+
return unwrapProp(await client.GET("/shop/orders/v1/{orderId}", { params: { path: { orderId } } }), "order");
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
products: {
|
|
1610
|
+
/**
|
|
1611
|
+
* Retrieve products
|
|
1612
|
+
*
|
|
1613
|
+
* Retrieve products from shop.
|
|
1614
|
+
*/
|
|
1615
|
+
async list(query) {
|
|
1616
|
+
return unwrap(await client.GET("/shop/products/v1", { params: { query } }));
|
|
1617
|
+
},
|
|
1618
|
+
/**
|
|
1619
|
+
* Retrieve products — iterates every item across all pages.
|
|
1620
|
+
*
|
|
1621
|
+
* Retrieve products from shop.
|
|
1622
|
+
*/
|
|
1623
|
+
iterate(query) {
|
|
1624
|
+
return paginate(
|
|
1625
|
+
async (nextPageToken) => unwrap(await client.GET("/shop/products/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1626
|
+
"products"
|
|
1627
|
+
);
|
|
1628
|
+
},
|
|
1629
|
+
/**
|
|
1630
|
+
* Get a product
|
|
1631
|
+
*
|
|
1632
|
+
* Get a certain product.
|
|
1633
|
+
*/
|
|
1634
|
+
async get(productId) {
|
|
1635
|
+
return unwrapProp(await client.GET("/shop/products/v1/{productId}", { params: { path: { productId } } }), "product");
|
|
1636
|
+
},
|
|
1637
|
+
/**
|
|
1638
|
+
* Create a product
|
|
1639
|
+
*
|
|
1640
|
+
* Create a product in shop.
|
|
1641
|
+
*/
|
|
1642
|
+
async create(body) {
|
|
1643
|
+
return unwrapProp(await client.POST("/shop/products/v1", { body }), "product");
|
|
1644
|
+
},
|
|
1645
|
+
/**
|
|
1646
|
+
* Update a product
|
|
1647
|
+
*
|
|
1648
|
+
* Update a certain product.
|
|
1649
|
+
*/
|
|
1650
|
+
async update(productId, body) {
|
|
1651
|
+
return unwrapProp(await client.PUT("/shop/products/v1/{productId}", { params: { path: { productId } }, body }), "product");
|
|
1652
|
+
},
|
|
1653
|
+
/**
|
|
1654
|
+
* Delete a product
|
|
1655
|
+
*
|
|
1656
|
+
* Delete a certain product.
|
|
1657
|
+
*/
|
|
1658
|
+
async delete(productId) {
|
|
1659
|
+
return unwrap(await client.DELETE("/shop/products/v1/{productId}", { params: { path: { productId } } }));
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// src/generated/resources/subscriptions.ts
|
|
1666
|
+
function createSubscriptions(client, defaults) {
|
|
1667
|
+
return {
|
|
1668
|
+
/** Retrieve subscriptions */
|
|
1669
|
+
async list(query) {
|
|
1670
|
+
return unwrap(await client.GET("/subscriptions/v1", { params: { query } }));
|
|
1671
|
+
},
|
|
1672
|
+
/** Retrieve subscriptions — iterates every item across all pages. */
|
|
1673
|
+
iterate(query) {
|
|
1674
|
+
return paginate(
|
|
1675
|
+
async (nextPageToken) => unwrap(await client.GET("/subscriptions/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1676
|
+
"subscriptions"
|
|
1677
|
+
);
|
|
1678
|
+
},
|
|
1679
|
+
/**
|
|
1680
|
+
* Retrieve a subscription
|
|
1681
|
+
*
|
|
1682
|
+
* Retrieve a certain subscription.
|
|
1683
|
+
*/
|
|
1684
|
+
async get(id) {
|
|
1685
|
+
return unwrapProp(await client.GET("/subscriptions/v1/{id}", { params: { path: { id } } }), "subscription");
|
|
1686
|
+
},
|
|
1687
|
+
/**
|
|
1688
|
+
* Create a subscription
|
|
1689
|
+
*
|
|
1690
|
+
* Create a subscription for a membership or company.
|
|
1691
|
+
*/
|
|
1692
|
+
async create(body) {
|
|
1693
|
+
return unwrapProp(await client.POST("/subscriptions/v1", { body }), "subscription");
|
|
1694
|
+
},
|
|
1695
|
+
/**
|
|
1696
|
+
* Update a subscription
|
|
1697
|
+
*
|
|
1698
|
+
* Update a certain subscription.
|
|
1699
|
+
*/
|
|
1700
|
+
async update(id, body) {
|
|
1701
|
+
return unwrap(await client.PATCH("/subscriptions/v1/{id}", { params: { path: { id } }, body }));
|
|
1702
|
+
},
|
|
1703
|
+
/**
|
|
1704
|
+
* Delete a subscription
|
|
1705
|
+
*
|
|
1706
|
+
* Delete a certain subscription.
|
|
1707
|
+
*/
|
|
1708
|
+
async delete(id) {
|
|
1709
|
+
return unwrap(await client.DELETE("/subscriptions/v1/{id}", { params: { path: { id } } }));
|
|
1710
|
+
},
|
|
1711
|
+
/** Create a subscription item */
|
|
1712
|
+
async createItem(id, body) {
|
|
1713
|
+
return unwrapProp(await client.POST("/subscriptions/v1/{id}/items", { params: { path: { id } }, body }), "subscription");
|
|
1714
|
+
},
|
|
1715
|
+
/** Delete a subscription item */
|
|
1716
|
+
async deleteItem(id, itemId) {
|
|
1717
|
+
return unwrap(await client.DELETE("/subscriptions/v1/{id}/items/{itemId}", { params: { path: { id, itemId } } }));
|
|
1718
|
+
},
|
|
1719
|
+
/** Update a subscription item */
|
|
1720
|
+
async updateItem(id, itemId, body) {
|
|
1721
|
+
return unwrap(await client.PATCH("/subscriptions/v1/{id}/items/{itemId}", { params: { path: { id, itemId } }, body }));
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// src/generated/resources/support.ts
|
|
1727
|
+
function createSupport(client, defaults) {
|
|
1728
|
+
return {
|
|
1729
|
+
tickets: {
|
|
1730
|
+
/**
|
|
1731
|
+
* Retrieve tickets
|
|
1732
|
+
*
|
|
1733
|
+
* Retrieve all support tickets.
|
|
1734
|
+
*/
|
|
1735
|
+
async list(query) {
|
|
1736
|
+
return unwrap(await client.GET("/support/tickets/v1", { params: { query } }));
|
|
1737
|
+
},
|
|
1738
|
+
/**
|
|
1739
|
+
* Retrieve tickets — iterates every item across all pages.
|
|
1740
|
+
*
|
|
1741
|
+
* Retrieve all support tickets.
|
|
1742
|
+
*/
|
|
1743
|
+
iterate(query) {
|
|
1744
|
+
return paginate(
|
|
1745
|
+
async (nextPageToken) => unwrap(await client.GET("/support/tickets/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1746
|
+
"tickets"
|
|
1747
|
+
);
|
|
1748
|
+
},
|
|
1749
|
+
/**
|
|
1750
|
+
* Retrieve a ticket
|
|
1751
|
+
*
|
|
1752
|
+
* Retrieve a support ticket.
|
|
1753
|
+
*/
|
|
1754
|
+
async get(id) {
|
|
1755
|
+
return unwrap(await client.GET("/support/tickets/v1/{id}", { params: { path: { id } } }));
|
|
1756
|
+
},
|
|
1757
|
+
/**
|
|
1758
|
+
* Create a ticket
|
|
1759
|
+
*
|
|
1760
|
+
* Create a support ticket.
|
|
1761
|
+
*/
|
|
1762
|
+
async create(body) {
|
|
1763
|
+
return unwrap(await client.POST("/support/tickets/v1", { body }));
|
|
1764
|
+
},
|
|
1765
|
+
/**
|
|
1766
|
+
* Update a ticket's assignee
|
|
1767
|
+
*
|
|
1768
|
+
* Update support ticket assignee.
|
|
1769
|
+
*/
|
|
1770
|
+
async updateAssignee(id, body) {
|
|
1771
|
+
return unwrap(await client.PUT("/support/tickets/v1/{id}/assignee", { params: { path: { id } }, body }));
|
|
1772
|
+
},
|
|
1773
|
+
/**
|
|
1774
|
+
* Update a ticket's status
|
|
1775
|
+
*
|
|
1776
|
+
* Update support ticket status.
|
|
1777
|
+
*/
|
|
1778
|
+
async updateStatus(id, body) {
|
|
1779
|
+
return unwrap(await client.PUT("/support/tickets/v1/{id}/status", { params: { path: { id } }, body }));
|
|
1780
|
+
},
|
|
1781
|
+
/**
|
|
1782
|
+
* Update a ticket's type
|
|
1783
|
+
*
|
|
1784
|
+
* Update a support ticket type.
|
|
1785
|
+
*/
|
|
1786
|
+
async updateType(id, body) {
|
|
1787
|
+
return unwrap(await client.PATCH("/support/tickets/v1/{id}/type", { params: { path: { id } }, body }));
|
|
1788
|
+
},
|
|
1789
|
+
comment: {
|
|
1790
|
+
/**
|
|
1791
|
+
* Create a ticket comment
|
|
1792
|
+
*
|
|
1793
|
+
* Create a support ticket comment.
|
|
1794
|
+
*/
|
|
1795
|
+
async create(body) {
|
|
1796
|
+
return unwrapProp(await client.POST("/support/tickets/v1/comment", { body }), "activity");
|
|
1797
|
+
},
|
|
1798
|
+
/**
|
|
1799
|
+
* Delete a ticket comment
|
|
1800
|
+
*
|
|
1801
|
+
* Delete a support ticket comment.
|
|
1802
|
+
*/
|
|
1803
|
+
async delete(id) {
|
|
1804
|
+
return unwrap(await client.DELETE("/support/tickets/v1/comment/{id}", { params: { path: { id } } }));
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// src/generated/resources/transactions.ts
|
|
1812
|
+
function createTransactions(client, defaults) {
|
|
1813
|
+
return {
|
|
1814
|
+
balances: {
|
|
1815
|
+
/**
|
|
1816
|
+
* Retrieve credit balance
|
|
1817
|
+
*
|
|
1818
|
+
* Retrieve credits balance.
|
|
1819
|
+
*/
|
|
1820
|
+
async getCredits(id) {
|
|
1821
|
+
return unwrapProp(await client.GET("/transactions/v1/balances/{id}/credits", { params: { path: { id } } }), "balances");
|
|
1822
|
+
},
|
|
1823
|
+
/** Retrieve day passes balance */
|
|
1824
|
+
async getDayPasses(id) {
|
|
1825
|
+
return unwrapProp(await client.GET("/transactions/v1/balances/{id}/day_passes", { params: { path: { id } } }), "balances");
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
credits: {
|
|
1829
|
+
/**
|
|
1830
|
+
* Retrieve credit transactions
|
|
1831
|
+
*
|
|
1832
|
+
* Retrieve credits transactions.
|
|
1833
|
+
*/
|
|
1834
|
+
async list(query) {
|
|
1835
|
+
return unwrap(await client.GET("/transactions/credits/v1", { params: { query } }));
|
|
1836
|
+
},
|
|
1837
|
+
/**
|
|
1838
|
+
* Retrieve credit transactions — iterates every item across all pages.
|
|
1839
|
+
*
|
|
1840
|
+
* Retrieve credits transactions.
|
|
1841
|
+
*/
|
|
1842
|
+
iterate(query) {
|
|
1843
|
+
return paginate(
|
|
1844
|
+
async (nextPageToken) => unwrap(await client.GET("/transactions/credits/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1845
|
+
"transactions"
|
|
1846
|
+
);
|
|
1847
|
+
},
|
|
1848
|
+
/**
|
|
1849
|
+
* Create a credit transaction
|
|
1850
|
+
*
|
|
1851
|
+
* Create a credits transaction.
|
|
1852
|
+
*/
|
|
1853
|
+
async create(body) {
|
|
1854
|
+
return unwrapProp(await client.POST("/transactions/credits/v1", { body }), "transaction");
|
|
1855
|
+
}
|
|
1856
|
+
},
|
|
1857
|
+
dayPasses: {
|
|
1858
|
+
/**
|
|
1859
|
+
* Retrieve day pass transactions
|
|
1860
|
+
*
|
|
1861
|
+
* Retrieve day passes transactions.
|
|
1862
|
+
*/
|
|
1863
|
+
async list(query) {
|
|
1864
|
+
return unwrap(await client.GET("/transactions/day_passes/v1", { params: { query } }));
|
|
1865
|
+
},
|
|
1866
|
+
/**
|
|
1867
|
+
* Retrieve day pass transactions — iterates every item across all pages.
|
|
1868
|
+
*
|
|
1869
|
+
* Retrieve day passes transactions.
|
|
1870
|
+
*/
|
|
1871
|
+
iterate(query) {
|
|
1872
|
+
return paginate(
|
|
1873
|
+
async (nextPageToken) => unwrap(await client.GET("/transactions/day_passes/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1874
|
+
"transactions"
|
|
1875
|
+
);
|
|
1876
|
+
},
|
|
1877
|
+
/**
|
|
1878
|
+
* Create a day pass transaction
|
|
1879
|
+
*
|
|
1880
|
+
* Create a day passes transaction.
|
|
1881
|
+
*/
|
|
1882
|
+
async create(body) {
|
|
1883
|
+
return unwrapProp(await client.POST("/transactions/day_passes/v1", { body }), "transaction");
|
|
1884
|
+
}
|
|
1885
|
+
},
|
|
1886
|
+
money: {
|
|
1887
|
+
/** Retrieve money transactions */
|
|
1888
|
+
async list(query) {
|
|
1889
|
+
return unwrap(await client.GET("/transactions/money/v1", { params: { query } }));
|
|
1890
|
+
},
|
|
1891
|
+
/** Retrieve money transactions — iterates every item across all pages. */
|
|
1892
|
+
iterate(query) {
|
|
1893
|
+
return paginate(
|
|
1894
|
+
async (nextPageToken) => unwrap(await client.GET("/transactions/money/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1895
|
+
"transactions"
|
|
1896
|
+
);
|
|
1897
|
+
},
|
|
1898
|
+
/** Retrieve a money transaction */
|
|
1899
|
+
async get(id) {
|
|
1900
|
+
return unwrapProp(await client.GET("/transactions/money/v1/{id}", { params: { path: { id } } }), "transaction");
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
// src/generated/resources/visitors.ts
|
|
1907
|
+
function createVisitors(client, defaults) {
|
|
1908
|
+
return {
|
|
1909
|
+
contacts: {
|
|
1910
|
+
/** Get contacts */
|
|
1911
|
+
async list(query) {
|
|
1912
|
+
return unwrap(await client.GET("/visitors/contacts/v1", { params: { query } }));
|
|
1913
|
+
},
|
|
1914
|
+
/** Get contacts — iterates every item across all pages. */
|
|
1915
|
+
iterate(query) {
|
|
1916
|
+
return paginate(
|
|
1917
|
+
async (nextPageToken) => unwrap(await client.GET("/visitors/contacts/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1918
|
+
"contacts"
|
|
1919
|
+
);
|
|
1920
|
+
},
|
|
1921
|
+
/** Get a contact */
|
|
1922
|
+
async get(contactId) {
|
|
1923
|
+
return unwrapProp(await client.GET("/visitors/contacts/v1/{contactId}", { params: { path: { contactId } } }), "contact");
|
|
1924
|
+
},
|
|
1925
|
+
/** Create a contact */
|
|
1926
|
+
async create(body) {
|
|
1927
|
+
return unwrapProp(await client.POST("/visitors/contacts/v1", { body }), "contact");
|
|
1928
|
+
}
|
|
1929
|
+
},
|
|
1930
|
+
requests: {
|
|
1931
|
+
/** Get requests */
|
|
1932
|
+
async list(query) {
|
|
1933
|
+
return unwrap(await client.GET("/visitors/requests/v1", { params: { query } }));
|
|
1934
|
+
},
|
|
1935
|
+
/** Get requests — iterates every item across all pages. */
|
|
1936
|
+
iterate(query) {
|
|
1937
|
+
return paginate(
|
|
1938
|
+
async (nextPageToken) => unwrap(await client.GET("/visitors/requests/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1939
|
+
"requests"
|
|
1940
|
+
);
|
|
1941
|
+
},
|
|
1942
|
+
/** Retrieve a request */
|
|
1943
|
+
async get(id) {
|
|
1944
|
+
return unwrapProp(await client.GET("/visitors/requests/v1/{id}", { params: { path: { id } } }), "request");
|
|
1945
|
+
},
|
|
1946
|
+
/** Create a request */
|
|
1947
|
+
async create(body) {
|
|
1948
|
+
return unwrapProp(await client.POST("/visitors/requests/v1", { body }), "request");
|
|
1949
|
+
},
|
|
1950
|
+
/** Approve a request */
|
|
1951
|
+
async approve(id) {
|
|
1952
|
+
return unwrapProp(await client.POST("/visitors/requests/v1/{id}/approve", { params: { path: { id } } }), "visit");
|
|
1953
|
+
},
|
|
1954
|
+
/** Reject a request */
|
|
1955
|
+
async reject(id) {
|
|
1956
|
+
return unwrap(await client.POST("/visitors/requests/v1/{id}/reject", { params: { path: { id } } }));
|
|
1957
|
+
}
|
|
1958
|
+
},
|
|
1959
|
+
visits: {
|
|
1960
|
+
/** Retrieve visits */
|
|
1961
|
+
async list(query) {
|
|
1962
|
+
return unwrap(await client.GET("/visitors/visits/v1", { params: { query } }));
|
|
1963
|
+
},
|
|
1964
|
+
/** Retrieve visits — iterates every item across all pages. */
|
|
1965
|
+
iterate(query) {
|
|
1966
|
+
return paginate(
|
|
1967
|
+
async (nextPageToken) => unwrap(await client.GET("/visitors/visits/v1", { params: { query: { ...query, nextPageToken } } })),
|
|
1968
|
+
"visits"
|
|
1969
|
+
);
|
|
1970
|
+
},
|
|
1971
|
+
/**
|
|
1972
|
+
* Retrieve a visit
|
|
1973
|
+
*
|
|
1974
|
+
* Retrieve a visit by id.
|
|
1975
|
+
*/
|
|
1976
|
+
async get(id) {
|
|
1977
|
+
return unwrapProp(await client.GET("/visitors/visits/v1/{id}", { params: { path: { id } } }), "visit");
|
|
1978
|
+
},
|
|
1979
|
+
/** Create a visit */
|
|
1980
|
+
async create(body) {
|
|
1981
|
+
return unwrapProp(await client.POST("/visitors/visits/v1", { body }), "visit");
|
|
1982
|
+
},
|
|
1983
|
+
/**
|
|
1984
|
+
* Update a visit
|
|
1985
|
+
*
|
|
1986
|
+
* Update a visit by id.
|
|
1987
|
+
*/
|
|
1988
|
+
async update(id, body) {
|
|
1989
|
+
return unwrapProp(await client.PUT("/visitors/visits/v1/{id}", { params: { path: { id } }, body }), "visit");
|
|
1990
|
+
},
|
|
1991
|
+
/**
|
|
1992
|
+
* Delete a visit
|
|
1993
|
+
*
|
|
1994
|
+
* Delete a visit by id.
|
|
1995
|
+
*/
|
|
1996
|
+
async delete(id) {
|
|
1997
|
+
return unwrap(await client.DELETE("/visitors/visits/v1/{id}", { params: { path: { id } } }));
|
|
1998
|
+
},
|
|
1999
|
+
/** Check in a visit */
|
|
2000
|
+
async checkIn(body) {
|
|
2001
|
+
return unwrapProp(await client.POST("/visitors/visits/v1/checkin", { body }), "visit");
|
|
2002
|
+
},
|
|
2003
|
+
/** Check out a visit */
|
|
2004
|
+
async checkOut(body) {
|
|
2005
|
+
return unwrapProp(await client.POST("/visitors/visits/v1/checkout", { body }), "visit");
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
};
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
// src/generated/resources/index.ts
|
|
2012
|
+
function createResources2(client, defaults) {
|
|
2013
|
+
return {
|
|
2014
|
+
altCurrencies: createAltcurrencies(client, defaults),
|
|
2015
|
+
benefits: createBenefits(client, defaults),
|
|
2016
|
+
billing: createBilling(client, defaults),
|
|
2017
|
+
community: createCommunity(client, defaults),
|
|
2018
|
+
contracts: createContracts(client, defaults),
|
|
2019
|
+
discounts: createDiscounts(client, defaults),
|
|
2020
|
+
events: createEvents(client, defaults),
|
|
2021
|
+
feed: createFeed(client, defaults),
|
|
2022
|
+
floors: createFloors(client, defaults),
|
|
2023
|
+
guides: createGuides(client, defaults),
|
|
2024
|
+
locations: createLocations(client, defaults),
|
|
2025
|
+
networks: createNetworks(client, defaults),
|
|
2026
|
+
plans: createPlans(client, defaults),
|
|
2027
|
+
registrations: createRegistrations(client, defaults),
|
|
2028
|
+
resources: createResources(client, defaults),
|
|
2029
|
+
shop: createShop(client, defaults),
|
|
2030
|
+
subscriptions: createSubscriptions(client, defaults),
|
|
2031
|
+
support: createSupport(client, defaults),
|
|
2032
|
+
transactions: createTransactions(client, defaults),
|
|
2033
|
+
visitors: createVisitors(client, defaults)
|
|
2034
|
+
};
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
// src/client.ts
|
|
2038
|
+
var Spacebring = class {
|
|
2039
|
+
/** Typed openapi-fetch client — escape hatch for endpoints or options the facade does not cover. */
|
|
2040
|
+
raw;
|
|
2041
|
+
constructor(config) {
|
|
2042
|
+
const headers = {
|
|
2043
|
+
Authorization: `Basic ${toBase64(`${config.clientId}:${config.clientSecret}`)}`
|
|
2044
|
+
};
|
|
2045
|
+
if (config.networkId) {
|
|
2046
|
+
headers["spacebring-network-id"] = config.networkId;
|
|
2047
|
+
}
|
|
2048
|
+
this.raw = createClient({
|
|
2049
|
+
baseUrl: config.baseUrl ?? "https://api.spacebring.com",
|
|
2050
|
+
headers,
|
|
2051
|
+
fetch: config.fetch
|
|
2052
|
+
});
|
|
2053
|
+
Object.assign(this, createResources2(this.raw, { networkId: config.networkId }));
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
function toBase64(value) {
|
|
2057
|
+
if (typeof Buffer !== "undefined") {
|
|
2058
|
+
return Buffer.from(value, "utf8").toString("base64");
|
|
2059
|
+
}
|
|
2060
|
+
let binary = "";
|
|
2061
|
+
for (const byte of new TextEncoder().encode(value)) {
|
|
2062
|
+
binary += String.fromCharCode(byte);
|
|
2063
|
+
}
|
|
2064
|
+
return btoa(binary);
|
|
2065
|
+
}
|
|
2066
|
+
export {
|
|
2067
|
+
Spacebring,
|
|
2068
|
+
SpacebringError
|
|
2069
|
+
};
|
|
2070
|
+
//# sourceMappingURL=index.js.map
|