@dv4resi/dvss-backend-module-offering-im 0.0.3 → 0.0.5
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/README.md +53 -79
- package/dist/index.d.ts +420 -18
- package/dist/index.js +757 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -603,10 +603,10 @@ var BaseAuth = class {
|
|
|
603
603
|
}
|
|
604
604
|
};
|
|
605
605
|
|
|
606
|
-
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/wellness/
|
|
607
|
-
var
|
|
606
|
+
// ../../packages/dvss-integration-libs/src/integration-operation-skeletons/capabilities/wellness/wellness-management.base.ts
|
|
607
|
+
var BaseWellnessManagement = class {
|
|
608
608
|
static {
|
|
609
|
-
__name(this, "
|
|
609
|
+
__name(this, "BaseWellnessManagement");
|
|
610
610
|
}
|
|
611
611
|
};
|
|
612
612
|
|
|
@@ -739,6 +739,29 @@ var INTEGRATION_PROVIDER_ENUM = /* @__PURE__ */ (function(INTEGRATION_PROVIDER_E
|
|
|
739
739
|
INTEGRATION_PROVIDER_ENUM2["TRYBE"] = "TRYBE";
|
|
740
740
|
return INTEGRATION_PROVIDER_ENUM2;
|
|
741
741
|
})({});
|
|
742
|
+
|
|
743
|
+
// ../../packages/dvss-integration-libs/src/integration-common-utils/models/wellness-management.model.ts
|
|
744
|
+
var BOOKABLE_ITEM_TYPE_ENUM = /* @__PURE__ */ (function(BOOKABLE_ITEM_TYPE_ENUM2) {
|
|
745
|
+
BOOKABLE_ITEM_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
|
|
746
|
+
BOOKABLE_ITEM_TYPE_ENUM2["SESSION"] = "SESSION";
|
|
747
|
+
BOOKABLE_ITEM_TYPE_ENUM2["COURSE"] = "COURSE";
|
|
748
|
+
return BOOKABLE_ITEM_TYPE_ENUM2;
|
|
749
|
+
})({});
|
|
750
|
+
var BOOKABLE_ITEM_STATUS_ENUM = /* @__PURE__ */ (function(BOOKABLE_ITEM_STATUS_ENUM2) {
|
|
751
|
+
BOOKABLE_ITEM_STATUS_ENUM2["ACTIVE"] = "ACTIVE";
|
|
752
|
+
BOOKABLE_ITEM_STATUS_ENUM2["INACTIVE"] = "INACTIVE";
|
|
753
|
+
return BOOKABLE_ITEM_STATUS_ENUM2;
|
|
754
|
+
})({});
|
|
755
|
+
var DAY_OF_WEEK = /* @__PURE__ */ (function(DAY_OF_WEEK2) {
|
|
756
|
+
DAY_OF_WEEK2["MON"] = "MON";
|
|
757
|
+
DAY_OF_WEEK2["TUE"] = "TUE";
|
|
758
|
+
DAY_OF_WEEK2["WED"] = "WED";
|
|
759
|
+
DAY_OF_WEEK2["THU"] = "THU";
|
|
760
|
+
DAY_OF_WEEK2["FRI"] = "FRI";
|
|
761
|
+
DAY_OF_WEEK2["SAT"] = "SAT";
|
|
762
|
+
DAY_OF_WEEK2["SUN"] = "SUN";
|
|
763
|
+
return DAY_OF_WEEK2;
|
|
764
|
+
})({});
|
|
742
765
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
743
766
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
744
767
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -950,7 +973,7 @@ function mapStatus(t) {
|
|
|
950
973
|
return CREDIT_STATUS_ENUM.ACTIVE;
|
|
951
974
|
}
|
|
952
975
|
__name(mapStatus, "mapStatus");
|
|
953
|
-
function mapTrybeCreditsToSystem(res) {
|
|
976
|
+
function mapTrybeCreditsToSystem(res, integration) {
|
|
954
977
|
const groups = /* @__PURE__ */ new Map();
|
|
955
978
|
for (const t of res.data) {
|
|
956
979
|
const key = `${t.coupon_name}|${t.issued_at}`;
|
|
@@ -959,10 +982,14 @@ function mapTrybeCreditsToSystem(res) {
|
|
|
959
982
|
groups.set(key, list);
|
|
960
983
|
}
|
|
961
984
|
const records = [];
|
|
985
|
+
let index = 0;
|
|
962
986
|
for (const [, items] of groups) {
|
|
963
987
|
const first = items[0];
|
|
964
988
|
const couponCodes = items.map((i) => i.coupon_code);
|
|
965
989
|
records.push({
|
|
990
|
+
id: BigInt(index + 1),
|
|
991
|
+
capabilityIntegrationId: integration.id,
|
|
992
|
+
projectId: integration.projectId,
|
|
966
993
|
name: first.coupon_name,
|
|
967
994
|
description: first.coupon_description ?? void 0,
|
|
968
995
|
type: CREDIT_TYPE_ENUM.COUPON,
|
|
@@ -984,6 +1011,7 @@ function mapTrybeCreditsToSystem(res) {
|
|
|
984
1011
|
}
|
|
985
1012
|
}
|
|
986
1013
|
});
|
|
1014
|
+
index++;
|
|
987
1015
|
}
|
|
988
1016
|
return {
|
|
989
1017
|
totalCount: records.length,
|
|
@@ -993,7 +1021,18 @@ function mapTrybeCreditsToSystem(res) {
|
|
|
993
1021
|
__name(mapTrybeCreditsToSystem, "mapTrybeCreditsToSystem");
|
|
994
1022
|
|
|
995
1023
|
// ../../packages/dvss-integration-trybe/src/capabilities/credit-management/credit-booking.service.ts
|
|
996
|
-
|
|
1024
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1025
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1026
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1027
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1028
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1029
|
+
}
|
|
1030
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
1031
|
+
function _ts_metadata10(k, v) {
|
|
1032
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1033
|
+
}
|
|
1034
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
1035
|
+
exports.TrybeCreditBooking = class _TrybeCreditBooking {
|
|
997
1036
|
static {
|
|
998
1037
|
__name(this, "TrybeCreditBooking");
|
|
999
1038
|
}
|
|
@@ -1024,40 +1063,725 @@ var TrybeCreditBooking = class _TrybeCreditBooking {
|
|
|
1024
1063
|
if (opts?.page != null) query.set("page", String(opts.page));
|
|
1025
1064
|
if (opts?.count != null) query.set("per_page", String(opts.count));
|
|
1026
1065
|
const statusFilterValues = opts?.filters?.[0]?.by === CREDIT_FILTER_BY_ENUM.STATUS ? opts.filters[0].values : [];
|
|
1027
|
-
if (statusFilterValues.
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1066
|
+
if (statusFilterValues.includes(CREDIT_STATUS_ENUM.EXPIRED)) {
|
|
1067
|
+
query.set("expired", "true");
|
|
1068
|
+
} else {
|
|
1069
|
+
query.set("expired", "false");
|
|
1070
|
+
}
|
|
1071
|
+
if (statusFilterValues.includes(CREDIT_STATUS_ENUM.REDEEMED)) {
|
|
1072
|
+
query.set("redeemed", "true");
|
|
1073
|
+
} else {
|
|
1074
|
+
query.set("redeemed", "false");
|
|
1075
|
+
}
|
|
1076
|
+
if (statusFilterValues.includes(CREDIT_STATUS_ENUM.REVOKED)) {
|
|
1077
|
+
query.set("revoked", "true");
|
|
1078
|
+
} else {
|
|
1079
|
+
query.set("revoked", "false");
|
|
1034
1080
|
}
|
|
1035
1081
|
const queryString = query.toString();
|
|
1036
|
-
const url = `/
|
|
1082
|
+
const url = `/customers/customers/${request.customerId}/credits` + (queryString ? `?${queryString}` : "");
|
|
1037
1083
|
const raw = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1038
1084
|
apiMethod: HTTP_METHOD.GET,
|
|
1039
1085
|
url,
|
|
1040
1086
|
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1041
1087
|
headers: validatedIntegration.headers
|
|
1042
1088
|
}, validatedIntegration, loggedInUserId);
|
|
1043
|
-
return mapTrybeCreditsToSystem(raw);
|
|
1089
|
+
return mapTrybeCreditsToSystem(raw, validatedIntegration);
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
exports.TrybeCreditBooking = _ts_decorate13([
|
|
1093
|
+
common.Injectable(),
|
|
1094
|
+
_ts_metadata10("design:type", Function),
|
|
1095
|
+
_ts_metadata10("design:paramtypes", [
|
|
1096
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
1097
|
+
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
1098
|
+
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
1099
|
+
])
|
|
1100
|
+
], exports.TrybeCreditBooking);
|
|
1101
|
+
|
|
1102
|
+
// ../../packages/dvss-integration-trybe/src/utils/date.util.ts
|
|
1103
|
+
function formatDateForTrybe(date, isStartOfDay) {
|
|
1104
|
+
const year = date.getFullYear();
|
|
1105
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
1106
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
1107
|
+
const hours = isStartOfDay ? "00" : "23";
|
|
1108
|
+
const minutes = isStartOfDay ? "00" : "59";
|
|
1109
|
+
const seconds = isStartOfDay ? "00" : "59";
|
|
1110
|
+
const offset = -date.getTimezoneOffset();
|
|
1111
|
+
const offsetHours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
|
1112
|
+
const offsetMinutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
|
1113
|
+
const offsetSign = offset >= 0 ? "+" : "-";
|
|
1114
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutes}`;
|
|
1115
|
+
}
|
|
1116
|
+
__name(formatDateForTrybe, "formatDateForTrybe");
|
|
1117
|
+
function extractTimeFromIsoString(isoString) {
|
|
1118
|
+
const timeMatch = isoString.match(/T(\d{2}:\d{2})/);
|
|
1119
|
+
return timeMatch ? timeMatch[1] : "";
|
|
1120
|
+
}
|
|
1121
|
+
__name(extractTimeFromIsoString, "extractTimeFromIsoString");
|
|
1122
|
+
function snakeToCamel(str) {
|
|
1123
|
+
return str.replaceAll(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1124
|
+
}
|
|
1125
|
+
__name(snakeToCamel, "snakeToCamel");
|
|
1126
|
+
function convertKeysToCamelCase(object) {
|
|
1127
|
+
if (object === null || object === void 0) {
|
|
1128
|
+
return object;
|
|
1129
|
+
}
|
|
1130
|
+
if (Array.isArray(object)) {
|
|
1131
|
+
return object.map((item) => convertKeysToCamelCase(item));
|
|
1132
|
+
}
|
|
1133
|
+
if (typeof object === "object") {
|
|
1134
|
+
const converted = {};
|
|
1135
|
+
for (const [key, value] of Object.entries(object)) {
|
|
1136
|
+
converted[snakeToCamel(key)] = convertKeysToCamelCase(value);
|
|
1137
|
+
}
|
|
1138
|
+
return converted;
|
|
1139
|
+
}
|
|
1140
|
+
return object;
|
|
1141
|
+
}
|
|
1142
|
+
__name(convertKeysToCamelCase, "convertKeysToCamelCase");
|
|
1143
|
+
|
|
1144
|
+
// ../../packages/dvss-integration-trybe/src/utils/pagination.util.ts
|
|
1145
|
+
var fetchAllPages = /* @__PURE__ */ __name(async (firstPageResponse, shouldFetchAll, fetchPage) => {
|
|
1146
|
+
const items = [];
|
|
1147
|
+
items.push(...firstPageResponse.data);
|
|
1148
|
+
if (!shouldFetchAll) {
|
|
1149
|
+
return items;
|
|
1150
|
+
}
|
|
1151
|
+
const lastPage = firstPageResponse.meta.last_page;
|
|
1152
|
+
for (let page = 2; page <= lastPage; page += 1) {
|
|
1153
|
+
const pageResponse = await fetchPage(page);
|
|
1154
|
+
items.push(...pageResponse.data);
|
|
1155
|
+
}
|
|
1156
|
+
return items;
|
|
1157
|
+
}, "fetchAllPages");
|
|
1158
|
+
|
|
1159
|
+
// ../../packages/dvss-integration-trybe/src/models/wellness-management.model.ts
|
|
1160
|
+
var TRYBE_OFFERING_TYPE_ENUM = /* @__PURE__ */ (function(TRYBE_OFFERING_TYPE_ENUM2) {
|
|
1161
|
+
TRYBE_OFFERING_TYPE_ENUM2["APPOINTMENT"] = "APPOINTMENT";
|
|
1162
|
+
TRYBE_OFFERING_TYPE_ENUM2["SESSION"] = "SESSION";
|
|
1163
|
+
TRYBE_OFFERING_TYPE_ENUM2["COURSE"] = "COURSE";
|
|
1164
|
+
return TRYBE_OFFERING_TYPE_ENUM2;
|
|
1165
|
+
})({});
|
|
1166
|
+
|
|
1167
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.mapper.ts
|
|
1168
|
+
var TRYBE_WEEKDAYS_MAPPING = {
|
|
1169
|
+
monday: DAY_OF_WEEK.MON,
|
|
1170
|
+
tuesday: DAY_OF_WEEK.TUE,
|
|
1171
|
+
wednesday: DAY_OF_WEEK.WED,
|
|
1172
|
+
thursday: DAY_OF_WEEK.THU,
|
|
1173
|
+
friday: DAY_OF_WEEK.FRI,
|
|
1174
|
+
saturday: DAY_OF_WEEK.SAT,
|
|
1175
|
+
sunday: DAY_OF_WEEK.SUN
|
|
1176
|
+
};
|
|
1177
|
+
function mapTrybeImageToMedia(image) {
|
|
1178
|
+
if (!image) return void 0;
|
|
1179
|
+
return {
|
|
1180
|
+
id: image.id,
|
|
1181
|
+
url: image.url,
|
|
1182
|
+
originalUrl: image.original_url,
|
|
1183
|
+
fileName: image.file_name,
|
|
1184
|
+
mimeType: image.mime_type
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
__name(mapTrybeImageToMedia, "mapTrybeImageToMedia");
|
|
1188
|
+
function mapTrybeWeekdays(weekdays) {
|
|
1189
|
+
return weekdays.map((day) => TRYBE_WEEKDAYS_MAPPING[day.toLowerCase()]);
|
|
1190
|
+
}
|
|
1191
|
+
__name(mapTrybeWeekdays, "mapTrybeWeekdays");
|
|
1192
|
+
function mapTrybePriceRuleToPriceMeta(priceRule, currency, index) {
|
|
1193
|
+
const normalizedCurrency = currency ? currency.toUpperCase() : "USD";
|
|
1194
|
+
if (!priceRule.weekdays || priceRule.weekdays.length === 0) {
|
|
1195
|
+
return [
|
|
1196
|
+
{
|
|
1197
|
+
id: BigInt(index),
|
|
1198
|
+
externalId: priceRule.id,
|
|
1199
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE,
|
|
1200
|
+
price: priceRule.price,
|
|
1201
|
+
currency: normalizedCurrency,
|
|
1202
|
+
config: priceRule
|
|
1203
|
+
}
|
|
1204
|
+
];
|
|
1205
|
+
}
|
|
1206
|
+
return [
|
|
1207
|
+
{
|
|
1208
|
+
id: BigInt(index),
|
|
1209
|
+
externalId: priceRule.id,
|
|
1210
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE,
|
|
1211
|
+
price: priceRule.price,
|
|
1212
|
+
currency: normalizedCurrency,
|
|
1213
|
+
configuredForDays: mapTrybeWeekdays(priceRule.weekdays)
|
|
1214
|
+
}
|
|
1215
|
+
];
|
|
1216
|
+
}
|
|
1217
|
+
__name(mapTrybePriceRuleToPriceMeta, "mapTrybePriceRuleToPriceMeta");
|
|
1218
|
+
function mapTrybePriceRulesToPrices(priceRules, currency, externalResourceId) {
|
|
1219
|
+
const normalizedCurrency = currency ? currency.toUpperCase() : "USD";
|
|
1220
|
+
return priceRules.map((priceRule, index) => ({
|
|
1221
|
+
id: BigInt(index + 1),
|
|
1222
|
+
label: void 0,
|
|
1223
|
+
currency: normalizedCurrency,
|
|
1224
|
+
price: priceRule.price,
|
|
1225
|
+
externalResourceId,
|
|
1226
|
+
configuredForDays: priceRule.weekdays ? mapTrybeWeekdays(priceRule.weekdays) : void 0,
|
|
1227
|
+
pricesMeta: mapTrybePriceRuleToPriceMeta(priceRule, currency, index + 1),
|
|
1228
|
+
config: priceRule
|
|
1229
|
+
}));
|
|
1230
|
+
}
|
|
1231
|
+
__name(mapTrybePriceRulesToPrices, "mapTrybePriceRulesToPrices");
|
|
1232
|
+
function mapTrybeAppointmentToBookableItem(appointment, index, linkedItems) {
|
|
1233
|
+
return {
|
|
1234
|
+
id: BigInt(index + 1),
|
|
1235
|
+
externalId: appointment.id,
|
|
1236
|
+
name: appointment.name,
|
|
1237
|
+
description: appointment.description,
|
|
1238
|
+
type: BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT,
|
|
1239
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE,
|
|
1240
|
+
icon: mapTrybeImageToMedia(appointment.image),
|
|
1241
|
+
primaryAsset: mapTrybeImageToMedia(appointment.image),
|
|
1242
|
+
prices: mapTrybePriceRulesToPrices(appointment.price_rules, appointment.currency, appointment.id),
|
|
1243
|
+
linkedBookableItems: linkedItems,
|
|
1244
|
+
updatedAt: appointment.updated_at ? new Date(appointment.updated_at) : void 0,
|
|
1245
|
+
meta: {
|
|
1246
|
+
// All Trybe-specific fields that don't map to system response
|
|
1247
|
+
externalId: appointment.id,
|
|
1248
|
+
productCode: appointment.product_code,
|
|
1249
|
+
siteIds: appointment.site_ids,
|
|
1250
|
+
roomIds: appointment.room_ids,
|
|
1251
|
+
equipmentIds: appointment.equipment_ids,
|
|
1252
|
+
practitionerIds: appointment.practitioner_ids,
|
|
1253
|
+
durations: appointment.durations,
|
|
1254
|
+
endBuffer: appointment.end_buffer,
|
|
1255
|
+
startTimeInterval: appointment.start_time_interval,
|
|
1256
|
+
maxAdvanceBookingsInterval: appointment.max_advance_bookings_interval,
|
|
1257
|
+
minAdvanceBookingsInterval: appointment.min_advance_bookings_interval,
|
|
1258
|
+
tagIds: appointment.tag_ids,
|
|
1259
|
+
tags: appointment.tags,
|
|
1260
|
+
categoryIds: appointment.category_ids,
|
|
1261
|
+
offeredOnline: appointment.offered_online,
|
|
1262
|
+
private: appointment.private,
|
|
1263
|
+
visibility: appointment.visibility,
|
|
1264
|
+
customersOnly: appointment.customers_only,
|
|
1265
|
+
membersOnly: appointment.members_only,
|
|
1266
|
+
membershipBookingWindowsEnabled: appointment.membership_booking_windows_enabled,
|
|
1267
|
+
membershipBookingWindows: appointment.membership_booking_windows,
|
|
1268
|
+
trybeMeta: appointment.meta,
|
|
1269
|
+
upsellOfferings: appointment.upsell_offerings,
|
|
1270
|
+
crossSellOfferings: appointment.cross_sell_offerings,
|
|
1271
|
+
relatedRetailOfferings: appointment.related_retail_offerings,
|
|
1272
|
+
customerCancellationPermitted: appointment.customer_cancellation_permitted,
|
|
1273
|
+
customerCancellationMinDuration: appointment.customer_cancellation_min_duration,
|
|
1274
|
+
minGuests: appointment.min_guests,
|
|
1275
|
+
maxGuests: appointment.max_guests,
|
|
1276
|
+
allocateMultiCapacityRooms: appointment.allocate_multi_capacity_rooms,
|
|
1277
|
+
enquiriesEnabled: appointment.enquiries_enabled,
|
|
1278
|
+
revenueCentre: appointment.revenue_centre,
|
|
1279
|
+
includePricingOnCalendar: appointment.include_pricing_on_calendar,
|
|
1280
|
+
maxPerBasket: appointment.max_per_basket,
|
|
1281
|
+
maxPerGuest: appointment.max_per_guest,
|
|
1282
|
+
shopPractitionerSelectionEnabled: appointment.shop_practitioner_selection_enabled,
|
|
1283
|
+
deletedAt: appointment.deleted_at
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
__name(mapTrybeAppointmentToBookableItem, "mapTrybeAppointmentToBookableItem");
|
|
1288
|
+
function mapTrybeSessionToBookableItem(session, index, linkedItems) {
|
|
1289
|
+
return {
|
|
1290
|
+
id: BigInt(index + 1),
|
|
1291
|
+
externalId: session.id,
|
|
1292
|
+
name: session.name,
|
|
1293
|
+
description: session.description,
|
|
1294
|
+
type: BOOKABLE_ITEM_TYPE_ENUM.SESSION,
|
|
1295
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE,
|
|
1296
|
+
icon: mapTrybeImageToMedia(session.image),
|
|
1297
|
+
primaryAsset: mapTrybeImageToMedia(session.image),
|
|
1298
|
+
prices: mapTrybePriceRulesToPrices(session.price_rules, session.currency, session.id),
|
|
1299
|
+
linkedBookableItems: linkedItems,
|
|
1300
|
+
updatedAt: session.updated_at ? new Date(session.updated_at) : void 0,
|
|
1301
|
+
meta: {
|
|
1302
|
+
// All Trybe-specific fields
|
|
1303
|
+
externalId: session.id,
|
|
1304
|
+
productCode: session.product_code,
|
|
1305
|
+
siteId: session.site_id,
|
|
1306
|
+
duration: session.duration,
|
|
1307
|
+
categoryIds: session.category_ids,
|
|
1308
|
+
offeredOnline: session.offered_online,
|
|
1309
|
+
private: session.private,
|
|
1310
|
+
visibility: session.visibility,
|
|
1311
|
+
customersOnly: session.customers_only,
|
|
1312
|
+
membersOnly: session.members_only,
|
|
1313
|
+
membershipBookingWindowsEnabled: session.membership_booking_windows_enabled,
|
|
1314
|
+
membershipBookingWindows: session.membership_booking_windows,
|
|
1315
|
+
maxBookingsPerMember: session.max_bookings_per_member,
|
|
1316
|
+
trybeMeta: session.meta,
|
|
1317
|
+
upsellOfferings: session.upsell_offerings,
|
|
1318
|
+
crossSellOfferings: session.cross_sell_offerings,
|
|
1319
|
+
relatedRetailOfferings: session.related_retail_offerings,
|
|
1320
|
+
customerCancellationPermitted: session.customer_cancellation_permitted,
|
|
1321
|
+
customerCancellationMinDuration: session.customer_cancellation_min_duration,
|
|
1322
|
+
waitlistEnabled: session.waitlist_enabled,
|
|
1323
|
+
maxAdvanceBookingsInterval: session.max_advance_bookings_interval,
|
|
1324
|
+
minAdvanceBookingsInterval: session.min_advance_bookings_interval,
|
|
1325
|
+
minGuests: session.min_guests,
|
|
1326
|
+
maxGuests: session.max_guests,
|
|
1327
|
+
maxBasketsPerSession: session.max_baskets_per_session,
|
|
1328
|
+
recurrenceGroups: session.recurrence_groups,
|
|
1329
|
+
revenueCentre: session.revenue_centre,
|
|
1330
|
+
includePricingOnCalendar: session.include_pricing_on_calendar,
|
|
1331
|
+
maxPerBasket: session.max_per_basket,
|
|
1332
|
+
maxPerGuest: session.max_per_guest,
|
|
1333
|
+
deletedAt: session.deleted_at
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
__name(mapTrybeSessionToBookableItem, "mapTrybeSessionToBookableItem");
|
|
1338
|
+
function mapTrybeCourseToBookableItem(course, index) {
|
|
1339
|
+
return {
|
|
1340
|
+
id: BigInt(index + 1),
|
|
1341
|
+
externalId: course.id,
|
|
1342
|
+
name: course.name,
|
|
1343
|
+
description: course.description,
|
|
1344
|
+
type: BOOKABLE_ITEM_TYPE_ENUM.COURSE,
|
|
1345
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE,
|
|
1346
|
+
icon: mapTrybeImageToMedia(course.image),
|
|
1347
|
+
primaryAsset: mapTrybeImageToMedia(course.image),
|
|
1348
|
+
prices: mapTrybePriceRulesToPrices(course.price_rules, course.currency, course.id),
|
|
1349
|
+
updatedAt: course.updated_at ? new Date(course.updated_at) : void 0,
|
|
1350
|
+
meta: {
|
|
1351
|
+
// All Trybe-specific fields
|
|
1352
|
+
externalId: course.id,
|
|
1353
|
+
productCode: course.product_code,
|
|
1354
|
+
couponId: course.coupon_id,
|
|
1355
|
+
offerings: course.offerings.map((offering) => ({
|
|
1356
|
+
offeringType: offering.offering_type,
|
|
1357
|
+
offeringId: offering.offering_id,
|
|
1358
|
+
offeringName: offering.offering_name
|
|
1359
|
+
})),
|
|
1360
|
+
offeringType: course.offering_type,
|
|
1361
|
+
offeringId: course.offering_id,
|
|
1362
|
+
quantity: course.quantity,
|
|
1363
|
+
creditsValidityInterval: course.credits_validity_interval,
|
|
1364
|
+
siteId: course.site_id,
|
|
1365
|
+
categoryIds: course.category_ids,
|
|
1366
|
+
offeredOnline: course.offered_online,
|
|
1367
|
+
private: course.private,
|
|
1368
|
+
visibility: course.visibility,
|
|
1369
|
+
customersOnly: course.customers_only,
|
|
1370
|
+
membersOnly: course.members_only,
|
|
1371
|
+
trybeMeta: course.meta,
|
|
1372
|
+
upsellOfferings: course.upsell_offerings,
|
|
1373
|
+
crossSellOfferings: course.cross_sell_offerings,
|
|
1374
|
+
relatedRetailOfferings: course.related_retail_offerings,
|
|
1375
|
+
availabilityRules: course.availability_rules,
|
|
1376
|
+
revenueCentre: course.revenue_centre,
|
|
1377
|
+
deletedAt: course.deleted_at
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
__name(mapTrybeCourseToBookableItem, "mapTrybeCourseToBookableItem");
|
|
1382
|
+
function mapTrybeCategoryToBookableItemCategory(category, index) {
|
|
1383
|
+
return {
|
|
1384
|
+
id: BigInt(index + 1),
|
|
1385
|
+
externalId: category.id,
|
|
1386
|
+
name: category.name,
|
|
1387
|
+
meta: {
|
|
1388
|
+
voucherApplicable: category.voucher_applicable
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
__name(mapTrybeCategoryToBookableItemCategory, "mapTrybeCategoryToBookableItemCategory");
|
|
1393
|
+
function mapTrybeAppointmentsToSystemResponse(appointments, totalCount, courseLookup) {
|
|
1394
|
+
const records = appointments.map((apt, index) => {
|
|
1395
|
+
const linkedCourses = courseLookup?.get(apt.id) ?? [];
|
|
1396
|
+
const linkedItems = linkedCourses.map((course, courseIndex) => mapTrybeCourseToBookableItem(course, courseIndex));
|
|
1397
|
+
return mapTrybeAppointmentToBookableItem(apt, index, linkedItems.length > 0 ? linkedItems : void 0);
|
|
1398
|
+
});
|
|
1399
|
+
return {
|
|
1400
|
+
totalCount,
|
|
1401
|
+
records
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
__name(mapTrybeAppointmentsToSystemResponse, "mapTrybeAppointmentsToSystemResponse");
|
|
1405
|
+
function mapTrybeSessionsToSystemResponse(sessions, totalCount, courseLookup) {
|
|
1406
|
+
const records = sessions.map((session, index) => {
|
|
1407
|
+
const linkedCourses = courseLookup?.get(session.id) ?? [];
|
|
1408
|
+
const linkedItems = linkedCourses.map((course, courseIndex) => mapTrybeCourseToBookableItem(course, courseIndex));
|
|
1409
|
+
return mapTrybeSessionToBookableItem(session, index, linkedItems.length > 0 ? linkedItems : void 0);
|
|
1410
|
+
});
|
|
1411
|
+
return {
|
|
1412
|
+
totalCount,
|
|
1413
|
+
records
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
__name(mapTrybeSessionsToSystemResponse, "mapTrybeSessionsToSystemResponse");
|
|
1417
|
+
function mapTrybeCoursesToSystemResponse(courses, totalCount) {
|
|
1418
|
+
const records = courses.map((course, index) => mapTrybeCourseToBookableItem(course, index));
|
|
1419
|
+
return {
|
|
1420
|
+
totalCount,
|
|
1421
|
+
records
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
__name(mapTrybeCoursesToSystemResponse, "mapTrybeCoursesToSystemResponse");
|
|
1425
|
+
function mapTrybeCategoriesToSystemResponse(categories, totalCount) {
|
|
1426
|
+
const records = categories.map((category, index) => mapTrybeCategoryToBookableItemCategory(category, index));
|
|
1427
|
+
return {
|
|
1428
|
+
totalCount,
|
|
1429
|
+
records
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
__name(mapTrybeCategoriesToSystemResponse, "mapTrybeCategoriesToSystemResponse");
|
|
1433
|
+
function mapTrybeOfferingTypeToBookableItemType(offeringType) {
|
|
1434
|
+
switch (offeringType) {
|
|
1435
|
+
case TRYBE_OFFERING_TYPE_ENUM.APPOINTMENT:
|
|
1436
|
+
return BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT;
|
|
1437
|
+
case TRYBE_OFFERING_TYPE_ENUM.SESSION:
|
|
1438
|
+
return BOOKABLE_ITEM_TYPE_ENUM.SESSION;
|
|
1439
|
+
case TRYBE_OFFERING_TYPE_ENUM.COURSE:
|
|
1440
|
+
return BOOKABLE_ITEM_TYPE_ENUM.COURSE;
|
|
1441
|
+
default:
|
|
1442
|
+
return BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
__name(mapTrybeOfferingTypeToBookableItemType, "mapTrybeOfferingTypeToBookableItemType");
|
|
1446
|
+
function mapTrybeCouponCodeOfferingToBookableItem(offering, index) {
|
|
1447
|
+
return {
|
|
1448
|
+
id: BigInt(index + 1),
|
|
1449
|
+
externalId: offering.offering_id,
|
|
1450
|
+
name: offering.offering_name,
|
|
1451
|
+
type: mapTrybeOfferingTypeToBookableItemType(offering.offering_type),
|
|
1452
|
+
status: BOOKABLE_ITEM_STATUS_ENUM.ACTIVE
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
__name(mapTrybeCouponCodeOfferingToBookableItem, "mapTrybeCouponCodeOfferingToBookableItem");
|
|
1456
|
+
function mapTrybeCouponCodeOfferingsToSystemResponse(offerings) {
|
|
1457
|
+
const records = offerings.map((offering, index) => mapTrybeCouponCodeOfferingToBookableItem(offering, index));
|
|
1458
|
+
return {
|
|
1459
|
+
totalCount: records.length,
|
|
1460
|
+
records
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
__name(mapTrybeCouponCodeOfferingsToSystemResponse, "mapTrybeCouponCodeOfferingsToSystemResponse");
|
|
1464
|
+
function groupByDate(items, getDateKey) {
|
|
1465
|
+
const result = {};
|
|
1466
|
+
for (const item of items) {
|
|
1467
|
+
const key = getDateKey(item);
|
|
1468
|
+
if (!result[key]) result[key] = [];
|
|
1469
|
+
result[key].push(item);
|
|
1470
|
+
}
|
|
1471
|
+
return result;
|
|
1472
|
+
}
|
|
1473
|
+
__name(groupByDate, "groupByDate");
|
|
1474
|
+
function mapTrybeSessionAvailabilityToSystemResponse(sessions) {
|
|
1475
|
+
const filtered = sessions.filter((s) => s.remaining_capacity > 0);
|
|
1476
|
+
const grouped = groupByDate(filtered, (s) => {
|
|
1477
|
+
const dateMatch = s.start_time.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
1478
|
+
return dateMatch ? dateMatch[1] : "";
|
|
1479
|
+
});
|
|
1480
|
+
const dates = Object.entries(grouped).filter(([date]) => date !== "").map(([date, sessionList]) => {
|
|
1481
|
+
const time = sessionList.map((session) => {
|
|
1482
|
+
const fromTime = extractTimeFromIsoString(session.start_time);
|
|
1483
|
+
const toTime = extractTimeFromIsoString(session.end_time);
|
|
1484
|
+
const { start_time: _s, end_time: _e, ...meta } = session;
|
|
1485
|
+
const camelCaseMeta = convertKeysToCamelCase(meta);
|
|
1486
|
+
return {
|
|
1487
|
+
fromTime,
|
|
1488
|
+
toTime,
|
|
1489
|
+
meta: camelCaseMeta
|
|
1490
|
+
};
|
|
1491
|
+
});
|
|
1492
|
+
return {
|
|
1493
|
+
date: new Date(date),
|
|
1494
|
+
meta: {},
|
|
1495
|
+
time
|
|
1496
|
+
};
|
|
1497
|
+
}).sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
1498
|
+
return {
|
|
1499
|
+
dates
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
__name(mapTrybeSessionAvailabilityToSystemResponse, "mapTrybeSessionAvailabilityToSystemResponse");
|
|
1503
|
+
function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
1504
|
+
const filtered = slots.filter((s) => s.quantity_available > 0);
|
|
1505
|
+
const grouped = groupByDate(filtered, (s) => {
|
|
1506
|
+
const dateMatch = s.start_time.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
1507
|
+
return dateMatch ? dateMatch[1] : "";
|
|
1508
|
+
});
|
|
1509
|
+
const dates = Object.entries(grouped).filter(([date]) => date !== "").map(([date, slotList]) => {
|
|
1510
|
+
const time = slotList.map((slot) => {
|
|
1511
|
+
const fromTime = extractTimeFromIsoString(slot.start_time);
|
|
1512
|
+
const toTime = extractTimeFromIsoString(slot.end_time);
|
|
1513
|
+
const { start_time: _s, end_time: _e, ...meta } = slot;
|
|
1514
|
+
const camelCaseMeta = convertKeysToCamelCase(meta);
|
|
1515
|
+
return {
|
|
1516
|
+
fromTime,
|
|
1517
|
+
toTime,
|
|
1518
|
+
meta: camelCaseMeta
|
|
1519
|
+
};
|
|
1520
|
+
});
|
|
1521
|
+
return {
|
|
1522
|
+
date: new Date(date),
|
|
1523
|
+
meta: {},
|
|
1524
|
+
time
|
|
1525
|
+
};
|
|
1526
|
+
}).sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
1527
|
+
return {
|
|
1528
|
+
dates
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
1532
|
+
|
|
1533
|
+
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
1534
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
1535
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1536
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1537
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1538
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1539
|
+
}
|
|
1540
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
1541
|
+
function _ts_metadata11(k, v) {
|
|
1542
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1543
|
+
}
|
|
1544
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1545
|
+
exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
1546
|
+
static {
|
|
1547
|
+
__name(this, "TrybeWellnessManagement");
|
|
1548
|
+
}
|
|
1549
|
+
logger;
|
|
1550
|
+
trafficGatewayService;
|
|
1551
|
+
trybeAuthService;
|
|
1552
|
+
fileName = "wellness-management.service";
|
|
1553
|
+
constructor(logger, trafficGatewayService, trybeAuthService) {
|
|
1554
|
+
this.logger = logger;
|
|
1555
|
+
this.trafficGatewayService = trafficGatewayService;
|
|
1556
|
+
this.trybeAuthService = trybeAuthService;
|
|
1557
|
+
}
|
|
1558
|
+
fetchPractitioners() {
|
|
1559
|
+
throw new Error("Method not implemented.");
|
|
1560
|
+
}
|
|
1561
|
+
fetchWellnessAppointmentSession() {
|
|
1562
|
+
throw new Error("Method not implemented.");
|
|
1563
|
+
}
|
|
1564
|
+
checkWellnessAppointmentSessionAvailability() {
|
|
1565
|
+
throw new Error("Method not implemented.");
|
|
1566
|
+
}
|
|
1567
|
+
createWellnessAppointmentSessionOrder() {
|
|
1568
|
+
throw new Error("Method not implemented.");
|
|
1569
|
+
}
|
|
1570
|
+
addWellnessAppointmentSessionOrderItems() {
|
|
1571
|
+
throw new Error("Method not implemented.");
|
|
1572
|
+
}
|
|
1573
|
+
confirmWellnessAppointmentSessionOrder() {
|
|
1574
|
+
throw new Error("Method not implemented.");
|
|
1575
|
+
}
|
|
1576
|
+
async fetchAppointments(request, integration, loggedInUserId) {
|
|
1577
|
+
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointments.name} Called`, {
|
|
1578
|
+
request
|
|
1579
|
+
});
|
|
1580
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1581
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
1582
|
+
if (request.shouldFetchAllAppointments && request.options?.page !== void 0) {
|
|
1583
|
+
throw new Error("Pagination options are not supported when fetching all appointments.");
|
|
1584
|
+
}
|
|
1585
|
+
const query = new URLSearchParams();
|
|
1586
|
+
if (request.options?.page != null) {
|
|
1587
|
+
query.set("page", String(request.options.page));
|
|
1588
|
+
}
|
|
1589
|
+
if (request.options?.count != null) {
|
|
1590
|
+
query.set("per_page", String(request.options.count));
|
|
1591
|
+
}
|
|
1592
|
+
const queryString = query.toString();
|
|
1593
|
+
const apiUrl = `/shop/appointment-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
1594
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1595
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1596
|
+
url: apiUrl,
|
|
1597
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1598
|
+
headers: validatedIntegration.headers
|
|
1599
|
+
}, validatedIntegration, loggedInUserId);
|
|
1600
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllAppointments, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
1601
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1602
|
+
url: `${apiUrl}&page=${page}`,
|
|
1603
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1604
|
+
headers: validatedIntegration.headers
|
|
1605
|
+
}, validatedIntegration, loggedInUserId));
|
|
1606
|
+
return mapTrybeAppointmentsToSystemResponse(records, firstPageResponse.meta.total);
|
|
1607
|
+
}
|
|
1608
|
+
async fetchSessions(request, integration, loggedInUserId) {
|
|
1609
|
+
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessions.name} Called`, {
|
|
1610
|
+
request
|
|
1611
|
+
});
|
|
1612
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1613
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
1614
|
+
if (request.shouldFetchAllSessions && request.options?.page !== void 0) {
|
|
1615
|
+
throw new Error("Pagination options are not supported when fetching all sessions.");
|
|
1616
|
+
}
|
|
1617
|
+
const query = new URLSearchParams();
|
|
1618
|
+
if (request.options?.page != null) {
|
|
1619
|
+
query.set("page", String(request.options.page));
|
|
1620
|
+
}
|
|
1621
|
+
if (request.options?.count != null) {
|
|
1622
|
+
query.set("per_page", String(request.options.count));
|
|
1623
|
+
}
|
|
1624
|
+
const queryString = query.toString();
|
|
1625
|
+
const apiUrl = `/shop/session-types?site_id=${siteId}` + (request.practitionerIds && request.practitionerIds.length > 0 ? `&practitioner_id=${request.practitionerIds.join(",")}` : "") + (queryString ? `&${queryString}` : "");
|
|
1626
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1627
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1628
|
+
url: apiUrl,
|
|
1629
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1630
|
+
headers: validatedIntegration.headers
|
|
1631
|
+
}, validatedIntegration, loggedInUserId);
|
|
1632
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllSessions, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
1633
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1634
|
+
url: `${apiUrl}&page=${page}`,
|
|
1635
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1636
|
+
headers: validatedIntegration.headers
|
|
1637
|
+
}, validatedIntegration, loggedInUserId));
|
|
1638
|
+
return mapTrybeSessionsToSystemResponse(records, firstPageResponse.meta.total);
|
|
1639
|
+
}
|
|
1640
|
+
async fetchCourses(request, integration, loggedInUserId) {
|
|
1641
|
+
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourses.name} Called`, {
|
|
1642
|
+
request
|
|
1643
|
+
});
|
|
1644
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1645
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
1646
|
+
if (request.shouldFetchAllCourses && request.options?.page !== void 0) {
|
|
1647
|
+
throw new Error("Pagination options are not supported when fetching all courses.");
|
|
1648
|
+
}
|
|
1649
|
+
const query = new URLSearchParams();
|
|
1650
|
+
if (request.options?.page != null) {
|
|
1651
|
+
query.set("page", String(request.options.page));
|
|
1652
|
+
}
|
|
1653
|
+
if (request.options?.count != null) {
|
|
1654
|
+
query.set("per_page", String(request.options.count));
|
|
1655
|
+
}
|
|
1656
|
+
const queryString = query.toString();
|
|
1657
|
+
const apiUrl = `/shop/course-types?organisation_id=${organisationId}` + (queryString ? `&${queryString}` : "");
|
|
1658
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1659
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1660
|
+
url: apiUrl,
|
|
1661
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1662
|
+
headers: validatedIntegration.headers
|
|
1663
|
+
}, validatedIntegration, loggedInUserId);
|
|
1664
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCourses, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
1665
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1666
|
+
url: `${apiUrl}&page=${page}`,
|
|
1667
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1668
|
+
headers: validatedIntegration.headers
|
|
1669
|
+
}, validatedIntegration, loggedInUserId));
|
|
1670
|
+
return mapTrybeCoursesToSystemResponse(records, firstPageResponse.meta.total);
|
|
1671
|
+
}
|
|
1672
|
+
async fetchCategories(request, integration, loggedInUserId) {
|
|
1673
|
+
this.logger.info(loggedInUserId, this.fetchCategories.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCategories.name} Called`, {
|
|
1674
|
+
request
|
|
1675
|
+
});
|
|
1676
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1677
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
1678
|
+
if (request.shouldFetchAllCategories && request.options?.page !== void 0) {
|
|
1679
|
+
throw new Error("Pagination options are not supported when fetching all categories.");
|
|
1680
|
+
}
|
|
1681
|
+
const query = new URLSearchParams();
|
|
1682
|
+
if (request.options?.page != null) {
|
|
1683
|
+
query.set("page", String(request.options.page));
|
|
1684
|
+
}
|
|
1685
|
+
if (request.options?.count != null) {
|
|
1686
|
+
query.set("per_page", String(request.options.count));
|
|
1687
|
+
}
|
|
1688
|
+
const queryString = query.toString();
|
|
1689
|
+
const apiUrl = `/shop/organisations/${organisationId}/categories` + (queryString ? `?${queryString}` : "");
|
|
1690
|
+
const firstPageResponse = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1691
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1692
|
+
url: apiUrl,
|
|
1693
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1694
|
+
headers: validatedIntegration.headers
|
|
1695
|
+
}, validatedIntegration, loggedInUserId);
|
|
1696
|
+
const records = await fetchAllPages(firstPageResponse, request.shouldFetchAllCategories, (page) => this.trafficGatewayService.executeIntegrationRequest({
|
|
1697
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1698
|
+
url: `${apiUrl}${apiUrl.includes("?") ? "&" : "?"}page=${page}`,
|
|
1699
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1700
|
+
headers: validatedIntegration.headers
|
|
1701
|
+
}, validatedIntegration, loggedInUserId));
|
|
1702
|
+
return mapTrybeCategoriesToSystemResponse(records, firstPageResponse.meta.total);
|
|
1703
|
+
}
|
|
1704
|
+
async fetchBookableItemsFromCredit(request, integration, loggedInUserId) {
|
|
1705
|
+
this.logger.info(loggedInUserId, this.fetchBookableItemsFromCredit.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchBookableItemsFromCredit.name} Called`, {
|
|
1706
|
+
request
|
|
1707
|
+
});
|
|
1708
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1709
|
+
const query = new URLSearchParams();
|
|
1710
|
+
if (request.options?.page != null) {
|
|
1711
|
+
query.set("page", String(request.options.page));
|
|
1712
|
+
}
|
|
1713
|
+
if (request.options?.count != null) {
|
|
1714
|
+
query.set("per_page", String(request.options.count));
|
|
1715
|
+
}
|
|
1716
|
+
const queryString = query.toString();
|
|
1717
|
+
const apiUrl = `/shop/coupon-codes/${request.couponCodeId}/offering-discounts` + (queryString ? `?${queryString}` : "");
|
|
1718
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1719
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1720
|
+
url: apiUrl,
|
|
1721
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1722
|
+
headers: validatedIntegration.headers
|
|
1723
|
+
}, validatedIntegration, loggedInUserId);
|
|
1724
|
+
return mapTrybeCouponCodeOfferingsToSystemResponse(response.data.offerings);
|
|
1725
|
+
}
|
|
1726
|
+
async fetchSessionAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
1727
|
+
this.logger.info(loggedInUserId, this.fetchSessionAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessionAvailabilityForOffering.name} Called`, {
|
|
1728
|
+
request
|
|
1729
|
+
});
|
|
1730
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1731
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
1732
|
+
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
|
|
1733
|
+
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
|
|
1734
|
+
const apiUrl = `/shop/item-availability/sessions/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&offeringId=${request.externalOfferingBookableItemId}`;
|
|
1735
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1736
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1737
|
+
url: apiUrl,
|
|
1738
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1739
|
+
headers: validatedIntegration.headers
|
|
1740
|
+
}, validatedIntegration, loggedInUserId);
|
|
1741
|
+
return mapTrybeSessionAvailabilityToSystemResponse(response.data);
|
|
1742
|
+
}
|
|
1743
|
+
async fetchAppointmentAvailabilityForOffering(request, integration, loggedInUserId) {
|
|
1744
|
+
this.logger.info(loggedInUserId, this.fetchAppointmentAvailabilityForOffering.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointmentAvailabilityForOffering.name} Called`, {
|
|
1745
|
+
request
|
|
1746
|
+
});
|
|
1747
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
1748
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
1749
|
+
const formattedDateTimeFrom = formatDateForTrybe(request.dateTimeFrom, true);
|
|
1750
|
+
const formattedDateTimeTo = formatDateForTrybe(request.dateTimeTo, false);
|
|
1751
|
+
const apiUrl = `/shop/item-availability/appointment-slots/${siteId}/${request.externalOfferingBookableItemId}?date_time_from=${encodeURIComponent(formattedDateTimeFrom)}&date_time_to=${encodeURIComponent(formattedDateTimeTo)}&OfferingID=${request.externalOfferingBookableItemId}`;
|
|
1752
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
1753
|
+
apiMethod: HTTP_METHOD.GET,
|
|
1754
|
+
url: apiUrl,
|
|
1755
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
1756
|
+
headers: validatedIntegration.headers
|
|
1757
|
+
}, validatedIntegration, loggedInUserId);
|
|
1758
|
+
return mapTrybeAppointmentAvailabilityToSystemResponse(response.data);
|
|
1044
1759
|
}
|
|
1045
1760
|
};
|
|
1761
|
+
exports.TrybeWellnessManagement = _ts_decorate14([
|
|
1762
|
+
common.Injectable(),
|
|
1763
|
+
_ts_metadata11("design:type", Function),
|
|
1764
|
+
_ts_metadata11("design:paramtypes", [
|
|
1765
|
+
typeof dvssBackendModuleUtility.LoggerService === "undefined" ? Object : dvssBackendModuleUtility.LoggerService,
|
|
1766
|
+
typeof exports.TrafficGatewayService === "undefined" ? Object : exports.TrafficGatewayService,
|
|
1767
|
+
typeof exports.TrybeAuthService === "undefined" ? Object : exports.TrybeAuthService
|
|
1768
|
+
])
|
|
1769
|
+
], exports.TrybeWellnessManagement);
|
|
1046
1770
|
|
|
1047
1771
|
// ../../packages/dvss-integration-trybe/src/app.module.ts
|
|
1048
|
-
function
|
|
1772
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
1049
1773
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1050
1774
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1051
1775
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1052
1776
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1053
1777
|
}
|
|
1054
|
-
__name(
|
|
1778
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
1055
1779
|
exports.IntegrationTrybeModule = class AppModule2 {
|
|
1056
1780
|
static {
|
|
1057
1781
|
__name(this, "AppModule");
|
|
1058
1782
|
}
|
|
1059
1783
|
};
|
|
1060
|
-
exports.IntegrationTrybeModule =
|
|
1784
|
+
exports.IntegrationTrybeModule = _ts_decorate15([
|
|
1061
1785
|
common.Module({
|
|
1062
1786
|
imports: [
|
|
1063
1787
|
// Load environment variables from root .env file
|
|
@@ -1076,44 +1800,32 @@ exports.IntegrationTrybeModule = _ts_decorate13([
|
|
|
1076
1800
|
AppService2,
|
|
1077
1801
|
exports.TrybeAuthService,
|
|
1078
1802
|
exports.TrybeCustomerManagement,
|
|
1079
|
-
TrybeCreditBooking
|
|
1803
|
+
exports.TrybeCreditBooking,
|
|
1804
|
+
exports.TrybeWellnessManagement
|
|
1080
1805
|
],
|
|
1081
1806
|
exports: [
|
|
1082
1807
|
exports.TrybeAuthService,
|
|
1083
1808
|
exports.TrybeCustomerManagement,
|
|
1084
|
-
TrybeCreditBooking
|
|
1809
|
+
exports.TrybeCreditBooking,
|
|
1810
|
+
exports.TrybeWellnessManagement
|
|
1085
1811
|
]
|
|
1086
1812
|
})
|
|
1087
1813
|
], exports.IntegrationTrybeModule);
|
|
1088
1814
|
|
|
1089
|
-
// ../../packages/dvss-integration-trybe/src/capabilities/package-management/package-management.service.ts
|
|
1090
|
-
var TrybePackageManagement = class {
|
|
1091
|
-
static {
|
|
1092
|
-
__name(this, "TrybePackageManagement");
|
|
1093
|
-
}
|
|
1094
|
-
};
|
|
1095
|
-
|
|
1096
|
-
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/appointment-booking.service.ts
|
|
1097
|
-
var TrybeWellnessAppointmentBooking = class extends BaseWellnessAppointmentBooking {
|
|
1098
|
-
static {
|
|
1099
|
-
__name(this, "TrybeWellnessAppointmentBooking");
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
1815
|
// src/app.module.ts
|
|
1104
|
-
function
|
|
1816
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
1105
1817
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1106
1818
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1107
1819
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1108
1820
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1109
1821
|
}
|
|
1110
|
-
__name(
|
|
1822
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
1111
1823
|
exports.OfferingIntegrationManager = class AppModule3 {
|
|
1112
1824
|
static {
|
|
1113
1825
|
__name(this, "AppModule");
|
|
1114
1826
|
}
|
|
1115
1827
|
};
|
|
1116
|
-
exports.OfferingIntegrationManager =
|
|
1828
|
+
exports.OfferingIntegrationManager = _ts_decorate16([
|
|
1117
1829
|
common.Module({
|
|
1118
1830
|
imports: [
|
|
1119
1831
|
exports.IntegrationTrybeModule,
|
|
@@ -1134,6 +1846,8 @@ exports.OfferingIntegrationManager = _ts_decorate14([
|
|
|
1134
1846
|
})
|
|
1135
1847
|
], exports.OfferingIntegrationManager);
|
|
1136
1848
|
|
|
1849
|
+
exports.BOOKABLE_ITEM_STATUS_ENUM = BOOKABLE_ITEM_STATUS_ENUM;
|
|
1850
|
+
exports.BOOKABLE_ITEM_TYPE_ENUM = BOOKABLE_ITEM_TYPE_ENUM;
|
|
1137
1851
|
exports.BaseAccountingContactManagement = BaseAccountingContactManagement;
|
|
1138
1852
|
exports.BaseAccountingCreditNoteManagement = BaseAccountingCreditNoteManagement;
|
|
1139
1853
|
exports.BaseAccountingCustomerManagement = BaseAccountingCustomerManagement;
|
|
@@ -1150,15 +1864,18 @@ exports.BasePackageManagement = BasePackageManagement;
|
|
|
1150
1864
|
exports.BasePayment = BasePayment;
|
|
1151
1865
|
exports.BasePaymentMethodManagement = BasePaymentMethodManagement;
|
|
1152
1866
|
exports.BasePaymentUserManagement = BasePaymentUserManagement;
|
|
1153
|
-
exports.
|
|
1867
|
+
exports.BaseWellnessManagement = BaseWellnessManagement;
|
|
1154
1868
|
exports.CREDIT_FILTER_BY_ENUM = CREDIT_FILTER_BY_ENUM;
|
|
1155
1869
|
exports.CREDIT_STATUS_ENUM = CREDIT_STATUS_ENUM;
|
|
1156
1870
|
exports.CREDIT_TYPE_ENUM = CREDIT_TYPE_ENUM;
|
|
1871
|
+
exports.DAY_OF_WEEK = DAY_OF_WEEK;
|
|
1157
1872
|
exports.HTTP_METHOD = HTTP_METHOD;
|
|
1158
1873
|
exports.INTEGRATION_PROVIDER_ENUM = INTEGRATION_PROVIDER_ENUM;
|
|
1159
1874
|
exports.TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY = TRAFFIC_ROUTER_CONFIGURATION_STORE_KEY;
|
|
1160
|
-
exports.
|
|
1161
|
-
exports.
|
|
1162
|
-
exports.
|
|
1875
|
+
exports.TRYBE_OFFERING_TYPE_ENUM = TRYBE_OFFERING_TYPE_ENUM;
|
|
1876
|
+
exports.convertKeysToCamelCase = convertKeysToCamelCase;
|
|
1877
|
+
exports.extractTimeFromIsoString = extractTimeFromIsoString;
|
|
1878
|
+
exports.fetchAllPages = fetchAllPages;
|
|
1879
|
+
exports.formatDateForTrybe = formatDateForTrybe;
|
|
1163
1880
|
//# sourceMappingURL=index.js.map
|
|
1164
1881
|
//# sourceMappingURL=index.js.map
|