uapi-json 1.17.1 → 1.17.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uapi-json",
3
- "version": "1.17.1",
3
+ "version": "1.17.3",
4
4
  "description": "Travelport Universal API",
5
5
  "main": "src/",
6
6
  "files": [
@@ -15,7 +15,8 @@
15
15
  "coveralls": "nyc report --reporter=text-lcov > coverage.lcov",
16
16
  "fix": "eslint --fix src/ test/",
17
17
  "lint": "eslint src/ test/",
18
- "prepublish": "npm run lint && npm run test"
18
+ "prepublish": "npm run lint && npm run test",
19
+ "cleanup": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +"
19
20
  },
20
21
  "repository": {
21
22
  "type": "git",
@@ -36,27 +37,27 @@
36
37
  ],
37
38
  "license": "MIT",
38
39
  "dependencies": {
39
- "joi": "^17.6.2",
40
- "axios": "^1.6.2",
40
+ "axios": "^1.7.7",
41
41
  "galileo-screen": "1.0.5",
42
- "handlebars": "^4.7.7",
42
+ "handlebars": "^4.7.8",
43
43
  "handlebars-helper-equal": "^1.0.0",
44
- "moment": "^2.29.4",
44
+ "joi": "^17.13.3",
45
+ "moment": "^2.30.1",
45
46
  "node-errors-helpers": "^1.0.0",
46
47
  "pretty-data": "^0.40.0",
47
- "promise-retry": "^1.1.1",
48
- "xml2js": "^0.5.0"
48
+ "promise-retry": "^2.0.1",
49
+ "xml2js": "^0.6.2"
49
50
  },
50
51
  "devDependencies": {
51
- "chai": "^4.3.7",
52
+ "chai": "^4.5.0",
52
53
  "eslint": "^8.39.0",
53
54
  "eslint-config-airbnb-base": "^15.0.0",
54
55
  "eslint-plugin-import": "^2.29.0",
55
- "mocha": "^10.2.0",
56
- "nyc": "^15.1.0",
56
+ "mocha": "^10.7.3",
57
+ "nyc": "^17.1.0",
57
58
  "proxyquire": "^2.1.3",
58
59
  "readline2": "^1.0.1",
59
- "sinon": "^16.1.1",
60
+ "sinon": "^19.0.2",
60
61
  "sinon-chai": "^3.7.0"
61
62
  }
62
63
  }
@@ -75,61 +75,71 @@ module.exports = function uapiRequest(
75
75
  return reqType;
76
76
  }));
77
77
 
78
- const sendRequest = function (xml) {
78
+ const sendRequest = async (xml) => {
79
79
  if (debugMode) {
80
80
  log('Request URL: ', service);
81
81
  log('Request XML: ', pd.xml(xml));
82
82
  }
83
- return axios.request({
84
- url: service,
85
- method: 'POST',
86
- timeout: config.timeout || 5000,
87
- auth: {
88
- username: auth.username,
89
- password: auth.password,
90
- },
91
- headers: {
92
- 'Accept-Encoding': 'gzip',
93
- 'Content-Type': 'text/xml',
94
- },
95
- data: xml,
96
- })
97
- .then((response) => {
98
- if (debugMode) {
99
- log('Response SOAP: ', pd.xml(response.data));
100
- }
101
- return response.data;
102
- })
103
- .catch((e) => {
104
- const rsp = e.response;
105
83
 
106
- if (['ECONNREFUSED', 'ECONNRESET'].includes(e.code)) {
107
- return Promise.reject(new RequestRuntimeError.UAPIServiceError(e));
108
- }
84
+ try {
85
+ const response = await axios.request({
86
+ url: service,
87
+ method: 'POST',
88
+ timeout: config.timeout || 5000,
89
+ auth: {
90
+ username: auth.username,
91
+ password: auth.password,
92
+ },
93
+ headers: {
94
+ 'Accept-Encoding': 'gzip',
95
+ 'Content-Type': 'text/xml',
96
+ },
97
+ data: xml,
98
+ });
109
99
 
110
- if (['ECONNABORTED'].includes(e.code)) {
111
- return Promise.reject(new RequestRuntimeError.UAPIServiceTimeout(e));
112
- }
100
+ if (debugMode) {
101
+ log('Response SOAP: ', pd.xml(response.data));
102
+ }
113
103
 
114
- if (!rsp) {
115
- if (debugMode) {
116
- log('Unexpected Error: ', pd.json(e));
117
- }
104
+ return response.data;
105
+ } catch (e) {
106
+ const rsp = e.response;
118
107
 
119
- return Promise.reject(new RequestSoapError.SoapUnexpectedError(e));
108
+ if (['ECONNREFUSED', 'ECONNRESET'].includes(e.code)) {
109
+ throw new RequestRuntimeError.UAPIServiceError(e);
110
+ }
111
+
112
+ if (['ECONNABORTED'].includes(e.code)) {
113
+ throw new RequestRuntimeError.UAPIServiceTimeout(e);
114
+ }
115
+
116
+ if (!rsp) {
117
+ if (debugMode) {
118
+ log('Unexpected Error: ', pd.json(e));
120
119
  }
121
120
 
122
- const error = {
123
- status: rsp.status,
124
- data: rsp.data,
125
- };
121
+ throw new RequestSoapError.SoapUnexpectedError(e);
122
+ }
126
123
 
124
+ // TVPT error response with 500 header
125
+ if (rsp.data.toUpperCase().includes('SOAP:FAULT')) {
127
126
  if (debugMode) {
128
- log('Error Response SOAP: ', pd.json(error));
127
+ log('Response SOAP: ', pd.xml(rsp.data));
129
128
  }
129
+ return rsp.data;
130
+ }
130
131
 
131
- return Promise.reject(new RequestSoapError.SoapRequestError(error));
132
- });
132
+ const error = {
133
+ status: rsp.status,
134
+ data: rsp.data,
135
+ };
136
+
137
+ if (debugMode) {
138
+ log('Error Response SOAP: ', pd.json(error));
139
+ }
140
+
141
+ throw new RequestSoapError.SoapRequestError(error);
142
+ }
133
143
  };
134
144
 
135
145
  const parseResponse = function (response, parseParams) {
@@ -146,6 +156,7 @@ module.exports = function uapiRequest(
146
156
  };
147
157
 
148
158
  const validateSOAP = function (parsedXML) {
159
+ console.log(parsedXML);
149
160
  if (parsedXML['SOAP:Fault']) {
150
161
  if (debugMode > 2) {
151
162
  log('Parsed error response', pd.json(parsedXML));
@@ -1,5 +1,5 @@
1
1
  module.exports = `
2
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:air="http://www.travelport.com/schema/air_v51_0" xmlns:com="http://www.travelport.com/schema/common_v51_0">
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:air="http://www.travelport.com/schema/air_v52_0" xmlns:com="http://www.travelport.com/schema/common_v52_0">
3
3
  <soapenv:Header/>
4
4
  <soapenv:Body>
5
5
  <air:EMDRetrieveReq TraceId="{{requestId}}" TargetBranch="{{TargetBranch}}" RetrieveProviderReservationDetails="false">
@@ -2,7 +2,7 @@ module.exports = `
2
2
  <soapenv:Envelope
3
3
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
4
4
  xmlns:univ="http://www.travelport.com/schema/universal_v52_0"
5
- xmlns:gds="http://www.travelport.com/schema/gdsQueue_v47_0"
5
+ xmlns:gds="http://www.travelport.com/schema/gdsQueue_v52_0"
6
6
  xmlns:com="http://www.travelport.com/schema/common_v52_0"
7
7
  >
8
8
  <soapenv:Header />
@@ -5,7 +5,7 @@ module.exports = `
5
5
  <univ:HotelCreateReservationReq
6
6
  xmlns:com="http://www.travelport.com/schema/common_v52_0"
7
7
  xmlns:common_v52_0="http://www.travelport.com/schema/common_v52_0"
8
- xmlns:hotel="http://www.travelport.com/schema/hotel_v47_0"
8
+ xmlns:hotel="http://www.travelport.com/schema/hotel_v52_0"
9
9
  xmlns:univ="http://www.travelport.com/schema/universal_v52_0"
10
10
  ProviderCode="TRM"
11
11
  TargetBranch="{{{TargetBranch}}}"
@@ -41,12 +41,12 @@ module.exports = `
41
41
 
42
42
 
43
43
  {{#rates}}
44
- <hotel:HotelRateDetail xmlns:hotel="http://www.travelport.com/schema/hotel_v47_0" RatePlanType="{{& RatePlanType}}" RateSupplier="{{& RateSupplier}}" RateOfferId="{{& RateOfferId}}" Base="{{& Base.currency}}{{& Base.value}}" Tax="{{& Tax.currency}}{{& Tax.value}}" Total="{{& Total.currency}}{{& Total.value}}" Surcharge="{{& Surcharge.currency}}{{& Surcharge.value}}" />
44
+ <hotel:HotelRateDetail xmlns:hotel="http://www.travelport.com/schema/hotel_v52_0" RatePlanType="{{& RatePlanType}}" RateSupplier="{{& RateSupplier}}" RateOfferId="{{& RateOfferId}}" Base="{{& Base.currency}}{{& Base.value}}" Tax="{{& Tax.currency}}{{& Tax.value}}" Total="{{& Total.currency}}{{& Total.value}}" Surcharge="{{& Surcharge.currency}}{{& Surcharge.value}}" />
45
45
  {{/rates}}
46
46
 
47
- <hotel:HotelProperty xmlns:hotel="http://www.travelport.com/schema/hotel_v47_0" HotelChain="{{& HotelChain}}" HotelCode="{{& HotelCode}}" {{#if Name}} Name="{{Name}}" {{/if}}>
47
+ <hotel:HotelProperty xmlns:hotel="http://www.travelport.com/schema/hotel_v52_0" HotelChain="{{& HotelChain}}" HotelCode="{{& HotelCode}}" {{#if Name}} Name="{{Name}}" {{/if}}>
48
48
  </hotel:HotelProperty>
49
- <hotel:HotelStay xmlns:hot="http://www.travelport.com/schema/hotel_v47_0">
49
+ <hotel:HotelStay xmlns:hot="http://www.travelport.com/schema/hotel_v52_0">
50
50
  <hotel:CheckinDate>{{{startDate}}}</hotel:CheckinDate>
51
51
  <hotel:CheckoutDate>{{{endDate}}}</hotel:CheckoutDate>
52
52
  </hotel:HotelStay>
@@ -59,7 +59,7 @@ module.exports = `
59
59
  <common_v52_0:HostToken Host="TRM">
60
60
  {{& HostToken}}
61
61
  </common_v52_0:HostToken>
62
- <hot:BookingGuestInformation xmlns:hot="http://www.travelport.com/schema/hotel_v47_0">
62
+ <hot:BookingGuestInformation xmlns:hot="http://www.travelport.com/schema/hotel_v52_0">
63
63
  {{#roomsRefs}}
64
64
  <hot:Room>
65
65
  <hot:Adults>{{& adults}}</hot:Adults>
@@ -3,7 +3,7 @@ module.exports = `
3
3
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
4
4
  <soapenv:Header/>
5
5
  <soapenv:Body>
6
- <hot:HotelDetailsReq xmlns:com="http://www.travelport.com/schema/common_v52_0" xmlns:hot="http://www.travelport.com/schema/hotel_v47_0" ReturnGuestReviews="true" ReturnMediaLinks="true" TargetBranch="{{TargetBranch}}">
6
+ <hot:HotelDetailsReq xmlns:com="http://www.travelport.com/schema/common_v52_0" xmlns:hot="http://www.travelport.com/schema/hotel_v52_0" ReturnGuestReviews="true" ReturnMediaLinks="true" TargetBranch="{{TargetBranch}}">
7
7
  <com:BillingPointOfSaleInfo OriginApplication="UAPI"/>
8
8
  <hot:HotelProperty HotelChain="{{HotelChain}}" HotelCode="{{HotelCode}}" {{#if Name}} Name="{{Name}}" {{/if}}/>
9
9
  <hot:HotelDetailsModifiers MaxWait="11000" RateRuleDetail="Complete" {{#if currency}} PreferredCurrency="{{currency}}" {{/if}}>
@@ -1,5 +1,5 @@
1
1
  module.exports = `
2
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hot="http://www.travelport.com/schema/hotel_v47_0" xmlns:com="http://www.travelport.com/schema/common_v52_0">
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hot="http://www.travelport.com/schema/hotel_v52_0" xmlns:com="http://www.travelport.com/schema/common_v52_0">
3
3
  <soapenv:Header/>
4
4
  <soapenv:Body>
5
5
  <hot:HotelSearchAvailabilityReq TargetBranch="{{TargetBranch}}" >
@@ -1,5 +1,5 @@
1
1
  module.exports = `
2
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hot="http://www.travelport.com/schema/hotel_v47_0" xmlns:com="http://www.travelport.com/schema/common_v52_0">
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hot="http://www.travelport.com/schema/hotel_v52_0" xmlns:com="http://www.travelport.com/schema/common_v52_0">
3
3
  <soapenv:Header/>
4
4
  <soapenv:Body>
5
5
  <hot:HotelSearchAvailabilityReq TargetBranch="{{TargetBranch}}" >