ti2-tourplan 1.0.125 → 1.0.126

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.
@@ -172,7 +172,7 @@ const getAvailabilityOnly = async ({
172
172
  const model = {
173
173
  OptionInfoRequest: {
174
174
  Opt: optionId,
175
- Info: 'AD',
175
+ Info: 'GAR',
176
176
  AgentID: hostConnectAgentID,
177
177
  Password: hostConnectAgentPassword,
178
178
  DateFrom: startDate,
@@ -186,7 +186,11 @@ const getAvailabilityOnly = async ({
186
186
  axios,
187
187
  xmlOptions: hostConnectXmlOptions,
188
188
  });
189
- return R.pathOr([], ['OptionInfoReply', 'Option', 'OptAvail'], replyObj);
189
+ const option = R.path(['OptionInfoReply', 'Option'], replyObj);
190
+ return {
191
+ optAvail: R.pathOr([], ['OptAvail'], option),
192
+ optRates: R.path(['OptRates'], option),
193
+ };
190
194
  };
191
195
  /*
192
196
  Get general option information from Tourplan API.
@@ -152,7 +152,7 @@ const searchAvailabilityForItinerary = async ({
152
152
  const isAvailabilityOnly = availabilityOnly === true;
153
153
 
154
154
  if (isAvailabilityOnly) {
155
- const availabilityOnlyResponse = await getAvailabilityOnly({
155
+ const { optAvail, optRates } = await getAvailabilityOnly({
156
156
  optionId,
157
157
  hostConnectEndpoint,
158
158
  hostConnectAgentID,
@@ -162,8 +162,9 @@ const searchAvailabilityForItinerary = async ({
162
162
  requestedEndDate,
163
163
  callTourplan,
164
164
  });
165
- const optAvailValues = getOptAvailValues(availabilityOnlyResponse);
165
+ const optAvailValues = getOptAvailValues(optAvail);
166
166
  const SCheckPass = isOptAvailBookable(optAvailValues);
167
+ const rates = (SCheckPass && optRates) ? [optRates] : [];
167
168
  return {
168
169
  bookable: SCheckPass,
169
170
  type: 'availability',
@@ -172,7 +173,7 @@ const searchAvailabilityForItinerary = async ({
172
173
  ? 'Availability checked successfully'
173
174
  : 'No availability found for the requested range',
174
175
  availability: optAvailValues,
175
- rates: [],
176
+ rates,
176
177
  };
177
178
  }
178
179
 
@@ -24,7 +24,7 @@ jest.mock('./itinerary-availability-helper', () => ({
24
24
  maxPaxPerCharge: null,
25
25
  })),
26
26
  getNoRatesAvailableError: jest.fn(async () => 'No rates available'),
27
- getAvailabilityOnly: jest.fn(async () => '-1 -1 -1'),
27
+ getAvailabilityOnly: jest.fn(async () => ({ optAvail: '-1 -1 -1', optRates: null })),
28
28
  getStayResults: jest.fn(async () => ([{
29
29
  RateId: 'R1',
30
30
  Currency: 'USD',
@@ -149,7 +149,18 @@ describe('searchAvailabilityForItinerary validation flags', () => {
149
149
  });
150
150
 
151
151
  it('uses availabilityOnly flow and keeps response shape consistent', async () => {
152
- itineraryAvailabilityHelper.getAvailabilityOnly.mockResolvedValueOnce('-1 -2 -1');
152
+ const mockOptRates = {
153
+ Currency: 'JPY',
154
+ OptRate: {
155
+ Date: '2026-06-01',
156
+ RateName: '26年',
157
+ PersonRates: { AdultRate: 2700000, ChildRate: 1700000 },
158
+ },
159
+ };
160
+ itineraryAvailabilityHelper.getAvailabilityOnly.mockResolvedValueOnce({
161
+ optAvail: '-1 -2 -1',
162
+ optRates: mockOptRates,
163
+ });
153
164
 
154
165
  const result = await searchAvailabilityForItinerary({
155
166
  axios: jest.fn(),
@@ -160,6 +171,7 @@ describe('searchAvailabilityForItinerary validation flags', () => {
160
171
  });
161
172
 
162
173
  expect(itineraryAvailabilityHelper.getAvailabilityOnly).toHaveBeenCalledTimes(1);
174
+ expect(itineraryAvailabilityHelper.getStayResults).not.toHaveBeenCalled();
163
175
  expect(itineraryAvailabilityHelper.getAgentCurrencyCode).not.toHaveBeenCalled();
164
176
  expect(result).toEqual({
165
177
  bookable: true,
@@ -167,12 +179,15 @@ describe('searchAvailabilityForItinerary validation flags', () => {
167
179
  endDate: '2025-04-05',
168
180
  message: 'Availability checked successfully',
169
181
  availability: [-1, -2, -1],
170
- rates: [],
182
+ rates: [mockOptRates],
171
183
  });
172
184
  });
173
185
 
174
186
  it('marks availabilityOnly response as not bookable when all days are unavailable', async () => {
175
- itineraryAvailabilityHelper.getAvailabilityOnly.mockResolvedValueOnce('-1 -1 -1');
187
+ itineraryAvailabilityHelper.getAvailabilityOnly.mockResolvedValueOnce({
188
+ optAvail: '-1 -1 -1',
189
+ optRates: null,
190
+ });
176
191
 
177
192
  const result = await searchAvailabilityForItinerary({
178
193
  axios: jest.fn(),
@@ -186,5 +201,6 @@ describe('searchAvailabilityForItinerary validation flags', () => {
186
201
  expect(result.message).toBe('No availability found for the requested range');
187
202
  expect(result.availability).toEqual([-1, -1, -1]);
188
203
  expect(result.rates).toEqual([]);
204
+ expect(itineraryAvailabilityHelper.getStayResults).not.toHaveBeenCalled();
189
205
  });
190
206
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.125",
3
+ "version": "1.0.126",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {