@timum/timum_pdk 1.0.8 → 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 +73 -23
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,
|
|
@@ -62,31 +79,57 @@ export const timumApiSlice = createApi({
|
|
|
62
79
|
invalidatesTags: (/* result, error, arg */) => [{ type: "Timeslot" }],
|
|
63
80
|
}),
|
|
64
81
|
|
|
65
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Returns an object with the following makeup:
|
|
84
|
+
* {
|
|
85
|
+
* contact: {
|
|
86
|
+
* name,
|
|
87
|
+
* email,
|
|
88
|
+
* mobile,
|
|
89
|
+
* phone
|
|
90
|
+
* },
|
|
91
|
+
* resource: {
|
|
92
|
+
* name,
|
|
93
|
+
* description,
|
|
94
|
+
* msgHelpText
|
|
95
|
+
* },
|
|
96
|
+
* provider: {
|
|
97
|
+
* name
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
*/
|
|
101
|
+
publicData: builder.query({
|
|
66
102
|
query: (props) => ({
|
|
67
|
-
url: constructUrl(`/resources/${props.
|
|
103
|
+
url: constructUrl(`/resources/${props.channelOrResourceId}/public_data`, props),
|
|
68
104
|
}),
|
|
69
105
|
}),
|
|
70
106
|
|
|
71
107
|
identifyCustomer: builder.query({
|
|
72
108
|
query: (props) => ({
|
|
73
109
|
url: constructUrl(
|
|
74
|
-
`/crms/${props.crmSlug}/resources/${props.
|
|
110
|
+
`/crms/${props.crmSlug}/resources/${props.channelOrResourceId}/customers/${props.personId}/identify`,
|
|
111
|
+
props
|
|
75
112
|
),
|
|
76
113
|
}),
|
|
114
|
+
keepUnusedDataFor: 9999999, // once identifoed it's not going to change
|
|
77
115
|
}),
|
|
78
116
|
|
|
79
117
|
/**
|
|
80
|
-
* body
|
|
118
|
+
* body contain:
|
|
119
|
+
* resource_id*,
|
|
120
|
+
* product_id*,
|
|
81
121
|
* provider_id,
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
122
|
+
* timeslotUuid (if available)
|
|
123
|
+
* from* (ISO format),
|
|
124
|
+
* to* (ISO format)
|
|
125
|
+
* -> * marks those which are required.
|
|
86
126
|
*/
|
|
87
127
|
reserveAppoinment: builder.mutation({
|
|
88
128
|
query: (props) => ({
|
|
89
|
-
url: constructUrl(
|
|
129
|
+
url: constructUrl(
|
|
130
|
+
`/resources/${props.channelOrResourceId}/reserve_appointment`,
|
|
131
|
+
props
|
|
132
|
+
),
|
|
90
133
|
method: "post",
|
|
91
134
|
body: props.body,
|
|
92
135
|
}),
|
|
@@ -99,7 +142,10 @@ export const timumApiSlice = createApi({
|
|
|
99
142
|
*/
|
|
100
143
|
revokeAppointmentReservation: builder.mutation({
|
|
101
144
|
query: (props) => ({
|
|
102
|
-
url: constructUrl(
|
|
145
|
+
url: constructUrl(
|
|
146
|
+
`/resources/${props.channelOrResourceId}/revoke_reservation`,
|
|
147
|
+
props
|
|
148
|
+
),
|
|
103
149
|
method: "post",
|
|
104
150
|
body: props.body,
|
|
105
151
|
}),
|
|
@@ -112,7 +158,8 @@ export const timumApiSlice = createApi({
|
|
|
112
158
|
getAccount: builder.query({
|
|
113
159
|
query: (props) => ({
|
|
114
160
|
url: constructUrl(
|
|
115
|
-
`/crms/${props.platform}/account/${props.accountReference}
|
|
161
|
+
`/crms/${props.platform}/account/${props.accountReference}`,
|
|
162
|
+
props
|
|
116
163
|
),
|
|
117
164
|
}),
|
|
118
165
|
providesTags: (/* result = [], error, arg */) => ["Account"],
|
|
@@ -121,7 +168,7 @@ export const timumApiSlice = createApi({
|
|
|
121
168
|
createAccount: builder.mutation({
|
|
122
169
|
query: (props) => {
|
|
123
170
|
return {
|
|
124
|
-
url: constructUrl(`/crms/${props.platform}/account
|
|
171
|
+
url: constructUrl(`/crms/${props.platform}/account`, props),
|
|
125
172
|
method: "post",
|
|
126
173
|
body: JSON.stringify(props.accountData),
|
|
127
174
|
};
|
|
@@ -132,7 +179,8 @@ export const timumApiSlice = createApi({
|
|
|
132
179
|
getProviders: builder.query({
|
|
133
180
|
query: (props) => ({
|
|
134
181
|
url: constructUrl(
|
|
135
|
-
`/crms/${props.platform}/account/${props.accountReference}/providers
|
|
182
|
+
`/crms/${props.platform}/account/${props.accountReference}/providers`,
|
|
183
|
+
props
|
|
136
184
|
),
|
|
137
185
|
}),
|
|
138
186
|
providesTags: (/* result = [], error, arg */) => ["Product"],
|
|
@@ -141,14 +189,15 @@ export const timumApiSlice = createApi({
|
|
|
141
189
|
getProvider: builder.query({
|
|
142
190
|
query: (props) => ({
|
|
143
191
|
url: constructUrl(
|
|
144
|
-
`/crms/${props.platform}/provider/${props.providerReference}
|
|
192
|
+
`/crms/${props.platform}/provider/${props.providerReference}`,
|
|
193
|
+
props
|
|
145
194
|
),
|
|
146
195
|
}),
|
|
147
196
|
}),
|
|
148
197
|
|
|
149
198
|
createProvider: builder.mutation({
|
|
150
199
|
query: (props) => ({
|
|
151
|
-
url: constructUrl(`/crms/${props.platform}/provider
|
|
200
|
+
url: constructUrl(`/crms/${props.platform}/provider`, props),
|
|
152
201
|
method: "post",
|
|
153
202
|
body: JSON.stringify(
|
|
154
203
|
(() => ({
|
|
@@ -177,14 +226,15 @@ export const timumApiSlice = createApi({
|
|
|
177
226
|
getUser: builder.query({
|
|
178
227
|
query: (props) => ({
|
|
179
228
|
url: constructUrl(
|
|
180
|
-
`/crms/${props.platform}/user/${props.userReference}
|
|
229
|
+
`/crms/${props.platform}/user/${props.userReference}`,
|
|
230
|
+
props
|
|
181
231
|
),
|
|
182
232
|
}),
|
|
183
233
|
}),
|
|
184
234
|
|
|
185
235
|
createUser: builder.mutation({
|
|
186
236
|
query: (props) => ({
|
|
187
|
-
url: constructUrl(`/crms/${props.platform}/user
|
|
237
|
+
url: constructUrl(`/crms/${props.platform}/user`, props),
|
|
188
238
|
method: "post",
|
|
189
239
|
body: JSON.stringify(props.userData),
|
|
190
240
|
}),
|
|
@@ -203,8 +253,8 @@ export const {
|
|
|
203
253
|
useCreateAppointmentWithConsumerMutation,
|
|
204
254
|
useIdentifyCustomerQuery,
|
|
205
255
|
useLazyIdentifyCustomerQuery,
|
|
206
|
-
|
|
207
|
-
|
|
256
|
+
usePublicDataQuery,
|
|
257
|
+
useLazyPublicDataQuery,
|
|
208
258
|
useReserveAppoinmentMutation,
|
|
209
259
|
useRevokeAppointmentReservationMutation,
|
|
210
260
|
|