@dv4resi/dvss-backend-module-offering-im 0.0.13 → 0.0.14
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 +178 -8
- package/dist/index.js +130 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONFIGURED_FOR_TYPE_ENUM, MEDIA_PROVIDER_ENUM, DAY_OF_WEEK, OFFERING_RESOURCE_TYPE, STATUS } from '@dv4resi/dvss-backend-module-datastore/dist/datastore/models';
|
|
2
|
-
import { LoggerService, GraphQLContext, AddAPIResponse } from '@dv4resi/dvss-backend-module-utility';
|
|
2
|
+
import { LoggerService, GraphQLContext, IMedia, AddAPIResponse } from '@dv4resi/dvss-backend-module-utility';
|
|
3
3
|
import { HttpService } from '@nestjs/axios';
|
|
4
4
|
import { CAPABILITY_PROVIDER_INTEGRATION_ENUM, CAPABILITY_CATEGORY_ENUM, ICapability } from '@dv4resi/dvss-backend-module-datastore/dist/datastore/models/capability.model';
|
|
5
5
|
import { schema, CommonValidationDatabaseService as CommonValidationDatabaseService$1 } from '@dv4resi/dvss-backend-module-datastore';
|
|
@@ -528,8 +528,9 @@ interface ICreateOrderRequest {
|
|
|
528
528
|
}
|
|
529
529
|
interface ICreateOrderResponse {
|
|
530
530
|
externalBookingId: string;
|
|
531
|
-
items: (IBookableItem & {
|
|
531
|
+
items: (Pick<IBookableItem, 'externalId' | 'type' | 'name'> & {
|
|
532
532
|
totalPrice?: number;
|
|
533
|
+
primaryAsset?: IMedia;
|
|
533
534
|
})[];
|
|
534
535
|
}
|
|
535
536
|
interface IAddItemToOrderItemConfig {
|
|
@@ -1166,11 +1167,6 @@ interface ITrybeAddOrderItemResponse {
|
|
|
1166
1167
|
net_total?: number;
|
|
1167
1168
|
};
|
|
1168
1169
|
}
|
|
1169
|
-
interface ITrybeSubmitOrderResponse {
|
|
1170
|
-
data: {
|
|
1171
|
-
id: string;
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
1170
|
interface ITrybeCancelOrderResponse {
|
|
1175
1171
|
data: {
|
|
1176
1172
|
id: string;
|
|
@@ -1203,6 +1199,15 @@ interface ITrybeZone {
|
|
|
1203
1199
|
interface ITrybeCreateOrderResponse extends ICreateOrderResponse {
|
|
1204
1200
|
meta: {
|
|
1205
1201
|
orderReference: string;
|
|
1202
|
+
room?: {
|
|
1203
|
+
id: string;
|
|
1204
|
+
name: string;
|
|
1205
|
+
capacity: number;
|
|
1206
|
+
};
|
|
1207
|
+
total: number;
|
|
1208
|
+
subTotal: number;
|
|
1209
|
+
totalTax: number;
|
|
1210
|
+
discount: number;
|
|
1206
1211
|
};
|
|
1207
1212
|
}
|
|
1208
1213
|
interface ITrybeGetOrderResponse extends IGetOrderResponse {
|
|
@@ -1218,6 +1223,149 @@ interface ITrybeUpdateOrderItemResponse {
|
|
|
1218
1223
|
id: string;
|
|
1219
1224
|
};
|
|
1220
1225
|
}
|
|
1226
|
+
interface ITrybeSubmitOrderResponse {
|
|
1227
|
+
data?: {
|
|
1228
|
+
id: string;
|
|
1229
|
+
order_ref: string;
|
|
1230
|
+
guests?: {
|
|
1231
|
+
id: string;
|
|
1232
|
+
name: string;
|
|
1233
|
+
first_name: string;
|
|
1234
|
+
last_name: string;
|
|
1235
|
+
email: string | null;
|
|
1236
|
+
intake_form_complete: boolean;
|
|
1237
|
+
checked_in_at: string | null;
|
|
1238
|
+
checked_out_at: string | null;
|
|
1239
|
+
is_lead_booker: boolean;
|
|
1240
|
+
customer_id: string;
|
|
1241
|
+
}[];
|
|
1242
|
+
labels: [];
|
|
1243
|
+
sales_channel: null;
|
|
1244
|
+
items_status: 'pending_confirmation';
|
|
1245
|
+
booking_items?: {
|
|
1246
|
+
id: string;
|
|
1247
|
+
status: string;
|
|
1248
|
+
item_type: string;
|
|
1249
|
+
date: string;
|
|
1250
|
+
type_id: string;
|
|
1251
|
+
type_name: string;
|
|
1252
|
+
type_product_code: string | null;
|
|
1253
|
+
guests: {
|
|
1254
|
+
id: string;
|
|
1255
|
+
name: string;
|
|
1256
|
+
first_name: string;
|
|
1257
|
+
last_name: string;
|
|
1258
|
+
email: string | null;
|
|
1259
|
+
intake_form_complete: boolean;
|
|
1260
|
+
checked_in_at: string | null;
|
|
1261
|
+
checked_out_at: string | null;
|
|
1262
|
+
is_lead_booker: boolean;
|
|
1263
|
+
customer_id: string;
|
|
1264
|
+
}[];
|
|
1265
|
+
price: number;
|
|
1266
|
+
discount_amount: number;
|
|
1267
|
+
discounts: [];
|
|
1268
|
+
order_discount_amount: number;
|
|
1269
|
+
booking_summary?: {
|
|
1270
|
+
id: string;
|
|
1271
|
+
status: string;
|
|
1272
|
+
offering: {
|
|
1273
|
+
id: string;
|
|
1274
|
+
type: string;
|
|
1275
|
+
name: string;
|
|
1276
|
+
product_code: string | null;
|
|
1277
|
+
};
|
|
1278
|
+
start_time: string;
|
|
1279
|
+
end_time: string;
|
|
1280
|
+
duration: number;
|
|
1281
|
+
practitioner_ids: string[];
|
|
1282
|
+
practitioners: {
|
|
1283
|
+
id: string;
|
|
1284
|
+
name: string;
|
|
1285
|
+
}[];
|
|
1286
|
+
room_id: string;
|
|
1287
|
+
room?: {
|
|
1288
|
+
id: string;
|
|
1289
|
+
name: string;
|
|
1290
|
+
capacity: number;
|
|
1291
|
+
};
|
|
1292
|
+
equipment_ids: string[];
|
|
1293
|
+
equipment: {
|
|
1294
|
+
id: string;
|
|
1295
|
+
name: string;
|
|
1296
|
+
}[];
|
|
1297
|
+
practitioner_was_requested: false;
|
|
1298
|
+
room_was_requested: false;
|
|
1299
|
+
};
|
|
1300
|
+
total_cost: number;
|
|
1301
|
+
net_total: number;
|
|
1302
|
+
inclusive_tax_amount: number;
|
|
1303
|
+
exclusive_tax_amount: number;
|
|
1304
|
+
booking_reserved_until: string;
|
|
1305
|
+
guest: {
|
|
1306
|
+
id: string;
|
|
1307
|
+
name: string;
|
|
1308
|
+
first_name: string;
|
|
1309
|
+
last_name: string;
|
|
1310
|
+
email: string | null;
|
|
1311
|
+
intake_form_complete: boolean;
|
|
1312
|
+
checked_in_at: string | null;
|
|
1313
|
+
checked_out_at: string | null;
|
|
1314
|
+
is_lead_booker: boolean;
|
|
1315
|
+
customer_id: string;
|
|
1316
|
+
};
|
|
1317
|
+
is_modifiable: boolean;
|
|
1318
|
+
}[];
|
|
1319
|
+
purchase_items: [];
|
|
1320
|
+
package_items: [];
|
|
1321
|
+
booking_items_start_date: string;
|
|
1322
|
+
booking_items_end_date: string;
|
|
1323
|
+
booking_items_span_multiple_days: false;
|
|
1324
|
+
currency: string;
|
|
1325
|
+
totals?: {
|
|
1326
|
+
subtotal?: number;
|
|
1327
|
+
inclusive_tax?: number;
|
|
1328
|
+
exclusive_tax?: number;
|
|
1329
|
+
order_discount?: number;
|
|
1330
|
+
total?: number;
|
|
1331
|
+
};
|
|
1332
|
+
total_cost: number;
|
|
1333
|
+
discount_total: number;
|
|
1334
|
+
total_tax: number;
|
|
1335
|
+
net_total: number;
|
|
1336
|
+
tip_amount: number;
|
|
1337
|
+
tips: [];
|
|
1338
|
+
service_charge: {
|
|
1339
|
+
amount: number;
|
|
1340
|
+
percentage: number;
|
|
1341
|
+
item_amounts: {
|
|
1342
|
+
item_id: string;
|
|
1343
|
+
amount: number;
|
|
1344
|
+
percentage: number;
|
|
1345
|
+
}[];
|
|
1346
|
+
};
|
|
1347
|
+
submit_payment_amount: number;
|
|
1348
|
+
submit_auth_amount: number;
|
|
1349
|
+
outstanding_payment_amount: number;
|
|
1350
|
+
payment_totals: {
|
|
1351
|
+
paid: number;
|
|
1352
|
+
pending: number;
|
|
1353
|
+
chargeable: number;
|
|
1354
|
+
provided: number;
|
|
1355
|
+
missing: number;
|
|
1356
|
+
unpaid: number;
|
|
1357
|
+
};
|
|
1358
|
+
total_paid_or_authed: number;
|
|
1359
|
+
taxes: [];
|
|
1360
|
+
payments: [];
|
|
1361
|
+
discounts: [];
|
|
1362
|
+
applied_promo_code_id: null;
|
|
1363
|
+
applied_promo_code_discount_total: number;
|
|
1364
|
+
is_promo_code_discount_applied: boolean;
|
|
1365
|
+
coupon_codes: [];
|
|
1366
|
+
voucher_codes: [];
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1221
1369
|
|
|
1222
1370
|
declare enum TRYBE_SUPPORTED_JOURNEYS_ENUM {
|
|
1223
1371
|
APPOINTMENT = "APPOINTMENT",
|
|
@@ -1301,25 +1449,47 @@ declare class TrybeWellnessManagement implements BaseWellnessManagement {
|
|
|
1301
1449
|
createWellnessAppointmentSessionOrder(): Promise<void>;
|
|
1302
1450
|
addWellnessAppointmentSessionOrderItems(): Promise<void>;
|
|
1303
1451
|
confirmWellnessAppointmentSessionOrder(): Promise<void>;
|
|
1452
|
+
getOffering(request: {
|
|
1453
|
+
offeringId: string;
|
|
1454
|
+
offeringType: TRYBE_OFFERING_TYPE_ENUM;
|
|
1455
|
+
}, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<{
|
|
1456
|
+
data: ITrybeSession | ITrybeCourse | ITrybeAppointment;
|
|
1457
|
+
}>;
|
|
1304
1458
|
createOrder(request: ICreateOrderRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ITrybeCreateOrderResponse>;
|
|
1305
1459
|
addCustomerToOrder(orderId: string, customerId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<void>;
|
|
1306
1460
|
getOrder(orderId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ITrybeGetOrderResponse>;
|
|
1307
1461
|
private mapOfferingTypeToTrybeApi;
|
|
1308
1462
|
addItemToOrder(request: IAddItemToOrderRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<IAddItemToOrderResponse>;
|
|
1309
1463
|
addCustomerCreditsToOrder(orderId: string, customerCreditId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<void>;
|
|
1310
|
-
submitOrder(orderId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<
|
|
1464
|
+
submitOrder(orderId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ITrybeSubmitOrderResponse>;
|
|
1311
1465
|
cancelOrder(orderId: string, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<void>;
|
|
1312
1466
|
updateOrder(request: IUpdateOrderRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<IUpdateOrderResponse>;
|
|
1313
1467
|
updateOrderItem(orderId: string, itemId: string, request: IUpdateOrderRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ITrybeUpdateOrderItemResponse>;
|
|
1314
1468
|
addPaymentToOrder(request: IAddPaymentToOrderRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<void>;
|
|
1315
1469
|
fetchAppointments(request: IGetAppointmentsRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IBookableItem>>;
|
|
1470
|
+
fetchAppointment(request: {
|
|
1471
|
+
appointmentId: string;
|
|
1472
|
+
}, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<{
|
|
1473
|
+
data: ITrybeAppointment;
|
|
1474
|
+
}>;
|
|
1316
1475
|
fetchSessions(request: IGetSessionsRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IBookableItem>>;
|
|
1476
|
+
fetchSession(request: {
|
|
1477
|
+
sessionId: string;
|
|
1478
|
+
}, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<{
|
|
1479
|
+
data: ITrybeSession;
|
|
1480
|
+
}>;
|
|
1317
1481
|
fetchCourses(request: IGetCoursesRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IBookableItem>>;
|
|
1482
|
+
fetchCourse(request: {
|
|
1483
|
+
courseId: string;
|
|
1484
|
+
}, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<{
|
|
1485
|
+
data: ITrybeCourse;
|
|
1486
|
+
}>;
|
|
1318
1487
|
fetchPractitioners(request: IGetPractitionersRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IOfferingResource>>;
|
|
1319
1488
|
fetchCategories(request: IGetCategoriesRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IBookableItemCategory>>;
|
|
1320
1489
|
fetchBookableItemsFromCredit(request: IGetBookableItemsFromCreditRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<ISystemResponse<IBookableItem>>;
|
|
1321
1490
|
fetchSessionAvailabilityForOffering(request: IFetchOfferingAvailabilityRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<IGetAvailableDatesAndTimeSlotsResponse>;
|
|
1322
1491
|
fetchAppointmentAvailabilityForOffering(request: IFetchOfferingAvailabilityRequest, integration: ICapabilityIntegration, loggedInUserId: bigint): Promise<IGetAvailableDatesAndTimeSlotsResponse>;
|
|
1492
|
+
mapTrybeOfferingTypeToBookableItemType(offeringType: string): BOOKABLE_ITEM_TYPE_ENUM;
|
|
1323
1493
|
}
|
|
1324
1494
|
|
|
1325
1495
|
declare function formatDateForTrybe(date: Date, isStartOfDay: boolean): string;
|
package/dist/index.js
CHANGED
|
@@ -3775,8 +3775,6 @@ function mapTrybeAppointmentAvailabilityToSystemResponse(slots) {
|
|
|
3775
3775
|
};
|
|
3776
3776
|
}
|
|
3777
3777
|
__name(mapTrybeAppointmentAvailabilityToSystemResponse, "mapTrybeAppointmentAvailabilityToSystemResponse");
|
|
3778
|
-
|
|
3779
|
-
// ../../packages/dvss-integration-trybe/src/capabilities/wellness/wellness-management.service.ts
|
|
3780
3778
|
function _ts_decorate18(decorators, target, key, desc2) {
|
|
3781
3779
|
var c = arguments.length, r = c < 3 ? target : desc2 === null ? desc2 = Object.getOwnPropertyDescriptor(target, key) : desc2, d;
|
|
3782
3780
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc2);
|
|
@@ -3816,11 +3814,33 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3816
3814
|
confirmWellnessAppointmentSessionOrder() {
|
|
3817
3815
|
throw new Error("Method not implemented.");
|
|
3818
3816
|
}
|
|
3817
|
+
async getOffering(request, integration, loggedInUserId) {
|
|
3818
|
+
switch (request.offeringType) {
|
|
3819
|
+
case TRYBE_OFFERING_TYPE_ENUM.SESSION:
|
|
3820
|
+
return this.fetchSession({
|
|
3821
|
+
sessionId: request.offeringId
|
|
3822
|
+
}, integration, loggedInUserId);
|
|
3823
|
+
case TRYBE_OFFERING_TYPE_ENUM.COURSE:
|
|
3824
|
+
return this.fetchCourse({
|
|
3825
|
+
courseId: request.offeringId
|
|
3826
|
+
}, integration, loggedInUserId);
|
|
3827
|
+
case TRYBE_OFFERING_TYPE_ENUM.APPOINTMENT:
|
|
3828
|
+
return this.fetchAppointment({
|
|
3829
|
+
appointmentId: request.offeringId
|
|
3830
|
+
}, integration, loggedInUserId);
|
|
3831
|
+
default:
|
|
3832
|
+
throw new Error(`Unsupported offering type: ${request.offeringType}`);
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3819
3835
|
async createOrder(request, integration, loggedInUserId) {
|
|
3820
3836
|
let orderId;
|
|
3821
3837
|
try {
|
|
3822
3838
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
3823
3839
|
const siteId = validated.config.integrationConfig.siteId;
|
|
3840
|
+
const offering = await this.getOffering({
|
|
3841
|
+
offeringId: request.bookableItems[0].externalId,
|
|
3842
|
+
offeringType: request.bookableItems[0].type
|
|
3843
|
+
}, integration, loggedInUserId);
|
|
3824
3844
|
const res = await this.trafficGatewayService.executeIntegrationRequest({
|
|
3825
3845
|
apiMethod: HTTP_METHOD.POST,
|
|
3826
3846
|
url: "/shop/orders",
|
|
@@ -3852,22 +3872,46 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
3852
3872
|
externalId: bookableItem.externalId,
|
|
3853
3873
|
name: orderItemResponse.name,
|
|
3854
3874
|
type: bookableItem.type,
|
|
3855
|
-
totalPrice: (orderItemResponse.netTotal ?? 0) / request.currencyMultiplier
|
|
3875
|
+
totalPrice: (orderItemResponse.netTotal ?? 0) / request.currencyMultiplier,
|
|
3876
|
+
primaryAsset: bookableItem.externalId === offering.data.id ? offering.data.image?.original_url ? {
|
|
3877
|
+
provider: models.MEDIA_PROVIDER_ENUM.CUSTOM_URL,
|
|
3878
|
+
meta: {
|
|
3879
|
+
url: offering.data.image.original_url
|
|
3880
|
+
}
|
|
3881
|
+
} : void 0 : void 0
|
|
3856
3882
|
});
|
|
3857
3883
|
}
|
|
3858
3884
|
if (request.customerCreditId) {
|
|
3859
3885
|
await this.addCustomerCreditsToOrder(orderId, request.customerCreditId, integration, loggedInUserId);
|
|
3860
3886
|
}
|
|
3861
|
-
await this.submitOrder(orderId, integration, loggedInUserId);
|
|
3887
|
+
const submitOrderResponse = await this.submitOrder(orderId, integration, loggedInUserId);
|
|
3862
3888
|
this.logger.info(loggedInUserId, this.createOrder.name, this.fileName, "Created Trybe order for offering booking", {
|
|
3863
3889
|
orderId
|
|
3864
3890
|
});
|
|
3865
3891
|
return {
|
|
3866
3892
|
externalBookingId: orderId,
|
|
3867
|
-
items,
|
|
3868
3893
|
meta: {
|
|
3869
|
-
orderReference: order.meta.orderReference
|
|
3870
|
-
|
|
3894
|
+
orderReference: submitOrderResponse.data?.order_ref ?? order.meta.orderReference,
|
|
3895
|
+
room: submitOrderResponse.data?.booking_items?.find((item) => item.booking_summary?.room?.id)?.booking_summary?.room,
|
|
3896
|
+
total: (submitOrderResponse.data?.totals?.total ?? 0) / request.currencyMultiplier,
|
|
3897
|
+
subTotal: (submitOrderResponse.data?.totals?.subtotal ?? 0) / request.currencyMultiplier,
|
|
3898
|
+
totalTax: (submitOrderResponse.data?.total_tax ?? 0) / request.currencyMultiplier,
|
|
3899
|
+
discount: (submitOrderResponse.data?.discount_total ?? 0) / request.currencyMultiplier
|
|
3900
|
+
},
|
|
3901
|
+
items: submitOrderResponse.data?.booking_items?.map((bookableItem) => {
|
|
3902
|
+
return {
|
|
3903
|
+
externalId: bookableItem.type_id,
|
|
3904
|
+
name: bookableItem.type_name,
|
|
3905
|
+
type: bookableItem.item_type,
|
|
3906
|
+
totalPrice: bookableItem.net_total,
|
|
3907
|
+
primaryAsset: offering.data.image?.original_url ? {
|
|
3908
|
+
provider: models.MEDIA_PROVIDER_ENUM.CUSTOM_URL,
|
|
3909
|
+
meta: {
|
|
3910
|
+
url: offering.data.image.original_url
|
|
3911
|
+
}
|
|
3912
|
+
} : void 0
|
|
3913
|
+
};
|
|
3914
|
+
}) ?? []
|
|
3871
3915
|
};
|
|
3872
3916
|
} catch (err) {
|
|
3873
3917
|
this.logger.error(loggedInUserId, this.createOrder.name, this.fileName, "Error creating Trybe order for offering booking", err);
|
|
@@ -4028,7 +4072,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4028
4072
|
orderId
|
|
4029
4073
|
});
|
|
4030
4074
|
const validated = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4031
|
-
await this.trafficGatewayService.executeIntegrationRequest({
|
|
4075
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4032
4076
|
apiMethod: HTTP_METHOD.POST,
|
|
4033
4077
|
url: `/shop/orders/${orderId}/submit`,
|
|
4034
4078
|
baseUrl: validated.config.platformConfig.baseUrl,
|
|
@@ -4037,6 +4081,7 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4037
4081
|
this.logger.info(loggedInUserId, this.submitOrder.name, this.fileName, "Successfully submitted Trybe order", {
|
|
4038
4082
|
orderId
|
|
4039
4083
|
});
|
|
4084
|
+
return response;
|
|
4040
4085
|
}
|
|
4041
4086
|
async cancelOrder(orderId, integration, loggedInUserId) {
|
|
4042
4087
|
this.logger.info(loggedInUserId, this.cancelOrder.name, this.fileName, "Cancelling Trybe order", {
|
|
@@ -4192,6 +4237,29 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4192
4237
|
throw err;
|
|
4193
4238
|
}
|
|
4194
4239
|
}
|
|
4240
|
+
async fetchAppointment(request, integration, loggedInUserId) {
|
|
4241
|
+
this.logger.info(loggedInUserId, this.fetchAppointment.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchAppointment.name} Called`, {
|
|
4242
|
+
request
|
|
4243
|
+
});
|
|
4244
|
+
try {
|
|
4245
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4246
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4247
|
+
const apiUrl = `/shop/appointment-types/${request.appointmentId}?site_id=${siteId}`;
|
|
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
|
+
this.logger.info(loggedInUserId, this.fetchAppointments.name, this.fileName, "Successfully fetched Trybe appointments", {
|
|
4255
|
+
appointmentId: request.appointmentId
|
|
4256
|
+
});
|
|
4257
|
+
return response;
|
|
4258
|
+
} catch (err) {
|
|
4259
|
+
this.logger.error(loggedInUserId, this.fetchAppointments.name, this.fileName, "Error fetching Trybe appointments", err);
|
|
4260
|
+
throw err;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4195
4263
|
async fetchSessions(request, integration, loggedInUserId) {
|
|
4196
4264
|
this.logger.info(loggedInUserId, this.fetchSessions.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSessions.name} Called`, {
|
|
4197
4265
|
request
|
|
@@ -4232,6 +4300,25 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4232
4300
|
throw err;
|
|
4233
4301
|
}
|
|
4234
4302
|
}
|
|
4303
|
+
async fetchSession(request, integration, loggedInUserId) {
|
|
4304
|
+
this.logger.info(loggedInUserId, this.fetchSession.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchSession.name} Called`, {
|
|
4305
|
+
request
|
|
4306
|
+
});
|
|
4307
|
+
try {
|
|
4308
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4309
|
+
const siteId = validatedIntegration.config.integrationConfig.siteId;
|
|
4310
|
+
const apiUrl = `/shop/session-types/${request.sessionId}?site_id=${siteId}`;
|
|
4311
|
+
return await this.trafficGatewayService.executeIntegrationRequest({
|
|
4312
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4313
|
+
url: apiUrl,
|
|
4314
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4315
|
+
headers: validatedIntegration.headers
|
|
4316
|
+
}, validatedIntegration, loggedInUserId);
|
|
4317
|
+
} catch (err) {
|
|
4318
|
+
this.logger.error(loggedInUserId, this.fetchSession.name, this.fileName, "Error fetching Trybe session", err);
|
|
4319
|
+
throw err;
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4235
4322
|
async fetchCourses(request, integration, loggedInUserId) {
|
|
4236
4323
|
this.logger.info(loggedInUserId, this.fetchCourses.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourses.name} Called`, {
|
|
4237
4324
|
request
|
|
@@ -4272,6 +4359,29 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4272
4359
|
throw err;
|
|
4273
4360
|
}
|
|
4274
4361
|
}
|
|
4362
|
+
async fetchCourse(request, integration, loggedInUserId) {
|
|
4363
|
+
this.logger.info(loggedInUserId, this.fetchCourse.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchCourse.name} Called`, {
|
|
4364
|
+
request
|
|
4365
|
+
});
|
|
4366
|
+
try {
|
|
4367
|
+
const validatedIntegration = this.trybeAuthService.validateConfig(integration, loggedInUserId);
|
|
4368
|
+
const organisationId = validatedIntegration.config.integrationConfig.organisationId;
|
|
4369
|
+
const apiUrl = `/shop/course-types/${request.courseId}?organisation_id=${organisationId}`;
|
|
4370
|
+
const response = await this.trafficGatewayService.executeIntegrationRequest({
|
|
4371
|
+
apiMethod: HTTP_METHOD.GET,
|
|
4372
|
+
url: apiUrl,
|
|
4373
|
+
baseUrl: validatedIntegration.config.platformConfig.baseUrl,
|
|
4374
|
+
headers: validatedIntegration.headers
|
|
4375
|
+
}, validatedIntegration, loggedInUserId);
|
|
4376
|
+
this.logger.info(loggedInUserId, this.fetchCourse.name, this.fileName, "Successfully fetched Trybe course", {
|
|
4377
|
+
courseId: request.courseId
|
|
4378
|
+
});
|
|
4379
|
+
return response;
|
|
4380
|
+
} catch (err) {
|
|
4381
|
+
this.logger.error(loggedInUserId, this.fetchCourse.name, this.fileName, "Error fetching Trybe course", err);
|
|
4382
|
+
throw err;
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4275
4385
|
async fetchPractitioners(request, integration, loggedInUserId) {
|
|
4276
4386
|
this.logger.info(loggedInUserId, this.fetchPractitioners.name, this.fileName, `${_TrybeWellnessManagement.name} -> ${this.fetchPractitioners.name} Called`, {
|
|
4277
4387
|
request
|
|
@@ -4421,6 +4531,18 @@ exports.TrybeWellnessManagement = class _TrybeWellnessManagement {
|
|
|
4421
4531
|
throw err;
|
|
4422
4532
|
}
|
|
4423
4533
|
}
|
|
4534
|
+
mapTrybeOfferingTypeToBookableItemType(offeringType) {
|
|
4535
|
+
switch (offeringType) {
|
|
4536
|
+
case "appointment":
|
|
4537
|
+
return BOOKABLE_ITEM_TYPE_ENUM.APPOINTMENT;
|
|
4538
|
+
case "session":
|
|
4539
|
+
return BOOKABLE_ITEM_TYPE_ENUM.SESSION;
|
|
4540
|
+
case "course":
|
|
4541
|
+
return BOOKABLE_ITEM_TYPE_ENUM.COURSE;
|
|
4542
|
+
default:
|
|
4543
|
+
throw new Error(`Unsupported offering type: ${offeringType}`);
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4424
4546
|
};
|
|
4425
4547
|
exports.TrybeWellnessManagement = _ts_decorate18([
|
|
4426
4548
|
common.Injectable(),
|