@timum/timum_pdk 1.0.9 → 1.0.11
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 +46 -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 Object.entries(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,18 @@ export const timumApiSlice = createApi({
|
|
|
83
100
|
*/
|
|
84
101
|
publicData: builder.query({
|
|
85
102
|
query: (props) => ({
|
|
86
|
-
url: constructUrl(
|
|
103
|
+
url: constructUrl(
|
|
104
|
+
`/resources/${props.channelOrResourceId}/public_data`,
|
|
105
|
+
props
|
|
106
|
+
),
|
|
87
107
|
}),
|
|
88
108
|
}),
|
|
89
109
|
|
|
90
110
|
identifyCustomer: builder.query({
|
|
91
111
|
query: (props) => ({
|
|
92
112
|
url: constructUrl(
|
|
93
|
-
`/crms/${props.crmSlug}/resources/${props.
|
|
113
|
+
`/crms/${props.crmSlug}/resources/${props.channelOrResourceId}/customers/${props.personId}/identify`,
|
|
114
|
+
props
|
|
94
115
|
),
|
|
95
116
|
}),
|
|
96
117
|
keepUnusedDataFor: 9999999, // once identifoed it's not going to change
|
|
@@ -108,7 +129,10 @@ export const timumApiSlice = createApi({
|
|
|
108
129
|
*/
|
|
109
130
|
reserveAppoinment: builder.mutation({
|
|
110
131
|
query: (props) => ({
|
|
111
|
-
url: constructUrl(
|
|
132
|
+
url: constructUrl(
|
|
133
|
+
`/resources/${props.channelOrResourceId}/reserve_appointment`,
|
|
134
|
+
props
|
|
135
|
+
),
|
|
112
136
|
method: "post",
|
|
113
137
|
body: props.body,
|
|
114
138
|
}),
|
|
@@ -121,7 +145,10 @@ export const timumApiSlice = createApi({
|
|
|
121
145
|
*/
|
|
122
146
|
revokeAppointmentReservation: builder.mutation({
|
|
123
147
|
query: (props) => ({
|
|
124
|
-
url: constructUrl(
|
|
148
|
+
url: constructUrl(
|
|
149
|
+
`/resources/${props.channelOrResourceId}/revoke_reservation`,
|
|
150
|
+
props
|
|
151
|
+
),
|
|
125
152
|
method: "post",
|
|
126
153
|
body: props.body,
|
|
127
154
|
}),
|
|
@@ -134,7 +161,8 @@ export const timumApiSlice = createApi({
|
|
|
134
161
|
getAccount: builder.query({
|
|
135
162
|
query: (props) => ({
|
|
136
163
|
url: constructUrl(
|
|
137
|
-
`/crms/${props.platform}/account/${props.accountReference}
|
|
164
|
+
`/crms/${props.platform}/account/${props.accountReference}`,
|
|
165
|
+
props
|
|
138
166
|
),
|
|
139
167
|
}),
|
|
140
168
|
providesTags: (/* result = [], error, arg */) => ["Account"],
|
|
@@ -143,7 +171,7 @@ export const timumApiSlice = createApi({
|
|
|
143
171
|
createAccount: builder.mutation({
|
|
144
172
|
query: (props) => {
|
|
145
173
|
return {
|
|
146
|
-
url: constructUrl(`/crms/${props.platform}/account
|
|
174
|
+
url: constructUrl(`/crms/${props.platform}/account`, props),
|
|
147
175
|
method: "post",
|
|
148
176
|
body: JSON.stringify(props.accountData),
|
|
149
177
|
};
|
|
@@ -154,7 +182,8 @@ export const timumApiSlice = createApi({
|
|
|
154
182
|
getProviders: builder.query({
|
|
155
183
|
query: (props) => ({
|
|
156
184
|
url: constructUrl(
|
|
157
|
-
`/crms/${props.platform}/account/${props.accountReference}/providers
|
|
185
|
+
`/crms/${props.platform}/account/${props.accountReference}/providers`,
|
|
186
|
+
props
|
|
158
187
|
),
|
|
159
188
|
}),
|
|
160
189
|
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
@@ -163,14 +192,15 @@ export const timumApiSlice = createApi({
|
|
|
163
192
|
getProvider: builder.query({
|
|
164
193
|
query: (props) => ({
|
|
165
194
|
url: constructUrl(
|
|
166
|
-
`/crms/${props.platform}/provider/${props.providerReference}
|
|
195
|
+
`/crms/${props.platform}/provider/${props.providerReference}`,
|
|
196
|
+
props
|
|
167
197
|
),
|
|
168
198
|
}),
|
|
169
199
|
}),
|
|
170
200
|
|
|
171
201
|
createProvider: builder.mutation({
|
|
172
202
|
query: (props) => ({
|
|
173
|
-
url: constructUrl(`/crms/${props.platform}/provider
|
|
203
|
+
url: constructUrl(`/crms/${props.platform}/provider`, props),
|
|
174
204
|
method: "post",
|
|
175
205
|
body: JSON.stringify(
|
|
176
206
|
(() => ({
|
|
@@ -199,14 +229,15 @@ export const timumApiSlice = createApi({
|
|
|
199
229
|
getUser: builder.query({
|
|
200
230
|
query: (props) => ({
|
|
201
231
|
url: constructUrl(
|
|
202
|
-
`/crms/${props.platform}/user/${props.userReference}
|
|
232
|
+
`/crms/${props.platform}/user/${props.userReference}`,
|
|
233
|
+
props
|
|
203
234
|
),
|
|
204
235
|
}),
|
|
205
236
|
}),
|
|
206
237
|
|
|
207
238
|
createUser: builder.mutation({
|
|
208
239
|
query: (props) => ({
|
|
209
|
-
url: constructUrl(`/crms/${props.platform}/user
|
|
240
|
+
url: constructUrl(`/crms/${props.platform}/user`, props),
|
|
210
241
|
method: "post",
|
|
211
242
|
body: JSON.stringify(props.userData),
|
|
212
243
|
}),
|