@allthings/sdk 10.0.0-beta.1 → 10.0.0-beta.3

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.
Files changed (54) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/lib.cjs.js +3 -3
  3. package/dist/package.json +172 -0
  4. package/dist/src/cli.js +15 -0
  5. package/dist/src/constants.js +25 -0
  6. package/dist/src/index.js +4 -0
  7. package/dist/src/oauth/authorizationCodeGrant.js +56 -0
  8. package/dist/src/oauth/clientCredentialsGrant.js +25 -0
  9. package/dist/src/oauth/createTokenStore.js +8 -0
  10. package/dist/src/oauth/implicitGrant.js +24 -0
  11. package/dist/src/oauth/makeFetchTokenRequester.js +38 -0
  12. package/dist/src/oauth/maybeUpdateToken.js +44 -0
  13. package/dist/src/oauth/passwordGrant.js +30 -0
  14. package/dist/src/oauth/refreshTokenGrant.js +26 -0
  15. package/dist/src/oauth/requestAndSaveToStore.js +5 -0
  16. package/dist/src/oauth/types.js +1 -0
  17. package/dist/src/rest/delete.js +3 -0
  18. package/dist/src/rest/get.js +3 -0
  19. package/dist/src/rest/index.js +160 -0
  20. package/dist/src/rest/methods/agent.js +26 -0
  21. package/dist/src/rest/methods/app.js +10 -0
  22. package/dist/src/rest/methods/booking.js +6 -0
  23. package/dist/src/rest/methods/bucket.js +22 -0
  24. package/dist/src/rest/methods/conversation.js +28 -0
  25. package/dist/src/rest/methods/file.js +11 -0
  26. package/dist/src/rest/methods/group.js +22 -0
  27. package/dist/src/rest/methods/idLookup.js +12 -0
  28. package/dist/src/rest/methods/notification.js +57 -0
  29. package/dist/src/rest/methods/notificationSettings.js +19 -0
  30. package/dist/src/rest/methods/property.js +17 -0
  31. package/dist/src/rest/methods/registrationCode.js +24 -0
  32. package/dist/src/rest/methods/serviceProvider.js +9 -0
  33. package/dist/src/rest/methods/ticket.js +34 -0
  34. package/dist/src/rest/methods/unit.js +95 -0
  35. package/dist/src/rest/methods/user.js +134 -0
  36. package/dist/src/rest/methods/userRelation.js +22 -0
  37. package/dist/src/rest/methods/utilisationPeriod.js +49 -0
  38. package/dist/src/rest/patch.js +3 -0
  39. package/dist/src/rest/post.js +3 -0
  40. package/dist/src/rest/put.js +3 -0
  41. package/dist/src/rest/request.js +159 -0
  42. package/dist/src/rest/types.js +62 -0
  43. package/dist/src/utils/environment.js +1 -0
  44. package/dist/src/utils/functional.js +14 -0
  45. package/dist/src/utils/logger.js +15 -0
  46. package/dist/src/utils/object.js +6 -0
  47. package/dist/src/utils/queryString.js +13 -0
  48. package/dist/src/utils/random.js +7 -0
  49. package/dist/src/utils/sleep.js +3 -0
  50. package/dist/src/utils/string.js +6 -0
  51. package/dist/src/utils/stringToDate.js +6 -0
  52. package/dist/src/utils/upload.js +24 -0
  53. package/package.json +12 -9
  54. package/dist/lib.esm.js +0 -1350
@@ -0,0 +1,160 @@
1
+ import { DEFAULT_API_WRAPPER_OPTIONS } from '../constants';
2
+ import { getRedirectUrl as getAuthorizationUrl, requestToken as requestTokenByCode, } from '../oauth/authorizationCodeGrant';
3
+ import createTokenStore from '../oauth/createTokenStore';
4
+ import makeFetchTokenRequester from '../oauth/makeFetchTokenRequester';
5
+ import { requestToken as performRefreshTokenGrant } from '../oauth/refreshTokenGrant';
6
+ import requestAndSaveToStore from '../oauth/requestAndSaveToStore';
7
+ import { partial } from '../utils/functional';
8
+ import { pseudoRandomString } from '../utils/random';
9
+ import httpDelete from './delete';
10
+ import httpGet from './get';
11
+ import { agentCreate, agentCreatePermissions } from './methods/agent';
12
+ import { appCreate, appGetById } from './methods/app';
13
+ import { bookingGetById, bookingUpdateById } from './methods/booking';
14
+ import { bucketAddFile, bucketCreate, bucketGet, bucketRemoveFile, bucketRemoveFilesInPath, } from './methods/bucket';
15
+ import { conversationCreateMessage, conversationGetById, } from './methods/conversation';
16
+ import { fileCreate, fileDelete } from './methods/file';
17
+ import { getGroups, groupCreate, groupGetById, groupUpdateById, } from './methods/group';
18
+ import { lookupIds } from './methods/idLookup';
19
+ import { notificationsGetByUser, notificationsUpdateReadByUser, notificationUpdateRead, } from './methods/notification';
20
+ import { notificationSettingsResetByUser, notificationSettingsUpdateByUser, } from './methods/notificationSettings';
21
+ import { getProperties, propertyCreate, propertyGetById, propertyUpdateById, } from './methods/property';
22
+ import { registrationCodeCreate, registrationCodeDelete, registrationCodeGetById, registrationCodeUpdateById, } from './methods/registrationCode';
23
+ import { serviceProviderCreate, serviceProviderGetById, serviceProviderUpdateById, } from './methods/serviceProvider';
24
+ import { ticketCreateOnServiceProvider, ticketCreateOnUser, ticketGetById, } from './methods/ticket';
25
+ import { EnumUnitObjectType, EnumUnitType, getUnits, unitCreate, unitGetById, unitUpdateById, } from './methods/unit';
26
+ import { EnumCommunicationPreferenceChannel, EnumUserPermissionObjectType, EnumUserPermissionRole, getCurrentUser, getUsers, userChangePassword, userCheckInToUtilisationPeriod, userCreate, userCreatePermission, userCreatePermissionBatch, userDeletePermission, userGetByEmail, userGetById, userGetPermissions, userGetUtilisationPeriods, userUpdateById, } from './methods/user';
27
+ import { EnumUserRelationType, userRelationCreate, userRelationDelete, userRelationsGetByUser, } from './methods/userRelation';
28
+ import { EnumUtilisationPeriodType, utilisationPeriodAddRegistrationCode, utilisationPeriodCheckInUser, utilisationPeriodCheckOutUser, utilisationPeriodCreate, utilisationPeriodDelete, utilisationPeriodGetById, utilisationPeriodUpdateById, } from './methods/utilisationPeriod';
29
+ import httpPatch from './patch';
30
+ import httpPost from './post';
31
+ import httpPut from './put';
32
+ import httpRequest from './request';
33
+ const API_METHODS = [
34
+ agentCreate,
35
+ agentCreatePermissions,
36
+ appCreate,
37
+ appGetById,
38
+ bucketCreate,
39
+ bucketAddFile,
40
+ bucketRemoveFile,
41
+ bucketRemoveFilesInPath,
42
+ bucketGet,
43
+ conversationGetById,
44
+ conversationCreateMessage,
45
+ fileCreate,
46
+ fileDelete,
47
+ notificationSettingsResetByUser,
48
+ notificationSettingsUpdateByUser,
49
+ groupCreate,
50
+ groupGetById,
51
+ groupUpdateById,
52
+ getGroups,
53
+ lookupIds,
54
+ notificationsGetByUser,
55
+ notificationUpdateRead,
56
+ notificationsUpdateReadByUser,
57
+ propertyCreate,
58
+ propertyGetById,
59
+ propertyUpdateById,
60
+ getProperties,
61
+ serviceProviderCreate,
62
+ serviceProviderGetById,
63
+ serviceProviderUpdateById,
64
+ registrationCodeCreate,
65
+ registrationCodeUpdateById,
66
+ registrationCodeDelete,
67
+ registrationCodeGetById,
68
+ ticketCreateOnUser,
69
+ ticketCreateOnServiceProvider,
70
+ ticketGetById,
71
+ unitCreate,
72
+ unitGetById,
73
+ unitUpdateById,
74
+ getUnits,
75
+ userCreate,
76
+ userGetById,
77
+ userUpdateById,
78
+ userChangePassword,
79
+ userCreatePermission,
80
+ userCreatePermissionBatch,
81
+ userGetPermissions,
82
+ userDeletePermission,
83
+ userCheckInToUtilisationPeriod,
84
+ userGetUtilisationPeriods,
85
+ userGetByEmail,
86
+ getCurrentUser,
87
+ getUsers,
88
+ userRelationCreate,
89
+ userRelationDelete,
90
+ userRelationsGetByUser,
91
+ utilisationPeriodCreate,
92
+ utilisationPeriodDelete,
93
+ utilisationPeriodGetById,
94
+ utilisationPeriodUpdateById,
95
+ utilisationPeriodCheckInUser,
96
+ utilisationPeriodCheckOutUser,
97
+ utilisationPeriodAddRegistrationCode,
98
+ bookingUpdateById,
99
+ bookingGetById,
100
+ ];
101
+ export { EnumCommunicationPreferenceChannel, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, };
102
+ export default function restClient(userOptions = DEFAULT_API_WRAPPER_OPTIONS) {
103
+ const options = {
104
+ ...DEFAULT_API_WRAPPER_OPTIONS,
105
+ ...userOptions,
106
+ };
107
+ if (options.apiUrl === undefined) {
108
+ throw new Error('API URL is undefined.');
109
+ }
110
+ if (options.oauthUrl === undefined) {
111
+ throw new Error('OAuth2 URL is undefined.');
112
+ }
113
+ if (!options.clientId &&
114
+ !(options.accessToken || options.tokenStore) &&
115
+ typeof window === 'undefined') {
116
+ throw new Error('Missing required "clientId" or "accessToken" parameter .');
117
+ }
118
+ const tokenRequester = makeFetchTokenRequester(`${options.oauthUrl}/oauth/token`);
119
+ const tokenStore = options.tokenStore ||
120
+ createTokenStore({
121
+ accessToken: options.accessToken,
122
+ refreshToken: options.refreshToken,
123
+ });
124
+ const request = partial(httpRequest, tokenStore, tokenRequester, options);
125
+ const del = partial(httpDelete, request);
126
+ const get = partial(httpGet, request);
127
+ const post = partial(httpPost, request);
128
+ const patch = partial(httpPatch, request);
129
+ const put = partial(httpPut, request);
130
+ const oauth = {
131
+ authorizationCode: {
132
+ getUri: (state = options.state || pseudoRandomString()) => partial(getAuthorizationUrl, {
133
+ ...options,
134
+ state,
135
+ })(),
136
+ requestToken: (authorizationCode) => requestAndSaveToStore(partial(requestTokenByCode, tokenRequester, {
137
+ ...options,
138
+ authorizationCode: authorizationCode || options.authorizationCode,
139
+ }), tokenStore),
140
+ },
141
+ generateState: pseudoRandomString,
142
+ refreshToken: (refreshToken) => requestAndSaveToStore(partial(performRefreshTokenGrant, tokenRequester, {
143
+ ...options,
144
+ refreshToken: refreshToken || tokenStore.get('refreshToken'),
145
+ }), tokenStore),
146
+ };
147
+ const client = API_METHODS.reduce((methods, method) => ({
148
+ ...methods,
149
+ [method.name]: (...arguments_) => method(client, ...arguments_),
150
+ }), {
151
+ delete: del,
152
+ get,
153
+ oauth,
154
+ options,
155
+ patch,
156
+ post,
157
+ put,
158
+ });
159
+ return client;
160
+ }
@@ -0,0 +1,26 @@
1
+ import { EnumUserType, } from './user';
2
+ export async function agentCreate(client, appId, propertyManagerId, username, data, sendInvitation, externalAgentCompany) {
3
+ const user = await client.userCreate(appId, username, {
4
+ ...data,
5
+ type: EnumUserType.customer,
6
+ });
7
+ const manager = await client.post(`/v1/property-managers/${propertyManagerId}/users`, {
8
+ userID: user.id,
9
+ ...(externalAgentCompany && { externalAgentCompany }),
10
+ });
11
+ return (!((typeof sendInvitation !== 'undefined' ? sendInvitation : true) &&
12
+ (await client.post(`/v1/users/${user.id}/invitations`))) && {
13
+ ...user,
14
+ ...manager,
15
+ });
16
+ }
17
+ export async function agentCreatePermissions(client, agentId, objectId, objectType, permissions, startDate, endDate) {
18
+ return client.userCreatePermissionBatch(agentId, {
19
+ endDate,
20
+ objectId,
21
+ objectType,
22
+ restrictions: [],
23
+ roles: permissions,
24
+ startDate,
25
+ });
26
+ }
@@ -0,0 +1,10 @@
1
+ export async function appCreate(client, userId, data) {
2
+ return client.post(`/v1/users/${userId}/apps`, {
3
+ availableLocales: { '0': 'de_DE' },
4
+ ...data,
5
+ siteUrl: data.siteUrl.replace('_', ''),
6
+ });
7
+ }
8
+ export async function appGetById(client, appId) {
9
+ return client.get(`/v1/apps/${appId}`);
10
+ }
@@ -0,0 +1,6 @@
1
+ export async function bookingGetById(client, bookingId) {
2
+ return client.get(`/v1/bookings/${bookingId}`);
3
+ }
4
+ export async function bookingUpdateById(client, bookingId, data) {
5
+ return client.patch(`/v1/bookings/${bookingId}`, data);
6
+ }
@@ -0,0 +1,22 @@
1
+ export async function bucketGet(client, bucketId) {
2
+ return client.get(`/v1/buckets/${bucketId}`);
3
+ }
4
+ export async function bucketCreate(client, data) {
5
+ return client.post('/v1/buckets', {
6
+ channels: data.channels,
7
+ name: data.name,
8
+ });
9
+ }
10
+ export async function bucketAddFile(client, bucketId, fileId) {
11
+ return ((await client.post(`/v1/buckets/${bucketId}/files`, {
12
+ id: fileId,
13
+ })) === '');
14
+ }
15
+ export async function bucketRemoveFile(client, bucketId, fileId) {
16
+ return (await client.delete(`/v1/buckets/${bucketId}/files/${fileId}`)) === '';
17
+ }
18
+ export async function bucketRemoveFilesInPath(client, bucketId, data) {
19
+ return ((await client.delete(`/v1/buckets/${bucketId}/files`, {
20
+ folder: data.path,
21
+ })) === '');
22
+ }
@@ -0,0 +1,28 @@
1
+ import { createManyFilesSorted } from '../../utils/upload';
2
+ export async function conversationGetById(client, conversationId) {
3
+ return client.get(`/v1/conversations/${conversationId}`);
4
+ }
5
+ export async function conversationCreateMessage(client, conversationId, messageData) {
6
+ const url = `/v1/conversations/${conversationId}/messages`;
7
+ const payload = messageData.attachments?.length
8
+ ? {
9
+ content: {
10
+ description: messageData.body,
11
+ files: (await createManyFilesSorted(messageData.attachments, client))
12
+ .success,
13
+ },
14
+ createdBy: messageData.createdBy,
15
+ inputChannel: messageData.inputChannel,
16
+ internal: false,
17
+ type: 'file',
18
+ }
19
+ : {
20
+ content: {
21
+ content: messageData.body,
22
+ },
23
+ createdBy: messageData.createdBy,
24
+ inputChannel: messageData.inputChannel,
25
+ type: 'text',
26
+ };
27
+ return client.post(url, payload);
28
+ }
@@ -0,0 +1,11 @@
1
+ export async function fileCreate(client, data) {
2
+ return client.post('/v1/files', {
3
+ formData: {
4
+ file: [data.file, data.name],
5
+ path: data.path || '',
6
+ },
7
+ });
8
+ }
9
+ export async function fileDelete(client, fileId) {
10
+ return (await client.delete(`/v1/files/${fileId}`)) === '';
11
+ }
@@ -0,0 +1,22 @@
1
+ export async function groupCreate(client, propertyId, data) {
2
+ const { propertyManagerId, ...rest } = data;
3
+ return client.post(`/v1/properties/${propertyId}/groups`, {
4
+ ...rest,
5
+ propertyManagerID: propertyManagerId,
6
+ });
7
+ }
8
+ export async function groupGetById(client, groupId) {
9
+ const { propertyManagerID: propertyManagerId, ...result } = await client.get(`/v1/groups/${groupId}`);
10
+ return { ...result, propertyManagerId };
11
+ }
12
+ export async function groupUpdateById(client, groupId, data) {
13
+ return client.patch(`/v1/groups/${groupId}`, data);
14
+ }
15
+ export async function getGroups(client, page = 1, limit = -1, filter = {}) {
16
+ const { _embedded: { items: groups }, total, } = await client.get('/v1/groups', {
17
+ filter: JSON.stringify(filter),
18
+ limit,
19
+ page,
20
+ });
21
+ return { _embedded: { items: groups }, total };
22
+ }
@@ -0,0 +1,12 @@
1
+ export async function lookupIds(client, appId, data) {
2
+ const url = data.dataSource
3
+ ? `/v1/id-lookup/${appId}/${data.resource}/${data.dataSource}`
4
+ : `/v1/id-lookup/${appId}/${data.resource}`;
5
+ return client.post(url, {
6
+ externalIds: typeof data.externalIds === 'string'
7
+ ? [data.externalIds]
8
+ : data.externalIds,
9
+ ...(data.parentId ? { parentId: data.parentId } : {}),
10
+ ...(data.userType ? { userType: data.userType } : {}),
11
+ });
12
+ }
@@ -0,0 +1,57 @@
1
+ import { dateToString, stringToDate } from '../../utils/stringToDate';
2
+ export var EnumNotificationCategory;
3
+ (function (EnumNotificationCategory) {
4
+ EnumNotificationCategory["events"] = "events";
5
+ EnumNotificationCategory["hintsAndTips"] = "hints-and-tips";
6
+ EnumNotificationCategory["lostAndFound"] = "lost-and-found";
7
+ EnumNotificationCategory["localDeals"] = "local-deals";
8
+ EnumNotificationCategory["localEvents"] = "local-events";
9
+ EnumNotificationCategory["miscellaneous"] = "miscellaneous";
10
+ EnumNotificationCategory["deals"] = "deals";
11
+ EnumNotificationCategory["messages"] = "messages";
12
+ EnumNotificationCategory["adminMessages"] = "admin-messages";
13
+ EnumNotificationCategory["newThingsToGive"] = "new-things-to-give";
14
+ EnumNotificationCategory["newThingsForSale"] = "new-things-for-sale";
15
+ EnumNotificationCategory["surveys"] = "surveys";
16
+ EnumNotificationCategory["supportOffer"] = "support-offer";
17
+ EnumNotificationCategory["supportRequest"] = "support-request";
18
+ EnumNotificationCategory["sustainability"] = "sustainability";
19
+ EnumNotificationCategory["localServices"] = "local-services";
20
+ EnumNotificationCategory["services"] = "services";
21
+ EnumNotificationCategory["ticketDigestEmail"] = "ticket-digest-email";
22
+ EnumNotificationCategory["appDigestEmail"] = "app-digest-email";
23
+ EnumNotificationCategory["newFile"] = "new-file";
24
+ })(EnumNotificationCategory || (EnumNotificationCategory = {}));
25
+ export var EnumNotificationType;
26
+ (function (EnumNotificationType) {
27
+ EnumNotificationType["clipboardThing"] = "clipboard-thing";
28
+ EnumNotificationType["comment"] = "comment";
29
+ EnumNotificationType["communityArticle"] = "community-article";
30
+ EnumNotificationType["newFile"] = "new-file";
31
+ EnumNotificationType["ticketComment"] = "ticket-comment";
32
+ EnumNotificationType["welcomeNotification"] = "welcome-notification";
33
+ })(EnumNotificationType || (EnumNotificationType = {}));
34
+ function remapNotificationResult({ createdAt, objectID, referencedObjectID, ...restNotification }) {
35
+ return {
36
+ createdAt: stringToDate(createdAt),
37
+ objectId: objectID,
38
+ referencedObjectId: referencedObjectID,
39
+ ...restNotification,
40
+ };
41
+ }
42
+ export async function notificationsGetByUser(client, userId, page = 1, limit = -1) {
43
+ const { _embedded: { items: notifications }, total, metaData, } = await client.get(`/v1/users/${userId}/notifications?page=${page}&limit=${limit}`);
44
+ return {
45
+ _embedded: { items: notifications.map(remapNotificationResult) },
46
+ metaData,
47
+ total,
48
+ };
49
+ }
50
+ export async function notificationsUpdateReadByUser(client, userId, lastReadAt = new Date()) {
51
+ return client.patch(`/v1/users/${userId}/notifications`, {
52
+ lastReadAt: dateToString(lastReadAt),
53
+ });
54
+ }
55
+ export async function notificationUpdateRead(client, notificationId) {
56
+ return remapNotificationResult(await client.patch(`/v1/notifications/${notificationId}`, { read: true }));
57
+ }
@@ -0,0 +1,19 @@
1
+ import { remapKeys } from '../../utils/object';
2
+ import { camelCaseToDash, dashCaseToCamel } from '../../utils/string';
3
+ export var EnumNotificationSettingsValue;
4
+ (function (EnumNotificationSettingsValue) {
5
+ EnumNotificationSettingsValue["never"] = "never";
6
+ EnumNotificationSettingsValue["immediately"] = "immediately";
7
+ EnumNotificationSettingsValue["daily"] = "daily";
8
+ EnumNotificationSettingsValue["weekly"] = "weekly";
9
+ EnumNotificationSettingsValue["biweekly"] = "biweekly";
10
+ EnumNotificationSettingsValue["monthly"] = "monthly";
11
+ })(EnumNotificationSettingsValue || (EnumNotificationSettingsValue = {}));
12
+ export async function notificationSettingsUpdateByUser(client, userId, data) {
13
+ const result = await client.patch(`/v1/users/${userId}/notification-settings`, { notificationSettings: remapKeys(data, camelCaseToDash) });
14
+ return remapKeys(result, dashCaseToCamel);
15
+ }
16
+ export async function notificationSettingsResetByUser(client, userId) {
17
+ const result = await client.delete(`/v1/users/${userId}/notification-settings`);
18
+ return remapKeys(result, dashCaseToCamel);
19
+ }
@@ -0,0 +1,17 @@
1
+ export async function propertyCreate(client, appId, data) {
2
+ return client.post(`/v1/apps/${appId}/properties`, data);
3
+ }
4
+ export async function propertyGetById(client, propertyId) {
5
+ return client.get(`/v1/properties/${propertyId}`);
6
+ }
7
+ export async function propertyUpdateById(client, propertyId, data) {
8
+ return client.patch(`/v1/properties/${propertyId}`, data);
9
+ }
10
+ export async function getProperties(client, page = 1, limit = -1, filter = {}) {
11
+ const { _embedded: { items: properties }, total, } = await client.get('/v1/properties', {
12
+ filter: JSON.stringify(filter),
13
+ limit,
14
+ page,
15
+ });
16
+ return { _embedded: { items: properties }, total };
17
+ }
@@ -0,0 +1,24 @@
1
+ export const remapRegistationCodeResult = (registrationCode) => {
2
+ const { tenantID: externalId, ...result } = registrationCode;
3
+ return { ...result, externalId };
4
+ };
5
+ export async function registrationCodeCreate(client, code, utilisationPeriods, options = { permanent: false }) {
6
+ const { externalId, ...moreOptions } = options;
7
+ return remapRegistationCodeResult(await client.post('/v1/registration-codes', {
8
+ code,
9
+ utilisationPeriods: typeof utilisationPeriods === 'string'
10
+ ? [utilisationPeriods]
11
+ : utilisationPeriods,
12
+ ...(externalId ? { externalId, tenantID: externalId } : {}),
13
+ ...moreOptions,
14
+ }));
15
+ }
16
+ export async function registrationCodeUpdateById(client, registrationCodeId, data) {
17
+ return remapRegistationCodeResult(await client.patch(`/v1/registration-codes/${registrationCodeId}`, data));
18
+ }
19
+ export async function registrationCodeGetById(client, registrationCodeId) {
20
+ return remapRegistationCodeResult(await client.get(`/v1/invitations/${registrationCodeId}`));
21
+ }
22
+ export async function registrationCodeDelete(client, registrationCodeId) {
23
+ return (await client.delete(`/v1/invitations/${registrationCodeId}`)) === '';
24
+ }
@@ -0,0 +1,9 @@
1
+ export async function serviceProviderCreate(client, data) {
2
+ return client.post('/v1/service-providers', data);
3
+ }
4
+ export async function serviceProviderGetById(client, serviceProviderId) {
5
+ return client.get(`/v1/service-providers/${serviceProviderId}`);
6
+ }
7
+ export async function serviceProviderUpdateById(client, serviceProviderId, data) {
8
+ return client.patch(`/v1/service-providers/${serviceProviderId}`, data);
9
+ }
@@ -0,0 +1,34 @@
1
+ import { createManyFilesSorted } from '../../utils/upload';
2
+ export var ETicketStatus;
3
+ (function (ETicketStatus) {
4
+ ETicketStatus["CLOSED"] = "closed";
5
+ ETicketStatus["WAITING_FOR_AGENT"] = "waiting-for-agent";
6
+ ETicketStatus["WAITING_FOR_CUSTOMER"] = "waiting-for-customer";
7
+ ETicketStatus["WAITING_FOR_EXTERNAL"] = "waiting-for-external";
8
+ })(ETicketStatus || (ETicketStatus = {}));
9
+ export var ETrafficLightColor;
10
+ (function (ETrafficLightColor) {
11
+ ETrafficLightColor["GREEN"] = "green";
12
+ ETrafficLightColor["RED"] = "red";
13
+ ETrafficLightColor["YELLOW"] = "yellow";
14
+ })(ETrafficLightColor || (ETrafficLightColor = {}));
15
+ export async function ticketGetById(client, ticketId) {
16
+ return client.get(`/v1/tickets/${ticketId}`);
17
+ }
18
+ export async function ticketCreateOnUser(client, userId, utilisationPeriodId, payload) {
19
+ return client.post(`/v1/users/${userId}/tickets`, {
20
+ ...payload,
21
+ files: payload.files
22
+ ? (await createManyFilesSorted(payload.files, client)).success
23
+ : [],
24
+ utilisationPeriod: utilisationPeriodId,
25
+ });
26
+ }
27
+ export async function ticketCreateOnServiceProvider(client, serviceProviderId, payload) {
28
+ return client.post(`/v1/property-managers/${serviceProviderId}/tickets`, {
29
+ ...payload,
30
+ files: payload.files
31
+ ? (await createManyFilesSorted(payload.files, client)).success
32
+ : [],
33
+ });
34
+ }
@@ -0,0 +1,95 @@
1
+ export var EnumUnitObjectType;
2
+ (function (EnumUnitObjectType) {
3
+ EnumUnitObjectType["adjoiningRoom"] = "adjoining-room";
4
+ EnumUnitObjectType["advertisingSpace"] = "advertising-space";
5
+ EnumUnitObjectType["aerial"] = "aerial";
6
+ EnumUnitObjectType["apartmentBuilding"] = "apartment-building";
7
+ EnumUnitObjectType["atm"] = "atm";
8
+ EnumUnitObjectType["atmRoom"] = "atm-room";
9
+ EnumUnitObjectType["attic"] = "attic";
10
+ EnumUnitObjectType["atticFlat"] = "attic-flat";
11
+ EnumUnitObjectType["bank"] = "bank";
12
+ EnumUnitObjectType["basment"] = "basment";
13
+ EnumUnitObjectType["bikeShed"] = "bike-shed";
14
+ EnumUnitObjectType["buildingLaw"] = "building-law";
15
+ EnumUnitObjectType["cafeteria"] = "cafeteria";
16
+ EnumUnitObjectType["caretakerRoom"] = "caretaker-room";
17
+ EnumUnitObjectType["carport"] = "carport";
18
+ EnumUnitObjectType["cellar"] = "cellar";
19
+ EnumUnitObjectType["commercialProperty"] = "commercial-property";
20
+ EnumUnitObjectType["commonRoom"] = "common-room";
21
+ EnumUnitObjectType["deliveryZone"] = "delivery-zone";
22
+ EnumUnitObjectType["diverse"] = "diverse";
23
+ EnumUnitObjectType["doubleParkingSpace"] = "double-parking-space";
24
+ EnumUnitObjectType["engineeringRoom"] = "engineering-room";
25
+ EnumUnitObjectType["entertainment"] = "entertainment";
26
+ EnumUnitObjectType["environment"] = "environment";
27
+ EnumUnitObjectType["estate"] = "estate";
28
+ EnumUnitObjectType["fillingStation"] = "filling-station";
29
+ EnumUnitObjectType["fitnessCenter"] = "fitness-center";
30
+ EnumUnitObjectType["flat"] = "flat";
31
+ EnumUnitObjectType["freeZone"] = "free-zone";
32
+ EnumUnitObjectType["garage"] = "garage";
33
+ EnumUnitObjectType["garden"] = "garden";
34
+ EnumUnitObjectType["gardenFlat"] = "garden-flat";
35
+ EnumUnitObjectType["heatingFacilities"] = "heating-facilities";
36
+ EnumUnitObjectType["hotel"] = "hotel";
37
+ EnumUnitObjectType["incidentalRentalExpenses"] = "incidental-rental-expenses";
38
+ EnumUnitObjectType["industry"] = "industry";
39
+ EnumUnitObjectType["kiosk"] = "kiosk";
40
+ EnumUnitObjectType["kitchen"] = "kitchen";
41
+ EnumUnitObjectType["loft"] = "loft";
42
+ EnumUnitObjectType["machine"] = "machine";
43
+ EnumUnitObjectType["maisonette"] = "maisonette";
44
+ EnumUnitObjectType["medicalPractice"] = "medical-practice";
45
+ EnumUnitObjectType["mopedShed"] = "moped-shed";
46
+ EnumUnitObjectType["motorcycleParkingSpace"] = "motorcycle-parking-space";
47
+ EnumUnitObjectType["office"] = "office";
48
+ EnumUnitObjectType["oneFamilyHouse"] = "one-family-house";
49
+ EnumUnitObjectType["parkingBox"] = "parking-box";
50
+ EnumUnitObjectType["parkingGarage"] = "parking-garage";
51
+ EnumUnitObjectType["parkingSpace"] = "parking-space";
52
+ EnumUnitObjectType["parkingSpaces"] = "parking-spaces";
53
+ EnumUnitObjectType["penthouse"] = "penthouse";
54
+ EnumUnitObjectType["productionPlant"] = "production-plant";
55
+ EnumUnitObjectType["pub"] = "pub";
56
+ EnumUnitObjectType["publicArea"] = "public-area";
57
+ EnumUnitObjectType["restaurant"] = "restaurant";
58
+ EnumUnitObjectType["retirementHome"] = "retirement-home";
59
+ EnumUnitObjectType["salesFloor"] = "sales-floor";
60
+ EnumUnitObjectType["school"] = "school";
61
+ EnumUnitObjectType["shelter"] = "shelter";
62
+ EnumUnitObjectType["storage"] = "storage";
63
+ EnumUnitObjectType["store"] = "store";
64
+ EnumUnitObjectType["storeroom"] = "storeroom";
65
+ EnumUnitObjectType["studio"] = "studio";
66
+ EnumUnitObjectType["terrace"] = "terrace";
67
+ EnumUnitObjectType["toilets"] = "toilets";
68
+ EnumUnitObjectType["utilityRoom"] = "utility-room";
69
+ EnumUnitObjectType["variableParkingSpace"] = "variable-parking-space";
70
+ EnumUnitObjectType["variableRoom"] = "variable-room";
71
+ EnumUnitObjectType["visitorParkingSpace"] = "visitor-parking-space";
72
+ EnumUnitObjectType["workshop"] = "workshop";
73
+ })(EnumUnitObjectType || (EnumUnitObjectType = {}));
74
+ export var EnumUnitType;
75
+ (function (EnumUnitType) {
76
+ EnumUnitType["rented"] = "rented";
77
+ EnumUnitType["owned"] = "owned";
78
+ })(EnumUnitType || (EnumUnitType = {}));
79
+ export async function unitCreate(client, groupId, data) {
80
+ return client.post(`/v1/groups/${groupId}/units`, data);
81
+ }
82
+ export async function unitGetById(client, unitId) {
83
+ return client.get(`/v1/units/${unitId}`);
84
+ }
85
+ export async function unitUpdateById(client, unitId, data) {
86
+ return client.patch(`/v1/units/${unitId}`, data);
87
+ }
88
+ export async function getUnits(client, page = 1, limit = -1, filter = {}) {
89
+ const { _embedded: { items: units }, total, } = await client.get('/v1/units', {
90
+ filter: JSON.stringify(filter),
91
+ limit,
92
+ page,
93
+ });
94
+ return { _embedded: { items: units }, total };
95
+ }