@dv4resi/dvss-backend-module-offering-im 0.0.11 → 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 +307 -172
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3853,7 +3853,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3853
3853
|
practitionerIds: request.offeringResources.map((r) => r.externalId),
|
|
3854
3854
|
durationMinutes: request.durationInMinutes,
|
|
3855
3855
|
timeIso: request.bookingStartTime.toISOString(),
|
|
3856
|
-
sessionId: request.meta
|
|
3856
|
+
sessionId: request.meta?.sessionId
|
|
3857
3857
|
}
|
|
3858
3858
|
}, integration, loggedInUserId);
|
|
3859
3859
|
items.push({
|
|
@@ -3886,6 +3886,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3886
3886
|
}
|
|
3887
3887
|
}
|
|
3888
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
|
+
});
|
|
3889
3893
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3890
3894
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3891
3895
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -3897,8 +3901,15 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3897
3901
|
source: "trybe"
|
|
3898
3902
|
}
|
|
3899
3903
|
}, validated, loggedInUserId);
|
|
3904
|
+
this.logger.info(loggedInUserId, this.addCustomerToOrder.name, this.fileName, "Successfully added customer to Trybe order", {
|
|
3905
|
+
orderId,
|
|
3906
|
+
customerId
|
|
3907
|
+
});
|
|
3900
3908
|
}
|
|
3901
3909
|
async getOrder(orderId, integration, loggedInUserId) {
|
|
3910
|
+
this.logger.info(loggedInUserId, this.getOrder.name, this.fileName, "Fetching Trybe order details", {
|
|
3911
|
+
orderId
|
|
3912
|
+
});
|
|
3902
3913
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3903
3914
|
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3904
3915
|
apiMethod: HTTP_METHOD.GET,
|
|
@@ -3906,6 +3917,10 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3906
3917
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
3907
3918
|
headers: validated.headers
|
|
3908
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
|
+
});
|
|
3909
3924
|
return {
|
|
3910
3925
|
orderId: res.data.id,
|
|
3911
3926
|
guests: res.data.guests.map((g) => ({
|
|
@@ -3931,6 +3946,11 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3931
3946
|
}
|
|
3932
3947
|
}
|
|
3933
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
|
+
});
|
|
3934
3954
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3935
3955
|
const { orderId, item } = request;
|
|
3936
3956
|
const offeringType = this.mapOfferingTypeToTrybeApi(item.offeringType);
|
|
@@ -3978,13 +3998,24 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3978
3998
|
headers: validated.headers,
|
|
3979
3999
|
body
|
|
3980
4000
|
}, validated, loggedInUserId);
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3983
|
-
name:
|
|
3984
|
-
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
|
|
3985
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;
|
|
3986
4013
|
}
|
|
3987
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
|
+
});
|
|
3988
4019
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3989
4020
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
3990
4021
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -3995,8 +4026,15 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3995
4026
|
id: customerCreditId
|
|
3996
4027
|
}
|
|
3997
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
|
+
});
|
|
3998
4033
|
}
|
|
3999
4034
|
async submitOrder(orderId, integration, loggedInUserId) {
|
|
4035
|
+
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Submitting Trybe order", {
|
|
4036
|
+
orderId
|
|
4037
|
+
});
|
|
4000
4038
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4001
4039
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4002
4040
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4004,8 +4042,14 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4004
4042
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4005
4043
|
headers: validated.headers
|
|
4006
4044
|
}, validated, loggedInUserId);
|
|
4045
|
+
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Successfully submitted Trybe order", {
|
|
4046
|
+
orderId
|
|
4047
|
+
});
|
|
4007
4048
|
}
|
|
4008
4049
|
async cancelOrder(orderId, integration, loggedInUserId) {
|
|
4050
|
+
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Cancelling Trybe order", {
|
|
4051
|
+
orderId
|
|
4052
|
+
});
|
|
4009
4053
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4010
4054
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4011
4055
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4013,20 +4057,39 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4013
4057
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4014
4058
|
headers: validated.headers
|
|
4015
4059
|
}, validated, loggedInUserId);
|
|
4060
|
+
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Successfully cancelled Trybe order", {
|
|
4061
|
+
orderId
|
|
4062
|
+
});
|
|
4016
4063
|
}
|
|
4017
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
|
+
});
|
|
4018
4069
|
const order = await this.getOrder(request.orderId, integration, loggedInUserId);
|
|
4019
4070
|
const itemId = order.items[0]?.id;
|
|
4020
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
|
+
});
|
|
4021
4075
|
throw new Error("Item not found in order");
|
|
4022
4076
|
}
|
|
4023
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
|
+
});
|
|
4024
4082
|
return {
|
|
4025
4083
|
success: Boolean(updateResponse.data.id),
|
|
4026
4084
|
data: updateResponse.data
|
|
4027
4085
|
};
|
|
4028
4086
|
}
|
|
4029
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
|
+
});
|
|
4030
4093
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4031
4094
|
const offeringType = this.mapOfferingTypeToTrybeApi(request.item.type);
|
|
4032
4095
|
let body;
|
|
@@ -4057,15 +4120,25 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4057
4120
|
} else {
|
|
4058
4121
|
throw new Error("Course is not updatable");
|
|
4059
4122
|
}
|
|
4060
|
-
|
|
4123
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4061
4124
|
apiMethod: HTTP_METHOD.PUT,
|
|
4062
4125
|
url: `/shop/orders/${orderId}/items/${itemId}`,
|
|
4063
4126
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
4064
4127
|
headers: validated.headers,
|
|
4065
4128
|
body
|
|
4066
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;
|
|
4067
4135
|
}
|
|
4068
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
|
+
});
|
|
4069
4142
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4070
4143
|
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4071
4144
|
apiMethod: HTTP_METHOD.POST,
|
|
@@ -4082,211 +4155,279 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4082
4155
|
}
|
|
4083
4156
|
}
|
|
4084
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
|
+
});
|
|
4085
4162
|
}
|
|
4086
4163
|
async fetchAppointments(request, integration, loggedInUserId) {
|
|
4087
4164
|
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointments.name} Called`, {
|
|
4088
4165
|
request
|
|
4089
4166
|
});
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
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;
|
|
4101
4201
|
}
|
|
4102
|
-
const queryString = query.toString();
|
|
4103
|
-
const apiUrl = `/shop/appointment-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4104
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4105
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4106
|
-
url: apiUrl,
|
|
4107
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4108
|
-
headers: validatedIntegration.headers
|
|
4109
|
-
}, validatedIntegration, loggedInUserId);
|
|
4110
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4111
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4112
|
-
url: `${apiUrl}&page=${page}`,
|
|
4113
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4114
|
-
headers: validatedIntegration.headers
|
|
4115
|
-
}, validatedIntegration, loggedInUserId));
|
|
4116
|
-
return mapTrybeAppointmentsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4117
4202
|
}
|
|
4118
4203
|
async fetchSessions(request, integration, loggedInUserId) {
|
|
4119
4204
|
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessions.name} Called`, {
|
|
4120
4205
|
request
|
|
4121
4206
|
});
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
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;
|
|
4133
4241
|
}
|
|
4134
|
-
const queryString = query.toString();
|
|
4135
|
-
const apiUrl = `/shop/session-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
4136
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4137
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4138
|
-
url: apiUrl,
|
|
4139
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4140
|
-
headers: validatedIntegration.headers
|
|
4141
|
-
}, validatedIntegration, loggedInUserId);
|
|
4142
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4143
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4144
|
-
url: `${apiUrl}&page=${page}`,
|
|
4145
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4146
|
-
headers: validatedIntegration.headers
|
|
4147
|
-
}, validatedIntegration, loggedInUserId));
|
|
4148
|
-
return mapTrybeSessionsToSystemResponse(records, firstPageResponse.meta.total);
|
|
4149
4242
|
}
|
|
4150
4243
|
async fetchCourses(request, integration, loggedInUserId) {
|
|
4151
4244
|
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourses.name} Called`, {
|
|
4152
4245
|
request
|
|
4153
4246
|
});
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
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;
|
|
4165
4281
|
}
|
|
4166
|
-
const queryString = query.toString();
|
|
4167
|
-
const apiUrl = `/shop/course-types?organisation_id=${organisationId}` + (queryString ? `&${queryString}` : "");
|
|
4168
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4169
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4170
|
-
url: apiUrl,
|
|
4171
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4172
|
-
headers: validatedIntegration.headers
|
|
4173
|
-
}, validatedIntegration, loggedInUserId);
|
|
4174
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4175
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4176
|
-
url: `${apiUrl}&page=${page}`,
|
|
4177
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4178
|
-
headers: validatedIntegration.headers
|
|
4179
|
-
}, validatedIntegration, loggedInUserId));
|
|
4180
|
-
return mapTrybeCoursesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4181
4282
|
}
|
|
4182
4283
|
async fetchPractitioners(request, integration, loggedInUserId) {
|
|
4183
4284
|
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchPractitioners.name} Called`, {
|
|
4184
4285
|
request
|
|
4185
4286
|
});
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
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
|
+
}
|
|
4202
4311
|
}
|
|
4203
4312
|
async fetchCategories(request, integration, loggedInUserId) {
|
|
4204
4313
|
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCategories.name} Called`, {
|
|
4205
4314
|
request
|
|
4206
4315
|
});
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
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;
|
|
4218
4350
|
}
|
|
4219
|
-
const queryString = query.toString();
|
|
4220
|
-
const apiUrl = `/shop/organisations/${organisationId}/categories` + (queryString ? `?${queryString}` : "");
|
|
4221
|
-
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4222
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4223
|
-
url: apiUrl,
|
|
4224
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4225
|
-
headers: validatedIntegration.headers
|
|
4226
|
-
}, validatedIntegration, loggedInUserId);
|
|
4227
|
-
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
4228
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4229
|
-
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}`,
|
|
4230
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4231
|
-
headers: validatedIntegration.headers
|
|
4232
|
-
}, validatedIntegration, loggedInUserId));
|
|
4233
|
-
return mapTrybeCategoriesToSystemResponse(records, firstPageResponse.meta.total);
|
|
4234
4351
|
}
|
|
4235
4352
|
async fetchBookableItemsFromCredit(request, integration, loggedInUserId) {
|
|
4236
4353
|
this.logger.info(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchBookableItemsFromCredit.name} Called`, {
|
|
4237
4354
|
request
|
|
4238
4355
|
});
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
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;
|
|
4246
4380
|
}
|
|
4247
|
-
const queryString = query.toString();
|
|
4248
|
-
const apiUrl = `/shop/coupon-codes/${request.couponCodeId}/offering-discounts` + (queryString ? `?${queryString}` : "");
|
|
4249
|
-
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4250
|
-
apiMethod: HTTP_METHOD.GET,
|
|
4251
|
-
url: apiUrl,
|
|
4252
|
-
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4253
|
-
headers: validatedIntegration.headers
|
|
4254
|
-
}, validatedIntegration, loggedInUserId);
|
|
4255
|
-
return mapTrybeCouponCodeOfferingsToSystemResponse(response.data.offerings);
|
|
4256
4381
|
}
|
|
4257
4382
|
async fetchSessionAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
4258
4383
|
this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessionAvailabilityForOffering.name} Called`, {
|
|
4259
4384
|
request
|
|
4260
4385
|
});
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
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
|
+
}
|
|
4273
4406
|
}
|
|
4274
4407
|
async fetchAppointmentAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
4275
4408
|
this.logger.info(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointmentAvailabilityForOffering.name} Called`, {
|
|
4276
4409
|
request
|
|
4277
4410
|
});
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
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
|
+
}
|
|
4290
4431
|
}
|
|
4291
4432
|
};
|
|
4292
4433
|
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
@@ -4431,12 +4572,6 @@ exports.TrybeIntegrationResourceManagementService = class TrybeIntegrationResour
|
|
|
4431
4572
|
resourceMappingConfig.catalogingBy !== TRYBE_CATALOGING_BY_ENUM.PEOPLE_RESOURCE) {
|
|
4432
4573
|
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: catalogingBy must be PEOPLE_RESOURCE");
|
|
4433
4574
|
}
|
|
4434
|
-
if (resourceMappingConfig.isExternalCmsIntegrationEnabled === void 0 || typeof resourceMappingConfig.isExternalCmsIntegrationEnabled !== "boolean" || resourceMappingConfig.isExternalCmsIntegrationEnabled === false) {
|
|
4435
|
-
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: isExternalCmsIntegrationEnabled must be true");
|
|
4436
|
-
}
|
|
4437
|
-
if (!resourceMappingConfig.externalCmsUrl || !isValidHttpUrl(resourceMappingConfig.externalCmsUrl)) {
|
|
4438
|
-
throw new dvssBackendModuleUtility.CustomException(dvssBackendModuleUtility.ERROR_NAMES.BAD_REQUEST, "Invalid Trybe resource mapping config: externalCmsUrl must be a valid HTTP(S) URL");
|
|
4439
|
-
}
|
|
4440
4575
|
if (!resourceMappingConfig.supportedJourneys.some((journey) => VALID_JOURNEY_VALUES.has(journey))) {
|
|
4441
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");
|
|
4442
4577
|
}
|