@timum/timum_pdk 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/index.js +43 -15
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -11,7 +11,17 @@ export const getBaseUrl = () => {
|
|
|
11
11
|
return getTimumApiHost() + "/rest/1";
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const constructUrl = (url, plain) => {
|
|
14
|
+
export const constructUrl = (url, props, plain) => {
|
|
15
|
+
if (props.params) {
|
|
16
|
+
for (const [paramName, paramValue] of props.params) {
|
|
17
|
+
if (!url.includes("?")) {
|
|
18
|
+
url = `${url}?${paramName}=${paramValue}`;
|
|
19
|
+
} else {
|
|
20
|
+
url = `${url}&${paramName}=${paramValue}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
if (!url.includes("?")) {
|
|
16
26
|
url = `${url}?X-DISABLE-COOKIES=true`;
|
|
17
27
|
} else {
|
|
@@ -39,14 +49,20 @@ export const timumApiSlice = createApi({
|
|
|
39
49
|
|
|
40
50
|
upcomingBookables: builder.query({
|
|
41
51
|
query: (props) => ({
|
|
42
|
-
url: constructUrl(
|
|
52
|
+
url: constructUrl(
|
|
53
|
+
`/resources/${props.channelOrResourceId}/upcoming_bookables`,
|
|
54
|
+
props
|
|
55
|
+
),
|
|
43
56
|
}),
|
|
44
57
|
providesTags: (/* result = [], error, arg */) => ["Timeslot"],
|
|
45
58
|
}),
|
|
46
59
|
|
|
47
60
|
activeProducts: builder.query({
|
|
48
61
|
query: (props) => ({
|
|
49
|
-
url: constructUrl(
|
|
62
|
+
url: constructUrl(
|
|
63
|
+
`/resources/${props.channelOrResourceId}/active_products`,
|
|
64
|
+
props
|
|
65
|
+
),
|
|
50
66
|
}),
|
|
51
67
|
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
52
68
|
}),
|
|
@@ -54,7 +70,8 @@ export const timumApiSlice = createApi({
|
|
|
54
70
|
createAppointmentWithConsumer: builder.mutation({
|
|
55
71
|
query: (props) => ({
|
|
56
72
|
url: constructUrl(
|
|
57
|
-
`/resources/${props.
|
|
73
|
+
`/resources/${props.channelOrResourceId}/create_appointment_with_consumer`,
|
|
74
|
+
props
|
|
58
75
|
),
|
|
59
76
|
method: "post",
|
|
60
77
|
body: props.body,
|
|
@@ -83,14 +100,15 @@ export const timumApiSlice = createApi({
|
|
|
83
100
|
*/
|
|
84
101
|
publicData: builder.query({
|
|
85
102
|
query: (props) => ({
|
|
86
|
-
url: constructUrl(`/resources/${props.
|
|
103
|
+
url: constructUrl(`/resources/${props.channelOrResourceId}/public_data`, props),
|
|
87
104
|
}),
|
|
88
105
|
}),
|
|
89
106
|
|
|
90
107
|
identifyCustomer: builder.query({
|
|
91
108
|
query: (props) => ({
|
|
92
109
|
url: constructUrl(
|
|
93
|
-
`/crms/${props.crmSlug}/resources/${props.
|
|
110
|
+
`/crms/${props.crmSlug}/resources/${props.channelOrResourceId}/customers/${props.personId}/identify`,
|
|
111
|
+
props
|
|
94
112
|
),
|
|
95
113
|
}),
|
|
96
114
|
keepUnusedDataFor: 9999999, // once identifoed it's not going to change
|
|
@@ -108,7 +126,10 @@ export const timumApiSlice = createApi({
|
|
|
108
126
|
*/
|
|
109
127
|
reserveAppoinment: builder.mutation({
|
|
110
128
|
query: (props) => ({
|
|
111
|
-
url: constructUrl(
|
|
129
|
+
url: constructUrl(
|
|
130
|
+
`/resources/${props.channelOrResourceId}/reserve_appointment`,
|
|
131
|
+
props
|
|
132
|
+
),
|
|
112
133
|
method: "post",
|
|
113
134
|
body: props.body,
|
|
114
135
|
}),
|
|
@@ -121,7 +142,10 @@ export const timumApiSlice = createApi({
|
|
|
121
142
|
*/
|
|
122
143
|
revokeAppointmentReservation: builder.mutation({
|
|
123
144
|
query: (props) => ({
|
|
124
|
-
url: constructUrl(
|
|
145
|
+
url: constructUrl(
|
|
146
|
+
`/resources/${props.channelOrResourceId}/revoke_reservation`,
|
|
147
|
+
props
|
|
148
|
+
),
|
|
125
149
|
method: "post",
|
|
126
150
|
body: props.body,
|
|
127
151
|
}),
|
|
@@ -134,7 +158,8 @@ export const timumApiSlice = createApi({
|
|
|
134
158
|
getAccount: builder.query({
|
|
135
159
|
query: (props) => ({
|
|
136
160
|
url: constructUrl(
|
|
137
|
-
`/crms/${props.platform}/account/${props.accountReference}
|
|
161
|
+
`/crms/${props.platform}/account/${props.accountReference}`,
|
|
162
|
+
props
|
|
138
163
|
),
|
|
139
164
|
}),
|
|
140
165
|
providesTags: (/* result = [], error, arg */) => ["Account"],
|
|
@@ -143,7 +168,7 @@ export const timumApiSlice = createApi({
|
|
|
143
168
|
createAccount: builder.mutation({
|
|
144
169
|
query: (props) => {
|
|
145
170
|
return {
|
|
146
|
-
url: constructUrl(`/crms/${props.platform}/account
|
|
171
|
+
url: constructUrl(`/crms/${props.platform}/account`, props),
|
|
147
172
|
method: "post",
|
|
148
173
|
body: JSON.stringify(props.accountData),
|
|
149
174
|
};
|
|
@@ -154,7 +179,8 @@ export const timumApiSlice = createApi({
|
|
|
154
179
|
getProviders: builder.query({
|
|
155
180
|
query: (props) => ({
|
|
156
181
|
url: constructUrl(
|
|
157
|
-
`/crms/${props.platform}/account/${props.accountReference}/providers
|
|
182
|
+
`/crms/${props.platform}/account/${props.accountReference}/providers`,
|
|
183
|
+
props
|
|
158
184
|
),
|
|
159
185
|
}),
|
|
160
186
|
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
@@ -163,14 +189,15 @@ export const timumApiSlice = createApi({
|
|
|
163
189
|
getProvider: builder.query({
|
|
164
190
|
query: (props) => ({
|
|
165
191
|
url: constructUrl(
|
|
166
|
-
`/crms/${props.platform}/provider/${props.providerReference}
|
|
192
|
+
`/crms/${props.platform}/provider/${props.providerReference}`,
|
|
193
|
+
props
|
|
167
194
|
),
|
|
168
195
|
}),
|
|
169
196
|
}),
|
|
170
197
|
|
|
171
198
|
createProvider: builder.mutation({
|
|
172
199
|
query: (props) => ({
|
|
173
|
-
url: constructUrl(`/crms/${props.platform}/provider
|
|
200
|
+
url: constructUrl(`/crms/${props.platform}/provider`, props),
|
|
174
201
|
method: "post",
|
|
175
202
|
body: JSON.stringify(
|
|
176
203
|
(() => ({
|
|
@@ -199,14 +226,15 @@ export const timumApiSlice = createApi({
|
|
|
199
226
|
getUser: builder.query({
|
|
200
227
|
query: (props) => ({
|
|
201
228
|
url: constructUrl(
|
|
202
|
-
`/crms/${props.platform}/user/${props.userReference}
|
|
229
|
+
`/crms/${props.platform}/user/${props.userReference}`,
|
|
230
|
+
props
|
|
203
231
|
),
|
|
204
232
|
}),
|
|
205
233
|
}),
|
|
206
234
|
|
|
207
235
|
createUser: builder.mutation({
|
|
208
236
|
query: (props) => ({
|
|
209
|
-
url: constructUrl(`/crms/${props.platform}/user
|
|
237
|
+
url: constructUrl(`/crms/${props.platform}/user`, props),
|
|
210
238
|
method: "post",
|
|
211
239
|
body: JSON.stringify(props.userData),
|
|
212
240
|
}),
|