@dv4resi/dvss-backend-module-offering-im 0.0.10 → 0.0.12
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/index.d.ts +0 -2
- package/dist/index.js +308 -172
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3852,7 +3852,8 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3852
3852
|
guestIds: order.guests.map((g) => g.id),
|
|
3853
3853
|
practitionerIds: request.offeringResources.map((r) => r.externalId),
|
|
3854
3854
|
durationMinutes: request.durationInMinutes,
|
|
3855
|
-
timeIso: request.bookingStartTime.toISOString()
|
|
3855
|
+
timeIso: request.bookingStartTime.toISOString(),
|
|
3856
|
+
sessionId: request.meta?.sessionId
|
|
3856
3857
|
}
|
|
3857
3858
|
}, integration, loggedInUserId);
|
|
3858
3859
|
items.push({
|
|
@@ -3885,6 +3886,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3885
3886
|
}
|
|
3886
3887
|
}
|
|
3887
3888
|
async addCustomerToOrder(orderId, customerId, integration, loggedInUserId) {
|
|
3889
|
+
this.logger.info(loggedInUserId, this.addCustomerToOrder.name, this.fileName, "Adding customer to Trybe order", {
|
|
3890
|
+
orderId,
|
|
3891
|
+
customerId
|
|
3892
|
+
});
|
|
3888
3893
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3889
3894
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3890
3895
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -3896,8 +3901,15 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3896
3901
|
source: "trybe"
|
|
3897
3902
|
}
|
|
3898
3903
|
}, validated, loggedInUserId);
|
|
3904
|
+
this.logger.info(loggedInUserId, this.addCustomerToOrder.name, this.fileName, "Successfully added customer to Trybe order", {
|
|
3905
|
+
orderId,
|
|
3906
|
+
customerId
|
|
3907
|
+
});
|
|
3899
3908
|
}
|
|
3900
3909
|
async getOrder(orderId, integration, loggedInUserId) {
|
|
3910
|
+
this.logger.info(loggedInUserId, this.getOrder.name, this.fileName, "Fetching Trybe order details", {
|
|
3911
|
+
orderId
|
|
3912
|
+
});
|
|
3901
3913
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3902
3914
|
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3903
3915
|
apiMethod: HTTP_METHOD.GET,
|
|
@@ -3905,6 +3917,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3905
3917
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3906
3918
|
headers: validated.headers
|
|
3907
3919
|
}, validated, loggedInUserId);
|
|
3920
|
+
this.logger.info(loggedInUserId, this.getOrder.name, this.fileName, "Successfully fetched Trybe order details", {
|
|
3921
|
+
orderId,
|
|
3922
|
+
guestCount: res.data.guests.length
|
|
3923
|
+
});
|
|
3908
3924
|
return {
|
|
3909
3925
|
orderId: res.data.id,
|
|
3910
3926
|
guests: res.data.guests.map((g) => ({
|
|
@@ -3930,6 +3946,11 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3930
3946
|
}
|
|
3931
3947
|
}
|
|
3932
3948
|
async addItemToOrder(request, integration, loggedInUserId) {
|
|
3949
|
+
this.logger.info(loggedInUserId, this.addItemToOrder.name, this.fileName, "Adding item to Trybe order", {
|
|
3950
|
+
orderId: request.orderId,
|
|
3951
|
+
offeringId: request.item.offeringId,
|
|
3952
|
+
offeringType: request.item.offeringType
|
|
3953
|
+
});
|
|
3933
3954
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3934
3955
|
const { orderId, item } = request;
|
|
3935
3956
|
const offeringType = this.mapOfferingTypeToTrybeApi(item.offeringType);
|
|
@@ -3977,13 +3998,24 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3977
3998
|
headers: validated.headers,
|
|
3978
3999
|
body
|
|
3979
4000
|
}, validated, loggedInUserId);
|
|
3980
|
-
const
|
|
3981
|
-
|
|
3982
|
-
name:
|
|
3983
|
-
netTotal:
|
|
4001
|
+
const data = res.data;
|
|
4002
|
+
const result = {
|
|
4003
|
+
name: data.booking_summary?.offering?.name ?? data.type_name ?? void 0,
|
|
4004
|
+
netTotal: data.net_total
|
|
3984
4005
|
};
|
|
4006
|
+
this.logger.info(loggedInUserId, this.addItemToOrder.name, this.fileName, "Successfully added item to Trybe order", {
|
|
4007
|
+
orderId,
|
|
4008
|
+
offeringId: item.offeringId,
|
|
4009
|
+
name: result.name,
|
|
4010
|
+
netTotal: result.netTotal
|
|
4011
|
+
});
|
|
4012
|
+
return result;
|
|
3985
4013
|
}
|
|
3986
4014
|
async addCustomerCreditsToOrder(orderId, customerCreditId, integration, loggedInUserId) {
|
|
4015
|
+
this.logger.info(loggedInUserId, this.addCustomerCreditsToOrder.name, this.fileName, "Adding customer credits to Trybe order", {
|
|
4016
|
+
orderId,
|
|
4017
|
+
customerCreditId
|
|
4018
|
+
});
|
|
3987
4019
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3988
4020
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3989
4021
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -3994,8 +4026,15 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3994
4026
|
id: customerCreditId
|
|
3995
4027
|
}
|
|
3996
4028
|
}, validated, loggedInUserId);
|
|
4029
|
+
this.logger.info(loggedInUserId, this.addCustomerCreditsToOrder.name, this.fileName, "Successfully added customer credits to Trybe order", {
|
|
4030
|
+
orderId,
|
|
4031
|
+
customerCreditId
|
|
4032
|
+
});
|
|
3997
4033
|
}
|
|
3998
4034
|
async submitOrder(orderId, integration, loggedInUserId) {
|
|
4035
|
+
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Submitting Trybe order", {
|
|
4036
|
+
orderId
|
|
4037
|
+
});
|
|
3999
4038
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4000
4039
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4001
4040
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4003,8 +4042,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4003
4042
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4004
4043
|
headers: validated.headers
|
|
4005
4044
|
}, validated, loggedInUserId);
|
|
4045
|
+
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Successfully submitted Trybe order", {
|
|
4046
|
+
orderId
|
|
4047
|
+
});
|
|
4006
4048
|
}
|
|
4007
4049
|
async cancelOrder(orderId, integration, loggedInUserId) {
|
|
4050
|
+
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Cancelling Trybe order", {
|
|
4051
|
+
orderId
|
|
4052
|
+
});
|
|
4008
4053
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4009
4054
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4010
4055
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4012,20 +4057,39 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4012
4057
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4013
4058
|
headers: validated.headers
|
|
4014
4059
|
}, validated, loggedInUserId);
|
|
4060
|
+
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Successfully cancelled Trybe order", {
|
|
4061
|
+
orderId
|
|
4062
|
+
});
|
|
4015
4063
|
}
|
|
4016
4064
|
async updateOrder(request, integration, loggedInUserId) {
|
|
4065
|
+
this.logger.info(loggedInUserId, this.updateOrder.name, this.fileName, "Updating Trybe order", {
|
|
4066
|
+
orderId: request.orderId,
|
|
4067
|
+
offeringType: request.item.type
|
|
4068
|
+
});
|
|
4017
4069
|
const order = await this.getOrder(request.orderId, integration, loggedInUserId);
|
|
4018
4070
|
const itemId = order.items[0]?.id;
|
|
4019
4071
|
if (!itemId) {
|
|
4072
|
+
this.logger.error(loggedInUserId, this.updateOrder.name, this.fileName, "Item not found in order during update", {
|
|
4073
|
+
orderId: request.orderId
|
|
4074
|
+
});
|
|
4020
4075
|
throw new Error("Item not found in order");
|
|
4021
4076
|
}
|
|
4022
4077
|
const updateResponse = await this.updateOrderItem(request.orderId, itemId, request, integration, loggedInUserId);
|
|
4078
|
+
this.logger.info(loggedInUserId, this.updateOrder.name, this.fileName, "Successfully updated Trybe order", {
|
|
4079
|
+
orderId: request.orderId,
|
|
4080
|
+
itemId
|
|
4081
|
+
});
|
|
4023
4082
|
return {
|
|
4024
4083
|
success: Boolean(updateResponse.data.id),
|
|
4025
4084
|
data: updateResponse.data
|
|
4026
4085
|
};
|
|
4027
4086
|
}
|
|
4028
4087
|
async updateOrderItem(orderId, itemId, request, integration, loggedInUserId) {
|
|
4088
|
+
this.logger.info(loggedInUserId, this.updateOrderItem.name, this.fileName, "Updating Trybe order item", {
|
|
4089
|
+
orderId,
|
|
4090
|
+
itemId,
|
|
4091
|
+
offeringType: request.item.type
|
|
4092
|
+
});
|
|
4029
4093
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4030
4094
|
const offeringType = this.mapOfferingTypeToTrybeApi(request.item.type);
|
|
4031
4095
|
let body;
|
|
@@ -4056,15 +4120,25 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4056
4120
|
} else {
|
|
4057
4121
|
throw new Error("Course is not updatable");
|
|
4058
4122
|
}
|
|
4059
|
-
|
|
4123
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4060
4124
|
apiMethod: HTTP_METHOD.PUT,
|
|
4061
4125
|
url: `/shop/orders/${orderId}/items/${itemId}`,
|
|
4062
4126
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4063
4127
|
headers: validated.headers,
|
|
4064
4128
|
body
|
|
4065
4129
|
}, validated, loggedInUserId);
|
|
4130
|
+
this.logger.info(loggedInUserId, this.updateOrderItem.name, this.fileName, "Successfully updated Trybe order item", {
|
|
4131
|
+
orderId,
|
|
4132
|
+
itemId
|
|
4133
|
+
});
|
|
4134
|
+
return response;
|
|
4066
4135
|
}
|
|
4067
4136
|
async addPaymentToOrder(request, integration, loggedInUserId) {
|
|
4137
|
+
this.logger.info(loggedInUserId, this.addPaymentToOrder.name, this.fileName, "Adding payment to Trybe order", {
|
|
4138
|
+
orderId: request.orderId,
|
|
4139
|
+
amount: request.amount,
|
|
4140
|
+
paymentTypeId: request.paymentTypeId
|
|
4141
|
+
});
|
|
4068
4142
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4069
4143
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4070
4144
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4081,211 +4155,279 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4081
4155
|
}
|
|
4082
4156
|
}
|
|
4083
4157
|
}, validated, loggedInUserId);
|
|
4158
|
+
this.logger.info(loggedInUserId, this.addPaymentToOrder.name, this.fileName, "Successfully added payment to Trybe order", {
|
|
4159
|
+
orderId: request.orderId,
|
|
4160
|
+
amount: request.amount
|
|
4161
|
+
});
|
|
4084
4162
|
}
|
|
4085
4163
|
async fetchAppointments(request, integration, loggedInUserId) {
|
|
4086
4164
|
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointments.name} Called`, {
|
|
4087
4165
|
request
|
|
4088
4166
|
});
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4167
|
+
try {
|
|
4168
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4169
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4170
|
+
if (request.shouldFetchAllAppointments && request.options?.page !== void 0) {
|
|
4171
|
+
throw new Error("Pagination options are not supported when fetching all appointments.");
|
|
4172
|
+
}
|
|
4173
|
+
const query = new URLSearchParams();
|
|
4174
|
+
if (request.options?.page != null) {
|
|
4175
|
+
query.set("page", String(request.options.page));
|
|
4176
|
+
}
|
|
4177
|
+
if (request.options?.count != null) {
|
|
4178
|
+
query.set("per_page", String(request.options.count));
|
|
4179
|
+
}
|
|
4180
|
+
const queryString = query.toString();
|
|
4181
|
+
const apiUrl = `/shop/appointment-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4182
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4183
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4184
|
+
url: apiUrl,
|
|
4185
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4186
|
+
headers: validatedIntegration.headers
|
|
4187
|
+
}, validatedIntegration, loggedInUserId);
|
|
4188
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4189
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4190
|
+
url: `${apiUrl}&page=${page}`,
|
|
4191
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4192
|
+
headers: validatedIntegration.headers
|
|
4193
|
+
}, validatedIntegration, loggedInUserId));
|
|
4194
|
+
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, "Successfully fetched Trybe appointments", {
|
|
4195
|
+
totalRecords: firstPageResponse.meta.total
|
|
4196
|
+
});
|
|
4197
|
+
return mapTrybeAppointmentsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4198
|
+
} catch (err) {
|
|
4199
|
+
this.logger.error(loggedInUserId, this.fetchAppointments.name, this.fileName, "Error fetching Trybe appointments", err);
|
|
4200
|
+
throw err;
|
|
4100
4201
|
}
|
|
4101
|
-
const queryString = query.toString();
|
|
4102
|
-
const apiUrl = `/shop/appointment-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4103
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4104
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4105
|
-
url: apiUrl,
|
|
4106
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4107
|
-
headers: validatedIntegration.headers
|
|
4108
|
-
}, validatedIntegration, loggedInUserId);
|
|
4109
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4110
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4111
|
-
url: `${apiUrl}&page=${page}`,
|
|
4112
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4113
|
-
headers: validatedIntegration.headers
|
|
4114
|
-
}, validatedIntegration, loggedInUserId));
|
|
4115
|
-
return mapTrybeAppointmentsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4116
4202
|
}
|
|
4117
4203
|
async fetchSessions(request, integration, loggedInUserId) {
|
|
4118
4204
|
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessions.name} Called`, {
|
|
4119
4205
|
request
|
|
4120
4206
|
});
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4207
|
+
try {
|
|
4208
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4209
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4210
|
+
if (request.shouldFetchAllSessions && request.options?.page !== void 0) {
|
|
4211
|
+
throw new Error("Pagination options are not supported when fetching all sessions.");
|
|
4212
|
+
}
|
|
4213
|
+
const query = new URLSearchParams();
|
|
4214
|
+
if (request.options?.page != null) {
|
|
4215
|
+
query.set("page", String(request.options.page));
|
|
4216
|
+
}
|
|
4217
|
+
if (request.options?.count != null) {
|
|
4218
|
+
query.set("per_page", String(request.options.count));
|
|
4219
|
+
}
|
|
4220
|
+
const queryString = query.toString();
|
|
4221
|
+
const apiUrl = `/shop/session-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4222
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4223
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4224
|
+
url: apiUrl,
|
|
4225
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4226
|
+
headers: validatedIntegration.headers
|
|
4227
|
+
}, validatedIntegration, loggedInUserId);
|
|
4228
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4229
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4230
|
+
url: `${apiUrl}&page=${page}`,
|
|
4231
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4232
|
+
headers: validatedIntegration.headers
|
|
4233
|
+
}, validatedIntegration, loggedInUserId));
|
|
4234
|
+
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, "Successfully fetched Trybe sessions", {
|
|
4235
|
+
totalRecords: firstPageResponse.meta.total
|
|
4236
|
+
});
|
|
4237
|
+
return mapTrybeSessionsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4238
|
+
} catch (err) {
|
|
4239
|
+
this.logger.error(loggedInUserId, this.fetchSessions.name, this.fileName, "Error fetching Trybe sessions", err);
|
|
4240
|
+
throw err;
|
|
4132
4241
|
}
|
|
4133
|
-
const queryString = query.toString();
|
|
4134
|
-
const apiUrl = `/shop/session-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4135
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4136
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4137
|
-
url: apiUrl,
|
|
4138
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4139
|
-
headers: validatedIntegration.headers
|
|
4140
|
-
}, validatedIntegration, loggedInUserId);
|
|
4141
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4142
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4143
|
-
url: `${apiUrl}&page=${page}`,
|
|
4144
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4145
|
-
headers: validatedIntegration.headers
|
|
4146
|
-
}, validatedIntegration, loggedInUserId));
|
|
4147
|
-
return mapTrybeSessionsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4148
4242
|
}
|
|
4149
4243
|
async fetchCourses(request, integration, loggedInUserId) {
|
|
4150
4244
|
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourses.name} Called`, {
|
|
4151
4245
|
request
|
|
4152
4246
|
});
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4247
|
+
try {
|
|
4248
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4249
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
4250
|
+
if (request.shouldFetchAllCourses && request.options?.page !== void 0) {
|
|
4251
|
+
throw new Error("Pagination options are not supported when fetching all courses.");
|
|
4252
|
+
}
|
|
4253
|
+
const query = new URLSearchParams();
|
|
4254
|
+
if (request.options?.page != null) {
|
|
4255
|
+
query.set("page", String(request.options.page));
|
|
4256
|
+
}
|
|
4257
|
+
if (request.options?.count != null) {
|
|
4258
|
+
query.set("per_page", String(request.options.count));
|
|
4259
|
+
}
|
|
4260
|
+
const queryString = query.toString();
|
|
4261
|
+
const apiUrl = `/shop/course-types?organisation_id=${organisationId}` + (queryString ? `&${queryString}` : "");
|
|
4262
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4263
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4264
|
+
url: apiUrl,
|
|
4265
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4266
|
+
headers: validatedIntegration.headers
|
|
4267
|
+
}, validatedIntegration, loggedInUserId);
|
|
4268
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4269
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4270
|
+
url: `${apiUrl}&page=${page}`,
|
|
4271
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4272
|
+
headers: validatedIntegration.headers
|
|
4273
|
+
}, validatedIntegration, loggedInUserId));
|
|
4274
|
+
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, "Successfully fetched Trybe courses", {
|
|
4275
|
+
totalRecords: firstPageResponse.meta.total
|
|
4276
|
+
});
|
|
4277
|
+
return mapTrybeCoursesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4278
|
+
} catch (err) {
|
|
4279
|
+
this.logger.error(loggedInUserId, this.fetchCourses.name, this.fileName, "Error fetching Trybe courses", err);
|
|
4280
|
+
throw err;
|
|
4164
4281
|
}
|
|
4165
|
-
const queryString = query.toString();
|
|
4166
|
-
const apiUrl = `/shop/course-types?organisation_id=${organisationId}` + (queryString ? `&${queryString}` : "");
|
|
4167
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4168
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4169
|
-
url: apiUrl,
|
|
4170
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4171
|
-
headers: validatedIntegration.headers
|
|
4172
|
-
}, validatedIntegration, loggedInUserId);
|
|
4173
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4174
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4175
|
-
url: `${apiUrl}&page=${page}`,
|
|
4176
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4177
|
-
headers: validatedIntegration.headers
|
|
4178
|
-
}, validatedIntegration, loggedInUserId));
|
|
4179
|
-
return mapTrybeCoursesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4180
4282
|
}
|
|
4181
4283
|
async fetchPractitioners(request, integration, loggedInUserId) {
|
|
4182
4284
|
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchPractitioners.name} Called`, {
|
|
4183
4285
|
request
|
|
4184
4286
|
});
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4287
|
+
try {
|
|
4288
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4289
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4290
|
+
const apiUrl = `/shop/practitioners/?site_id=${siteId}`;
|
|
4291
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4292
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4293
|
+
url: apiUrl,
|
|
4294
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4295
|
+
headers: validatedIntegration.headers
|
|
4296
|
+
}, validatedIntegration, loggedInUserId);
|
|
4297
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllPractitioners, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4298
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4299
|
+
url: `${apiUrl}&page=${page}`,
|
|
4300
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4301
|
+
headers: validatedIntegration.headers
|
|
4302
|
+
}, validatedIntegration, loggedInUserId));
|
|
4303
|
+
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, "Successfully fetched Trybe practitioners", {
|
|
4304
|
+
totalRecords: firstPageResponse.meta.total
|
|
4305
|
+
});
|
|
4306
|
+
return mapTrybePractitionersToSystemResponse(records, firstPageResponse.meta.total);
|
|
4307
|
+
} catch (err) {
|
|
4308
|
+
this.logger.error(loggedInUserId, this.fetchPractitioners.name, this.fileName, "Error fetching Trybe practitioners", err);
|
|
4309
|
+
throw err;
|
|
4310
|
+
}
|
|
4201
4311
|
}
|
|
4202
4312
|
async fetchCategories(request, integration, loggedInUserId) {
|
|
4203
4313
|
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCategories.name} Called`, {
|
|
4204
4314
|
request
|
|
4205
4315
|
});
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4316
|
+
try {
|
|
4317
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4318
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
4319
|
+
if (request.shouldFetchAllCategories && request.options?.page !== void 0) {
|
|
4320
|
+
throw new Error("Pagination options are not supported when fetching all categories.");
|
|
4321
|
+
}
|
|
4322
|
+
const query = new URLSearchParams();
|
|
4323
|
+
if (request.options?.page != null) {
|
|
4324
|
+
query.set("page", String(request.options.page));
|
|
4325
|
+
}
|
|
4326
|
+
if (request.options?.count != null) {
|
|
4327
|
+
query.set("per_page", String(request.options.count));
|
|
4328
|
+
}
|
|
4329
|
+
const queryString = query.toString();
|
|
4330
|
+
const apiUrl = `/shop/organisations/${organisationId}/categories` + (queryString ? `?${queryString}` : "");
|
|
4331
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4332
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4333
|
+
url: apiUrl,
|
|
4334
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4335
|
+
headers: validatedIntegration.headers
|
|
4336
|
+
}, validatedIntegration, loggedInUserId);
|
|
4337
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4338
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4339
|
+
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}`,
|
|
4340
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4341
|
+
headers: validatedIntegration.headers
|
|
4342
|
+
}, validatedIntegration, loggedInUserId));
|
|
4343
|
+
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, "Successfully fetched Trybe categories", {
|
|
4344
|
+
totalRecords: firstPageResponse.meta.total
|
|
4345
|
+
});
|
|
4346
|
+
return mapTrybeCategoriesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4347
|
+
} catch (err) {
|
|
4348
|
+
this.logger.error(loggedInUserId, this.fetchCategories.name, this.fileName, "Error fetching Trybe categories", err);
|
|
4349
|
+
throw err;
|
|
4217
4350
|
}
|
|
4218
|
-
const queryString = query.toString();
|
|
4219
|
-
const apiUrl = `/shop/organisations/${organisationId}/categories` + (queryString ? `?${queryString}` : "");
|
|
4220
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4221
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4222
|
-
url: apiUrl,
|
|
4223
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4224
|
-
headers: validatedIntegration.headers
|
|
4225
|
-
}, validatedIntegration, loggedInUserId);
|
|
4226
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4227
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4228
|
-
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}`,
|
|
4229
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4230
|
-
headers: validatedIntegration.headers
|
|
4231
|
-
}, validatedIntegration, loggedInUserId));
|
|
4232
|
-
return mapTrybeCategoriesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4233
4351
|
}
|
|
4234
4352
|
async fetchBookableItemsFromCredit(request, integration, loggedInUserId) {
|
|
4235
4353
|
this.logger.info(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchBookableItemsFromCredit.name} Called`, {
|
|
4236
4354
|
request
|
|
4237
4355
|
});
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4356
|
+
try {
|
|
4357
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4358
|
+
const query = new URLSearchParams();
|
|
4359
|
+
if (request.options?.page != null) {
|
|
4360
|
+
query.set("page", String(request.options.page));
|
|
4361
|
+
}
|
|
4362
|
+
if (request.options?.count != null) {
|
|
4363
|
+
query.set("per_page", String(request.options.count));
|
|
4364
|
+
}
|
|
4365
|
+
const queryString = query.toString();
|
|
4366
|
+
const apiUrl = `/shop/coupon-codes/${request.couponCodeId}/offering-discounts` + (queryString ? `?${queryString}` : "");
|
|
4367
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4368
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4369
|
+
url: apiUrl,
|
|
4370
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4371
|
+
headers: validatedIntegration.headers
|
|
4372
|
+
}, validatedIntegration, loggedInUserId);
|
|
4373
|
+
this.logger.info(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, "Successfully fetched bookable items from credit", {
|
|
4374
|
+
couponCodeId: request.couponCodeId
|
|
4375
|
+
});
|
|
4376
|
+
return mapTrybeCouponCodeOfferingsToSystemResponse(response.data.offerings);
|
|
4377
|
+
} catch (err) {
|
|
4378
|
+
this.logger.error(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, "Error fetching bookable items from credit", err);
|
|
4379
|
+
throw err;
|
|
4245
4380
|
}
|
|
4246
|
-
const queryString = query.toString();
|
|
4247
|
-
const apiUrl = `/shop/coupon-codes/${request.couponCodeId}/offering-discounts` + (queryString ? `?${queryString}` : "");
|
|
4248
|
-
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4249
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4250
|
-
url: apiUrl,
|
|
4251
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4252
|
-
headers: validatedIntegration.headers
|
|
4253
|
-
}, validatedIntegration, loggedInUserId);
|
|
4254
|
-
return mapTrybeCouponCodeOfferingsToSystemResponse(response.data.offerings);
|
|
4255
4381
|
}
|
|
4256
4382
|
async fetchSessionAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
4257
4383
|
this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessionAvailabilityForOffering.name} Called`, {
|
|
4258
4384
|
request
|
|
4259
4385
|
});
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4386
|
+
try {
|
|
4387
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4388
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4389
|
+
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
|
|
4390
|
+
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
|
|
4391
|
+
const apiUrl = `/shop/item-availability/sessions/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&offeringId=${request.externalOfferingBookableItemId}`;
|
|
4392
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4393
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4394
|
+
url: apiUrl,
|
|
4395
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4396
|
+
headers: validatedIntegration.headers
|
|
4397
|
+
}, validatedIntegration, loggedInUserId);
|
|
4398
|
+
this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, "Successfully fetched session availability for offering", {
|
|
4399
|
+
externalOfferingBookableItemId: request.externalOfferingBookableItemId
|
|
4400
|
+
});
|
|
4401
|
+
return mapTrybeSessionAvailabilityToSystemResponse(response.data);
|
|
4402
|
+
} catch (err) {
|
|
4403
|
+
this.logger.error(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, "Error fetching session availability for offering", err);
|
|
4404
|
+
throw err;
|
|
4405
|
+
}
|
|
4272
4406
|
}
|
|
4273
4407
|
async fetchAppointmentAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
4274
4408
|
this.logger.info(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointmentAvailabilityForOffering.name} Called`, {
|
|
4275
4409
|
request
|
|
4276
4410
|
});
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4411
|
+
try {
|
|
4412
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4413
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4414
|
+
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
|
|
4415
|
+
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
|
|
4416
|
+
const apiUrl = `/shop/item-availability/appointment-slots/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&OfferingID=${request.externalOfferingBookableItemId}`;
|
|
4417
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4418
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4419
|
+
url: apiUrl,
|
|
4420
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4421
|
+
headers: validatedIntegration.headers
|
|
4422
|
+
}, validatedIntegration, loggedInUserId);
|
|
4423
|
+
this.logger.info(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, "Successfully fetched appointment availability for offering", {
|
|
4424
|
+
externalOfferingBookableItemId: request.externalOfferingBookableItemId
|
|
4425
|
+
});
|
|
4426
|
+
return mapTrybeAppointmentAvailabilityToSystemResponse(response.data);
|
|
4427
|
+
} catch (err) {
|
|
4428
|
+
this.logger.error(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, "Error fetching appointment availability for offering", err);
|
|
4429
|
+
throw err;
|
|
4430
|
+
}
|
|
4289
4431
|
}
|
|
4290
4432
|
};
|
|
4291
4433
|
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
@@ -4430,12 +4572,6 @@ exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResour
|
|
|
4430
4572
|
resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
|
|
4431
4573
|
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
|
|
4432
4574
|
}
|
|
4433
|
-
if (resourceMappingConfig.isExternalCmsIntegrationEnabled === void 0 || typeof resourceMappingConfig.isExternalCmsIntegrationEnabled !== "boolean" || resourceMappingConfig.isExternalCmsIntegrationEnabled === false) {
|
|
4434
|
-
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: isExternalCmsIntegrationEnabled must be true");
|
|
4435
|
-
}
|
|
4436
|
-
if (!resourceMappingConfig.externalCmsUrl || !isValidHttpUrl(resourceMappingConfig.externalCmsUrl)) {
|
|
4437
|
-
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: externalCmsUrl must be a valid HTTP(S) URL");
|
|
4438
|
-
}
|
|
4439
4575
|
if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
|
|
4440
4576
|
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: supportedJourneys must contain at least one of SESSION, COURSE, APPOINTMENT");
|
|
4441
4577
|
}
|