@revolugo/booking-api-client
Advanced tools
Comparing version 1.8.0 to 1.8.2
@@ -36,2 +36,3 @@ "use strict"; | ||
constructor(config) { | ||
var _a, _b; | ||
Object.defineProperty(this, "config", { | ||
@@ -55,5 +56,3 @@ enumerable: true, | ||
const apiConfig = new runtime_1.Configuration({ | ||
basePath: this.config.apiBaseUrl ?? | ||
constants_1.URLS[this.config.apiEnvironment] ?? | ||
`${process.env.BOOKING_API_BASE_URL}`, | ||
basePath: (_b = (_a = this.config.apiBaseUrl) !== null && _a !== void 0 ? _a : constants_1.URLS[this.config.apiEnvironment]) !== null && _b !== void 0 ? _b : `${process.env.BOOKING_API_BASE_URL}`, | ||
fetchApi: cross_fetch_1.default, | ||
@@ -60,0 +59,0 @@ headers: { |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -21,3 +22,3 @@ exports.URLS = exports.ApiVersionEnum = exports.POLLER = exports.Environment = void 0; | ||
exports.URLS = { | ||
[Environment.LOCAL]: `http://localhost:${process.env.PORT ?? 3333}`, | ||
[Environment.LOCAL]: `http://localhost:${(_a = process.env.PORT) !== null && _a !== void 0 ? _a : 3333}`, | ||
[Environment.STAGING]: 'https://booking-api.staging.revolugo.com', | ||
@@ -24,0 +25,0 @@ [Environment.SANDBOX]: 'https://booking-api.sandbox.revolugo.com', |
export interface IPollerResponse { | ||
data?: any; | ||
data?: unknown; | ||
meta?: { | ||
@@ -4,0 +4,0 @@ status: string; |
@@ -61,3 +61,4 @@ "use strict"; | ||
async onRequest(result, request, options) { | ||
const resultFormatted = (0, case_transformers_1.keysChangeCase)(result ?? {}, case_transformers_1.CASE_TRANSFORMERS.CAMEL_CASE); | ||
var _a; | ||
const resultFormatted = (0, case_transformers_1.keysChangeCase)(result !== null && result !== void 0 ? result : {}, case_transformers_1.CASE_TRANSFORMERS.CAMEL_CASE); | ||
if (!this.isActivePoller(options)) { | ||
@@ -78,3 +79,3 @@ return; | ||
else { | ||
if (resultFormatted?.meta?.status) { | ||
if ((_a = resultFormatted === null || resultFormatted === void 0 ? void 0 : resultFormatted.meta) === null || _a === void 0 ? void 0 : _a.status) { | ||
resultFormatted.meta.status = 'COMPLETE'; | ||
@@ -95,3 +96,4 @@ } | ||
isInProgress(result) { | ||
return (result?.meta?.status ?? '').toLowerCase() !== 'complete'; | ||
var _a, _b; | ||
return ((_b = (_a = result === null || result === void 0 ? void 0 : result.meta) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : '').toLowerCase() !== 'complete'; | ||
} | ||
@@ -112,3 +114,6 @@ buildPollerOptions(options) { | ||
if (options.type) { | ||
return (!!this.pollings[options.type] && | ||
return ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
!!this.pollings[options.type] && | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
this.pollings[options.type] === options.uuid); | ||
@@ -123,4 +128,5 @@ } | ||
removeCurrentPolling(options) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (options.type && this.pollings[options.type]) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete, @typescript-eslint/no-explicit-any | ||
delete this.pollings[options.type]; | ||
@@ -141,5 +147,7 @@ } | ||
if (pollerCallback && typeof pollerCallback === 'function') { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('data', (result) => { | ||
pollerCallback(null, result); | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('error', (err) => { | ||
@@ -152,2 +160,3 @@ pollerCallback(err); | ||
poller.on('error', reject); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('complete', (hotelOffers) => { | ||
@@ -154,0 +163,0 @@ resolve(hotelOffers); |
@@ -33,3 +33,3 @@ "use strict"; | ||
const keysChangeCase = ( | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
obj, toCase, | ||
@@ -40,7 +40,11 @@ // eslint-disable-next-line unicorn/no-object-as-default-parameter | ||
return (0, lodash_1.reduce)(obj, (result, value, key) => { | ||
result[options?.exclude && matches(options.exclude, key) | ||
result[(options === null || options === void 0 ? void 0 : options.exclude) && matches(options.exclude, key) | ||
? key | ||
: CASE_TRANSORMERS_MAPPING[toCase](key)] = options.deep ? (0, exports.keysChangeCase)(obj[key], toCase, options) : obj[key]; | ||
: CASE_TRANSORMERS_MAPPING[toCase](key)] = options.deep | ||
? (0, exports.keysChangeCase)(obj[key], toCase, options) | ||
: obj[key]; | ||
return result; | ||
}, {}); | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
{}); | ||
} | ||
@@ -47,0 +51,0 @@ else if (Array.isArray(obj)) { |
@@ -107,3 +107,3 @@ "use strict"; | ||
...(0, merge_1.default)(initOverrides, { | ||
headers: (0, merge_1.default)({}, headers, initOverrides?.headers) | ||
headers: (0, merge_1.default)({}, headers, initOverrides === null || initOverrides === void 0 ? void 0 : initOverrides.headers) | ||
}) | ||
@@ -110,0 +110,0 @@ }; |
@@ -36,3 +36,3 @@ { | ||
"types": "build/index.d.ts", | ||
"version": "1.8.0", | ||
"version": "1.8.2", | ||
"devDependencies": { | ||
@@ -39,0 +39,0 @@ "terser-webpack-plugin": "^5.3.3" |
@@ -6,3 +6,3 @@ import { v4 as uuidv4 } from 'uuid' | ||
export interface IPollerResponse { | ||
data?: any | ||
data?: unknown | ||
meta?: { | ||
@@ -143,4 +143,5 @@ status: string | ||
if (options.type && !options.uuid) { | ||
options.uuid = uuidv4(); | ||
(this.pollings as any)[options.type] = options.uuid | ||
options.uuid = uuidv4() | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, semi-style | ||
;(this.pollings as any)[options.type] = options.uuid | ||
} | ||
@@ -152,3 +153,5 @@ } | ||
return ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
!!(this.pollings as any)[options.type] && | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(this.pollings as any)[options.type] === options.uuid | ||
@@ -167,4 +170,5 @@ ) | ||
private removeCurrentPolling (options: TOptions<V>): void { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (options.type && (this.pollings as any)[options.type]) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete, @typescript-eslint/no-explicit-any | ||
delete (this.pollings as any)[options.type] | ||
@@ -192,2 +196,3 @@ } | ||
if (pollerCallback && typeof pollerCallback === 'function') { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('data', (result: any) => { | ||
@@ -197,2 +202,3 @@ pollerCallback(null, result) | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('error', (err: any) => { | ||
@@ -208,2 +214,3 @@ pollerCallback(err) | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
poller.on('complete', (hotelOffers: any) => { | ||
@@ -210,0 +217,0 @@ resolve(hotelOffers) |
@@ -34,3 +34,3 @@ import { camelCase } from 'camel-case' | ||
function isObject (o: any): boolean { | ||
function isObject (o: unknown): boolean { | ||
return o === Object(o) && !Array.isArray(o) && typeof o !== 'function' | ||
@@ -40,3 +40,3 @@ } | ||
export const keysChangeCase = ( | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
obj: any, | ||
@@ -46,2 +46,3 @@ toCase: CASE_TRANSFORMERS, | ||
options: { deep?: boolean; exclude?: (string | RegExp)[] } = { deep: true }, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
): any => { | ||
@@ -56,6 +57,9 @@ if (isObject(obj)) { | ||
: CASE_TRANSORMERS_MAPPING[toCase](key) | ||
] = options.deep ? keysChangeCase(obj[key], toCase, options) : obj[key] | ||
] = options.deep | ||
? keysChangeCase(obj[key as keyof typeof obj], toCase, options) | ||
: obj[key as keyof typeof obj] | ||
return result | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
<any>{}, | ||
@@ -62,0 +66,0 @@ ) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1156780
22261