@vendit-dev/thirdparty-adapters 0.7.6-beta.2 → 0.7.8
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/.idea/codeStyles/Project.xml +50 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/thirdparty-adapters.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/lib/adapters/externalChannelManagers/externalChannelManager.type.d.ts +130 -0
- package/lib/adapters/externalChannelManagers/externalChannelManager.type.js +40 -0
- package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.d.ts +10 -0
- package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.js +79 -0
- package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.type.d.ts +4 -0
- package/lib/adapters/externalChannelManagers/externalChannelManagerCaller.type.js +27 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.d.ts +25 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.helper.d.ts +23 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.helper.js +313 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.js +321 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.types.d.ts +583 -0
- package/lib/adapters/externalChannelManagers/tl-lincoln.types.js +32 -0
- package/lib/adapters/externalChannelManagers/tl-sample.d.ts +1218 -0
- package/lib/adapters/externalChannelManagers/tl-sample.js +3974 -0
- package/lib/adapters/parking/nicePark.js +8 -4
- package/lib/index.d.ts +4 -2
- package/lib/index.js +7 -3
- package/lib/types/common.d.ts +385 -0
- package/lib/types/common.js +2 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/types/tl-lincoln.ota.d.ts +1 -0
- package/lib/types/tl-lincoln.ota.js +119 -0
- package/lib/utils/function.d.ts +2 -0
- package/lib/utils/function.js +15 -0
- package/package.json +48 -49
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.withAsyncBandwidth = exports.refineReservationData = exports.formattedPaxCountText = exports.formattedNameForMealCondition = exports.getExternalReservationTypeFromDataClassification = exports.getReservationStatusFromDataClassification = exports.xmlToJson = exports.jsonToXml = void 0;
|
|
27
|
+
var fast_xml_parser_1 = require("fast-xml-parser");
|
|
28
|
+
var moment_1 = __importDefault(require("moment"));
|
|
29
|
+
var tl_lincoln_types_1 = require("./tl-lincoln.types");
|
|
30
|
+
var function_1 = require("../../utils/function");
|
|
31
|
+
var tl_lincoln_ota_1 = require("../../types/tl-lincoln.ota");
|
|
32
|
+
function jsonToXml(json) {
|
|
33
|
+
var options = {
|
|
34
|
+
ignoreAttributes: false,
|
|
35
|
+
format: true,
|
|
36
|
+
suppressEmptyNode: true,
|
|
37
|
+
};
|
|
38
|
+
var builder = new fast_xml_parser_1.XMLBuilder(options);
|
|
39
|
+
var xmlContent = {
|
|
40
|
+
'soapenv:Envelope': {
|
|
41
|
+
'@_xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
|
|
42
|
+
'@_xmlns:pms': json.pmsUrl,
|
|
43
|
+
'soapenv:Body': {
|
|
44
|
+
'pms:execute': {
|
|
45
|
+
arg0: __assign({ commonRequest: __assign({}, json.commonRequest) }, json.request),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return builder.build(xmlContent);
|
|
51
|
+
}
|
|
52
|
+
exports.jsonToXml = jsonToXml;
|
|
53
|
+
function xmlToJson(xml) {
|
|
54
|
+
try {
|
|
55
|
+
var parser = new fast_xml_parser_1.XMLParser();
|
|
56
|
+
return parser.parse(xml);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
console.error("xmlToJson failed: ".concat(e));
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.xmlToJson = xmlToJson;
|
|
64
|
+
function getReservationStatusFromDataClassification(dataClassification) {
|
|
65
|
+
switch (dataClassification) {
|
|
66
|
+
case 'NewBookReport':
|
|
67
|
+
case 'ModificationReport':
|
|
68
|
+
return 'RESERVED';
|
|
69
|
+
case 'CancellationReport':
|
|
70
|
+
return 'CANCELLED';
|
|
71
|
+
default:
|
|
72
|
+
return 'RESERVED';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.getReservationStatusFromDataClassification = getReservationStatusFromDataClassification;
|
|
76
|
+
function getExternalReservationTypeFromDataClassification(dataClassification) {
|
|
77
|
+
switch (dataClassification) {
|
|
78
|
+
case 'NewBookReport':
|
|
79
|
+
return 'CREATED';
|
|
80
|
+
case 'ModificationReport':
|
|
81
|
+
return 'UPDATED';
|
|
82
|
+
case 'CancellationReport':
|
|
83
|
+
return 'CANCELLED';
|
|
84
|
+
default:
|
|
85
|
+
return 'CREATED';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.getExternalReservationTypeFromDataClassification = getExternalReservationTypeFromDataClassification;
|
|
89
|
+
var getSpecificMealConditionText = function (_specificType) {
|
|
90
|
+
switch (_specificType) {
|
|
91
|
+
case 'IncludingBreakfast':
|
|
92
|
+
return ['조식'];
|
|
93
|
+
case 'IncludingLunch':
|
|
94
|
+
return ['중식'];
|
|
95
|
+
case 'IncludingDinner':
|
|
96
|
+
return ['석식'];
|
|
97
|
+
case 'IncludingLunchAndDinner':
|
|
98
|
+
return ['중식', '석식'];
|
|
99
|
+
case 'IncludingBreakfastAndLunch':
|
|
100
|
+
return ['조식', '중식'];
|
|
101
|
+
case 'IncludingBreakfastAndDinner':
|
|
102
|
+
return ['조식', '석식'];
|
|
103
|
+
case 'IncludingBreakfastAndLunchAndDinner':
|
|
104
|
+
return ['조식', '중식', '석식'];
|
|
105
|
+
case 'None Specified':
|
|
106
|
+
return [];
|
|
107
|
+
default:
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var getMealConditionText = function (_mealCondition) {
|
|
112
|
+
switch (_mealCondition) {
|
|
113
|
+
case '1night2meals':
|
|
114
|
+
return '1박2식';
|
|
115
|
+
case '1nightBreakfast':
|
|
116
|
+
return '1박조식';
|
|
117
|
+
default:
|
|
118
|
+
return '조식 없음';
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var formattedNameForMealCondition = function (mealCondition, specificMealCondition) {
|
|
122
|
+
var _a;
|
|
123
|
+
return "".concat(getMealConditionText(mealCondition)).concat(((_a = getSpecificMealConditionText(specificMealCondition)) === null || _a === void 0 ? void 0 : _a.length) > 0 ? "(".concat(getSpecificMealConditionText(specificMealCondition)
|
|
124
|
+
.join(', '), ")") : '');
|
|
125
|
+
};
|
|
126
|
+
exports.formattedNameForMealCondition = formattedNameForMealCondition;
|
|
127
|
+
var formattedPaxCountText = function (roomInformation, genderDivision) {
|
|
128
|
+
if ('RoomPaxMaleCount' in roomInformation) {
|
|
129
|
+
var _a = roomInformation, _b = _a.RoomPaxMaleCount, RoomPaxMaleCount = _b === void 0 ? 0 : _b, _c = _a.RoomPaxFemaleCount, RoomPaxFemaleCount = _c === void 0 ? 0 : _c, _d = _a.RoomChildA70Count, RoomChildA70Count = _d === void 0 ? 0 : _d, _e = _a.RoomChildB50Count, RoomChildB50Count = _e === void 0 ? 0 : _e, _f = _a.RoomChildC30Count, RoomChildC30Count = _f === void 0 ? 0 : _f, _g = _a.RoomChildDNoneCount, RoomChildDNoneCount = _g === void 0 ? 0 : _g, _h = _a.RoomChildOtherCount, RoomChildOtherCount = _h === void 0 ? 0 : _h;
|
|
130
|
+
return "".concat([
|
|
131
|
+
// RoomPaxMaleCount ? `성인남성 ${RoomPaxMaleCount}명` : '',
|
|
132
|
+
// RoomPaxFemaleCount ? `성인여성 ${RoomPaxFemaleCount}명` : '',
|
|
133
|
+
genderDivision ? "\uB0A8 ".concat(RoomPaxMaleCount, "\uBA85, \uC5EC ").concat(RoomPaxFemaleCount, "\uBA85") : "\uC131\uC778 ".concat((RoomPaxMaleCount) + (RoomPaxFemaleCount), "\uBA85"),
|
|
134
|
+
RoomChildA70Count ? "\uD559\uC0DD ".concat(RoomChildA70Count, "\uBA85") : '',
|
|
135
|
+
RoomChildB50Count || RoomChildC30Count || RoomChildOtherCount ? "\uC544\uB3D9 ".concat(RoomChildB50Count + RoomChildC30Count + RoomChildOtherCount, "\uBA85") : '',
|
|
136
|
+
RoomChildDNoneCount ? "\uC720\uC544 ".concat(RoomChildDNoneCount, "\uBA85") : '',
|
|
137
|
+
].filter(Boolean).join(', '));
|
|
138
|
+
}
|
|
139
|
+
var _j = roomInformation, _k = _j.TotalPaxMaleCount, TotalPaxMaleCount = _k === void 0 ? 0 : _k, _l = _j.TotalPaxFemaleCount, TotalPaxFemaleCount = _l === void 0 ? 0 : _l, _m = _j.TotalChildA70Count, TotalChildA70Count = _m === void 0 ? 0 : _m, _o = _j.TotalChildB50Count, TotalChildB50Count = _o === void 0 ? 0 : _o, _p = _j.TotalChildC30Count, TotalChildC30Count = _p === void 0 ? 0 : _p, _q = _j.TotalChildDNoneCount, TotalChildDNoneCount = _q === void 0 ? 0 : _q, _r = _j.TotalChildOtherCount, TotalChildOtherCount = _r === void 0 ? 0 : _r;
|
|
140
|
+
return "".concat([
|
|
141
|
+
genderDivision ? "\uB0A8 ".concat(TotalPaxMaleCount, "\uBA85, \uC5EC ").concat(TotalPaxFemaleCount, "\uBA85") : "\uC131\uC778 ".concat((TotalPaxMaleCount) + (TotalPaxFemaleCount), "\uBA85"),
|
|
142
|
+
TotalChildA70Count ? "\uD559\uC0DD ".concat(TotalChildA70Count, "\uBA85") : '',
|
|
143
|
+
TotalChildB50Count || TotalChildC30Count || TotalChildOtherCount ? "\uC544\uB3D9 ".concat(TotalChildB50Count + TotalChildC30Count + TotalChildOtherCount, "\uBA85") : '',
|
|
144
|
+
TotalChildDNoneCount ? "\uC720\uC544 ".concat(TotalChildDNoneCount, "\uBA85") : '',
|
|
145
|
+
].filter(Boolean).join(', '));
|
|
146
|
+
};
|
|
147
|
+
exports.formattedPaxCountText = formattedPaxCountText;
|
|
148
|
+
function formatPhoneNumber(text) {
|
|
149
|
+
var onlyNumberText = text === null || text === void 0 ? void 0 : text.replace(/[^0-9]/g, '');
|
|
150
|
+
return onlyNumberText ? "010".concat(onlyNumberText.slice(-8)) : '';
|
|
151
|
+
}
|
|
152
|
+
var makePaymentInfo = function (_a) {
|
|
153
|
+
var datas = _a.datas, basicRateInformation = _a.basicRateInformation, basicInformation = _a.basicInformation, reservationType = _a.reservationType, CheckInDate = _a.CheckInDate, OptionList = _a.OptionList, roomsSortedByDate = _a.roomsSortedByDate;
|
|
154
|
+
return datas.reduce(function (paymentInput, _a) {
|
|
155
|
+
var _b, _c, _d;
|
|
156
|
+
var RoomInfo = _a.RoomInformation, RoomRateInformation = _a.RoomRateInformation;
|
|
157
|
+
var roomAmount = (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomRate) || (((RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerMaleRate) || 0) * (RoomInfo.RoomPaxMaleCount || 0) + ((RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerFemaleRate) || (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.PerMaleRate) || 0) * (RoomInfo.RoomPaxFemaleCount || 0)) || (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomRate) || basicRateInformation.TotalAccommodationCharge || 0;
|
|
158
|
+
paymentInput.amount += roomAmount;
|
|
159
|
+
(_b = paymentInput.segments) === null || _b === void 0 ? void 0 : _b.push({
|
|
160
|
+
amount: roomAmount,
|
|
161
|
+
servedAt: RoomRateInformation.RoomDate,
|
|
162
|
+
referenceType: 'RESERVATION',
|
|
163
|
+
referenceSubType: reservationType,
|
|
164
|
+
});
|
|
165
|
+
if (basicInformation.MealCondition !== 'Other' && basicInformation.MealCondition !== 'WithoutMeal') {
|
|
166
|
+
paymentInput.amount += (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomServiceFee) || 0;
|
|
167
|
+
(_c = paymentInput.segments) === null || _c === void 0 ? void 0 : _c.push({
|
|
168
|
+
amount: (RoomRateInformation === null || RoomRateInformation === void 0 ? void 0 : RoomRateInformation.TotalPerRoomServiceFee) || 0,
|
|
169
|
+
servedAt: RoomRateInformation.RoomDate,
|
|
170
|
+
referenceType: 'SERVICE',
|
|
171
|
+
referenceSubType: (0, exports.formattedNameForMealCondition)(basicInformation.MealCondition, basicInformation.SpecificMealCondition),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if ((OptionList === null || OptionList === void 0 ? void 0 : OptionList.length) > 0) {
|
|
175
|
+
(_d = paymentInput.segments) === null || _d === void 0 ? void 0 : _d.push.apply(_d, OptionList.map(function (option) { return ({
|
|
176
|
+
amount: 0,
|
|
177
|
+
servedAt: option.OptionDate,
|
|
178
|
+
referenceType: 'SERVICE',
|
|
179
|
+
referenceSubType: option.Name,
|
|
180
|
+
}); }));
|
|
181
|
+
}
|
|
182
|
+
return Object.assign(paymentInput, {
|
|
183
|
+
reservationType: reservationType,
|
|
184
|
+
type: 'platform',
|
|
185
|
+
externalRoomTypeCode: roomsSortedByDate[0].RoomInformation.NetRmTypeGroupCode,
|
|
186
|
+
externalRoomTypeName: roomsSortedByDate[0].RoomInformation.RoomTypeName,
|
|
187
|
+
useStartAt: "".concat(CheckInDate).concat((basicInformation === null || basicInformation === void 0 ? void 0 : basicInformation.CheckInTime) ? " ".concat(basicInformation === null || basicInformation === void 0 ? void 0 : basicInformation.CheckInTime) : ''),
|
|
188
|
+
});
|
|
189
|
+
}, {
|
|
190
|
+
amount: 0,
|
|
191
|
+
commissionAmount: 0,
|
|
192
|
+
reservationType: 'lodge',
|
|
193
|
+
segments: [],
|
|
194
|
+
externalRoomTypeCode: '',
|
|
195
|
+
externalRoomTypeName: '',
|
|
196
|
+
type: 'platform',
|
|
197
|
+
useStartAt: '',
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
var refineReservationData = function (infoTravelXML) {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
var _c = infoTravelXML.AllotmentBookingReport, TransactionType = _c.TransactionType, RisaplsInformation = _c.RisaplsInformation, BasicInformation = _c.BasicInformation, BasicRateInformation = _c.BasicRateInformation, SalesOfficeInformation = _c.SalesOfficeInformation;
|
|
203
|
+
var _d = TransactionType.DataID.split('-'), ID = _d[0], REVISION = _d[1];
|
|
204
|
+
var isGroupReservation = BasicInformation.TotalRoomCount > 1;
|
|
205
|
+
var RisaplsCommonInformation = RisaplsInformation.RisaplsCommonInformation, AgentNativeInformation = RisaplsInformation.AgentNativeInformation;
|
|
206
|
+
var RoomAndRoomRateInformation = RisaplsCommonInformation.RoomAndRoomRateInformation, Allotment = RisaplsCommonInformation.Allotment, Member = RisaplsCommonInformation.Member, OtherInfo = RisaplsCommonInformation.OtherInfo, Basic = RisaplsCommonInformation.Basic, BasicRate = RisaplsCommonInformation.BasicRate, Option = RisaplsCommonInformation.Option;
|
|
207
|
+
var isFullyPaid = !!((_a = AgentNativeInformation === null || AgentNativeInformation === void 0 ? void 0 : AgentNativeInformation.Extendmytrip) === null || _a === void 0 ? void 0 : _a.SettlementDiv) && !((_b = AgentNativeInformation === null || AgentNativeInformation === void 0 ? void 0 : AgentNativeInformation.Extend) === null || _b === void 0 ? void 0 : _b.AmountClaimed) && (BasicRateInformation === null || BasicRateInformation === void 0 ? void 0 : BasicRateInformation.Payment) !== 'Hotel Collect';
|
|
208
|
+
var roomAndRoomRateInformations = (0, tl_lincoln_types_1.makeArray)(RoomAndRoomRateInformation);
|
|
209
|
+
var groupedRooms = (0, function_1.groupBy)(roomAndRoomRateInformations, 'RoomInformation.RoomByRoomConfirmationNumber');
|
|
210
|
+
var status = getReservationStatusFromDataClassification(TransactionType.DataClassification);
|
|
211
|
+
var useStartAt = "".concat(BasicInformation.CheckInDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) : '');
|
|
212
|
+
var useExpireAt = "".concat((0, moment_1.default)(BasicInformation.CheckInDate)
|
|
213
|
+
.add(BasicInformation.Nights, 'days')
|
|
214
|
+
.format('YYYY-MM-DD')).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) : '');
|
|
215
|
+
var PointDiscountList = [];
|
|
216
|
+
if (BasicRate === null || BasicRate === void 0 ? void 0 : BasicRate.PointsDiscountList) {
|
|
217
|
+
PointDiscountList = (0, tl_lincoln_types_1.makeArray)(BasicRate.PointsDiscountList);
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
type: getExternalReservationTypeFromDataClassification(TransactionType.DataClassification),
|
|
221
|
+
externalId: ID,
|
|
222
|
+
externalRevision: REVISION,
|
|
223
|
+
guestOrGroupInfo: {
|
|
224
|
+
isGroupReservation: isGroupReservation,
|
|
225
|
+
name: BasicInformation.GuestOrGroupNameKanjiName,
|
|
226
|
+
email: Member === null || Member === void 0 ? void 0 : Member.UserMailAddr,
|
|
227
|
+
reservedBy: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName,
|
|
228
|
+
memo: "".concat((Member === null || Member === void 0 ? void 0 : Member.UserKana) || (Member === null || Member === void 0 ? void 0 : Member.UserName) || "".concat(BasicInformation.GuestOrGroupNameKanjiName), " ").concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.PackagePlanName, "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.GuestRequest) ? "[\uC694\uCCAD\uC0AC\uD56D]\n".concat(OtherInfo.GuestRequest) : '', "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.AdditionalInformation) ? "[\uCD94\uAC00\uC815\uBCF4]\n".concat(OtherInfo.AdditionalInformation) : '', "\n").concat((0, exports.formattedPaxCountText)(BasicInformation), "\n[\uACB0\uC81C\uC815\uBCF4]\n\uC9C0\uBD88\uC218\uB2E8: ").concat(BasicRateInformation.Payment || '정보 없음', "\n").concat(BasicRateInformation.Payment === 'CreditCard' ? "\uCE74\uB4DC\uC0AC\uBA85: ".concat(BasicRateInformation.CreditCardAuthority, "\n\uCE74\uB4DC\uBC88\uD638: ").concat(BasicRateInformation.CreditCardNumber, "\n\uC720\uD6A8\uAE30\uAC04: ").concat(BasicRateInformation.ExpireDate, "\n\uC18C\uC9C0\uC790\uBA85: ").concat(BasicRateInformation.CardHolderName, "\n\uC774\uC804 \uCDE8\uC18C\uAE08\uC561: ").concat(BasicRateInformation.CancellationCharge, "\n") : '', "\n\uC218\uC218\uB8CC\uC728: ").concat(BasicRateInformation.CommissionPercentage ? "".concat(BasicRateInformation.CommissionPercentage, "%") : '정보 없음', "\n\uC218\uC218\uB8CC \uCD1D\uC561: ").concat(BasicRateInformation.TotalAccommodationCommissionAmount ? "".concat(BasicRateInformation.TotalAccommodationCommissionAmount, "\uC6D0") : '정보 없음', "\n[\uD560\uC778\uC815\uBCF4]\n").concat((PointDiscountList === null || PointDiscountList === void 0 ? void 0 : PointDiscountList.length) > 0 ? "".concat(PointDiscountList.map(function (point) { return "".concat(point.PointsDiscountName, ": ").concat(point.PointsDiscount); }).join('\n')) : ''),
|
|
229
|
+
status: 'reserved',
|
|
230
|
+
phone: formatPhoneNumber("".concat((Member === null || Member === void 0 ? void 0 : Member.UserTel) || Basic.PhoneNumber || '')),
|
|
231
|
+
useExpireAt: useExpireAt,
|
|
232
|
+
useStartAt: useStartAt,
|
|
233
|
+
platform: tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName),
|
|
234
|
+
externalPlatformCode: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCode,
|
|
235
|
+
externalPlatformName: (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeName),
|
|
236
|
+
},
|
|
237
|
+
reservations: Object.keys(groupedRooms)
|
|
238
|
+
.map(function (key, index) {
|
|
239
|
+
var _a, _b, _c, _d;
|
|
240
|
+
var datas = groupedRooms[key];
|
|
241
|
+
var roomsSortedByDate = datas.sort(function (a, b) { return new Date(a.RoomRateInformation.RoomDate).valueOf() - new Date(b.RoomRateInformation.RoomDate).valueOf(); });
|
|
242
|
+
var reservationType = (Number(Allotment.UseDiv) === 1 && BasicInformation.CheckInDate === BasicInformation.CheckOutDate) ? 'rent' : 'lodge';
|
|
243
|
+
var CheckInDate = roomsSortedByDate[0].RoomRateInformation.RoomDate;
|
|
244
|
+
var CheckOutDate = (_a = (0, moment_1.default)(CheckInDate)
|
|
245
|
+
.add(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.Nights, 'days')) === null || _a === void 0 ? void 0 : _a.format('YYYY-MM-DD');
|
|
246
|
+
var OptionList = Option ? (0, tl_lincoln_types_1.makeArray)(Option) : [];
|
|
247
|
+
var DepositList = (BasicRate === null || BasicRate === void 0 ? void 0 : BasicRate.DepositList) && (0, tl_lincoln_types_1.makeArray)(BasicRate.DepositList);
|
|
248
|
+
var paymentInfo = makePaymentInfo({
|
|
249
|
+
datas: datas,
|
|
250
|
+
basicRateInformation: BasicRateInformation,
|
|
251
|
+
basicInformation: BasicInformation,
|
|
252
|
+
reservationType: reservationType,
|
|
253
|
+
CheckInDate: CheckInDate,
|
|
254
|
+
OptionList: OptionList,
|
|
255
|
+
roomsSortedByDate: roomsSortedByDate,
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
useStartAt: "".concat(CheckInDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckInTime) : ''),
|
|
259
|
+
useExpireAt: "".concat(CheckOutDate).concat((BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) ? " ".concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.CheckOutTime) : ''),
|
|
260
|
+
sleeps: (_c = (_b = roomsSortedByDate[0]) === null || _b === void 0 ? void 0 : _b.RoomInformation) === null || _c === void 0 ? void 0 : _c.PerRoomPaxCount,
|
|
261
|
+
guestName: "".concat(BasicInformation.GuestOrGroupNameSingleByte || BasicInformation.GuestOrGroupNameKanjiName || 'Anonymous').concat(isGroupReservation ? " ".concat(index + 1) : ''),
|
|
262
|
+
externalPlatformCode: SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCode,
|
|
263
|
+
externalPlatformName: (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeName),
|
|
264
|
+
cmsOtaNumber: "".concat(BasicInformation.TravelAgencyBookingNumber).concat(isGroupReservation ? "-v".concat(index + 1) : ''),
|
|
265
|
+
cmsProductName: roomsSortedByDate[0].RoomInformation.RoomTypeName || BasicInformation.PackagePlanName,
|
|
266
|
+
platform: tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName),
|
|
267
|
+
otaNumber: "".concat(tl_lincoln_ota_1.TL_LINCOLN_TO_VENDIT_OTA_MAP[(SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName) || 'ANONYMOUS'] || (SalesOfficeInformation === null || SalesOfficeInformation === void 0 ? void 0 : SalesOfficeInformation.SalesOfficeCompanyName), "|").concat((_d = "".concat(BasicInformation.TravelAgencyBookingNumber)) === null || _d === void 0 ? void 0 : _d.slice(-4)),
|
|
268
|
+
externalRoomTypeCode: roomsSortedByDate[0].RoomInformation.NetRmTypeGroupCode,
|
|
269
|
+
externalRoomTypeName: roomsSortedByDate[0].RoomInformation.RoomTypeName,
|
|
270
|
+
type: reservationType,
|
|
271
|
+
phone: formatPhoneNumber("".concat((Member === null || Member === void 0 ? void 0 : Member.UserTel) || Basic.PhoneNumber || '')),
|
|
272
|
+
status: status,
|
|
273
|
+
memoContent: "".concat((Member === null || Member === void 0 ? void 0 : Member.UserKana) || (Member === null || Member === void 0 ? void 0 : Member.UserName) || "".concat(BasicInformation.GuestOrGroupNameKanjiName), " ").concat(BasicInformation === null || BasicInformation === void 0 ? void 0 : BasicInformation.PackagePlanName, "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.GuestRequest) ? "[\uC694\uCCAD\uC0AC\uD56D]\n".concat(OtherInfo.GuestRequest) : '', "\n").concat((OtherInfo === null || OtherInfo === void 0 ? void 0 : OtherInfo.AdditionalInformation) ? "[\uCD94\uAC00\uC815\uBCF4]\n".concat(OtherInfo.AdditionalInformation) : '', "\n[\uC778\uC6D0\uC815\uBCF4]\n").concat((0, exports.formattedPaxCountText)(roomsSortedByDate[0].RoomInformation), "\n").concat((OptionList === null || OptionList === void 0 ? void 0 : OptionList.length) > 0 ? "[\uC635\uC158]\n".concat(OptionList.map(function (option) { return "".concat(option.Name, ": ").concat(option.OptionCount, "(").concat(option.OptionDate, ")"); }).join('\n')) : ''),
|
|
274
|
+
paymentInfo: Object.assign(paymentInfo, !isFullyPaid && {
|
|
275
|
+
amount: (DepositList === null || DepositList === void 0 ? void 0 : DepositList.reduce(function (acc, deposit) { return acc + ((deposit === null || deposit === void 0 ? void 0 : deposit.DepositAmount) || 0); }, 0)) || 0,
|
|
276
|
+
isFullyPaid: false,
|
|
277
|
+
outstandingAmount: paymentInfo.amount - ((DepositList === null || DepositList === void 0 ? void 0 : DepositList.reduce(function (acc, deposit) { return acc + ((deposit === null || deposit === void 0 ? void 0 : deposit.DepositAmount) || 0); }, 0)) || 0),
|
|
278
|
+
}),
|
|
279
|
+
};
|
|
280
|
+
}),
|
|
281
|
+
rawData: JSON.stringify(infoTravelXML),
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
exports.refineReservationData = refineReservationData;
|
|
285
|
+
var withAsyncBandwidth = function (array, asyncMapper, _a) {
|
|
286
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.bandwidth, bandwidth = _c === void 0 ? 5 : _c;
|
|
287
|
+
if (bandwidth < 2)
|
|
288
|
+
throw new Error('Bandwidth must bigger than 1');
|
|
289
|
+
var entries = __spreadArray([], array, true);
|
|
290
|
+
var chainedResponses = new Array(bandwidth)
|
|
291
|
+
.fill(undefined)
|
|
292
|
+
.map(function () { return new Promise(function (resolve) { return resolve(); }); });
|
|
293
|
+
var iterator = 0;
|
|
294
|
+
var index = 0;
|
|
295
|
+
var _loop_1 = function () {
|
|
296
|
+
var currentEntry = entries.pop();
|
|
297
|
+
var currentIndex = index;
|
|
298
|
+
var beforeResponse = chainedResponses[iterator];
|
|
299
|
+
chainedResponses[iterator] = beforeResponse.then(function () { return asyncMapper(currentEntry, currentIndex); });
|
|
300
|
+
index += 1;
|
|
301
|
+
if (iterator < bandwidth - 1) {
|
|
302
|
+
iterator += 1;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
iterator = 0;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
while (entries.length) {
|
|
309
|
+
_loop_1();
|
|
310
|
+
}
|
|
311
|
+
return chainedResponses;
|
|
312
|
+
};
|
|
313
|
+
exports.withAsyncBandwidth = withAsyncBandwidth;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.TlLincoln = void 0;
|
|
63
|
+
/* eslint-disable no-await-in-loop */
|
|
64
|
+
var node_fetch_1 = __importDefault(require("node-fetch"));
|
|
65
|
+
var moment_1 = __importDefault(require("moment"));
|
|
66
|
+
var externalChannelManager_type_1 = require("./externalChannelManager.type");
|
|
67
|
+
var tl_lincoln_helper_1 = require("./tl-lincoln.helper");
|
|
68
|
+
var tl_lincoln_types_1 = require("./tl-lincoln.types");
|
|
69
|
+
var TlLincoln = /** @class */ (function () {
|
|
70
|
+
function TlLincoln(_a) {
|
|
71
|
+
var credentials = _a.credentials, apiHost = _a.apiHost;
|
|
72
|
+
this.API_URL = 'https://test472.tl-lincoln.net/pmsservice/V1/';
|
|
73
|
+
if (apiHost) {
|
|
74
|
+
this.API_URL = apiHost;
|
|
75
|
+
}
|
|
76
|
+
this.systemId = credentials.systemId;
|
|
77
|
+
this.pmsUserId = credentials.pmsUserId;
|
|
78
|
+
this.pmsPassword = credentials.pmsPassword;
|
|
79
|
+
}
|
|
80
|
+
TlLincoln.prototype.getReservations = function (input, mergedReservations) {
|
|
81
|
+
if (mergedReservations === void 0) { mergedReservations = []; }
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var continueFetching, result, reservations, _a, isSuccess, errorDescription, failureReason, _b, bookingInfoList, configurationSettings, refinedArrayReservationList;
|
|
84
|
+
return __generator(this, function (_c) {
|
|
85
|
+
switch (_c.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
continueFetching = true;
|
|
88
|
+
result = __spreadArray([], mergedReservations, true);
|
|
89
|
+
_c.label = 1;
|
|
90
|
+
case 1:
|
|
91
|
+
if (!continueFetching) return [3 /*break*/, 4];
|
|
92
|
+
return [4 /*yield*/, this.bookingInfoOutputService(input)];
|
|
93
|
+
case 2:
|
|
94
|
+
reservations = _c.sent();
|
|
95
|
+
_a = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, isSuccess = _a.isSuccess, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
|
|
96
|
+
if (!isSuccess) {
|
|
97
|
+
throw new externalChannelManager_type_1.ExternalChannelManagerError({
|
|
98
|
+
message: "Failed to load Reservations - ".concat(errorDescription, ": ").concat(failureReason),
|
|
99
|
+
code: failureReason,
|
|
100
|
+
description: errorDescription,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
_b = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return, bookingInfoList = _b.bookingInfoList, configurationSettings = _b.configurationSettings;
|
|
104
|
+
refinedArrayReservationList = (0, tl_lincoln_types_1.makeArray)(bookingInfoList);
|
|
105
|
+
if (!(configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId)) {
|
|
106
|
+
throw new externalChannelManager_type_1.ExternalChannelManagerError({
|
|
107
|
+
message: 'Failed to load Reservations - outputId is not found',
|
|
108
|
+
code: 'outputId is not found',
|
|
109
|
+
description: 'outputId is not found',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return [4 /*yield*/, this.outputCompleteService(configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId)];
|
|
113
|
+
case 3:
|
|
114
|
+
_c.sent();
|
|
115
|
+
result = refinedArrayReservationList.reduce(function (acc, reservation) {
|
|
116
|
+
if (reservation === null || reservation === void 0 ? void 0 : reservation.infoTravelXML) {
|
|
117
|
+
var refinedData = (0, tl_lincoln_helper_1.refineReservationData)((0, tl_lincoln_helper_1.xmlToJson)(reservation.infoTravelXML));
|
|
118
|
+
acc.push(refinedData);
|
|
119
|
+
}
|
|
120
|
+
return acc;
|
|
121
|
+
}, result);
|
|
122
|
+
// 다음 페이지가 있는지 여부 확인: 100개면 추가 호출이 필요하다고 가정
|
|
123
|
+
continueFetching = refinedArrayReservationList.length === 100;
|
|
124
|
+
return [3 /*break*/, 1];
|
|
125
|
+
case 4: return [2 /*return*/, result];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
TlLincoln.prototype.getRoomTypes = function () {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var result, _a, errorDescription, failureReason, _b, rmTypeList, netRmTypeGroupList, netAgtRmTypeList, aggregateRoomTypeGroups, aggregateAgentRoomTypeGroups;
|
|
133
|
+
return __generator(this, function (_c) {
|
|
134
|
+
switch (_c.label) {
|
|
135
|
+
case 0: return [4 /*yield*/, this.netRoomTypeMasterSearchService()];
|
|
136
|
+
case 1:
|
|
137
|
+
result = _c.sent();
|
|
138
|
+
if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse.isSuccess) {
|
|
139
|
+
_a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
|
|
140
|
+
throw new externalChannelManager_type_1.ExternalChannelManagerError({
|
|
141
|
+
message: "Failed to load RoomTypes - ".concat(errorDescription, ": ").concat(failureReason),
|
|
142
|
+
code: failureReason,
|
|
143
|
+
description: errorDescription,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
_b = result['S:Envelope']['S:Body']['ns2:executeResponse'].return, rmTypeList = _b.rmTypeList, netRmTypeGroupList = _b.netRmTypeGroupList, netAgtRmTypeList = _b.netAgtRmTypeList;
|
|
147
|
+
aggregateRoomTypeGroups = function (rmTypeCode) {
|
|
148
|
+
var groups = (0, tl_lincoln_types_1.isArray)(netRmTypeGroupList) ? netRmTypeGroupList.filter(function (group) { return group.rmTypeCode === rmTypeCode; }) : [netRmTypeGroupList];
|
|
149
|
+
return groups.map(function (group) { return ({
|
|
150
|
+
groupCode: group.netRmTypeGroupCode,
|
|
151
|
+
groupName: group.netRmTypeGroupName,
|
|
152
|
+
roomTypeCode: group.rmTypeCode,
|
|
153
|
+
}); });
|
|
154
|
+
};
|
|
155
|
+
aggregateAgentRoomTypeGroups = function (rmTypeCode) {
|
|
156
|
+
var groups = (0, tl_lincoln_types_1.isArray)(netAgtRmTypeList) ? netAgtRmTypeList.filter(function (group) { return group.rmTypeCode === rmTypeCode; }) : [netAgtRmTypeList];
|
|
157
|
+
return groups.map(function (group) { return ({
|
|
158
|
+
agentRoomTypeCode: group.netAgtRmTypeCode,
|
|
159
|
+
agentRoomTypeName: group.netAgtRmTypeName,
|
|
160
|
+
groupCode: group.netRmTypeGroupCode,
|
|
161
|
+
rmTypeCode: group.rmTypeCode,
|
|
162
|
+
}); });
|
|
163
|
+
};
|
|
164
|
+
return [2 /*return*/, (0, tl_lincoln_types_1.isArray)(rmTypeList) ? rmTypeList.map(function (roomType) { return ({
|
|
165
|
+
roomTypeCode: roomType.rmTypeCode,
|
|
166
|
+
roomTypeName: roomType.rmTypeName,
|
|
167
|
+
groups: aggregateRoomTypeGroups(roomType.rmTypeCode),
|
|
168
|
+
agentRoomTypes: aggregateAgentRoomTypeGroups(roomType.rmTypeCode),
|
|
169
|
+
}); }) : [{
|
|
170
|
+
roomTypeCode: rmTypeList.rmTypeCode,
|
|
171
|
+
roomTypeName: rmTypeList.rmTypeName,
|
|
172
|
+
groups: aggregateRoomTypeGroups(rmTypeList.rmTypeCode),
|
|
173
|
+
agentRoomTypes: aggregateAgentRoomTypeGroups(rmTypeList.rmTypeCode),
|
|
174
|
+
}]];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
TlLincoln.prototype.updatePricePlans = function () {
|
|
180
|
+
return Promise.resolve(false);
|
|
181
|
+
};
|
|
182
|
+
TlLincoln.prototype.updateStocks = function (input) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
var refinedDatas;
|
|
185
|
+
var _this = this;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
refinedDatas = input.map(this.refineUpdateStockData.bind(this));
|
|
188
|
+
refinedDatas.map(function (refinedData) { return __awaiter(_this, void 0, void 0, function () {
|
|
189
|
+
var _this = this;
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
(0, tl_lincoln_helper_1.withAsyncBandwidth)(refinedData, (function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
192
|
+
var result, _a, errorDescription, failureReason;
|
|
193
|
+
return __generator(this, function (_b) {
|
|
194
|
+
switch (_b.label) {
|
|
195
|
+
case 0: return [4 /*yield*/, this.netStockAdjustmentService(data)];
|
|
196
|
+
case 1:
|
|
197
|
+
result = _b.sent();
|
|
198
|
+
if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse.isSuccess) {
|
|
199
|
+
_a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
|
|
200
|
+
throw new externalChannelManager_type_1.ExternalChannelManagerError({
|
|
201
|
+
message: "Failed to update RoomType stocks - ".concat(errorDescription, ": ").concat(failureReason),
|
|
202
|
+
code: failureReason,
|
|
203
|
+
description: "".concat(errorDescription, ": ").concat(JSON.stringify(data)),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return [2 /*return*/, result === null || result === void 0 ? void 0 : result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse.isSuccess];
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}); }));
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
});
|
|
212
|
+
}); });
|
|
213
|
+
return [2 /*return*/, true];
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
TlLincoln.prototype.generateEightByteId = function () {
|
|
218
|
+
return Math.random().toString(36).substring(2, 10);
|
|
219
|
+
};
|
|
220
|
+
TlLincoln.prototype.refineUpdateStockData = function (input) {
|
|
221
|
+
var _this = this;
|
|
222
|
+
return input.dailyStocks.map(function (stock) { return ({
|
|
223
|
+
adjustmentDate: (0, moment_1.default)(stock.date).format('YYYYMMDD'),
|
|
224
|
+
netRmTypeGroupCode: input.roomTypeCode,
|
|
225
|
+
adjustmentProcedureCode: tl_lincoln_types_1.AdjustmentProcedureCode.NET_ROOM_TYPE_GROUP_CODE,
|
|
226
|
+
// stock이 0이 아니더라도 salesStatus를 START 하지 않을 수도 있음
|
|
227
|
+
salesStatus: stock.stock === 0 ? tl_lincoln_types_1.AdjustmentSaleStatus.STOP : tl_lincoln_types_1.AdjustmentSaleStatus.START,
|
|
228
|
+
remainingCount: "".concat(stock.stock),
|
|
229
|
+
requestId: _this.generateEightByteId(),
|
|
230
|
+
}); });
|
|
231
|
+
};
|
|
232
|
+
TlLincoln.prototype.callApi = function (url, xmlUrl, input) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
+
var commonRequest, response, responseText;
|
|
235
|
+
return __generator(this, function (_a) {
|
|
236
|
+
switch (_a.label) {
|
|
237
|
+
case 0:
|
|
238
|
+
commonRequest = {
|
|
239
|
+
systemId: this.systemId,
|
|
240
|
+
pmsUserId: this.pmsUserId,
|
|
241
|
+
pmsPassword: this.pmsPassword,
|
|
242
|
+
};
|
|
243
|
+
return [4 /*yield*/, (0, node_fetch_1.default)(url, {
|
|
244
|
+
method: 'POST',
|
|
245
|
+
headers: {
|
|
246
|
+
'Content-Type': 'text/xml',
|
|
247
|
+
},
|
|
248
|
+
body: (0, tl_lincoln_helper_1.jsonToXml)({
|
|
249
|
+
commonRequest: commonRequest,
|
|
250
|
+
request: input,
|
|
251
|
+
pmsUrl: xmlUrl,
|
|
252
|
+
}),
|
|
253
|
+
})];
|
|
254
|
+
case 1:
|
|
255
|
+
response = _a.sent();
|
|
256
|
+
return [4 /*yield*/, response.text()];
|
|
257
|
+
case 2:
|
|
258
|
+
responseText = _a.sent();
|
|
259
|
+
return [2 /*return*/, (0, tl_lincoln_helper_1.xmlToJson)(responseText)];
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
TlLincoln.prototype.netRoomTypeMasterSearchService = function () {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "NetRoomTypeMasterSearchService"), 'http://pmsfc1002.pmsfc10.pms.lincoln.seanuts.co.jp/', {
|
|
268
|
+
extractionCondition: {
|
|
269
|
+
extractionProcedureCode: '0',
|
|
270
|
+
},
|
|
271
|
+
})];
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
TlLincoln.prototype.netStockAdjustmentService = function (input) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
return __generator(this, function (_a) {
|
|
278
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "NetStockAdjustmentService"), 'http://pmsfc3002.pmsfc30.pms.lincoln.seanuts.co.jp/', {
|
|
279
|
+
adjustmentTarget: input,
|
|
280
|
+
})];
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
TlLincoln.prototype.netPlanMasterSearchService = function () {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
+
return __generator(this, function (_a) {
|
|
287
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "NetPlanMasterSearchService"), 'http://pmsfc1003.pmsfc10.pms.lincoln.seanuts.co.jp/', {})];
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
TlLincoln.prototype.netPriceAdjustmentService = function () {
|
|
292
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "NetPriceAdjustmentService"), 'http://pmsfc4001.pmsfc40.pms.lincoln.seanuts.co.jp/', {})];
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
TlLincoln.prototype.bookingInfoOutputService = function (input) {
|
|
299
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
300
|
+
return __generator(this, function (_a) {
|
|
301
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "BookingInfoOutputService"), 'http://pmsfc5001.pmsfc50.pms.lincoln.seanuts.co.jp/', {
|
|
302
|
+
outputTarget: __assign({ systemCode: '1' }, input),
|
|
303
|
+
})];
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
TlLincoln.prototype.outputCompleteService = function (outputId) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
+
return __generator(this, function (_a) {
|
|
310
|
+
return [2 /*return*/, this.callApi("".concat(this.API_URL, "OutputCompleteService"), 'http://pmsfc5002.pmsfc50.pms.lincoln.seanuts.co.jp/', {
|
|
311
|
+
outputTarget: {
|
|
312
|
+
systemCode: 1,
|
|
313
|
+
outputId: outputId,
|
|
314
|
+
},
|
|
315
|
+
})];
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
return TlLincoln;
|
|
320
|
+
}());
|
|
321
|
+
exports.TlLincoln = TlLincoln;
|