@reservamos/browser-analytics 0.1.4-alpha.9 → 0.2.1
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/browser-analytics.cjs +4 -3
- package/dist/browser-analytics.cjs.map +1 -0
- package/dist/browser-analytics.d.ts +429 -166
- package/dist/browser-analytics.esm.js +2823 -224
- package/dist/browser-analytics.esm.js.map +1 -0
- package/dist/browser-analytics.iife.js +4 -3
- package/dist/browser-analytics.iife.js.map +1 -0
- package/package.json +2 -1
- package/src/events/customEvent/customEventSchema.ts +19 -0
- package/src/events/customEvent/index.ts +7 -0
- package/src/events/customEvent/trackCustomEvent.ts +19 -0
- package/src/events/identify/identify.ts +17 -10
- package/src/events/identify/identifySchema.ts +2 -1
- package/src/events/identify/index.ts +3 -1
- package/src/events/interestInHome/trackInterestInHome.ts +7 -2
- package/src/events/interestInSearch/trackInterestInSearch.ts +7 -2
- package/src/events/passengersCreated/passengersCreatedSchema.ts +11 -48
- package/src/events/passengersCreated/trackPassengersCreated.ts +12 -3
- package/src/events/paymentAttempt/paymentAttemptSchema.ts +12 -45
- package/src/events/pickedDeparture/pickedDepartureSchema.ts +2 -9
- package/src/events/pickedDeparture/trackPickedDeparture.ts +7 -2
- package/src/events/purchaseAttempt/purchaseAttemptSchema.ts +6 -66
- package/src/events/purchaseAttempt/trackPurchaseAttempt.ts +8 -3
- package/src/events/search/trackSearch.ts +4 -2
- package/src/events/seatChange/trackSeatChange.ts +12 -3
- package/src/events/sharedSchemas/tripSchema.ts +42 -0
- package/src/events/viewResults/trackViewResults.ts +7 -2
- package/src/index.ts +17 -0
- package/src/init.ts +20 -3
- package/src/js-api-client.d.ts +15 -0
- package/src/profiles/createAnonymousProfile/createAnonymousProfile.test.ts +38 -0
- package/src/profiles/createAnonymousProfile/createAnonymousProfile.ts +78 -0
- package/src/profiles/createAnonymousProfile/createAnonymousProfileSchema.ts +15 -0
- package/src/profiles/createAnonymousProfile/index.ts +5 -0
- package/src/services/config.ts +24 -0
- package/src/services/fingerprint.ts +38 -2
- package/src/services/mixpanel.ts +21 -1
- package/src/services/validator.ts +21 -4
- package/src/track.ts +39 -5
- package/src/types/eventData.ts +5 -0
- package/src/util/primitiveFields.ts +70 -0
|
@@ -3910,19 +3910,17 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3910
3910
|
quotelessJson,
|
|
3911
3911
|
ZodError
|
|
3912
3912
|
});
|
|
3913
|
-
const
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
const
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
const
|
|
3924
|
-
product: productValidation
|
|
3925
|
-
});
|
|
3913
|
+
const allowedPrimitiveSchema = z.union([
|
|
3914
|
+
z.string(),
|
|
3915
|
+
z.boolean(),
|
|
3916
|
+
z.number(),
|
|
3917
|
+
z.undefined()
|
|
3918
|
+
]);
|
|
3919
|
+
const customEventSchema = z.record(
|
|
3920
|
+
z.string(),
|
|
3921
|
+
z.union([allowedPrimitiveSchema, z.array(allowedPrimitiveSchema)])
|
|
3922
|
+
);
|
|
3923
|
+
const eventNameSchema = z.string().min(1, "Event name is required");
|
|
3926
3924
|
var __assign = function() {
|
|
3927
3925
|
__assign = Object.assign || function __assign2(t) {
|
|
3928
3926
|
for (var s2, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -4531,6 +4529,7 @@ class FpjsClient {
|
|
|
4531
4529
|
}
|
|
4532
4530
|
const DEFAULT_CACHE_NAME = "default_fingerprint_cache";
|
|
4533
4531
|
const DEFAULT_CACHE_TIME_IN_DAYS = 7;
|
|
4532
|
+
const PROXY_QUERY_PARAM = "apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>";
|
|
4534
4533
|
const getExpirationDate = (cacheTimeInDays) => {
|
|
4535
4534
|
const currentDate = /* @__PURE__ */ new Date();
|
|
4536
4535
|
const futureDate = new Date(
|
|
@@ -4562,11 +4561,22 @@ const setCachedFingerprint = (fingerprint) => {
|
|
|
4562
4561
|
};
|
|
4563
4562
|
localStorage.setItem(cacheName, JSON.stringify(cacheData));
|
|
4564
4563
|
};
|
|
4565
|
-
|
|
4564
|
+
function buildProxyUrl(url) {
|
|
4565
|
+
return `${url}?${PROXY_QUERY_PARAM}`;
|
|
4566
|
+
}
|
|
4567
|
+
async function initFingerprint(apiKey, proxyUrl) {
|
|
4568
|
+
const customEndpointArray = [i$1];
|
|
4569
|
+
const customScriptEndpointArray = [B];
|
|
4570
|
+
if (proxyUrl) {
|
|
4571
|
+
customEndpointArray.unshift(proxyUrl);
|
|
4572
|
+
customScriptEndpointArray.unshift(buildProxyUrl(proxyUrl));
|
|
4573
|
+
}
|
|
4566
4574
|
window.fingerprintConfig = {};
|
|
4567
4575
|
window.fpClient = new FpjsClient({
|
|
4568
4576
|
loadOptions: {
|
|
4569
|
-
apiKey
|
|
4577
|
+
apiKey,
|
|
4578
|
+
endpoint: customEndpointArray,
|
|
4579
|
+
scriptUrlPattern: customScriptEndpointArray
|
|
4570
4580
|
}
|
|
4571
4581
|
});
|
|
4572
4582
|
try {
|
|
@@ -4606,7 +4616,8 @@ function isFingerprintReady() {
|
|
|
4606
4616
|
const fingerprintService = {
|
|
4607
4617
|
initFingerprint,
|
|
4608
4618
|
getFingerprint,
|
|
4609
|
-
isFingerprintReady
|
|
4619
|
+
isFingerprintReady,
|
|
4620
|
+
getCachedFingerprint
|
|
4610
4621
|
};
|
|
4611
4622
|
var NodeType;
|
|
4612
4623
|
(function(NodeType2) {
|
|
@@ -4802,14 +4813,14 @@ function getValidTagName(element) {
|
|
|
4802
4813
|
return processedTagName;
|
|
4803
4814
|
}
|
|
4804
4815
|
function extractOrigin(url) {
|
|
4805
|
-
let
|
|
4816
|
+
let origin2 = "";
|
|
4806
4817
|
if (url.indexOf("//") > -1) {
|
|
4807
|
-
|
|
4818
|
+
origin2 = url.split("/").slice(0, 3).join("/");
|
|
4808
4819
|
} else {
|
|
4809
|
-
|
|
4820
|
+
origin2 = url.split("/")[0];
|
|
4810
4821
|
}
|
|
4811
|
-
|
|
4812
|
-
return
|
|
4822
|
+
origin2 = origin2.split("?")[0];
|
|
4823
|
+
return origin2;
|
|
4813
4824
|
}
|
|
4814
4825
|
let canvasService;
|
|
4815
4826
|
let canvasCtx;
|
|
@@ -4818,11 +4829,11 @@ const URL_PROTOCOL_MATCH = /^(?:[a-z+]+:)?\/\//i;
|
|
|
4818
4829
|
const URL_WWW_MATCH = /^www\..*/i;
|
|
4819
4830
|
const DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
4820
4831
|
function absoluteToStylesheet(cssText, href) {
|
|
4821
|
-
return (cssText || "").replace(URL_IN_CSS_REF, (
|
|
4832
|
+
return (cssText || "").replace(URL_IN_CSS_REF, (origin2, quote1, path1, quote2, path2, path3) => {
|
|
4822
4833
|
const filePath = path1 || path2 || path3;
|
|
4823
4834
|
const maybeQuote = quote1 || quote2 || "";
|
|
4824
4835
|
if (!filePath) {
|
|
4825
|
-
return
|
|
4836
|
+
return origin2;
|
|
4826
4837
|
}
|
|
4827
4838
|
if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) {
|
|
4828
4839
|
return `url(${maybeQuote}${filePath}${maybeQuote})`;
|
|
@@ -13008,14 +13019,15 @@ function loadNoop(_src, onload) {
|
|
|
13008
13019
|
onload();
|
|
13009
13020
|
}
|
|
13010
13021
|
var mixpanel = init_as_module(loadNoop);
|
|
13011
|
-
function init$1(mixpanelToken, debug = false) {
|
|
13022
|
+
function init$1(mixpanelToken, debug = false, proxyUrl) {
|
|
13012
13023
|
return new Promise((resolve) => {
|
|
13013
13024
|
mixpanel.init(mixpanelToken, {
|
|
13014
13025
|
debug,
|
|
13015
13026
|
loaded: () => {
|
|
13016
13027
|
window.mixpanel = mixpanel;
|
|
13017
13028
|
resolve();
|
|
13018
|
-
}
|
|
13029
|
+
},
|
|
13030
|
+
...proxyUrl && { api_host: proxyUrl }
|
|
13019
13031
|
});
|
|
13020
13032
|
});
|
|
13021
13033
|
}
|
|
@@ -13041,45 +13053,43 @@ function track(eventName, properties) {
|
|
|
13041
13053
|
}
|
|
13042
13054
|
mixpanel.track(eventName, properties);
|
|
13043
13055
|
}
|
|
13056
|
+
const getMixpanelDistinctId = () => {
|
|
13057
|
+
if (mixpanel && mixpanel.get_distinct_id) {
|
|
13058
|
+
return mixpanel.get_distinct_id();
|
|
13059
|
+
}
|
|
13060
|
+
return null;
|
|
13061
|
+
};
|
|
13044
13062
|
const mixpanelService = {
|
|
13045
13063
|
init: init$1,
|
|
13046
13064
|
isReady,
|
|
13047
13065
|
track,
|
|
13048
13066
|
identify: identify$1,
|
|
13049
|
-
attachProperty
|
|
13067
|
+
attachProperty,
|
|
13068
|
+
getMixpanelDistinctId
|
|
13050
13069
|
};
|
|
13051
|
-
const
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
}
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
...defaultProperties,
|
|
13065
|
-
...eventProperties
|
|
13066
|
-
};
|
|
13067
|
-
mixpanelService.track(eventName, properties);
|
|
13068
|
-
} catch (error) {
|
|
13069
|
-
console.error("Error tracking event:", error);
|
|
13070
|
-
throw error;
|
|
13071
|
-
}
|
|
13072
|
-
}
|
|
13070
|
+
const IdentifySchema = z.object({
|
|
13071
|
+
firstName: z.string().optional(),
|
|
13072
|
+
lastName: z.string().optional(),
|
|
13073
|
+
email: z.string().email().optional(),
|
|
13074
|
+
phone: z.string().regex(/^\+?[1-9]\d{1,14}$/).optional()
|
|
13075
|
+
});
|
|
13076
|
+
const PRODUCT_TYPES = ["web", "web-mobile", "ios", "android", "app"];
|
|
13077
|
+
const productValidation = z.enum(PRODUCT_TYPES).refine((val) => PRODUCT_TYPES.includes(val), {
|
|
13078
|
+
message: `Product must be one of: ${PRODUCT_TYPES.join(", ")}`
|
|
13079
|
+
});
|
|
13080
|
+
const interestInHomeSchema = z.object({
|
|
13081
|
+
product: productValidation
|
|
13082
|
+
});
|
|
13073
13083
|
const EVENT_NAME$9 = "Interest In Home";
|
|
13074
|
-
function trackInterestInHome(eventData) {
|
|
13075
|
-
trackEvent(EVENT_NAME$9, eventData);
|
|
13084
|
+
function trackInterestInHome(eventData, meta = {}) {
|
|
13085
|
+
trackEvent(EVENT_NAME$9, eventData, meta);
|
|
13076
13086
|
}
|
|
13077
13087
|
const interestInSearchSchema = z.object({
|
|
13078
13088
|
product: productValidation
|
|
13079
13089
|
});
|
|
13080
13090
|
const EVENT_NAME$8 = "Interest In Search";
|
|
13081
|
-
function trackInterestInSearch(eventData) {
|
|
13082
|
-
trackEvent(EVENT_NAME$8, eventData);
|
|
13091
|
+
function trackInterestInSearch(eventData, meta = {}) {
|
|
13092
|
+
trackEvent(EVENT_NAME$8, eventData, meta);
|
|
13083
13093
|
}
|
|
13084
13094
|
const dateValidation = (val) => {
|
|
13085
13095
|
const dateRegex2 = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -13093,59 +13103,78 @@ const dateValidation = (val) => {
|
|
|
13093
13103
|
}
|
|
13094
13104
|
return false;
|
|
13095
13105
|
};
|
|
13096
|
-
const
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13106
|
+
const stringField = (fieldName) => z.string().refine((val) => val, {
|
|
13107
|
+
message: `${fieldName} must be a string`
|
|
13108
|
+
});
|
|
13109
|
+
const numberField = (fieldName) => z.number().refine((val) => val, {
|
|
13110
|
+
message: `${fieldName} must be a number`
|
|
13111
|
+
});
|
|
13112
|
+
const intField = (fieldName) => z.number().int().refine((val) => val, {
|
|
13113
|
+
message: `${fieldName} must be an integer`
|
|
13114
|
+
});
|
|
13115
|
+
const dateField = (fieldName) => z.string().refine(dateValidation, {
|
|
13116
|
+
message: `Invalid ${fieldName} datetime format`
|
|
13117
|
+
});
|
|
13118
|
+
const arrayField = (schema, fieldName, minLength) => {
|
|
13119
|
+
const arraySchema = z.array(schema);
|
|
13120
|
+
{
|
|
13121
|
+
return arraySchema.min(
|
|
13122
|
+
minLength,
|
|
13123
|
+
`${fieldName} must have at least ${minLength} items`
|
|
13124
|
+
);
|
|
13125
|
+
}
|
|
13126
|
+
};
|
|
13127
|
+
const tripSchema = z.object({
|
|
13128
|
+
"Departure Arrival": dateField("Departure Arrival"),
|
|
13129
|
+
"Departure Destination": stringField("Departure Destination"),
|
|
13130
|
+
"Departure Destination Terminal": stringField(
|
|
13131
|
+
"Departure Destination Terminal"
|
|
13132
|
+
),
|
|
13133
|
+
"Departure Line": stringField("Departure Line"),
|
|
13134
|
+
"Departure Origin": stringField("Departure Origin"),
|
|
13135
|
+
"Departure Origin Terminal": stringField("Departure Origin Terminal"),
|
|
13136
|
+
"Departure Price": numberField("Departure Price"),
|
|
13137
|
+
"Departure Route": stringField("Departure Route"),
|
|
13138
|
+
"Departure Stops": intField("Departure Stops"),
|
|
13139
|
+
"Departure Time": dateField("Departure Time"),
|
|
13140
|
+
"Departure Transport Type": stringField("Departure Transport Type"),
|
|
13141
|
+
"Departure Transporter": stringField("Departure Transporter"),
|
|
13142
|
+
"Return Arrival": dateField("Return Arrival").optional(),
|
|
13143
|
+
"Return Destination": stringField("Return Destination").optional(),
|
|
13144
|
+
"Return Destination Terminal": stringField(
|
|
13145
|
+
"Return Destination Terminal"
|
|
13146
|
+
).optional(),
|
|
13147
|
+
"Return Line": stringField("Return Line").optional(),
|
|
13148
|
+
"Return Origin": stringField("Return Origin").optional(),
|
|
13149
|
+
"Return Origin Terminal": stringField("Return Origin Terminal").optional(),
|
|
13150
|
+
"Return Price": numberField("Return Price").optional(),
|
|
13151
|
+
"Return Route": stringField("Return Route").optional(),
|
|
13152
|
+
"Return Stops": intField("Return Stops").optional(),
|
|
13153
|
+
"Return Time": dateField("Return Time").optional(),
|
|
13154
|
+
"Return Transport Type": stringField("Return Transport Type").optional(),
|
|
13155
|
+
"Return Transporter": stringField("Return Transporter").optional(),
|
|
13113
13156
|
"Recommended Trip": z.boolean(),
|
|
13114
|
-
"Recommended Trip Type":
|
|
13115
|
-
"Routes": z.number().int("Routes must be an integer").positive(),
|
|
13116
|
-
"Total": z.number().positive("Total must be a positive number"),
|
|
13117
|
-
"Trip Length": z.number().int("Trip Length must be an integer").nonnegative().optional(),
|
|
13118
|
-
"product": productValidation
|
|
13157
|
+
"Recommended Trip Type": stringField("Recommended Trip Type").optional()
|
|
13119
13158
|
});
|
|
13159
|
+
const passengersCreatedSchema = z.object({
|
|
13160
|
+
"Trips": arrayField(tripSchema, "Trips", 1),
|
|
13161
|
+
"Passenger Count": intField("Passenger Count"),
|
|
13162
|
+
"Trip Count": intField("Trip Count").optional(),
|
|
13163
|
+
"Total": numberField("Total"),
|
|
13164
|
+
"product": productValidation
|
|
13165
|
+
}).strict();
|
|
13120
13166
|
const EVENT_NAME$7 = "Passengers Created";
|
|
13121
|
-
|
|
13122
|
-
trackEvent(EVENT_NAME$7, eventProps);
|
|
13123
|
-
}
|
|
13167
|
+
function trackPassengersCreated(eventProps, meta = {}) {
|
|
13168
|
+
trackEvent(EVENT_NAME$7, eventProps, meta);
|
|
13169
|
+
}
|
|
13124
13170
|
const paymentAttemptSchema = z.object({
|
|
13125
|
-
"
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
"Departure Destination": z.string().min(1, "Departure Destination is required"),
|
|
13129
|
-
"Departure Destination Terminal": z.string().min(1, "Departure Destination Terminal is required"),
|
|
13130
|
-
"Departure Line": z.string().min(1, "Departure Line is required"),
|
|
13131
|
-
"Departure Origin": z.string().min(1, "Departure Origin is required"),
|
|
13132
|
-
"Departure Origin Terminal": z.string().min(1, "Departure Origin Terminal is required"),
|
|
13133
|
-
"Departure Price": z.number().positive("Departure Price must be a positive number"),
|
|
13134
|
-
"Departure Route": z.string().min(1, "Departure Route is required"),
|
|
13135
|
-
"Departure Stop Cities": z.string().optional(),
|
|
13136
|
-
"Departure Stops": z.number().int("Departure Stops must be an integer").nonnegative().optional(),
|
|
13137
|
-
"Departure Time": z.string().refine(dateValidation, {
|
|
13138
|
-
message: "Invalid departure time datetime format. Must include at least YYYY-MM-DD"
|
|
13139
|
-
}),
|
|
13140
|
-
"Departure Transporter": z.string().min(1, "Departure Transporter is required"),
|
|
13141
|
-
"Passenger Count": z.number().int("Passenger Count must be an integer").positive(),
|
|
13171
|
+
"Trips": arrayField(tripSchema, "Trips", 1),
|
|
13172
|
+
"Passenger Count": intField("Passenger Count"),
|
|
13173
|
+
"Trip Count": intField("Trip Count"),
|
|
13142
13174
|
"Payment Type": z.string().min(1, "Payment Type is required"),
|
|
13143
|
-
"
|
|
13144
|
-
"Recommended Trip Type": z.string().optional(),
|
|
13145
|
-
"Routes": z.number().int("Routes must be an integer").positive(),
|
|
13146
|
-
"Total": z.number().positive("Total must be a positive number"),
|
|
13175
|
+
"Total": numberField("Total"),
|
|
13147
13176
|
"product": productValidation
|
|
13148
|
-
});
|
|
13177
|
+
}).strict();
|
|
13149
13178
|
const EVENT_NAME$6 = "Payment Attempt";
|
|
13150
13179
|
const trackPaymentAttempt = async (eventProps) => {
|
|
13151
13180
|
trackEvent(EVENT_NAME$6, eventProps);
|
|
@@ -13169,75 +13198,23 @@ const pickedDepartureSchema = z.object({
|
|
|
13169
13198
|
"Transport Type": z.string().min(1, "Transport Type is required"),
|
|
13170
13199
|
"Transporter": z.string().min(1, "Transporter is required"),
|
|
13171
13200
|
"product": productValidation,
|
|
13172
|
-
"Recommended Trip": z.boolean()
|
|
13173
|
-
|
|
13174
|
-
}),
|
|
13175
|
-
"Recommended Trip Type": z.string().or(z.null()).refine((val) => val === null || typeof val === "string", {
|
|
13176
|
-
message: "Recommended Trip Type must be a string or null"
|
|
13177
|
-
})
|
|
13201
|
+
"Recommended Trip": z.boolean(),
|
|
13202
|
+
"Recommended Trip Type": z.string().optional()
|
|
13178
13203
|
});
|
|
13179
13204
|
const EVENT_NAME$5 = "Picked Departure";
|
|
13180
|
-
function trackSearch$
|
|
13181
|
-
trackEvent(EVENT_NAME$5, eventData);
|
|
13205
|
+
function trackSearch$1(eventData, meta = {}) {
|
|
13206
|
+
trackEvent(EVENT_NAME$5, eventData, meta);
|
|
13182
13207
|
}
|
|
13183
13208
|
const purchaseAttemptSchema = z.object({
|
|
13184
|
-
"
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
"
|
|
13188
|
-
|
|
13189
|
-
}),
|
|
13190
|
-
"Departure Destination Terminal": z.string().refine((val) => val, {
|
|
13191
|
-
message: "Departure Destination Terminal must be a string"
|
|
13192
|
-
}),
|
|
13193
|
-
"Departure Line": z.string().refine((val) => val, {
|
|
13194
|
-
message: "Departure Line must be a string"
|
|
13195
|
-
}),
|
|
13196
|
-
"Departure Origin": z.string().refine((val) => val, {
|
|
13197
|
-
message: "Departure Origin must be a string"
|
|
13198
|
-
}),
|
|
13199
|
-
"Departure Origin Terminal": z.string().refine((val) => val, {
|
|
13200
|
-
message: "Departure Origin Terminal must be a string"
|
|
13201
|
-
}),
|
|
13202
|
-
"Departure Price": z.number().refine((val) => val, {
|
|
13203
|
-
message: "Departure Price must be a number"
|
|
13204
|
-
}),
|
|
13205
|
-
"Departure Route": z.string().refine((val) => val, {
|
|
13206
|
-
message: "Departure Route must be a string"
|
|
13207
|
-
}),
|
|
13208
|
-
"Departure Stops": z.number().int().refine((val) => val, {
|
|
13209
|
-
message: "Departure Stops must be an integer"
|
|
13210
|
-
}),
|
|
13211
|
-
"Departure Time": z.string().refine(dateValidation, {
|
|
13212
|
-
message: "Invalid departure time datetime format"
|
|
13213
|
-
}),
|
|
13214
|
-
"Departure Transport Type": z.string().refine((val) => val, {
|
|
13215
|
-
message: "Departure Transport Type must be a string"
|
|
13216
|
-
}),
|
|
13217
|
-
"Departure Transporter": z.string().refine((val) => val, {
|
|
13218
|
-
message: "Departure Transporter must be a string"
|
|
13219
|
-
}),
|
|
13220
|
-
"Passenger Count": z.number().int().refine((val) => val, {
|
|
13221
|
-
message: "Passenger Count must be an integer"
|
|
13222
|
-
}),
|
|
13223
|
-
"Recommended Trip": z.boolean().refine((val) => val, {
|
|
13224
|
-
message: "Recommended Trip must be a boolean"
|
|
13225
|
-
}),
|
|
13226
|
-
"Recommended Trip Type": z.string().or(z.null()).refine((val) => val === null || typeof val === "string", {
|
|
13227
|
-
message: "Recommended Trip Type must be a string or null"
|
|
13228
|
-
}).optional(),
|
|
13229
|
-
"Routes": z.number().int().refine((val) => val, {
|
|
13230
|
-
message: "Routes must be an integer"
|
|
13231
|
-
}),
|
|
13232
|
-
"Total": z.number().refine((val) => val, {
|
|
13233
|
-
message: "Total must be a number"
|
|
13234
|
-
}),
|
|
13235
|
-
"product": productValidation,
|
|
13236
|
-
"Trip Length": z.number().int().optional()
|
|
13209
|
+
"Trips": arrayField(tripSchema, "Trips", 1),
|
|
13210
|
+
"Passenger Count": intField("Passenger Count"),
|
|
13211
|
+
"Trip Count": intField("Trip Count"),
|
|
13212
|
+
"Total": numberField("Total"),
|
|
13213
|
+
"product": productValidation
|
|
13237
13214
|
}).strict();
|
|
13238
13215
|
const EVENT_NAME$4 = "Purchase Attempt";
|
|
13239
|
-
function
|
|
13240
|
-
trackEvent(EVENT_NAME$4, eventData);
|
|
13216
|
+
function trackPurchaseAttempt(eventData, meta = {}) {
|
|
13217
|
+
trackEvent(EVENT_NAME$4, eventData, meta);
|
|
13241
13218
|
}
|
|
13242
13219
|
const searchSchema = z.object({
|
|
13243
13220
|
"Departure": z.string().refine(dateValidation, {
|
|
@@ -13257,8 +13234,8 @@ const searchSchema = z.object({
|
|
|
13257
13234
|
"product": productValidation
|
|
13258
13235
|
});
|
|
13259
13236
|
const EVENT_NAME$3 = "Search";
|
|
13260
|
-
function trackSearch(eventData) {
|
|
13261
|
-
trackEvent(EVENT_NAME$3, eventData);
|
|
13237
|
+
function trackSearch(eventData, meta = {}) {
|
|
13238
|
+
trackEvent(EVENT_NAME$3, eventData, meta);
|
|
13262
13239
|
}
|
|
13263
13240
|
const seatChangeSchema = z.object({
|
|
13264
13241
|
"Arrival": z.string().refine(dateValidation, {
|
|
@@ -13283,12 +13260,12 @@ const seatChangeSchema = z.object({
|
|
|
13283
13260
|
"product": productValidation
|
|
13284
13261
|
});
|
|
13285
13262
|
const EVENT_NAME$2 = "Seat Change";
|
|
13286
|
-
|
|
13287
|
-
trackEvent(EVENT_NAME$2, eventProps);
|
|
13288
|
-
}
|
|
13263
|
+
function trackSeatChange(eventProps, meta = {}) {
|
|
13264
|
+
trackEvent(EVENT_NAME$2, eventProps, meta);
|
|
13265
|
+
}
|
|
13289
13266
|
const EVENT_NAME$1 = "View Results";
|
|
13290
|
-
function trackViewResults(eventData) {
|
|
13291
|
-
trackEvent(EVENT_NAME$1, eventData);
|
|
13267
|
+
function trackViewResults(eventData, meta = {}) {
|
|
13268
|
+
trackEvent(EVENT_NAME$1, eventData, meta);
|
|
13292
13269
|
}
|
|
13293
13270
|
const viewResultsSchema = z.object({
|
|
13294
13271
|
"Bus count": z.number().int("Bus count must be an integer"),
|
|
@@ -13318,7 +13295,20 @@ const InitConfigSchema = z.object({
|
|
|
13318
13295
|
/**
|
|
13319
13296
|
* Key for tracking user identities.
|
|
13320
13297
|
*/
|
|
13321
|
-
identificationKey: z.string().min(1, "Identification key is required")
|
|
13298
|
+
identificationKey: z.string().min(1, "Identification key is required"),
|
|
13299
|
+
/**
|
|
13300
|
+
* Optional flag to determine if the sandbox environment should be used.
|
|
13301
|
+
* When set to true, the sandbox environment will be used; otherwise, the production environment will be used.
|
|
13302
|
+
*/
|
|
13303
|
+
isSandbox: z.boolean().optional().default(false),
|
|
13304
|
+
/**
|
|
13305
|
+
* Optional proxy URL for Mixpanel requests.
|
|
13306
|
+
*/
|
|
13307
|
+
mixpanelProxyUrl: z.string().optional(),
|
|
13308
|
+
/**
|
|
13309
|
+
* Optional proxy URL for identify requests.
|
|
13310
|
+
*/
|
|
13311
|
+
identifyProxyUrl: z.string().optional()
|
|
13322
13312
|
});
|
|
13323
13313
|
const SchemaErrorFormatter = (error) => {
|
|
13324
13314
|
return error.issues.map((issue) => {
|
|
@@ -13364,7 +13354,7 @@ const eventSchemas = {
|
|
|
13364
13354
|
"Picked Departure": pickedDepartureSchema
|
|
13365
13355
|
};
|
|
13366
13356
|
function parseEventProps(eventName, eventData) {
|
|
13367
|
-
const eventSchema = eventSchemas[eventName];
|
|
13357
|
+
const eventSchema = eventSchemas[eventName] || customEventSchema;
|
|
13368
13358
|
if (!eventSchema) {
|
|
13369
13359
|
throw { message: `Event ${eventName} not found` };
|
|
13370
13360
|
}
|
|
@@ -13398,68 +13388,2675 @@ function parseIdentifyProps(properties) {
|
|
|
13398
13388
|
const validatorService = {
|
|
13399
13389
|
parseEventProps,
|
|
13400
13390
|
parseInitProps,
|
|
13401
|
-
parseIdentifyProps
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
const
|
|
13405
|
-
function
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13391
|
+
parseIdentifyProps,
|
|
13392
|
+
validateProps
|
|
13393
|
+
};
|
|
13394
|
+
const FP_TRIGGER_EVENTS = ["Search", "View Results"];
|
|
13395
|
+
function flattenEventData(data) {
|
|
13396
|
+
return Object.entries(data).reduce((flattenedData, [key, value]) => {
|
|
13397
|
+
if (!Array.isArray(value)) {
|
|
13398
|
+
flattenedData[key] = value;
|
|
13399
|
+
return flattenedData;
|
|
13400
|
+
}
|
|
13401
|
+
value.forEach((item) => {
|
|
13402
|
+
if (typeof item !== "object" || item === null) return;
|
|
13403
|
+
Object.entries(item).forEach(([innerKey, innerValue]) => {
|
|
13404
|
+
if (!flattenedData[innerKey]) {
|
|
13405
|
+
flattenedData[innerKey] = [innerValue];
|
|
13406
|
+
} else {
|
|
13407
|
+
flattenedData[innerKey].push(
|
|
13408
|
+
innerValue
|
|
13409
|
+
);
|
|
13410
|
+
}
|
|
13411
|
+
});
|
|
13412
|
+
});
|
|
13413
|
+
return flattenedData;
|
|
13414
|
+
}, {});
|
|
13422
13415
|
}
|
|
13423
|
-
async function
|
|
13416
|
+
async function trackEvent(eventName, eventProperties, meta = {}) {
|
|
13424
13417
|
if (!mixpanelService.isReady()) {
|
|
13425
|
-
throw new Error("
|
|
13418
|
+
throw new Error("Mixpanel is not initialized.");
|
|
13426
13419
|
}
|
|
13427
13420
|
try {
|
|
13428
|
-
validatorService.
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
const
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13421
|
+
validatorService.parseEventProps(eventName, eventProperties);
|
|
13422
|
+
const cacheOnly = !FP_TRIGGER_EVENTS.includes(eventName);
|
|
13423
|
+
const fingerprint = await fingerprintService.getFingerprint(cacheOnly);
|
|
13424
|
+
const defaultProperties = {
|
|
13425
|
+
"User Fingerprint": fingerprint
|
|
13426
|
+
};
|
|
13427
|
+
const simplifiedData = flattenEventData(eventProperties);
|
|
13428
|
+
const properties = {
|
|
13429
|
+
...defaultProperties,
|
|
13430
|
+
...simplifiedData,
|
|
13431
|
+
...meta
|
|
13432
|
+
};
|
|
13433
|
+
mixpanelService.track(eventName, properties);
|
|
13438
13434
|
} catch (error) {
|
|
13439
|
-
console.error(
|
|
13435
|
+
console.error(`Error tracking event '${eventName}':`, error);
|
|
13440
13436
|
}
|
|
13441
13437
|
}
|
|
13442
|
-
|
|
13443
|
-
function trackTest() {
|
|
13444
|
-
trackEvent(EVENT_NAME, {});
|
|
13445
|
-
}
|
|
13446
|
-
function onLoaded() {
|
|
13447
|
-
window.dispatchEvent(new CustomEvent("Tracker Ready"));
|
|
13448
|
-
}
|
|
13449
|
-
async function init(config) {
|
|
13450
|
-
validatorService.parseInitProps(config);
|
|
13451
|
-
const { mixpanelToken, debug = false, identificationKey } = config;
|
|
13452
|
-
await mixpanelService.init(mixpanelToken, debug);
|
|
13438
|
+
function trackCustomEvent(eventName, eventData = {}) {
|
|
13453
13439
|
try {
|
|
13454
|
-
|
|
13440
|
+
eventNameSchema.parse(eventName);
|
|
13441
|
+
trackEvent(eventName, eventData);
|
|
13455
13442
|
} catch (error) {
|
|
13456
|
-
console.error("Error
|
|
13443
|
+
console.error("Error trackCustomEvent:", error);
|
|
13444
|
+
return;
|
|
13457
13445
|
}
|
|
13458
|
-
onLoaded();
|
|
13459
13446
|
}
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13447
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
13448
|
+
var jsApiClient = { exports: {} };
|
|
13449
|
+
(function(module, exports) {
|
|
13450
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
13451
|
+
module.exports = factory();
|
|
13452
|
+
})(typeof self !== "undefined" ? self : commonjsGlobal, function() {
|
|
13453
|
+
return (
|
|
13454
|
+
/******/
|
|
13455
|
+
function(modules) {
|
|
13456
|
+
var installedModules = {};
|
|
13457
|
+
function __webpack_require__(moduleId) {
|
|
13458
|
+
if (installedModules[moduleId]) {
|
|
13459
|
+
return installedModules[moduleId].exports;
|
|
13460
|
+
}
|
|
13461
|
+
var module2 = installedModules[moduleId] = {
|
|
13462
|
+
/******/
|
|
13463
|
+
i: moduleId,
|
|
13464
|
+
/******/
|
|
13465
|
+
l: false,
|
|
13466
|
+
/******/
|
|
13467
|
+
exports: {}
|
|
13468
|
+
/******/
|
|
13469
|
+
};
|
|
13470
|
+
modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
|
|
13471
|
+
module2.l = true;
|
|
13472
|
+
return module2.exports;
|
|
13473
|
+
}
|
|
13474
|
+
__webpack_require__.m = modules;
|
|
13475
|
+
__webpack_require__.c = installedModules;
|
|
13476
|
+
__webpack_require__.d = function(exports2, name, getter) {
|
|
13477
|
+
if (!__webpack_require__.o(exports2, name)) {
|
|
13478
|
+
Object.defineProperty(exports2, name, {
|
|
13479
|
+
/******/
|
|
13480
|
+
configurable: false,
|
|
13481
|
+
/******/
|
|
13482
|
+
enumerable: true,
|
|
13483
|
+
/******/
|
|
13484
|
+
get: getter
|
|
13485
|
+
/******/
|
|
13486
|
+
});
|
|
13487
|
+
}
|
|
13488
|
+
};
|
|
13489
|
+
__webpack_require__.n = function(module2) {
|
|
13490
|
+
var getter = module2 && module2.__esModule ? (
|
|
13491
|
+
/******/
|
|
13492
|
+
function getDefault() {
|
|
13493
|
+
return module2["default"];
|
|
13494
|
+
}
|
|
13495
|
+
) : (
|
|
13496
|
+
/******/
|
|
13497
|
+
function getModuleExports() {
|
|
13498
|
+
return module2;
|
|
13499
|
+
}
|
|
13500
|
+
);
|
|
13501
|
+
__webpack_require__.d(getter, "a", getter);
|
|
13502
|
+
return getter;
|
|
13503
|
+
};
|
|
13504
|
+
__webpack_require__.o = function(object, property) {
|
|
13505
|
+
return Object.prototype.hasOwnProperty.call(object, property);
|
|
13506
|
+
};
|
|
13507
|
+
__webpack_require__.p = "";
|
|
13508
|
+
return __webpack_require__(__webpack_require__.s = 3);
|
|
13509
|
+
}([
|
|
13510
|
+
/* 0 */
|
|
13511
|
+
/***/
|
|
13512
|
+
function(module2, exports2, __webpack_require__) {
|
|
13513
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
13514
|
+
value: true
|
|
13515
|
+
});
|
|
13516
|
+
var _extends = Object.assign || function(target) {
|
|
13517
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13518
|
+
var source = arguments[i];
|
|
13519
|
+
for (var key in source) {
|
|
13520
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13521
|
+
target[key] = source[key];
|
|
13522
|
+
}
|
|
13523
|
+
}
|
|
13524
|
+
}
|
|
13525
|
+
return target;
|
|
13526
|
+
};
|
|
13527
|
+
exports2.post = post;
|
|
13528
|
+
exports2.get = get;
|
|
13529
|
+
exports2.put = put;
|
|
13530
|
+
exports2.deleteMethod = deleteMethod;
|
|
13531
|
+
exports2.poll = poll;
|
|
13532
|
+
var _config = __webpack_require__(1);
|
|
13533
|
+
var _config2 = _interopRequireDefault(_config);
|
|
13534
|
+
var _request = __webpack_require__(2);
|
|
13535
|
+
var request = _interopRequireWildcard(_request);
|
|
13536
|
+
var _Poll = __webpack_require__(9);
|
|
13537
|
+
var _Poll2 = _interopRequireDefault(_Poll);
|
|
13538
|
+
function _interopRequireWildcard(obj) {
|
|
13539
|
+
if (obj && obj.__esModule) {
|
|
13540
|
+
return obj;
|
|
13541
|
+
} else {
|
|
13542
|
+
var newObj = {};
|
|
13543
|
+
if (obj != null) {
|
|
13544
|
+
for (var key in obj) {
|
|
13545
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
13546
|
+
}
|
|
13547
|
+
}
|
|
13548
|
+
newObj.default = obj;
|
|
13549
|
+
return newObj;
|
|
13550
|
+
}
|
|
13551
|
+
}
|
|
13552
|
+
function _interopRequireDefault(obj) {
|
|
13553
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
13554
|
+
}
|
|
13555
|
+
function _toConsumableArray(arr) {
|
|
13556
|
+
if (Array.isArray(arr)) {
|
|
13557
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
|
13558
|
+
arr2[i] = arr[i];
|
|
13559
|
+
}
|
|
13560
|
+
return arr2;
|
|
13561
|
+
} else {
|
|
13562
|
+
return Array.from(arr);
|
|
13563
|
+
}
|
|
13564
|
+
}
|
|
13565
|
+
var headerOptions = { apiKey: _config2.default.apiKey };
|
|
13566
|
+
function serializeQueryParams(options) {
|
|
13567
|
+
var ignore = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
13568
|
+
if (!options) {
|
|
13569
|
+
return "";
|
|
13570
|
+
}
|
|
13571
|
+
var ignoreList = [null, void 0, ""].concat(_toConsumableArray(ignore));
|
|
13572
|
+
var optionList = [];
|
|
13573
|
+
Object.keys(options).forEach(function(key) {
|
|
13574
|
+
var value = options[key];
|
|
13575
|
+
if (!ignoreList.includes(value)) {
|
|
13576
|
+
optionList.push(key + "=" + value);
|
|
13577
|
+
}
|
|
13578
|
+
});
|
|
13579
|
+
return optionList.length ? "?" + optionList.join("&") : "";
|
|
13580
|
+
}
|
|
13581
|
+
function buildUrl(_ref) {
|
|
13582
|
+
var endpoint = _ref.endpoint, _ref$apiVersion = _ref.apiVersion, apiVersion = _ref$apiVersion === void 0 ? _config2.default.version : _ref$apiVersion, queryParams = _ref.queryParams, apiType = _ref.apiType;
|
|
13583
|
+
if (apiType === "core") {
|
|
13584
|
+
return _config2.default.coreUrl + "/" + _config2.default.coreVersion + "/" + endpoint + serializeQueryParams(queryParams);
|
|
13585
|
+
}
|
|
13586
|
+
var apiUrl = /search|redirect|places/.test(endpoint) ? _config2.default.searchUrl : _config2.default.purchaseUrl;
|
|
13587
|
+
return apiUrl + "/" + apiVersion + "/" + endpoint + serializeQueryParams(queryParams);
|
|
13588
|
+
}
|
|
13589
|
+
function post(endpoint, payload) {
|
|
13590
|
+
var _ref2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref2.apiVersion, apiType = _ref2.apiType;
|
|
13591
|
+
var url = buildUrl({ endpoint, apiVersion, apiType });
|
|
13592
|
+
return request.post(url, payload, headerOptions);
|
|
13593
|
+
}
|
|
13594
|
+
function get(endpoint) {
|
|
13595
|
+
var _ref3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref3.apiVersion, queryParams = _ref3.queryParams, apiType = _ref3.apiType;
|
|
13596
|
+
var url = buildUrl({ endpoint, apiVersion, queryParams, apiType });
|
|
13597
|
+
return request.get(url, headerOptions);
|
|
13598
|
+
}
|
|
13599
|
+
function put(endpoint, payload) {
|
|
13600
|
+
var _ref4 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref4.apiVersion, apiType = _ref4.apiType;
|
|
13601
|
+
var url = buildUrl({ endpoint, apiVersion, apiType });
|
|
13602
|
+
return request.put(url, payload, headerOptions);
|
|
13603
|
+
}
|
|
13604
|
+
function deleteMethod(endpoint) {
|
|
13605
|
+
var _ref5 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref5.apiVersion;
|
|
13606
|
+
_ref5.queryParams;
|
|
13607
|
+
var apiType = _ref5.apiType;
|
|
13608
|
+
var url = buildUrl({ endpoint, apiVersion, apiType });
|
|
13609
|
+
return request.deleteMethod(url, headerOptions);
|
|
13610
|
+
}
|
|
13611
|
+
function poll(endpoint, eachCall) {
|
|
13612
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
13613
|
+
var apiVersion = arguments[3];
|
|
13614
|
+
var apiType = arguments[4];
|
|
13615
|
+
var url = buildUrl({ endpoint, apiVersion, apiType });
|
|
13616
|
+
var pollOptions = _extends({ url, eachCall }, options);
|
|
13617
|
+
return new _Poll2.default(pollOptions);
|
|
13618
|
+
}
|
|
13619
|
+
},
|
|
13620
|
+
/* 1 */
|
|
13621
|
+
/***/
|
|
13622
|
+
function(module2, exports2, __webpack_require__) {
|
|
13623
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
13624
|
+
value: true
|
|
13625
|
+
});
|
|
13626
|
+
exports2.setConfig = setConfig;
|
|
13627
|
+
exports2.setUserAuthToken = setUserAuthToken;
|
|
13628
|
+
var configRoots = {
|
|
13629
|
+
sandbox: {
|
|
13630
|
+
search: "https://search.resertravel.com/api",
|
|
13631
|
+
purchase: "https://purchases.resertravel.com/api",
|
|
13632
|
+
core: ""
|
|
13633
|
+
},
|
|
13634
|
+
production: {
|
|
13635
|
+
search: "https://search.reservamos.mx/api",
|
|
13636
|
+
purchase: "https://compras.reservamos.mx/api",
|
|
13637
|
+
core: ""
|
|
13638
|
+
}
|
|
13639
|
+
};
|
|
13640
|
+
var defaultEnv = "sandbox";
|
|
13641
|
+
var defaultVersion = "v2";
|
|
13642
|
+
var defaultCoreVersion = "v1";
|
|
13643
|
+
var defaultConfig = {
|
|
13644
|
+
env: defaultEnv,
|
|
13645
|
+
headers: {},
|
|
13646
|
+
searchUrl: configRoots[defaultEnv].search,
|
|
13647
|
+
purchaseUrl: configRoots[defaultEnv].purchase,
|
|
13648
|
+
coreUrl: configRoots[defaultEnv].core,
|
|
13649
|
+
version: defaultVersion,
|
|
13650
|
+
coreVersion: defaultCoreVersion,
|
|
13651
|
+
apiKey: void 0,
|
|
13652
|
+
userAuthToken: void 0,
|
|
13653
|
+
withCredentials: false
|
|
13654
|
+
};
|
|
13655
|
+
var config = exports2.config = Object.assign({}, defaultConfig);
|
|
13656
|
+
function setConfig() {
|
|
13657
|
+
var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
13658
|
+
if (userConfig.env !== void 0) {
|
|
13659
|
+
userConfig.searchUrl = configRoots[userConfig.env].search;
|
|
13660
|
+
userConfig.purchaseUrl = configRoots[userConfig.env].purchase;
|
|
13661
|
+
userConfig.coreUrl = configRoots[userConfig.env].core;
|
|
13662
|
+
userConfig.coreVersion = configRoots[userConfig.env].coreVersion;
|
|
13663
|
+
}
|
|
13664
|
+
return Object.assign(config, userConfig);
|
|
13665
|
+
}
|
|
13666
|
+
function setUserAuthToken(userAuthToken) {
|
|
13667
|
+
return Object.assign(config, { userAuthToken });
|
|
13668
|
+
}
|
|
13669
|
+
exports2.default = config;
|
|
13670
|
+
},
|
|
13671
|
+
/* 2 */
|
|
13672
|
+
/***/
|
|
13673
|
+
function(module2, exports2, __webpack_require__) {
|
|
13674
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
13675
|
+
value: true
|
|
13676
|
+
});
|
|
13677
|
+
var _extends = Object.assign || function(target) {
|
|
13678
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13679
|
+
var source = arguments[i];
|
|
13680
|
+
for (var key in source) {
|
|
13681
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
13682
|
+
target[key] = source[key];
|
|
13683
|
+
}
|
|
13684
|
+
}
|
|
13685
|
+
}
|
|
13686
|
+
return target;
|
|
13687
|
+
};
|
|
13688
|
+
exports2.post = post;
|
|
13689
|
+
exports2.get = get;
|
|
13690
|
+
exports2.put = put;
|
|
13691
|
+
exports2.deleteMethod = deleteMethod;
|
|
13692
|
+
var _config = __webpack_require__(1);
|
|
13693
|
+
var _config2 = _interopRequireDefault(_config);
|
|
13694
|
+
var _NetworkError = __webpack_require__(7);
|
|
13695
|
+
var _NetworkError2 = _interopRequireDefault(_NetworkError);
|
|
13696
|
+
var _errorTypes = __webpack_require__(8);
|
|
13697
|
+
var _errorTypes2 = _interopRequireDefault(_errorTypes);
|
|
13698
|
+
function _interopRequireDefault(obj) {
|
|
13699
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
13700
|
+
}
|
|
13701
|
+
function _defineProperty(obj, key, value) {
|
|
13702
|
+
if (key in obj) {
|
|
13703
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
13704
|
+
} else {
|
|
13705
|
+
obj[key] = value;
|
|
13706
|
+
}
|
|
13707
|
+
return obj;
|
|
13708
|
+
}
|
|
13709
|
+
function checkStatus(response) {
|
|
13710
|
+
var handledErrors = [404, 422, 500];
|
|
13711
|
+
var body = response.json();
|
|
13712
|
+
if (response.ok) {
|
|
13713
|
+
return body;
|
|
13714
|
+
} else if (handledErrors.includes(response.status)) {
|
|
13715
|
+
switch (response.status) {
|
|
13716
|
+
case 404:
|
|
13717
|
+
throw new _NetworkError2.default(100, "Not found");
|
|
13718
|
+
case 422:
|
|
13719
|
+
return body;
|
|
13720
|
+
case 500:
|
|
13721
|
+
throw new _NetworkError2.default(101, "Server error");
|
|
13722
|
+
default:
|
|
13723
|
+
throw new _NetworkError2.default();
|
|
13724
|
+
}
|
|
13725
|
+
} else {
|
|
13726
|
+
throw new _NetworkError2.default(response.status, response.statusText);
|
|
13727
|
+
}
|
|
13728
|
+
}
|
|
13729
|
+
function handleErrors(response) {
|
|
13730
|
+
if (response.errors instanceof Array) {
|
|
13731
|
+
var _ref = response.errors[0] || {}, _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
13732
|
+
var knownError = (0, _errorTypes2.default)(message)[code];
|
|
13733
|
+
if (knownError) {
|
|
13734
|
+
throw new _NetworkError2.default(knownError.code, knownError.message);
|
|
13735
|
+
} else {
|
|
13736
|
+
throw new _NetworkError2.default(code, message);
|
|
13737
|
+
}
|
|
13738
|
+
} else {
|
|
13739
|
+
return response;
|
|
13740
|
+
}
|
|
13741
|
+
}
|
|
13742
|
+
function buildHeaders() {
|
|
13743
|
+
for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
|
|
13744
|
+
sources[_key] = arguments[_key];
|
|
13745
|
+
}
|
|
13746
|
+
var keys = Object.keys(Object.assign.apply(Object, [{}].concat(sources)));
|
|
13747
|
+
var headers = keys.reduce(function(result, key) {
|
|
13748
|
+
return _extends({}, result, _defineProperty({}, key, sources.map(function(source) {
|
|
13749
|
+
return key in source && source[key];
|
|
13750
|
+
}).filter(Boolean)));
|
|
13751
|
+
}, {});
|
|
13752
|
+
return new Headers(headers);
|
|
13753
|
+
}
|
|
13754
|
+
function fetchJson(url) {
|
|
13755
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
13756
|
+
var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
13757
|
+
var onRequestError = arguments[3];
|
|
13758
|
+
var apiKey = _config2.default.apiKey, withCredentials = _config2.default.withCredentials, userAuthToken = _config2.default.userAuthToken, defaultHeaders = _config2.default.headers;
|
|
13759
|
+
var headers = {
|
|
13760
|
+
"Accept": "application/json",
|
|
13761
|
+
"Authorization": "Token token=" + (headerOptions.apiKey || apiKey),
|
|
13762
|
+
"Content-Type": "application/json"
|
|
13763
|
+
};
|
|
13764
|
+
if (userAuthToken) {
|
|
13765
|
+
headers.Authorization = "Token " + (headerOptions.apiKey || apiKey) + ", Bearer " + userAuthToken;
|
|
13766
|
+
}
|
|
13767
|
+
options.headers = buildHeaders(defaultHeaders, headers);
|
|
13768
|
+
options.credentials = withCredentials ? "include" : "omit";
|
|
13769
|
+
if (typeof options.body !== "string") {
|
|
13770
|
+
options.body = JSON.stringify(options.body);
|
|
13771
|
+
}
|
|
13772
|
+
return fetch(url, options).then(checkStatus).then(handleErrors).catch(onRequestError);
|
|
13773
|
+
}
|
|
13774
|
+
function post(url, payload) {
|
|
13775
|
+
var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
13776
|
+
return fetchJson(url, {
|
|
13777
|
+
method: "POST",
|
|
13778
|
+
body: JSON.stringify(payload)
|
|
13779
|
+
}, headerOptions);
|
|
13780
|
+
}
|
|
13781
|
+
function get(url) {
|
|
13782
|
+
var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
13783
|
+
var onRequestError = arguments[2];
|
|
13784
|
+
return fetchJson(url, headerOptions, {}, onRequestError);
|
|
13785
|
+
}
|
|
13786
|
+
function put(url, payload) {
|
|
13787
|
+
var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
13788
|
+
return fetchJson(url, {
|
|
13789
|
+
method: "PUT",
|
|
13790
|
+
body: JSON.stringify(payload)
|
|
13791
|
+
}, headerOptions);
|
|
13792
|
+
}
|
|
13793
|
+
function deleteMethod(url) {
|
|
13794
|
+
var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
13795
|
+
return fetchJson(url, {
|
|
13796
|
+
method: "DELETE"
|
|
13797
|
+
}, headerOptions);
|
|
13798
|
+
}
|
|
13799
|
+
},
|
|
13800
|
+
/* 3 */
|
|
13801
|
+
/***/
|
|
13802
|
+
function(module2, exports2, __webpack_require__) {
|
|
13803
|
+
__webpack_require__(4);
|
|
13804
|
+
__webpack_require__(5);
|
|
13805
|
+
module2.exports = __webpack_require__(6);
|
|
13806
|
+
},
|
|
13807
|
+
/* 4 */
|
|
13808
|
+
/***/
|
|
13809
|
+
function(module2, exports2) {
|
|
13810
|
+
if (typeof Object.assign !== "function") {
|
|
13811
|
+
Object.assign = function(target, varArgs) {
|
|
13812
|
+
if (target == null) {
|
|
13813
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
13814
|
+
}
|
|
13815
|
+
var to = Object(target);
|
|
13816
|
+
for (var index = 1; index < arguments.length; index++) {
|
|
13817
|
+
var nextSource = arguments[index];
|
|
13818
|
+
if (nextSource != null) {
|
|
13819
|
+
for (var nextKey in nextSource) {
|
|
13820
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
13821
|
+
to[nextKey] = nextSource[nextKey];
|
|
13822
|
+
}
|
|
13823
|
+
}
|
|
13824
|
+
}
|
|
13825
|
+
}
|
|
13826
|
+
return to;
|
|
13827
|
+
};
|
|
13828
|
+
}
|
|
13829
|
+
},
|
|
13830
|
+
/* 5 */
|
|
13831
|
+
/***/
|
|
13832
|
+
function(module2, exports2) {
|
|
13833
|
+
(function(self2) {
|
|
13834
|
+
if (self2.fetch) {
|
|
13835
|
+
return;
|
|
13836
|
+
}
|
|
13837
|
+
var support = {
|
|
13838
|
+
searchParams: "URLSearchParams" in self2,
|
|
13839
|
+
iterable: "Symbol" in self2 && "iterator" in Symbol,
|
|
13840
|
+
blob: "FileReader" in self2 && "Blob" in self2 && function() {
|
|
13841
|
+
try {
|
|
13842
|
+
new Blob();
|
|
13843
|
+
return true;
|
|
13844
|
+
} catch (e) {
|
|
13845
|
+
return false;
|
|
13846
|
+
}
|
|
13847
|
+
}(),
|
|
13848
|
+
formData: "FormData" in self2,
|
|
13849
|
+
arrayBuffer: "ArrayBuffer" in self2
|
|
13850
|
+
};
|
|
13851
|
+
if (support.arrayBuffer) {
|
|
13852
|
+
var viewClasses = [
|
|
13853
|
+
"[object Int8Array]",
|
|
13854
|
+
"[object Uint8Array]",
|
|
13855
|
+
"[object Uint8ClampedArray]",
|
|
13856
|
+
"[object Int16Array]",
|
|
13857
|
+
"[object Uint16Array]",
|
|
13858
|
+
"[object Int32Array]",
|
|
13859
|
+
"[object Uint32Array]",
|
|
13860
|
+
"[object Float32Array]",
|
|
13861
|
+
"[object Float64Array]"
|
|
13862
|
+
];
|
|
13863
|
+
var isDataView = function(obj) {
|
|
13864
|
+
return obj && DataView.prototype.isPrototypeOf(obj);
|
|
13865
|
+
};
|
|
13866
|
+
var isArrayBufferView = ArrayBuffer.isView || function(obj) {
|
|
13867
|
+
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
|
|
13868
|
+
};
|
|
13869
|
+
}
|
|
13870
|
+
function normalizeName(name) {
|
|
13871
|
+
if (typeof name !== "string") {
|
|
13872
|
+
name = String(name);
|
|
13873
|
+
}
|
|
13874
|
+
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
|
|
13875
|
+
throw new TypeError("Invalid character in header field name");
|
|
13876
|
+
}
|
|
13877
|
+
return name.toLowerCase();
|
|
13878
|
+
}
|
|
13879
|
+
function normalizeValue(value) {
|
|
13880
|
+
if (typeof value !== "string") {
|
|
13881
|
+
value = String(value);
|
|
13882
|
+
}
|
|
13883
|
+
return value;
|
|
13884
|
+
}
|
|
13885
|
+
function iteratorFor(items) {
|
|
13886
|
+
var iterator = {
|
|
13887
|
+
next: function() {
|
|
13888
|
+
var value = items.shift();
|
|
13889
|
+
return { done: value === void 0, value };
|
|
13890
|
+
}
|
|
13891
|
+
};
|
|
13892
|
+
if (support.iterable) {
|
|
13893
|
+
iterator[Symbol.iterator] = function() {
|
|
13894
|
+
return iterator;
|
|
13895
|
+
};
|
|
13896
|
+
}
|
|
13897
|
+
return iterator;
|
|
13898
|
+
}
|
|
13899
|
+
function Headers2(headers) {
|
|
13900
|
+
this.map = {};
|
|
13901
|
+
if (headers instanceof Headers2) {
|
|
13902
|
+
headers.forEach(function(value, name) {
|
|
13903
|
+
this.append(name, value);
|
|
13904
|
+
}, this);
|
|
13905
|
+
} else if (Array.isArray(headers)) {
|
|
13906
|
+
headers.forEach(function(header) {
|
|
13907
|
+
this.append(header[0], header[1]);
|
|
13908
|
+
}, this);
|
|
13909
|
+
} else if (headers) {
|
|
13910
|
+
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
13911
|
+
this.append(name, headers[name]);
|
|
13912
|
+
}, this);
|
|
13913
|
+
}
|
|
13914
|
+
}
|
|
13915
|
+
Headers2.prototype.append = function(name, value) {
|
|
13916
|
+
name = normalizeName(name);
|
|
13917
|
+
value = normalizeValue(value);
|
|
13918
|
+
var oldValue = this.map[name];
|
|
13919
|
+
this.map[name] = oldValue ? oldValue + "," + value : value;
|
|
13920
|
+
};
|
|
13921
|
+
Headers2.prototype["delete"] = function(name) {
|
|
13922
|
+
delete this.map[normalizeName(name)];
|
|
13923
|
+
};
|
|
13924
|
+
Headers2.prototype.get = function(name) {
|
|
13925
|
+
name = normalizeName(name);
|
|
13926
|
+
return this.has(name) ? this.map[name] : null;
|
|
13927
|
+
};
|
|
13928
|
+
Headers2.prototype.has = function(name) {
|
|
13929
|
+
return this.map.hasOwnProperty(normalizeName(name));
|
|
13930
|
+
};
|
|
13931
|
+
Headers2.prototype.set = function(name, value) {
|
|
13932
|
+
this.map[normalizeName(name)] = normalizeValue(value);
|
|
13933
|
+
};
|
|
13934
|
+
Headers2.prototype.forEach = function(callback, thisArg) {
|
|
13935
|
+
for (var name in this.map) {
|
|
13936
|
+
if (this.map.hasOwnProperty(name)) {
|
|
13937
|
+
callback.call(thisArg, this.map[name], name, this);
|
|
13938
|
+
}
|
|
13939
|
+
}
|
|
13940
|
+
};
|
|
13941
|
+
Headers2.prototype.keys = function() {
|
|
13942
|
+
var items = [];
|
|
13943
|
+
this.forEach(function(value, name) {
|
|
13944
|
+
items.push(name);
|
|
13945
|
+
});
|
|
13946
|
+
return iteratorFor(items);
|
|
13947
|
+
};
|
|
13948
|
+
Headers2.prototype.values = function() {
|
|
13949
|
+
var items = [];
|
|
13950
|
+
this.forEach(function(value) {
|
|
13951
|
+
items.push(value);
|
|
13952
|
+
});
|
|
13953
|
+
return iteratorFor(items);
|
|
13954
|
+
};
|
|
13955
|
+
Headers2.prototype.entries = function() {
|
|
13956
|
+
var items = [];
|
|
13957
|
+
this.forEach(function(value, name) {
|
|
13958
|
+
items.push([name, value]);
|
|
13959
|
+
});
|
|
13960
|
+
return iteratorFor(items);
|
|
13961
|
+
};
|
|
13962
|
+
if (support.iterable) {
|
|
13963
|
+
Headers2.prototype[Symbol.iterator] = Headers2.prototype.entries;
|
|
13964
|
+
}
|
|
13965
|
+
function consumed(body) {
|
|
13966
|
+
if (body.bodyUsed) {
|
|
13967
|
+
return Promise.reject(new TypeError("Already read"));
|
|
13968
|
+
}
|
|
13969
|
+
body.bodyUsed = true;
|
|
13970
|
+
}
|
|
13971
|
+
function fileReaderReady(reader) {
|
|
13972
|
+
return new Promise(function(resolve, reject) {
|
|
13973
|
+
reader.onload = function() {
|
|
13974
|
+
resolve(reader.result);
|
|
13975
|
+
};
|
|
13976
|
+
reader.onerror = function() {
|
|
13977
|
+
reject(reader.error);
|
|
13978
|
+
};
|
|
13979
|
+
});
|
|
13980
|
+
}
|
|
13981
|
+
function readBlobAsArrayBuffer(blob) {
|
|
13982
|
+
var reader = new FileReader();
|
|
13983
|
+
var promise = fileReaderReady(reader);
|
|
13984
|
+
reader.readAsArrayBuffer(blob);
|
|
13985
|
+
return promise;
|
|
13986
|
+
}
|
|
13987
|
+
function readBlobAsText(blob) {
|
|
13988
|
+
var reader = new FileReader();
|
|
13989
|
+
var promise = fileReaderReady(reader);
|
|
13990
|
+
reader.readAsText(blob);
|
|
13991
|
+
return promise;
|
|
13992
|
+
}
|
|
13993
|
+
function readArrayBufferAsText(buf) {
|
|
13994
|
+
var view = new Uint8Array(buf);
|
|
13995
|
+
var chars2 = new Array(view.length);
|
|
13996
|
+
for (var i = 0; i < view.length; i++) {
|
|
13997
|
+
chars2[i] = String.fromCharCode(view[i]);
|
|
13998
|
+
}
|
|
13999
|
+
return chars2.join("");
|
|
14000
|
+
}
|
|
14001
|
+
function bufferClone(buf) {
|
|
14002
|
+
if (buf.slice) {
|
|
14003
|
+
return buf.slice(0);
|
|
14004
|
+
} else {
|
|
14005
|
+
var view = new Uint8Array(buf.byteLength);
|
|
14006
|
+
view.set(new Uint8Array(buf));
|
|
14007
|
+
return view.buffer;
|
|
14008
|
+
}
|
|
14009
|
+
}
|
|
14010
|
+
function Body() {
|
|
14011
|
+
this.bodyUsed = false;
|
|
14012
|
+
this._initBody = function(body) {
|
|
14013
|
+
this._bodyInit = body;
|
|
14014
|
+
if (!body) {
|
|
14015
|
+
this._bodyText = "";
|
|
14016
|
+
} else if (typeof body === "string") {
|
|
14017
|
+
this._bodyText = body;
|
|
14018
|
+
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
14019
|
+
this._bodyBlob = body;
|
|
14020
|
+
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
14021
|
+
this._bodyFormData = body;
|
|
14022
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14023
|
+
this._bodyText = body.toString();
|
|
14024
|
+
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
14025
|
+
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
14026
|
+
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
14027
|
+
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
14028
|
+
this._bodyArrayBuffer = bufferClone(body);
|
|
14029
|
+
} else {
|
|
14030
|
+
throw new Error("unsupported BodyInit type");
|
|
14031
|
+
}
|
|
14032
|
+
if (!this.headers.get("content-type")) {
|
|
14033
|
+
if (typeof body === "string") {
|
|
14034
|
+
this.headers.set("content-type", "text/plain;charset=UTF-8");
|
|
14035
|
+
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
14036
|
+
this.headers.set("content-type", this._bodyBlob.type);
|
|
14037
|
+
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
14038
|
+
this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
|
|
14039
|
+
}
|
|
14040
|
+
}
|
|
14041
|
+
};
|
|
14042
|
+
if (support.blob) {
|
|
14043
|
+
this.blob = function() {
|
|
14044
|
+
var rejected = consumed(this);
|
|
14045
|
+
if (rejected) {
|
|
14046
|
+
return rejected;
|
|
14047
|
+
}
|
|
14048
|
+
if (this._bodyBlob) {
|
|
14049
|
+
return Promise.resolve(this._bodyBlob);
|
|
14050
|
+
} else if (this._bodyArrayBuffer) {
|
|
14051
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
14052
|
+
} else if (this._bodyFormData) {
|
|
14053
|
+
throw new Error("could not read FormData body as blob");
|
|
14054
|
+
} else {
|
|
14055
|
+
return Promise.resolve(new Blob([this._bodyText]));
|
|
14056
|
+
}
|
|
14057
|
+
};
|
|
14058
|
+
this.arrayBuffer = function() {
|
|
14059
|
+
if (this._bodyArrayBuffer) {
|
|
14060
|
+
return consumed(this) || Promise.resolve(this._bodyArrayBuffer);
|
|
14061
|
+
} else {
|
|
14062
|
+
return this.blob().then(readBlobAsArrayBuffer);
|
|
14063
|
+
}
|
|
14064
|
+
};
|
|
14065
|
+
}
|
|
14066
|
+
this.text = function() {
|
|
14067
|
+
var rejected = consumed(this);
|
|
14068
|
+
if (rejected) {
|
|
14069
|
+
return rejected;
|
|
14070
|
+
}
|
|
14071
|
+
if (this._bodyBlob) {
|
|
14072
|
+
return readBlobAsText(this._bodyBlob);
|
|
14073
|
+
} else if (this._bodyArrayBuffer) {
|
|
14074
|
+
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
|
|
14075
|
+
} else if (this._bodyFormData) {
|
|
14076
|
+
throw new Error("could not read FormData body as text");
|
|
14077
|
+
} else {
|
|
14078
|
+
return Promise.resolve(this._bodyText);
|
|
14079
|
+
}
|
|
14080
|
+
};
|
|
14081
|
+
if (support.formData) {
|
|
14082
|
+
this.formData = function() {
|
|
14083
|
+
return this.text().then(decode);
|
|
14084
|
+
};
|
|
14085
|
+
}
|
|
14086
|
+
this.json = function() {
|
|
14087
|
+
return this.text().then(JSON.parse);
|
|
14088
|
+
};
|
|
14089
|
+
return this;
|
|
14090
|
+
}
|
|
14091
|
+
var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
|
|
14092
|
+
function normalizeMethod(method) {
|
|
14093
|
+
var upcased = method.toUpperCase();
|
|
14094
|
+
return methods.indexOf(upcased) > -1 ? upcased : method;
|
|
14095
|
+
}
|
|
14096
|
+
function Request(input, options) {
|
|
14097
|
+
options = options || {};
|
|
14098
|
+
var body = options.body;
|
|
14099
|
+
if (input instanceof Request) {
|
|
14100
|
+
if (input.bodyUsed) {
|
|
14101
|
+
throw new TypeError("Already read");
|
|
14102
|
+
}
|
|
14103
|
+
this.url = input.url;
|
|
14104
|
+
this.credentials = input.credentials;
|
|
14105
|
+
if (!options.headers) {
|
|
14106
|
+
this.headers = new Headers2(input.headers);
|
|
14107
|
+
}
|
|
14108
|
+
this.method = input.method;
|
|
14109
|
+
this.mode = input.mode;
|
|
14110
|
+
if (!body && input._bodyInit != null) {
|
|
14111
|
+
body = input._bodyInit;
|
|
14112
|
+
input.bodyUsed = true;
|
|
14113
|
+
}
|
|
14114
|
+
} else {
|
|
14115
|
+
this.url = String(input);
|
|
14116
|
+
}
|
|
14117
|
+
this.credentials = options.credentials || this.credentials || "omit";
|
|
14118
|
+
if (options.headers || !this.headers) {
|
|
14119
|
+
this.headers = new Headers2(options.headers);
|
|
14120
|
+
}
|
|
14121
|
+
this.method = normalizeMethod(options.method || this.method || "GET");
|
|
14122
|
+
this.mode = options.mode || this.mode || null;
|
|
14123
|
+
this.referrer = null;
|
|
14124
|
+
if ((this.method === "GET" || this.method === "HEAD") && body) {
|
|
14125
|
+
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
14126
|
+
}
|
|
14127
|
+
this._initBody(body);
|
|
14128
|
+
}
|
|
14129
|
+
Request.prototype.clone = function() {
|
|
14130
|
+
return new Request(this, { body: this._bodyInit });
|
|
14131
|
+
};
|
|
14132
|
+
function decode(body) {
|
|
14133
|
+
var form = new FormData();
|
|
14134
|
+
body.trim().split("&").forEach(function(bytes) {
|
|
14135
|
+
if (bytes) {
|
|
14136
|
+
var split = bytes.split("=");
|
|
14137
|
+
var name = split.shift().replace(/\+/g, " ");
|
|
14138
|
+
var value = split.join("=").replace(/\+/g, " ");
|
|
14139
|
+
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
14140
|
+
}
|
|
14141
|
+
});
|
|
14142
|
+
return form;
|
|
14143
|
+
}
|
|
14144
|
+
function parseHeaders(rawHeaders) {
|
|
14145
|
+
var headers = new Headers2();
|
|
14146
|
+
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
|
|
14147
|
+
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
|
14148
|
+
var parts = line.split(":");
|
|
14149
|
+
var key = parts.shift().trim();
|
|
14150
|
+
if (key) {
|
|
14151
|
+
var value = parts.join(":").trim();
|
|
14152
|
+
headers.append(key, value);
|
|
14153
|
+
}
|
|
14154
|
+
});
|
|
14155
|
+
return headers;
|
|
14156
|
+
}
|
|
14157
|
+
Body.call(Request.prototype);
|
|
14158
|
+
function Response2(bodyInit, options) {
|
|
14159
|
+
if (!options) {
|
|
14160
|
+
options = {};
|
|
14161
|
+
}
|
|
14162
|
+
this.type = "default";
|
|
14163
|
+
this.status = options.status === void 0 ? 200 : options.status;
|
|
14164
|
+
this.ok = this.status >= 200 && this.status < 300;
|
|
14165
|
+
this.statusText = "statusText" in options ? options.statusText : "OK";
|
|
14166
|
+
this.headers = new Headers2(options.headers);
|
|
14167
|
+
this.url = options.url || "";
|
|
14168
|
+
this._initBody(bodyInit);
|
|
14169
|
+
}
|
|
14170
|
+
Body.call(Response2.prototype);
|
|
14171
|
+
Response2.prototype.clone = function() {
|
|
14172
|
+
return new Response2(this._bodyInit, {
|
|
14173
|
+
status: this.status,
|
|
14174
|
+
statusText: this.statusText,
|
|
14175
|
+
headers: new Headers2(this.headers),
|
|
14176
|
+
url: this.url
|
|
14177
|
+
});
|
|
14178
|
+
};
|
|
14179
|
+
Response2.error = function() {
|
|
14180
|
+
var response = new Response2(null, { status: 0, statusText: "" });
|
|
14181
|
+
response.type = "error";
|
|
14182
|
+
return response;
|
|
14183
|
+
};
|
|
14184
|
+
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
14185
|
+
Response2.redirect = function(url, status) {
|
|
14186
|
+
if (redirectStatuses.indexOf(status) === -1) {
|
|
14187
|
+
throw new RangeError("Invalid status code");
|
|
14188
|
+
}
|
|
14189
|
+
return new Response2(null, { status, headers: { location: url } });
|
|
14190
|
+
};
|
|
14191
|
+
self2.Headers = Headers2;
|
|
14192
|
+
self2.Request = Request;
|
|
14193
|
+
self2.Response = Response2;
|
|
14194
|
+
self2.fetch = function(input, init2) {
|
|
14195
|
+
return new Promise(function(resolve, reject) {
|
|
14196
|
+
var request = new Request(input, init2);
|
|
14197
|
+
var xhr = new XMLHttpRequest();
|
|
14198
|
+
xhr.onload = function() {
|
|
14199
|
+
var options = {
|
|
14200
|
+
status: xhr.status,
|
|
14201
|
+
statusText: xhr.statusText,
|
|
14202
|
+
headers: parseHeaders(xhr.getAllResponseHeaders() || "")
|
|
14203
|
+
};
|
|
14204
|
+
options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
|
|
14205
|
+
var body = "response" in xhr ? xhr.response : xhr.responseText;
|
|
14206
|
+
resolve(new Response2(body, options));
|
|
14207
|
+
};
|
|
14208
|
+
xhr.onerror = function() {
|
|
14209
|
+
reject(new TypeError("Network request failed"));
|
|
14210
|
+
};
|
|
14211
|
+
xhr.ontimeout = function() {
|
|
14212
|
+
reject(new TypeError("Network request failed"));
|
|
14213
|
+
};
|
|
14214
|
+
xhr.open(request.method, request.url, true);
|
|
14215
|
+
if (request.credentials === "include") {
|
|
14216
|
+
xhr.withCredentials = true;
|
|
14217
|
+
} else if (request.credentials === "omit") {
|
|
14218
|
+
xhr.withCredentials = false;
|
|
14219
|
+
}
|
|
14220
|
+
if ("responseType" in xhr && support.blob) {
|
|
14221
|
+
xhr.responseType = "blob";
|
|
14222
|
+
}
|
|
14223
|
+
request.headers.forEach(function(value, name) {
|
|
14224
|
+
xhr.setRequestHeader(name, value);
|
|
14225
|
+
});
|
|
14226
|
+
xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
|
|
14227
|
+
});
|
|
14228
|
+
};
|
|
14229
|
+
self2.fetch.polyfill = true;
|
|
14230
|
+
})(typeof self !== "undefined" ? self : this);
|
|
14231
|
+
},
|
|
14232
|
+
/* 6 */
|
|
14233
|
+
/***/
|
|
14234
|
+
function(module2, exports2, __webpack_require__) {
|
|
14235
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14236
|
+
value: true
|
|
14237
|
+
});
|
|
14238
|
+
exports2.core = exports2.adyen = exports2.exchange = exports2.priceAlert = exports2.users = exports2.quotes = exports2.redirect = exports2.utils = exports2.purchase = exports2.trip = exports2.search = exports2.collections = exports2.session = exports2.apiRequest = exports2.setUserAuthToken = exports2.setConfig = void 0;
|
|
14239
|
+
var _config = __webpack_require__(1);
|
|
14240
|
+
var _apiRequest = __webpack_require__(0);
|
|
14241
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14242
|
+
var _session = __webpack_require__(10);
|
|
14243
|
+
var session = _interopRequireWildcard(_session);
|
|
14244
|
+
var _collections = __webpack_require__(11);
|
|
14245
|
+
var collections = _interopRequireWildcard(_collections);
|
|
14246
|
+
var _search = __webpack_require__(12);
|
|
14247
|
+
var search = _interopRequireWildcard(_search);
|
|
14248
|
+
var _trip = __webpack_require__(13);
|
|
14249
|
+
var trip = _interopRequireWildcard(_trip);
|
|
14250
|
+
var _purchase = __webpack_require__(14);
|
|
14251
|
+
var purchase = _interopRequireWildcard(_purchase);
|
|
14252
|
+
var _utils = __webpack_require__(17);
|
|
14253
|
+
var utils = _interopRequireWildcard(_utils);
|
|
14254
|
+
var _redirect = __webpack_require__(19);
|
|
14255
|
+
var redirect = _interopRequireWildcard(_redirect);
|
|
14256
|
+
var _quotes = __webpack_require__(20);
|
|
14257
|
+
var quotes = _interopRequireWildcard(_quotes);
|
|
14258
|
+
var _users = __webpack_require__(21);
|
|
14259
|
+
var users = _interopRequireWildcard(_users);
|
|
14260
|
+
var _priceAlert = __webpack_require__(22);
|
|
14261
|
+
var priceAlert = _interopRequireWildcard(_priceAlert);
|
|
14262
|
+
var _exchange = __webpack_require__(23);
|
|
14263
|
+
var exchange = _interopRequireWildcard(_exchange);
|
|
14264
|
+
var _adyen = __webpack_require__(24);
|
|
14265
|
+
var adyen = _interopRequireWildcard(_adyen);
|
|
14266
|
+
var _core = __webpack_require__(25);
|
|
14267
|
+
var core = _interopRequireWildcard(_core);
|
|
14268
|
+
function _interopRequireWildcard(obj) {
|
|
14269
|
+
if (obj && obj.__esModule) {
|
|
14270
|
+
return obj;
|
|
14271
|
+
} else {
|
|
14272
|
+
var newObj = {};
|
|
14273
|
+
if (obj != null) {
|
|
14274
|
+
for (var key in obj) {
|
|
14275
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14276
|
+
}
|
|
14277
|
+
}
|
|
14278
|
+
newObj.default = obj;
|
|
14279
|
+
return newObj;
|
|
14280
|
+
}
|
|
14281
|
+
}
|
|
14282
|
+
exports2.setConfig = _config.setConfig;
|
|
14283
|
+
exports2.setUserAuthToken = _config.setUserAuthToken;
|
|
14284
|
+
exports2.apiRequest = apiRequest;
|
|
14285
|
+
exports2.session = session;
|
|
14286
|
+
exports2.collections = collections;
|
|
14287
|
+
exports2.search = search;
|
|
14288
|
+
exports2.trip = trip;
|
|
14289
|
+
exports2.purchase = purchase;
|
|
14290
|
+
exports2.utils = utils;
|
|
14291
|
+
exports2.redirect = redirect;
|
|
14292
|
+
exports2.quotes = quotes;
|
|
14293
|
+
exports2.users = users;
|
|
14294
|
+
exports2.priceAlert = priceAlert;
|
|
14295
|
+
exports2.exchange = exchange;
|
|
14296
|
+
exports2.adyen = adyen;
|
|
14297
|
+
exports2.core = core;
|
|
14298
|
+
},
|
|
14299
|
+
/* 7 */
|
|
14300
|
+
/***/
|
|
14301
|
+
function(module2, exports2, __webpack_require__) {
|
|
14302
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14303
|
+
value: true
|
|
14304
|
+
});
|
|
14305
|
+
function _classCallCheck(instance, Constructor) {
|
|
14306
|
+
if (!(instance instanceof Constructor)) {
|
|
14307
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14308
|
+
}
|
|
14309
|
+
}
|
|
14310
|
+
function _possibleConstructorReturn(self2, call) {
|
|
14311
|
+
if (!self2) {
|
|
14312
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
14313
|
+
}
|
|
14314
|
+
return call && (typeof call === "object" || typeof call === "function") ? call : self2;
|
|
14315
|
+
}
|
|
14316
|
+
function _inherits(subClass, superClass) {
|
|
14317
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
14318
|
+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
14319
|
+
}
|
|
14320
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
|
|
14321
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
14322
|
+
}
|
|
14323
|
+
var NetworkError = function(_Error) {
|
|
14324
|
+
_inherits(NetworkError2, _Error);
|
|
14325
|
+
function NetworkError2() {
|
|
14326
|
+
var code = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : -100;
|
|
14327
|
+
var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Unknown error";
|
|
14328
|
+
_classCallCheck(this, NetworkError2);
|
|
14329
|
+
var _this = _possibleConstructorReturn(this, (NetworkError2.__proto__ || Object.getPrototypeOf(NetworkError2)).call(this, message));
|
|
14330
|
+
_this.code = code;
|
|
14331
|
+
_this.stack = new Error().stack;
|
|
14332
|
+
return _this;
|
|
14333
|
+
}
|
|
14334
|
+
return NetworkError2;
|
|
14335
|
+
}(Error);
|
|
14336
|
+
exports2.default = NetworkError;
|
|
14337
|
+
},
|
|
14338
|
+
/* 8 */
|
|
14339
|
+
/***/
|
|
14340
|
+
function(module2, exports2, __webpack_require__) {
|
|
14341
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14342
|
+
value: true
|
|
14343
|
+
});
|
|
14344
|
+
var _extends = Object.assign || function(target) {
|
|
14345
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14346
|
+
var source = arguments[i];
|
|
14347
|
+
for (var key in source) {
|
|
14348
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14349
|
+
target[key] = source[key];
|
|
14350
|
+
}
|
|
14351
|
+
}
|
|
14352
|
+
}
|
|
14353
|
+
return target;
|
|
14354
|
+
};
|
|
14355
|
+
var authorizationErrors = {
|
|
14356
|
+
// UNAUTHORIZED
|
|
14357
|
+
1: {
|
|
14358
|
+
code: 200,
|
|
14359
|
+
message: "Operación no autorizada"
|
|
14360
|
+
}
|
|
14361
|
+
};
|
|
14362
|
+
var generalErrors = {
|
|
14363
|
+
// INCORRECT_PARAMS
|
|
14364
|
+
3: {
|
|
14365
|
+
code: 300,
|
|
14366
|
+
message: "Parámetros incorrectos"
|
|
14367
|
+
},
|
|
14368
|
+
// INCORRECT_DATE
|
|
14369
|
+
7: {
|
|
14370
|
+
code: 301,
|
|
14371
|
+
message: "Fecha inválida"
|
|
14372
|
+
}
|
|
14373
|
+
};
|
|
14374
|
+
var tripErrors = {
|
|
14375
|
+
// NONEXISTENT_TRIP
|
|
14376
|
+
10: {
|
|
14377
|
+
code: 400,
|
|
14378
|
+
message: "No existe el viaje"
|
|
14379
|
+
},
|
|
14380
|
+
// journey_key_not_found
|
|
14381
|
+
20: {
|
|
14382
|
+
code: 60,
|
|
14383
|
+
message: "No se encontró el viaje"
|
|
14384
|
+
},
|
|
14385
|
+
// sold_out_fare_code
|
|
14386
|
+
21: {
|
|
14387
|
+
code: 60,
|
|
14388
|
+
message: "Tarifa no disponible"
|
|
14389
|
+
},
|
|
14390
|
+
// unavailable_fare_code
|
|
14391
|
+
22: {
|
|
14392
|
+
code: 60,
|
|
14393
|
+
message: "Tarifa no disponible"
|
|
14394
|
+
}
|
|
14395
|
+
};
|
|
14396
|
+
var discountCodeErrors = function discountCodeErrors2(message) {
|
|
14397
|
+
return {
|
|
14398
|
+
// INVALID_DISCOUNT
|
|
14399
|
+
11: {
|
|
14400
|
+
code: 500,
|
|
14401
|
+
message
|
|
14402
|
+
},
|
|
14403
|
+
//EXPIRED_DISCOUNT
|
|
14404
|
+
12: {
|
|
14405
|
+
code: 501,
|
|
14406
|
+
message
|
|
14407
|
+
}
|
|
14408
|
+
};
|
|
14409
|
+
};
|
|
14410
|
+
var ticketErrors = {
|
|
14411
|
+
// unavailable_student
|
|
14412
|
+
23: {
|
|
14413
|
+
code: 60,
|
|
14414
|
+
message: "Estudiante no disponible"
|
|
14415
|
+
},
|
|
14416
|
+
// unavailable_teacher
|
|
14417
|
+
24: {
|
|
14418
|
+
code: 60,
|
|
14419
|
+
message: "Profesor no disponible"
|
|
14420
|
+
},
|
|
14421
|
+
// unavailable_minor
|
|
14422
|
+
25: {
|
|
14423
|
+
code: 60,
|
|
14424
|
+
message: "Menor no disponible"
|
|
14425
|
+
},
|
|
14426
|
+
// unavailable_special
|
|
14427
|
+
26: {
|
|
14428
|
+
code: 60,
|
|
14429
|
+
message: "Capacidades diferentes no disponible"
|
|
14430
|
+
},
|
|
14431
|
+
// unavailable_older
|
|
14432
|
+
27: {
|
|
14433
|
+
code: 60,
|
|
14434
|
+
message: "INSEN no disponible"
|
|
14435
|
+
},
|
|
14436
|
+
// unavailable_general
|
|
14437
|
+
28: {
|
|
14438
|
+
code: 60,
|
|
14439
|
+
message: "General no disponible"
|
|
14440
|
+
},
|
|
14441
|
+
// unavailable_unknown
|
|
14442
|
+
29: {
|
|
14443
|
+
code: 60,
|
|
14444
|
+
message: "Error desconocido"
|
|
14445
|
+
}
|
|
14446
|
+
};
|
|
14447
|
+
var exchange = function exchange2(message) {
|
|
14448
|
+
return {
|
|
14449
|
+
30: {
|
|
14450
|
+
code: 30,
|
|
14451
|
+
message
|
|
14452
|
+
}
|
|
14453
|
+
};
|
|
14454
|
+
};
|
|
14455
|
+
var paymentErrors = {
|
|
14456
|
+
50: {
|
|
14457
|
+
code: 50,
|
|
14458
|
+
message: "Unknow Error"
|
|
14459
|
+
}
|
|
14460
|
+
};
|
|
14461
|
+
var apiErrors = exports2.apiErrors = function apiErrors2(message) {
|
|
14462
|
+
return _extends({}, authorizationErrors, generalErrors, tripErrors, discountCodeErrors(message), ticketErrors, paymentErrors, exchange(message));
|
|
14463
|
+
};
|
|
14464
|
+
exports2.default = apiErrors;
|
|
14465
|
+
},
|
|
14466
|
+
/* 9 */
|
|
14467
|
+
/***/
|
|
14468
|
+
function(module2, exports2, __webpack_require__) {
|
|
14469
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14470
|
+
value: true
|
|
14471
|
+
});
|
|
14472
|
+
var _createClass = /* @__PURE__ */ function() {
|
|
14473
|
+
function defineProperties(target, props) {
|
|
14474
|
+
for (var i = 0; i < props.length; i++) {
|
|
14475
|
+
var descriptor = props[i];
|
|
14476
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
14477
|
+
descriptor.configurable = true;
|
|
14478
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
14479
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
14480
|
+
}
|
|
14481
|
+
}
|
|
14482
|
+
return function(Constructor, protoProps, staticProps) {
|
|
14483
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
14484
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
14485
|
+
return Constructor;
|
|
14486
|
+
};
|
|
14487
|
+
}();
|
|
14488
|
+
var _request = __webpack_require__(2);
|
|
14489
|
+
var request = _interopRequireWildcard(_request);
|
|
14490
|
+
function _interopRequireWildcard(obj) {
|
|
14491
|
+
if (obj && obj.__esModule) {
|
|
14492
|
+
return obj;
|
|
14493
|
+
} else {
|
|
14494
|
+
var newObj = {};
|
|
14495
|
+
if (obj != null) {
|
|
14496
|
+
for (var key in obj) {
|
|
14497
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14498
|
+
}
|
|
14499
|
+
}
|
|
14500
|
+
newObj.default = obj;
|
|
14501
|
+
return newObj;
|
|
14502
|
+
}
|
|
14503
|
+
}
|
|
14504
|
+
function _classCallCheck(instance, Constructor) {
|
|
14505
|
+
if (!(instance instanceof Constructor)) {
|
|
14506
|
+
throw new TypeError("Cannot call a class as a function");
|
|
14507
|
+
}
|
|
14508
|
+
}
|
|
14509
|
+
var Poll = function() {
|
|
14510
|
+
function Poll2(_ref) {
|
|
14511
|
+
var url = _ref.url, watch = _ref.watch, expect = _ref.expect, _ref$maxRetries = _ref.maxRetries, maxRetries = _ref$maxRetries === void 0 ? 30 : _ref$maxRetries, _ref$interval = _ref.interval, interval = _ref$interval === void 0 ? 2e3 : _ref$interval, _ref$eachCall = _ref.eachCall, eachCall = _ref$eachCall === void 0 ? null : _ref$eachCall;
|
|
14512
|
+
_classCallCheck(this, Poll2);
|
|
14513
|
+
this.url = url;
|
|
14514
|
+
this.watch = watch;
|
|
14515
|
+
this.expect = expect instanceof Array ? expect : [expect];
|
|
14516
|
+
this.interval = interval;
|
|
14517
|
+
this.maxRetries = maxRetries;
|
|
14518
|
+
this.eachCall = eachCall && eachCall.bind(this);
|
|
14519
|
+
this.aborted = false;
|
|
14520
|
+
this.timers = [];
|
|
14521
|
+
this.execute = this.execute.bind(this);
|
|
14522
|
+
this.executeEachCall = this.executeEachCall.bind(this);
|
|
14523
|
+
}
|
|
14524
|
+
_createClass(Poll2, [{
|
|
14525
|
+
key: "start",
|
|
14526
|
+
value: function start() {
|
|
14527
|
+
return this.execute(this.maxRetries);
|
|
14528
|
+
}
|
|
14529
|
+
}, {
|
|
14530
|
+
key: "abort",
|
|
14531
|
+
value: function abort() {
|
|
14532
|
+
this.aborted = true;
|
|
14533
|
+
}
|
|
14534
|
+
}, {
|
|
14535
|
+
key: "execute",
|
|
14536
|
+
value: function execute(retries) {
|
|
14537
|
+
var _this = this;
|
|
14538
|
+
var onRequestSuccess = function onRequestSuccess2(payload) {
|
|
14539
|
+
if (_this.expect.includes(payload[_this.watch]) || retries === 1 || _this.aborted) {
|
|
14540
|
+
var status = payload[_this.watch];
|
|
14541
|
+
if (retries === 1) {
|
|
14542
|
+
status = "retries_exceeded";
|
|
14543
|
+
} else if (_this.aborted) {
|
|
14544
|
+
status = "aborted";
|
|
14545
|
+
}
|
|
14546
|
+
_this.timers.forEach(clearInterval);
|
|
14547
|
+
_this.executeEachCall(status, payload);
|
|
14548
|
+
} else if (payload[_this.watch] === "failed") {
|
|
14549
|
+
_this.timers.forEach(clearInterval);
|
|
14550
|
+
_this.executeEachCall("failed", payload);
|
|
14551
|
+
} else {
|
|
14552
|
+
_this.executeEachCall("pending", payload);
|
|
14553
|
+
var timer = window.setTimeout(_this.execute, _this.interval, retries - 1);
|
|
14554
|
+
_this.timers.push(timer);
|
|
14555
|
+
}
|
|
14556
|
+
};
|
|
14557
|
+
var onRequestError = function onRequestError2(err) {
|
|
14558
|
+
return _this.executeEachCall("error", err);
|
|
14559
|
+
};
|
|
14560
|
+
return request.get(this.url, {}, onRequestError).then(onRequestSuccess);
|
|
14561
|
+
}
|
|
14562
|
+
}, {
|
|
14563
|
+
key: "executeEachCall",
|
|
14564
|
+
value: function executeEachCall(status, payload) {
|
|
14565
|
+
if (this.eachCall instanceof Function) {
|
|
14566
|
+
if (this.eachCall({ status, payload })) {
|
|
14567
|
+
this.abort();
|
|
14568
|
+
}
|
|
14569
|
+
}
|
|
14570
|
+
}
|
|
14571
|
+
}]);
|
|
14572
|
+
return Poll2;
|
|
14573
|
+
}();
|
|
14574
|
+
exports2.default = Poll;
|
|
14575
|
+
},
|
|
14576
|
+
/* 10 */
|
|
14577
|
+
/***/
|
|
14578
|
+
function(module2, exports2, __webpack_require__) {
|
|
14579
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14580
|
+
value: true
|
|
14581
|
+
});
|
|
14582
|
+
exports2.get = get;
|
|
14583
|
+
exports2.agency = agency;
|
|
14584
|
+
var _apiRequest = __webpack_require__(0);
|
|
14585
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14586
|
+
function _interopRequireWildcard(obj) {
|
|
14587
|
+
if (obj && obj.__esModule) {
|
|
14588
|
+
return obj;
|
|
14589
|
+
} else {
|
|
14590
|
+
var newObj = {};
|
|
14591
|
+
if (obj != null) {
|
|
14592
|
+
for (var key in obj) {
|
|
14593
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14594
|
+
}
|
|
14595
|
+
}
|
|
14596
|
+
newObj.default = obj;
|
|
14597
|
+
return newObj;
|
|
14598
|
+
}
|
|
14599
|
+
}
|
|
14600
|
+
function get() {
|
|
14601
|
+
return new Promise(function(resolve, reject) {
|
|
14602
|
+
apiRequest.get("session", { apiVersion: "v1" }).then(function(session) {
|
|
14603
|
+
return resolve(session);
|
|
14604
|
+
}).catch(function(_ref) {
|
|
14605
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
14606
|
+
return reject({ code, message });
|
|
14607
|
+
});
|
|
14608
|
+
});
|
|
14609
|
+
}
|
|
14610
|
+
function agency() {
|
|
14611
|
+
return new Promise(function(resolve, reject) {
|
|
14612
|
+
apiRequest.get("get_agency").then(function(agency2) {
|
|
14613
|
+
return resolve(agency2);
|
|
14614
|
+
}).catch(function(_ref2) {
|
|
14615
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
14616
|
+
return reject({ code, message });
|
|
14617
|
+
});
|
|
14618
|
+
});
|
|
14619
|
+
}
|
|
14620
|
+
},
|
|
14621
|
+
/* 11 */
|
|
14622
|
+
/***/
|
|
14623
|
+
function(module2, exports2, __webpack_require__) {
|
|
14624
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14625
|
+
value: true
|
|
14626
|
+
});
|
|
14627
|
+
exports2.getCountries = getCountries;
|
|
14628
|
+
exports2.getPlaces = getPlaces;
|
|
14629
|
+
var _apiRequest = __webpack_require__(0);
|
|
14630
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14631
|
+
function _interopRequireWildcard(obj) {
|
|
14632
|
+
if (obj && obj.__esModule) {
|
|
14633
|
+
return obj;
|
|
14634
|
+
} else {
|
|
14635
|
+
var newObj = {};
|
|
14636
|
+
if (obj != null) {
|
|
14637
|
+
for (var key in obj) {
|
|
14638
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14639
|
+
}
|
|
14640
|
+
}
|
|
14641
|
+
newObj.default = obj;
|
|
14642
|
+
return newObj;
|
|
14643
|
+
}
|
|
14644
|
+
}
|
|
14645
|
+
function getCountries() {
|
|
14646
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
14647
|
+
var _options$prefetch = options.prefetch, prefetch = _options$prefetch === void 0 ? true : _options$prefetch, _options$q = options.q, q = _options$q === void 0 ? "" : _options$q;
|
|
14648
|
+
var queryParams = { prefetch, q };
|
|
14649
|
+
return new Promise(function(resolve, reject) {
|
|
14650
|
+
apiRequest.get("countries", { queryParams }).then(function(countries) {
|
|
14651
|
+
return resolve(countries);
|
|
14652
|
+
}).catch(function(_ref) {
|
|
14653
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
14654
|
+
return reject({ code, message });
|
|
14655
|
+
});
|
|
14656
|
+
});
|
|
14657
|
+
}
|
|
14658
|
+
function getPlaces(q, from) {
|
|
14659
|
+
var queryParams = !q ? { prefetch: true } : { q, from };
|
|
14660
|
+
return new Promise(function(resolve, reject) {
|
|
14661
|
+
apiRequest.get("places", { queryParams }).then(function(places) {
|
|
14662
|
+
return resolve(places);
|
|
14663
|
+
}).catch(function(_ref2) {
|
|
14664
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
14665
|
+
return reject({ code, message });
|
|
14666
|
+
});
|
|
14667
|
+
});
|
|
14668
|
+
}
|
|
14669
|
+
},
|
|
14670
|
+
/* 12 */
|
|
14671
|
+
/***/
|
|
14672
|
+
function(module2, exports2, __webpack_require__) {
|
|
14673
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14674
|
+
value: true
|
|
14675
|
+
});
|
|
14676
|
+
var _slicedToArray = /* @__PURE__ */ function() {
|
|
14677
|
+
function sliceIterator(arr, i) {
|
|
14678
|
+
var _arr = [];
|
|
14679
|
+
var _n = true;
|
|
14680
|
+
var _d = false;
|
|
14681
|
+
var _e = void 0;
|
|
14682
|
+
try {
|
|
14683
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
14684
|
+
_arr.push(_s.value);
|
|
14685
|
+
if (i && _arr.length === i) break;
|
|
14686
|
+
}
|
|
14687
|
+
} catch (err) {
|
|
14688
|
+
_d = true;
|
|
14689
|
+
_e = err;
|
|
14690
|
+
} finally {
|
|
14691
|
+
try {
|
|
14692
|
+
if (!_n && _i["return"]) _i["return"]();
|
|
14693
|
+
} finally {
|
|
14694
|
+
if (_d) throw _e;
|
|
14695
|
+
}
|
|
14696
|
+
}
|
|
14697
|
+
return _arr;
|
|
14698
|
+
}
|
|
14699
|
+
return function(arr, i) {
|
|
14700
|
+
if (Array.isArray(arr)) {
|
|
14701
|
+
return arr;
|
|
14702
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
14703
|
+
return sliceIterator(arr, i);
|
|
14704
|
+
} else {
|
|
14705
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
14706
|
+
}
|
|
14707
|
+
};
|
|
14708
|
+
}();
|
|
14709
|
+
var _extends = Object.assign || function(target) {
|
|
14710
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14711
|
+
var source = arguments[i];
|
|
14712
|
+
for (var key in source) {
|
|
14713
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14714
|
+
target[key] = source[key];
|
|
14715
|
+
}
|
|
14716
|
+
}
|
|
14717
|
+
}
|
|
14718
|
+
return target;
|
|
14719
|
+
};
|
|
14720
|
+
exports2.create = create;
|
|
14721
|
+
exports2.stopSearch = stopSearch;
|
|
14722
|
+
exports2.stopAllSearches = stopAllSearches;
|
|
14723
|
+
exports2.get = get;
|
|
14724
|
+
exports2.validateExternalCoupon = validateExternalCoupon;
|
|
14725
|
+
exports2.walletSearchDiscount = walletSearchDiscount;
|
|
14726
|
+
var _apiRequest = __webpack_require__(0);
|
|
14727
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14728
|
+
function _interopRequireWildcard(obj) {
|
|
14729
|
+
if (obj && obj.__esModule) {
|
|
14730
|
+
return obj;
|
|
14731
|
+
} else {
|
|
14732
|
+
var newObj = {};
|
|
14733
|
+
if (obj != null) {
|
|
14734
|
+
for (var key in obj) {
|
|
14735
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14736
|
+
}
|
|
14737
|
+
}
|
|
14738
|
+
newObj.default = obj;
|
|
14739
|
+
return newObj;
|
|
14740
|
+
}
|
|
14741
|
+
}
|
|
14742
|
+
var currentPolls = {};
|
|
14743
|
+
function startPolls(payload, polling) {
|
|
14744
|
+
var _payload$search = payload.search, id = _payload$search.id, typeOfTransport = _payload$search.type_of_transport;
|
|
14745
|
+
var bus = typeOfTransport.bus, flights = typeOfTransport.flights, mix = typeOfTransport.mix;
|
|
14746
|
+
var _polling$initBuses = polling.initBuses, initBuses = _polling$initBuses === void 0 ? true : _polling$initBuses, _polling$initFlights = polling.initFlights, initFlights = _polling$initFlights === void 0 ? true : _polling$initFlights, _polling$initRides = polling.initRides, initRides = _polling$initRides === void 0 ? false : _polling$initRides, _polling$initMix = polling.initMix, initMix = _polling$initMix === void 0 ? true : _polling$initMix, onReceiveBuses = polling.onReceiveBuses, onReceiveFlights = polling.onReceiveFlights, onReceiveRides = polling.onReceiveRides, onReceiveMixed = polling.onReceiveMixed;
|
|
14747
|
+
var pollOptions = _extends({
|
|
14748
|
+
watch: "state",
|
|
14749
|
+
expect: "finished"
|
|
14750
|
+
}, polling.options || {});
|
|
14751
|
+
var polls = [];
|
|
14752
|
+
if (bus && bus.active && initBuses) {
|
|
14753
|
+
var poll = apiRequest.poll("search/" + id + "?type=bus", onReceiveBuses, pollOptions);
|
|
14754
|
+
poll.start();
|
|
14755
|
+
polls.push(poll);
|
|
14756
|
+
} else if (onReceiveBuses) {
|
|
14757
|
+
onReceiveBuses({ status: "deactivated" });
|
|
14758
|
+
}
|
|
14759
|
+
if (flights && flights.active && initFlights) {
|
|
14760
|
+
var _poll = apiRequest.poll("search/" + id + "?type=plane", onReceiveFlights, pollOptions);
|
|
14761
|
+
_poll.start();
|
|
14762
|
+
polls.push(_poll);
|
|
14763
|
+
} else if (onReceiveFlights) {
|
|
14764
|
+
onReceiveFlights({ status: "deactivated" });
|
|
14765
|
+
}
|
|
14766
|
+
if (mix && mix.active && initMix) {
|
|
14767
|
+
var _poll2 = apiRequest.poll("search/" + id + "?type=mix", onReceiveMixed, pollOptions);
|
|
14768
|
+
_poll2.start();
|
|
14769
|
+
polls.push(_poll2);
|
|
14770
|
+
} else if (onReceiveMixed) {
|
|
14771
|
+
onReceiveMixed({ status: "deactivated" });
|
|
14772
|
+
}
|
|
14773
|
+
if (initRides) {
|
|
14774
|
+
var _poll3 = apiRequest.poll("search/" + id + "?type=car", onReceiveRides, pollOptions);
|
|
14775
|
+
_poll3.start();
|
|
14776
|
+
polls.push(_poll3);
|
|
14777
|
+
}
|
|
14778
|
+
currentPolls[id] = polls;
|
|
14779
|
+
return payload;
|
|
14780
|
+
}
|
|
14781
|
+
function create(params, polling) {
|
|
14782
|
+
var onCreateSuccess = function onCreateSuccess2(search) {
|
|
14783
|
+
return startPolls(search, polling);
|
|
14784
|
+
};
|
|
14785
|
+
return apiRequest.post("search", params).then(onCreateSuccess);
|
|
14786
|
+
}
|
|
14787
|
+
function stopSearch(searchId) {
|
|
14788
|
+
if (!currentPolls || !searchId || !currentPolls[searchId]) {
|
|
14789
|
+
return false;
|
|
14790
|
+
}
|
|
14791
|
+
currentPolls[searchId].forEach(function(p2) {
|
|
14792
|
+
return p2.abort();
|
|
14793
|
+
});
|
|
14794
|
+
Reflect.deleteProperty(currentPolls, searchId);
|
|
14795
|
+
return true;
|
|
14796
|
+
}
|
|
14797
|
+
function stopAllSearches() {
|
|
14798
|
+
if (!currentPolls) {
|
|
14799
|
+
return false;
|
|
14800
|
+
}
|
|
14801
|
+
Object.entries(currentPolls).forEach(function(_ref) {
|
|
14802
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
14803
|
+
_ref2[0];
|
|
14804
|
+
var polls = _ref2[1];
|
|
14805
|
+
return polls.forEach(function(p2) {
|
|
14806
|
+
return p2.abort();
|
|
14807
|
+
});
|
|
14808
|
+
});
|
|
14809
|
+
currentPolls = {};
|
|
14810
|
+
return true;
|
|
14811
|
+
}
|
|
14812
|
+
function get(id, polling) {
|
|
14813
|
+
return new Promise(function(resolve, reject) {
|
|
14814
|
+
apiRequest.get("search/" + id + "/info").then(function(search) {
|
|
14815
|
+
return resolve(startPolls(search, polling));
|
|
14816
|
+
}).catch(function(_ref3) {
|
|
14817
|
+
var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
|
|
14818
|
+
return reject({ code, message });
|
|
14819
|
+
});
|
|
14820
|
+
});
|
|
14821
|
+
}
|
|
14822
|
+
function validateExternalCoupon(couponCode) {
|
|
14823
|
+
var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
14824
|
+
var query = new URLSearchParams(params).toString();
|
|
14825
|
+
var queryParams = query ? "?" + query : "";
|
|
14826
|
+
return new Promise(function(resolve, reject) {
|
|
14827
|
+
apiRequest.get("search/discounts/validate_external_coupon/" + couponCode + queryParams).then(function(response) {
|
|
14828
|
+
return resolve(response);
|
|
14829
|
+
}).catch(function(_ref4) {
|
|
14830
|
+
var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
|
|
14831
|
+
return reject({ code, message });
|
|
14832
|
+
});
|
|
14833
|
+
});
|
|
14834
|
+
}
|
|
14835
|
+
function walletSearchDiscount(wallet) {
|
|
14836
|
+
var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
14837
|
+
var query = new URLSearchParams(params).toString();
|
|
14838
|
+
var queryParams = query ? "?" + query : "";
|
|
14839
|
+
return new Promise(function(resolve, reject) {
|
|
14840
|
+
apiRequest.get(wallet + "/discounts" + queryParams).then(function(response) {
|
|
14841
|
+
return resolve(response);
|
|
14842
|
+
}).catch(function(_ref5) {
|
|
14843
|
+
var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
|
|
14844
|
+
return reject({ code, message });
|
|
14845
|
+
});
|
|
14846
|
+
});
|
|
14847
|
+
}
|
|
14848
|
+
},
|
|
14849
|
+
/* 13 */
|
|
14850
|
+
/***/
|
|
14851
|
+
function(module2, exports2, __webpack_require__) {
|
|
14852
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14853
|
+
value: true
|
|
14854
|
+
});
|
|
14855
|
+
var _extends = Object.assign || function(target) {
|
|
14856
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14857
|
+
var source = arguments[i];
|
|
14858
|
+
for (var key in source) {
|
|
14859
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14860
|
+
target[key] = source[key];
|
|
14861
|
+
}
|
|
14862
|
+
}
|
|
14863
|
+
}
|
|
14864
|
+
return target;
|
|
14865
|
+
};
|
|
14866
|
+
exports2.get = get;
|
|
14867
|
+
exports2.getWithBus = getWithBus;
|
|
14868
|
+
var _apiRequest = __webpack_require__(0);
|
|
14869
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14870
|
+
function _interopRequireWildcard(obj) {
|
|
14871
|
+
if (obj && obj.__esModule) {
|
|
14872
|
+
return obj;
|
|
14873
|
+
} else {
|
|
14874
|
+
var newObj = {};
|
|
14875
|
+
if (obj != null) {
|
|
14876
|
+
for (var key in obj) {
|
|
14877
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14878
|
+
}
|
|
14879
|
+
}
|
|
14880
|
+
newObj.default = obj;
|
|
14881
|
+
return newObj;
|
|
14882
|
+
}
|
|
14883
|
+
}
|
|
14884
|
+
function startPoll(slug, payload, polling) {
|
|
14885
|
+
var id = payload.id;
|
|
14886
|
+
var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, _polling$options = polling.options, options = _polling$options === void 0 ? {} : _polling$options, onReceiveTrip = polling.onReceiveTrip;
|
|
14887
|
+
var pollOptions = _extends({
|
|
14888
|
+
watch: "state",
|
|
14889
|
+
expect: "finished"
|
|
14890
|
+
}, options);
|
|
14891
|
+
var poll = void 0;
|
|
14892
|
+
var startedPoll = void 0;
|
|
14893
|
+
if (init2) {
|
|
14894
|
+
poll = apiRequest.poll("trips/" + slug + "/details_requests/" + id, onReceiveTrip, pollOptions);
|
|
14895
|
+
startedPoll = poll.start();
|
|
14896
|
+
}
|
|
14897
|
+
return {
|
|
14898
|
+
payload,
|
|
14899
|
+
polls: {
|
|
14900
|
+
trip: startedPoll,
|
|
14901
|
+
abort: function abort() {
|
|
14902
|
+
return poll.abort();
|
|
14903
|
+
}
|
|
14904
|
+
}
|
|
14905
|
+
};
|
|
14906
|
+
}
|
|
14907
|
+
function encodePassengers(passengers) {
|
|
14908
|
+
var encoded = [];
|
|
14909
|
+
Object.keys(passengers).forEach(function(key) {
|
|
14910
|
+
var quantity = passengers[key];
|
|
14911
|
+
if (quantity) {
|
|
14912
|
+
encoded.push(key + "=" + quantity);
|
|
14913
|
+
}
|
|
14914
|
+
});
|
|
14915
|
+
return encoded.join("&");
|
|
14916
|
+
}
|
|
14917
|
+
function get(id) {
|
|
14918
|
+
var passengers = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
14919
|
+
return new Promise(function(resolve, reject) {
|
|
14920
|
+
apiRequest.get("trips/" + id + "?" + encodePassengers(passengers)).then(function(trip) {
|
|
14921
|
+
return resolve(trip);
|
|
14922
|
+
}).catch(function(_ref) {
|
|
14923
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
14924
|
+
return reject({ code, message });
|
|
14925
|
+
});
|
|
14926
|
+
});
|
|
14927
|
+
}
|
|
14928
|
+
function getWithBus(id) {
|
|
14929
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
14930
|
+
var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
14931
|
+
var postPayload = _extends({
|
|
14932
|
+
with_pricing: true
|
|
14933
|
+
}, options);
|
|
14934
|
+
return new Promise(function(resolve, reject) {
|
|
14935
|
+
apiRequest.post("trips/" + id + "/details_requests", postPayload).then(function(trip) {
|
|
14936
|
+
return resolve(startPoll(id, trip, polling));
|
|
14937
|
+
}).catch(function(_ref2) {
|
|
14938
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
14939
|
+
return reject({ code, message });
|
|
14940
|
+
});
|
|
14941
|
+
});
|
|
14942
|
+
}
|
|
14943
|
+
},
|
|
14944
|
+
/* 14 */
|
|
14945
|
+
/***/
|
|
14946
|
+
function(module2, exports2, __webpack_require__) {
|
|
14947
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
14948
|
+
value: true
|
|
14949
|
+
});
|
|
14950
|
+
exports2.startTicketsPoll = void 0;
|
|
14951
|
+
var _extends = Object.assign || function(target) {
|
|
14952
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
14953
|
+
var source = arguments[i];
|
|
14954
|
+
for (var key in source) {
|
|
14955
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14956
|
+
target[key] = source[key];
|
|
14957
|
+
}
|
|
14958
|
+
}
|
|
14959
|
+
}
|
|
14960
|
+
return target;
|
|
14961
|
+
};
|
|
14962
|
+
exports2.startPurchasePoll = startPurchasePoll;
|
|
14963
|
+
exports2.create = create;
|
|
14964
|
+
exports2.get = get;
|
|
14965
|
+
exports2.update = update;
|
|
14966
|
+
exports2.createPassengers = createPassengers;
|
|
14967
|
+
exports2.updatePassengers = updatePassengers;
|
|
14968
|
+
exports2.deletePassenger = deletePassenger;
|
|
14969
|
+
exports2.createTickets = createTickets;
|
|
14970
|
+
exports2.applyDiscountCode = applyDiscountCode;
|
|
14971
|
+
exports2.removeDiscountCode = removeDiscountCode;
|
|
14972
|
+
exports2.createPayment = createPayment;
|
|
14973
|
+
exports2.getPayment = getPayment;
|
|
14974
|
+
exports2.sendEmail = sendEmail;
|
|
14975
|
+
exports2.confirmPaypalPayment = confirmPaypalPayment;
|
|
14976
|
+
exports2.updateWallet = updateWallet;
|
|
14977
|
+
exports2.verifyPhoneNumber = verifyPhoneNumber;
|
|
14978
|
+
exports2.verifySmsCode = verifySmsCode;
|
|
14979
|
+
exports2.unlockSeats = unlockSeats;
|
|
14980
|
+
exports2.generateOTP = generateOTP;
|
|
14981
|
+
exports2.validateOTP = validateOTP;
|
|
14982
|
+
exports2.membershipDiscountPayment = membershipDiscountPayment;
|
|
14983
|
+
exports2.membershipDiscountPaymentDelete = membershipDiscountPaymentDelete;
|
|
14984
|
+
exports2.downloadTickets = downloadTickets;
|
|
14985
|
+
exports2.downloadPurchasesHistory = downloadPurchasesHistory;
|
|
14986
|
+
exports2.increaseExpiration = increaseExpiration;
|
|
14987
|
+
var _apiRequest = __webpack_require__(0);
|
|
14988
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
14989
|
+
var _payment = __webpack_require__(15);
|
|
14990
|
+
var _tickets = __webpack_require__(16);
|
|
14991
|
+
function _interopRequireWildcard(obj) {
|
|
14992
|
+
if (obj && obj.__esModule) {
|
|
14993
|
+
return obj;
|
|
14994
|
+
} else {
|
|
14995
|
+
var newObj = {};
|
|
14996
|
+
if (obj != null) {
|
|
14997
|
+
for (var key in obj) {
|
|
14998
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
14999
|
+
}
|
|
15000
|
+
}
|
|
15001
|
+
newObj.default = obj;
|
|
15002
|
+
return newObj;
|
|
15003
|
+
}
|
|
15004
|
+
}
|
|
15005
|
+
var PURCHASE = "purchases";
|
|
15006
|
+
var WALLET = "wallet_movements";
|
|
15007
|
+
var WALLET_CANCEL = "cancel";
|
|
15008
|
+
var PASSENGER_REQUESTS = "passenger_requests";
|
|
15009
|
+
var PASSENGER_REQUESTS_UPDATE = PASSENGER_REQUESTS + "/update";
|
|
15010
|
+
var TICKET_REQUESTS = "ticket_requests";
|
|
15011
|
+
var TICKET_RESEND = "tickets/resend";
|
|
15012
|
+
var DISCOUNTS = "discounts";
|
|
15013
|
+
var CANCEL = "cancel";
|
|
15014
|
+
var PAYMENT_DISCOUNT = "payment_discounts";
|
|
15015
|
+
var PAYMENTS = "payments";
|
|
15016
|
+
var PURCHASES_HISTORY = "purchase_history/search";
|
|
15017
|
+
var EXTEND_EXPIRE_AT = "session-extension";
|
|
15018
|
+
function startPurchasePoll(token, polling) {
|
|
15019
|
+
var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePurchase = polling.onReceivePurchase;
|
|
15020
|
+
var endpoint = "purchases/" + token;
|
|
15021
|
+
var pollOptions = _extends({
|
|
15022
|
+
watch: "state",
|
|
15023
|
+
expect: ["completed"]
|
|
15024
|
+
}, polling.options || {});
|
|
15025
|
+
var poll = void 0;
|
|
15026
|
+
var startedPoll = void 0;
|
|
15027
|
+
if (init2) {
|
|
15028
|
+
poll = apiRequest.poll(endpoint, onReceivePurchase, pollOptions);
|
|
15029
|
+
startedPoll = poll.start();
|
|
15030
|
+
}
|
|
15031
|
+
return {
|
|
15032
|
+
polls: {
|
|
15033
|
+
payment: startedPoll,
|
|
15034
|
+
abort: function abort() {
|
|
15035
|
+
return poll.abort();
|
|
15036
|
+
}
|
|
15037
|
+
}
|
|
15038
|
+
};
|
|
15039
|
+
}
|
|
15040
|
+
function create(params) {
|
|
15041
|
+
return new Promise(function(resolve, reject) {
|
|
15042
|
+
apiRequest.post(PURCHASE, params).then(function(purchase) {
|
|
15043
|
+
return resolve(purchase);
|
|
15044
|
+
}).catch(function(_ref) {
|
|
15045
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
15046
|
+
return reject({ code, message });
|
|
15047
|
+
});
|
|
15048
|
+
});
|
|
15049
|
+
}
|
|
15050
|
+
function get(id, queryParams, polling) {
|
|
15051
|
+
if (polling) {
|
|
15052
|
+
return startPurchasePoll(id, polling);
|
|
15053
|
+
}
|
|
15054
|
+
return new Promise(function(resolve, reject) {
|
|
15055
|
+
apiRequest.get(PURCHASE + "/" + id, { queryParams }).then(function(purchase) {
|
|
15056
|
+
return resolve(purchase);
|
|
15057
|
+
}).catch(function(_ref2) {
|
|
15058
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
15059
|
+
return reject({ code, message });
|
|
15060
|
+
});
|
|
15061
|
+
});
|
|
15062
|
+
}
|
|
15063
|
+
function update(id, params) {
|
|
15064
|
+
return new Promise(function(resolve, reject) {
|
|
15065
|
+
apiRequest.put(PURCHASE + "/" + id, params).then(function(purchase) {
|
|
15066
|
+
return resolve(purchase);
|
|
15067
|
+
}).catch(function(_ref3) {
|
|
15068
|
+
var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
|
|
15069
|
+
return reject({ code, message });
|
|
15070
|
+
});
|
|
15071
|
+
});
|
|
15072
|
+
}
|
|
15073
|
+
function createPassengers(id, passengers) {
|
|
15074
|
+
return new Promise(function(resolve, reject) {
|
|
15075
|
+
apiRequest.post(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS, { passengers }).then(function(passengers2) {
|
|
15076
|
+
return resolve(passengers2);
|
|
15077
|
+
}).catch(function(_ref4) {
|
|
15078
|
+
var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
|
|
15079
|
+
return reject({ code, message });
|
|
15080
|
+
});
|
|
15081
|
+
});
|
|
15082
|
+
}
|
|
15083
|
+
function updatePassengers(id, passengers) {
|
|
15084
|
+
return new Promise(function(resolve, reject) {
|
|
15085
|
+
apiRequest.put(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS_UPDATE, { passengers }).then(function(passengers2) {
|
|
15086
|
+
return resolve(passengers2);
|
|
15087
|
+
}).catch(function(_ref5) {
|
|
15088
|
+
var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
|
|
15089
|
+
return reject({ code, message });
|
|
15090
|
+
});
|
|
15091
|
+
});
|
|
15092
|
+
}
|
|
15093
|
+
function deletePassenger(id, passengerId) {
|
|
15094
|
+
return new Promise(function(resolve, reject) {
|
|
15095
|
+
apiRequest.deleteMethod(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS + "/" + passengerId).then(function(response) {
|
|
15096
|
+
return resolve(response);
|
|
15097
|
+
}).catch(function(_ref6) {
|
|
15098
|
+
var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknown error" : _ref6$message;
|
|
15099
|
+
return reject({ code, message });
|
|
15100
|
+
});
|
|
15101
|
+
});
|
|
15102
|
+
}
|
|
15103
|
+
function createTickets(id, params) {
|
|
15104
|
+
var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
15105
|
+
return new Promise(function(resolve, reject) {
|
|
15106
|
+
apiRequest.post(PURCHASE + "/" + id + "/" + TICKET_REQUESTS, params).then(function(tickets) {
|
|
15107
|
+
return resolve((0, _tickets.startTicketsPoll)(id, tickets, polling));
|
|
15108
|
+
}).catch(function(_ref7) {
|
|
15109
|
+
var _ref7$code = _ref7.code, code = _ref7$code === void 0 ? -100 : _ref7$code, _ref7$message = _ref7.message, message = _ref7$message === void 0 ? "Unknown error" : _ref7$message;
|
|
15110
|
+
return reject({ code, message });
|
|
15111
|
+
});
|
|
15112
|
+
});
|
|
15113
|
+
}
|
|
15114
|
+
function applyDiscountCode(id, code) {
|
|
15115
|
+
return new Promise(function(resolve, reject) {
|
|
15116
|
+
apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS, { code }, { apiVersion: "v2" }).then(function() {
|
|
15117
|
+
return get(id);
|
|
15118
|
+
}).then(function(purchase) {
|
|
15119
|
+
return resolve(purchase);
|
|
15120
|
+
}).catch(function(_ref8) {
|
|
15121
|
+
var _ref8$code = _ref8.code, code2 = _ref8$code === void 0 ? -100 : _ref8$code, _ref8$message = _ref8.message, message = _ref8$message === void 0 ? "Unknown error" : _ref8$message;
|
|
15122
|
+
return reject({ code: code2, message });
|
|
15123
|
+
});
|
|
15124
|
+
});
|
|
15125
|
+
}
|
|
15126
|
+
function removeDiscountCode(id) {
|
|
15127
|
+
return new Promise(function(resolve, reject) {
|
|
15128
|
+
apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS + "/" + CANCEL, { apiVersion: "v2" }).then(function() {
|
|
15129
|
+
return get(id);
|
|
15130
|
+
}).then(function(purchase) {
|
|
15131
|
+
return resolve(purchase);
|
|
15132
|
+
}).catch(function(_ref9) {
|
|
15133
|
+
var _ref9$code = _ref9.code, code = _ref9$code === void 0 ? -100 : _ref9$code, _ref9$message = _ref9.message, message = _ref9$message === void 0 ? "Unknown error" : _ref9$message;
|
|
15134
|
+
return reject({ code, message });
|
|
15135
|
+
});
|
|
15136
|
+
});
|
|
15137
|
+
}
|
|
15138
|
+
function createPayment(id, params) {
|
|
15139
|
+
var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
15140
|
+
return new Promise(function(resolve, reject) {
|
|
15141
|
+
apiRequest.post(PURCHASE + "/" + id + "/" + PAYMENTS, params).then(function(payment) {
|
|
15142
|
+
return resolve((0, _payment.startPaymentPoll)(id, payment, polling));
|
|
15143
|
+
}).catch(function(_ref10) {
|
|
15144
|
+
var _ref10$code = _ref10.code, code = _ref10$code === void 0 ? -100 : _ref10$code, _ref10$message = _ref10.message, message = _ref10$message === void 0 ? "Unknown error" : _ref10$message;
|
|
15145
|
+
return reject({ code, message });
|
|
15146
|
+
});
|
|
15147
|
+
});
|
|
15148
|
+
}
|
|
15149
|
+
function getPayment(purchaseToken, paymentId, polling) {
|
|
15150
|
+
if (polling) {
|
|
15151
|
+
return (0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling);
|
|
15152
|
+
}
|
|
15153
|
+
return new Promise(function(resolve, reject) {
|
|
15154
|
+
apiRequest.get(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId).then(function(payment) {
|
|
15155
|
+
return resolve(payment);
|
|
15156
|
+
}).catch(function(_ref11) {
|
|
15157
|
+
var _ref11$code = _ref11.code, code = _ref11$code === void 0 ? -100 : _ref11$code, _ref11$message = _ref11.message, message = _ref11$message === void 0 ? "Unknown error" : _ref11$message;
|
|
15158
|
+
return reject({ code, message });
|
|
15159
|
+
});
|
|
15160
|
+
});
|
|
15161
|
+
}
|
|
15162
|
+
function sendEmail(token, email) {
|
|
15163
|
+
var queryParams = { email };
|
|
15164
|
+
return new Promise(function(resolve, reject) {
|
|
15165
|
+
apiRequest.get(PURCHASE + "/" + token + "/" + TICKET_RESEND, { queryParams }).then(function() {
|
|
15166
|
+
return resolve();
|
|
15167
|
+
}).catch(function(_ref12) {
|
|
15168
|
+
var _ref12$code = _ref12.code, code = _ref12$code === void 0 ? -100 : _ref12$code, _ref12$message = _ref12.message, message = _ref12$message === void 0 ? "Unknown error" : _ref12$message;
|
|
15169
|
+
reject({ code, message });
|
|
15170
|
+
});
|
|
15171
|
+
});
|
|
15172
|
+
}
|
|
15173
|
+
function confirmPaypalPayment(purchaseToken, paymentId) {
|
|
15174
|
+
var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
15175
|
+
return new Promise(function(resolve, reject) {
|
|
15176
|
+
apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/confirm.json").then(function(payload) {
|
|
15177
|
+
resolve((0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling));
|
|
15178
|
+
}).catch(function(_ref13) {
|
|
15179
|
+
var _ref13$code = _ref13.code, code = _ref13$code === void 0 ? -100 : _ref13$code, _ref13$message = _ref13.message, message = _ref13$message === void 0 ? "Unknown error" : _ref13$message;
|
|
15180
|
+
reject({ code, message });
|
|
15181
|
+
});
|
|
15182
|
+
});
|
|
15183
|
+
}
|
|
15184
|
+
function updateWallet(purchaseToken, using) {
|
|
15185
|
+
var params = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
15186
|
+
var baseUrl = PURCHASE + "/" + purchaseToken + "/" + WALLET;
|
|
15187
|
+
var url = using ? baseUrl : baseUrl + "/" + WALLET_CANCEL;
|
|
15188
|
+
return apiRequest.post(url, params).then(function() {
|
|
15189
|
+
return get(purchaseToken);
|
|
15190
|
+
});
|
|
15191
|
+
}
|
|
15192
|
+
function verifyPhoneNumber(purchaseToken, paymentId, params) {
|
|
15193
|
+
return apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/send_verification", params);
|
|
15194
|
+
}
|
|
15195
|
+
function verifySmsCode(purchaseToken, paymentId, code) {
|
|
15196
|
+
return apiRequest.post(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/verify_code", {
|
|
15197
|
+
code
|
|
15198
|
+
});
|
|
15199
|
+
}
|
|
15200
|
+
function unlockSeats(purchaseToken) {
|
|
15201
|
+
return new Promise(function(resolve, reject) {
|
|
15202
|
+
apiRequest.post(PURCHASE + "/" + purchaseToken + "/unlock_seats").then(function(response) {
|
|
15203
|
+
return resolve(response);
|
|
15204
|
+
}).catch(function(_ref14) {
|
|
15205
|
+
var _ref14$code = _ref14.code, code = _ref14$code === void 0 ? -100 : _ref14$code, _ref14$message = _ref14.message, message = _ref14$message === void 0 ? "Unknown error" : _ref14$message;
|
|
15206
|
+
return reject({ code, message });
|
|
15207
|
+
});
|
|
15208
|
+
});
|
|
15209
|
+
}
|
|
15210
|
+
function generateOTP(path, payload) {
|
|
15211
|
+
return new Promise(function(resolve, reject) {
|
|
15212
|
+
apiRequest.post(path + "/otp-generate", payload).then(function() {
|
|
15213
|
+
return resolve();
|
|
15214
|
+
}).catch(function(_ref15) {
|
|
15215
|
+
var _ref15$code = _ref15.code, code = _ref15$code === void 0 ? -100 : _ref15$code, _ref15$message = _ref15.message, message = _ref15$message === void 0 ? "Unknown error" : _ref15$message;
|
|
15216
|
+
return reject({ code, message });
|
|
15217
|
+
});
|
|
15218
|
+
});
|
|
15219
|
+
}
|
|
15220
|
+
function validateOTP(path, otp) {
|
|
15221
|
+
return new Promise(function(resolve, reject) {
|
|
15222
|
+
var payload = { otp };
|
|
15223
|
+
apiRequest.post(path + "/otp-validate", payload).then(function() {
|
|
15224
|
+
return resolve();
|
|
15225
|
+
}).catch(function(_ref16) {
|
|
15226
|
+
var _ref16$code = _ref16.code, code = _ref16$code === void 0 ? -100 : _ref16$code, _ref16$message = _ref16.message, message = _ref16$message === void 0 ? "Unknown error" : _ref16$message;
|
|
15227
|
+
return reject({ code, message });
|
|
15228
|
+
});
|
|
15229
|
+
});
|
|
15230
|
+
}
|
|
15231
|
+
function membershipDiscountPayment(token, payload) {
|
|
15232
|
+
return new Promise(function(resolve, reject) {
|
|
15233
|
+
apiRequest.post(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT, payload).then(function() {
|
|
15234
|
+
return resolve();
|
|
15235
|
+
}).catch(function(_ref17) {
|
|
15236
|
+
var _ref17$code = _ref17.code, code = _ref17$code === void 0 ? -100 : _ref17$code, _ref17$message = _ref17.message, message = _ref17$message === void 0 ? "Unknown error" : _ref17$message;
|
|
15237
|
+
return reject({ code, message });
|
|
15238
|
+
});
|
|
15239
|
+
});
|
|
15240
|
+
}
|
|
15241
|
+
function membershipDiscountPaymentDelete(token) {
|
|
15242
|
+
return new Promise(function(resolve, reject) {
|
|
15243
|
+
apiRequest.deleteMethod(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT).then(function() {
|
|
15244
|
+
return resolve();
|
|
15245
|
+
}).catch(function(_ref18) {
|
|
15246
|
+
var _ref18$code = _ref18.code, code = _ref18$code === void 0 ? -100 : _ref18$code, _ref18$message = _ref18.message, message = _ref18$message === void 0 ? "Unknown error" : _ref18$message;
|
|
15247
|
+
return reject({ code, message });
|
|
15248
|
+
});
|
|
15249
|
+
});
|
|
15250
|
+
}
|
|
15251
|
+
function downloadTickets(payload) {
|
|
15252
|
+
return new Promise(function(resolve, reject) {
|
|
15253
|
+
apiRequest.post("tickets/pdf", payload).then(function(ticketResponse) {
|
|
15254
|
+
return resolve(ticketResponse);
|
|
15255
|
+
}).catch(function(_ref19) {
|
|
15256
|
+
var _ref19$code = _ref19.code, code = _ref19$code === void 0 ? -100 : _ref19$code, _ref19$message = _ref19.message, message = _ref19$message === void 0 ? "Unknown error" : _ref19$message;
|
|
15257
|
+
return reject({ code, message });
|
|
15258
|
+
});
|
|
15259
|
+
});
|
|
15260
|
+
}
|
|
15261
|
+
function downloadPurchasesHistory(payload) {
|
|
15262
|
+
return new Promise(function(resolve, reject) {
|
|
15263
|
+
apiRequest.post(PURCHASES_HISTORY, payload).then(function(history) {
|
|
15264
|
+
return resolve(history);
|
|
15265
|
+
}).catch(function(_ref20) {
|
|
15266
|
+
var _ref20$code = _ref20.code, code = _ref20$code === void 0 ? -100 : _ref20$code, _ref20$message = _ref20.message, message = _ref20$message === void 0 ? "Unknown error" : _ref20$message;
|
|
15267
|
+
return reject({ code, message });
|
|
15268
|
+
});
|
|
15269
|
+
});
|
|
15270
|
+
}
|
|
15271
|
+
function increaseExpiration(token) {
|
|
15272
|
+
return new Promise(function(resolve, reject) {
|
|
15273
|
+
apiRequest.post(PURCHASE + "/" + token + "/" + EXTEND_EXPIRE_AT).then(function(response) {
|
|
15274
|
+
return resolve(response);
|
|
15275
|
+
}).catch(function(_ref21) {
|
|
15276
|
+
var _ref21$code = _ref21.code, code = _ref21$code === void 0 ? -100 : _ref21$code, _ref21$message = _ref21.message, message = _ref21$message === void 0 ? "Unknown error" : _ref21$message;
|
|
15277
|
+
return reject({ code, message });
|
|
15278
|
+
});
|
|
15279
|
+
});
|
|
15280
|
+
}
|
|
15281
|
+
exports2.startTicketsPoll = _tickets.startTicketsPoll;
|
|
15282
|
+
},
|
|
15283
|
+
/* 15 */
|
|
15284
|
+
/***/
|
|
15285
|
+
function(module2, exports2, __webpack_require__) {
|
|
15286
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15287
|
+
value: true
|
|
15288
|
+
});
|
|
15289
|
+
var _extends = Object.assign || function(target) {
|
|
15290
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15291
|
+
var source = arguments[i];
|
|
15292
|
+
for (var key in source) {
|
|
15293
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15294
|
+
target[key] = source[key];
|
|
15295
|
+
}
|
|
15296
|
+
}
|
|
15297
|
+
}
|
|
15298
|
+
return target;
|
|
15299
|
+
};
|
|
15300
|
+
exports2.startPaymentPoll = startPaymentPoll;
|
|
15301
|
+
var _apiRequest = __webpack_require__(0);
|
|
15302
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15303
|
+
function _interopRequireWildcard(obj) {
|
|
15304
|
+
if (obj && obj.__esModule) {
|
|
15305
|
+
return obj;
|
|
15306
|
+
} else {
|
|
15307
|
+
var newObj = {};
|
|
15308
|
+
if (obj != null) {
|
|
15309
|
+
for (var key in obj) {
|
|
15310
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15311
|
+
}
|
|
15312
|
+
}
|
|
15313
|
+
newObj.default = obj;
|
|
15314
|
+
return newObj;
|
|
15315
|
+
}
|
|
15316
|
+
}
|
|
15317
|
+
var paymentFailed = function paymentFailed2(_ref) {
|
|
15318
|
+
var payload = _ref.payload;
|
|
15319
|
+
return ["suspicious", "failed", "rejected"].includes(payload.status);
|
|
15320
|
+
};
|
|
15321
|
+
function checkPaymentPayload(onReceivePayment) {
|
|
15322
|
+
return function(pollResponse) {
|
|
15323
|
+
var _pollResponse$payload = pollResponse.payload, using3dsecure = _pollResponse$payload.using_3d_secure, needsVerification = _pollResponse$payload.needs_verification;
|
|
15324
|
+
if (onReceivePayment) {
|
|
15325
|
+
onReceivePayment(pollResponse);
|
|
15326
|
+
}
|
|
15327
|
+
return paymentFailed(pollResponse) || using3dsecure || needsVerification;
|
|
15328
|
+
};
|
|
15329
|
+
}
|
|
15330
|
+
function startPaymentPoll(token, payload, polling) {
|
|
15331
|
+
var id = payload.id;
|
|
15332
|
+
var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePayment = polling.onReceivePayment;
|
|
15333
|
+
var endpoint = "purchases/" + token + "/payments/" + id;
|
|
15334
|
+
var pollOptions = _extends({
|
|
15335
|
+
watch: "purchase_state",
|
|
15336
|
+
expect: ["completed", "pending"]
|
|
15337
|
+
}, polling.options || {});
|
|
15338
|
+
var poll = void 0;
|
|
15339
|
+
var startedPoll = void 0;
|
|
15340
|
+
if (init2) {
|
|
15341
|
+
poll = apiRequest.poll(endpoint, checkPaymentPayload(onReceivePayment), pollOptions);
|
|
15342
|
+
startedPoll = poll.start();
|
|
15343
|
+
}
|
|
15344
|
+
return {
|
|
15345
|
+
payload,
|
|
15346
|
+
polls: {
|
|
15347
|
+
payment: startedPoll,
|
|
15348
|
+
abort: function abort() {
|
|
15349
|
+
return poll.abort();
|
|
15350
|
+
}
|
|
15351
|
+
}
|
|
15352
|
+
};
|
|
15353
|
+
}
|
|
15354
|
+
},
|
|
15355
|
+
/* 16 */
|
|
15356
|
+
/***/
|
|
15357
|
+
function(module2, exports2, __webpack_require__) {
|
|
15358
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15359
|
+
value: true
|
|
15360
|
+
});
|
|
15361
|
+
var _extends = Object.assign || function(target) {
|
|
15362
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15363
|
+
var source = arguments[i];
|
|
15364
|
+
for (var key in source) {
|
|
15365
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15366
|
+
target[key] = source[key];
|
|
15367
|
+
}
|
|
15368
|
+
}
|
|
15369
|
+
}
|
|
15370
|
+
return target;
|
|
15371
|
+
};
|
|
15372
|
+
exports2.startTicketsPoll = startTicketsPoll;
|
|
15373
|
+
var _apiRequest = __webpack_require__(0);
|
|
15374
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15375
|
+
function _interopRequireWildcard(obj) {
|
|
15376
|
+
if (obj && obj.__esModule) {
|
|
15377
|
+
return obj;
|
|
15378
|
+
} else {
|
|
15379
|
+
var newObj = {};
|
|
15380
|
+
if (obj != null) {
|
|
15381
|
+
for (var key in obj) {
|
|
15382
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15383
|
+
}
|
|
15384
|
+
}
|
|
15385
|
+
newObj.default = obj;
|
|
15386
|
+
return newObj;
|
|
15387
|
+
}
|
|
15388
|
+
}
|
|
15389
|
+
function startTicketsPoll(token, payload, polling) {
|
|
15390
|
+
var id = payload.id;
|
|
15391
|
+
var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceiveTickets = polling.onReceiveTickets;
|
|
15392
|
+
var endpoint = "purchases/" + token + "/ticket_requests/" + id;
|
|
15393
|
+
var pollOptions = _extends({
|
|
15394
|
+
watch: "state",
|
|
15395
|
+
expect: "finished"
|
|
15396
|
+
}, polling.options || {});
|
|
15397
|
+
var poll = void 0;
|
|
15398
|
+
var startedPoll = void 0;
|
|
15399
|
+
if (init2) {
|
|
15400
|
+
poll = apiRequest.poll(endpoint, onReceiveTickets, pollOptions);
|
|
15401
|
+
startedPoll = poll.start();
|
|
15402
|
+
}
|
|
15403
|
+
return {
|
|
15404
|
+
payload,
|
|
15405
|
+
polls: {
|
|
15406
|
+
tickets: startedPoll,
|
|
15407
|
+
abort: function abort() {
|
|
15408
|
+
return poll.abort();
|
|
15409
|
+
}
|
|
15410
|
+
}
|
|
15411
|
+
};
|
|
15412
|
+
}
|
|
15413
|
+
},
|
|
15414
|
+
/* 17 */
|
|
15415
|
+
/***/
|
|
15416
|
+
function(module2, exports2, __webpack_require__) {
|
|
15417
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15418
|
+
value: true
|
|
15419
|
+
});
|
|
15420
|
+
var _seatFinder = __webpack_require__(18);
|
|
15421
|
+
Object.defineProperty(exports2, "findSeats", {
|
|
15422
|
+
enumerable: true,
|
|
15423
|
+
get: function get() {
|
|
15424
|
+
return _seatFinder.findSeats;
|
|
15425
|
+
}
|
|
15426
|
+
});
|
|
15427
|
+
},
|
|
15428
|
+
/* 18 */
|
|
15429
|
+
/***/
|
|
15430
|
+
function(module2, exports2, __webpack_require__) {
|
|
15431
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15432
|
+
value: true
|
|
15433
|
+
});
|
|
15434
|
+
var _slicedToArray = /* @__PURE__ */ function() {
|
|
15435
|
+
function sliceIterator(arr, i) {
|
|
15436
|
+
var _arr = [];
|
|
15437
|
+
var _n = true;
|
|
15438
|
+
var _d = false;
|
|
15439
|
+
var _e = void 0;
|
|
15440
|
+
try {
|
|
15441
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
15442
|
+
_arr.push(_s.value);
|
|
15443
|
+
if (i && _arr.length === i) break;
|
|
15444
|
+
}
|
|
15445
|
+
} catch (err) {
|
|
15446
|
+
_d = true;
|
|
15447
|
+
_e = err;
|
|
15448
|
+
} finally {
|
|
15449
|
+
try {
|
|
15450
|
+
if (!_n && _i["return"]) _i["return"]();
|
|
15451
|
+
} finally {
|
|
15452
|
+
if (_d) throw _e;
|
|
15453
|
+
}
|
|
15454
|
+
}
|
|
15455
|
+
return _arr;
|
|
15456
|
+
}
|
|
15457
|
+
return function(arr, i) {
|
|
15458
|
+
if (Array.isArray(arr)) {
|
|
15459
|
+
return arr;
|
|
15460
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
15461
|
+
return sliceIterator(arr, i);
|
|
15462
|
+
} else {
|
|
15463
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
15464
|
+
}
|
|
15465
|
+
};
|
|
15466
|
+
}();
|
|
15467
|
+
exports2.findSeats = findSeats;
|
|
15468
|
+
function hasAvailableSeats(rowSeats) {
|
|
15469
|
+
var count = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
15470
|
+
var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
15471
|
+
var availableSeats = rowSeats.filter(function(seat) {
|
|
15472
|
+
return !(seat.occupied || except.includes(seat.number));
|
|
15473
|
+
});
|
|
15474
|
+
return availableSeats.length >= count;
|
|
15475
|
+
}
|
|
15476
|
+
function findAvailableSeats(n, deck) {
|
|
15477
|
+
var selectedSeats = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
15478
|
+
var pending = arguments[3];
|
|
15479
|
+
var rowCount = deck.length;
|
|
15480
|
+
var selectedCount = selectedSeats.length;
|
|
15481
|
+
var newDeck = deck;
|
|
15482
|
+
var newSeats = void 0;
|
|
15483
|
+
if (typeof pending === "undefined") {
|
|
15484
|
+
pending = n - selectedCount;
|
|
15485
|
+
}
|
|
15486
|
+
if (!pending) {
|
|
15487
|
+
return selectedSeats;
|
|
15488
|
+
}
|
|
15489
|
+
for (var i = 0; i < rowCount; i++) {
|
|
15490
|
+
var rowSeats = deck[i].filter(function(busSpace) {
|
|
15491
|
+
return ["seat", "seat_tv"].includes(busSpace.category);
|
|
15492
|
+
});
|
|
15493
|
+
newSeats = findAvailableAdjecentSeats(pending, rowSeats, selectedSeats);
|
|
15494
|
+
if (newSeats.length === pending) {
|
|
15495
|
+
newDeck = deck.slice(i);
|
|
15496
|
+
newDeck = newDeck.concat(deck.slice(0, i));
|
|
15497
|
+
selectedSeats = selectedSeats.concat(newSeats);
|
|
15498
|
+
selectedCount = selectedSeats.length;
|
|
15499
|
+
break;
|
|
15500
|
+
}
|
|
15501
|
+
}
|
|
15502
|
+
if (!newSeats.length) {
|
|
15503
|
+
pending -= 1;
|
|
15504
|
+
} else {
|
|
15505
|
+
pending = n - selectedCount;
|
|
15506
|
+
}
|
|
15507
|
+
return findAvailableSeats(n, newDeck, selectedSeats, pending);
|
|
15508
|
+
}
|
|
15509
|
+
function findAvailableAdjecentSeats(n, rowSeats) {
|
|
15510
|
+
var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
15511
|
+
var adjecent = [];
|
|
15512
|
+
var hasEnoughSeats = false;
|
|
15513
|
+
if (!hasAvailableSeats(rowSeats, n, except)) {
|
|
15514
|
+
return adjecent;
|
|
15515
|
+
}
|
|
15516
|
+
for (var i = rowSeats.length - 1; i >= 0; i--) {
|
|
15517
|
+
var seat = rowSeats[i];
|
|
15518
|
+
if (seat.occupied) {
|
|
15519
|
+
adjecent = [];
|
|
15520
|
+
} else {
|
|
15521
|
+
adjecent.push(seat.number);
|
|
15522
|
+
}
|
|
15523
|
+
if (adjecent.length === n) {
|
|
15524
|
+
hasEnoughSeats = true;
|
|
15525
|
+
break;
|
|
15526
|
+
}
|
|
15527
|
+
}
|
|
15528
|
+
if (hasEnoughSeats) {
|
|
15529
|
+
return adjecent;
|
|
15530
|
+
} else {
|
|
15531
|
+
return [];
|
|
15532
|
+
}
|
|
15533
|
+
}
|
|
15534
|
+
function findSeats(n, layout) {
|
|
15535
|
+
var _layout = _slicedToArray(layout, 2), firstDeck = _layout[0], secondDeck = _layout[1];
|
|
15536
|
+
var firstDeckSeats = findAvailableSeats(n, firstDeck);
|
|
15537
|
+
var selectedSeats = [];
|
|
15538
|
+
if (firstDeckSeats.length < n && secondDeck) {
|
|
15539
|
+
var secondDeckSeats = findAvailableSeats(n, secondDeck);
|
|
15540
|
+
if (secondDeckSeats.length < n) {
|
|
15541
|
+
selectedSeats = firstDeckSeats.concat(secondDeckSeats).slice(0, n);
|
|
15542
|
+
} else {
|
|
15543
|
+
selectedSeats = secondDeckSeats;
|
|
15544
|
+
}
|
|
15545
|
+
} else {
|
|
15546
|
+
selectedSeats = firstDeckSeats;
|
|
15547
|
+
}
|
|
15548
|
+
return selectedSeats.length ? selectedSeats : null;
|
|
15549
|
+
}
|
|
15550
|
+
},
|
|
15551
|
+
/* 19 */
|
|
15552
|
+
/***/
|
|
15553
|
+
function(module2, exports2, __webpack_require__) {
|
|
15554
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15555
|
+
value: true
|
|
15556
|
+
});
|
|
15557
|
+
exports2.get = get;
|
|
15558
|
+
var _apiRequest = __webpack_require__(0);
|
|
15559
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15560
|
+
function _interopRequireWildcard(obj) {
|
|
15561
|
+
if (obj && obj.__esModule) {
|
|
15562
|
+
return obj;
|
|
15563
|
+
} else {
|
|
15564
|
+
var newObj = {};
|
|
15565
|
+
if (obj != null) {
|
|
15566
|
+
for (var key in obj) {
|
|
15567
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15568
|
+
}
|
|
15569
|
+
}
|
|
15570
|
+
newObj.default = obj;
|
|
15571
|
+
return newObj;
|
|
15572
|
+
}
|
|
15573
|
+
}
|
|
15574
|
+
function get(queryParams) {
|
|
15575
|
+
return new Promise(function(resolve, reject) {
|
|
15576
|
+
apiRequest.get("redirect", { apiVersion: "v2", queryParams }).then(function(response) {
|
|
15577
|
+
return resolve(response);
|
|
15578
|
+
}).catch(function(_ref) {
|
|
15579
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
15580
|
+
return reject({ code, message });
|
|
15581
|
+
});
|
|
15582
|
+
});
|
|
15583
|
+
}
|
|
15584
|
+
},
|
|
15585
|
+
/* 20 */
|
|
15586
|
+
/***/
|
|
15587
|
+
function(module2, exports2, __webpack_require__) {
|
|
15588
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15589
|
+
value: true
|
|
15590
|
+
});
|
|
15591
|
+
exports2.get = get;
|
|
15592
|
+
var _apiRequest = __webpack_require__(0);
|
|
15593
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15594
|
+
function _interopRequireWildcard(obj) {
|
|
15595
|
+
if (obj && obj.__esModule) {
|
|
15596
|
+
return obj;
|
|
15597
|
+
} else {
|
|
15598
|
+
var newObj = {};
|
|
15599
|
+
if (obj != null) {
|
|
15600
|
+
for (var key in obj) {
|
|
15601
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15602
|
+
}
|
|
15603
|
+
}
|
|
15604
|
+
newObj.default = obj;
|
|
15605
|
+
return newObj;
|
|
15606
|
+
}
|
|
15607
|
+
}
|
|
15608
|
+
function get(queryParams) {
|
|
15609
|
+
return new Promise(function(resolve, reject) {
|
|
15610
|
+
apiRequest.get("quotes", { queryParams }).then(function(quotes) {
|
|
15611
|
+
return resolve(quotes);
|
|
15612
|
+
}).catch(function(_ref) {
|
|
15613
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
15614
|
+
return reject({ code, message });
|
|
15615
|
+
});
|
|
15616
|
+
});
|
|
15617
|
+
}
|
|
15618
|
+
},
|
|
15619
|
+
/* 21 */
|
|
15620
|
+
/***/
|
|
15621
|
+
function(module2, exports2, __webpack_require__) {
|
|
15622
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15623
|
+
value: true
|
|
15624
|
+
});
|
|
15625
|
+
exports2.getUser = getUser;
|
|
15626
|
+
exports2.getCreditCards = getCreditCards;
|
|
15627
|
+
var _apiRequest = __webpack_require__(0);
|
|
15628
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15629
|
+
var _config = __webpack_require__(1);
|
|
15630
|
+
var _config2 = _interopRequireDefault(_config);
|
|
15631
|
+
function _interopRequireDefault(obj) {
|
|
15632
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
15633
|
+
}
|
|
15634
|
+
function _interopRequireWildcard(obj) {
|
|
15635
|
+
if (obj && obj.__esModule) {
|
|
15636
|
+
return obj;
|
|
15637
|
+
} else {
|
|
15638
|
+
var newObj = {};
|
|
15639
|
+
if (obj != null) {
|
|
15640
|
+
for (var key in obj) {
|
|
15641
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15642
|
+
}
|
|
15643
|
+
}
|
|
15644
|
+
newObj.default = obj;
|
|
15645
|
+
return newObj;
|
|
15646
|
+
}
|
|
15647
|
+
}
|
|
15648
|
+
var USERS = "users";
|
|
15649
|
+
var USERS_PROFILE = USERS + "/profile.json";
|
|
15650
|
+
var USERS_CREDIT_CARDS = USERS + "/list_cards.json";
|
|
15651
|
+
function getUser() {
|
|
15652
|
+
if (!_config2.default.userAuthToken) return null;
|
|
15653
|
+
return apiRequest.get(USERS_PROFILE);
|
|
15654
|
+
}
|
|
15655
|
+
function getCreditCards() {
|
|
15656
|
+
if (!_config2.default.userAuthToken) return null;
|
|
15657
|
+
return apiRequest.get(USERS_CREDIT_CARDS);
|
|
15658
|
+
}
|
|
15659
|
+
},
|
|
15660
|
+
/* 22 */
|
|
15661
|
+
/***/
|
|
15662
|
+
function(module2, exports2, __webpack_require__) {
|
|
15663
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15664
|
+
value: true
|
|
15665
|
+
});
|
|
15666
|
+
exports2.createPriceAlert = createPriceAlert;
|
|
15667
|
+
exports2.deletePriceAlert = deletePriceAlert;
|
|
15668
|
+
var _apiRequest = __webpack_require__(0);
|
|
15669
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15670
|
+
function _interopRequireWildcard(obj) {
|
|
15671
|
+
if (obj && obj.__esModule) {
|
|
15672
|
+
return obj;
|
|
15673
|
+
} else {
|
|
15674
|
+
var newObj = {};
|
|
15675
|
+
if (obj != null) {
|
|
15676
|
+
for (var key in obj) {
|
|
15677
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15678
|
+
}
|
|
15679
|
+
}
|
|
15680
|
+
newObj.default = obj;
|
|
15681
|
+
return newObj;
|
|
15682
|
+
}
|
|
15683
|
+
}
|
|
15684
|
+
var PRICE_ALERTS = "price_alerts";
|
|
15685
|
+
var CANCEL = "cancel.json";
|
|
15686
|
+
function createPriceAlert(alertData) {
|
|
15687
|
+
return apiRequest.post(PRICE_ALERTS + ".json", alertData);
|
|
15688
|
+
}
|
|
15689
|
+
function deletePriceAlert(id) {
|
|
15690
|
+
return apiRequest.get(PRICE_ALERTS + "/" + id + "/" + CANCEL);
|
|
15691
|
+
}
|
|
15692
|
+
},
|
|
15693
|
+
/* 23 */
|
|
15694
|
+
/***/
|
|
15695
|
+
function(module2, exports2, __webpack_require__) {
|
|
15696
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15697
|
+
value: true
|
|
15698
|
+
});
|
|
15699
|
+
var _extends = Object.assign || function(target) {
|
|
15700
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
15701
|
+
var source = arguments[i];
|
|
15702
|
+
for (var key in source) {
|
|
15703
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
15704
|
+
target[key] = source[key];
|
|
15705
|
+
}
|
|
15706
|
+
}
|
|
15707
|
+
}
|
|
15708
|
+
return target;
|
|
15709
|
+
};
|
|
15710
|
+
exports2.validate = validate;
|
|
15711
|
+
exports2.cancelTicket = cancelTicket;
|
|
15712
|
+
exports2.getCancelledTicketStatusPoll = getCancelledTicketStatusPoll;
|
|
15713
|
+
var _apiRequest = __webpack_require__(0);
|
|
15714
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15715
|
+
function _interopRequireWildcard(obj) {
|
|
15716
|
+
if (obj && obj.__esModule) {
|
|
15717
|
+
return obj;
|
|
15718
|
+
} else {
|
|
15719
|
+
var newObj = {};
|
|
15720
|
+
if (obj != null) {
|
|
15721
|
+
for (var key in obj) {
|
|
15722
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15723
|
+
}
|
|
15724
|
+
}
|
|
15725
|
+
newObj.default = obj;
|
|
15726
|
+
return newObj;
|
|
15727
|
+
}
|
|
15728
|
+
}
|
|
15729
|
+
var EXCHANGE = "exchanges";
|
|
15730
|
+
function validate(operationNumber, nit, origin2, destination, recaptchaToken, email, document2) {
|
|
15731
|
+
var payload = _extends({}, email && { email }, document2 && { document: document2 }, {
|
|
15732
|
+
operation_number: operationNumber
|
|
15733
|
+
}, nit && { nit }, origin2 && { origin: origin2 }, destination && { destination }, recaptchaToken && { recaptcha_token: recaptchaToken });
|
|
15734
|
+
return new Promise(function(resolve, reject) {
|
|
15735
|
+
apiRequest.post(EXCHANGE + "/validate", payload).then(function(validation) {
|
|
15736
|
+
return resolve(validation);
|
|
15737
|
+
}).catch(function(_ref) {
|
|
15738
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
15739
|
+
return reject({ code, message });
|
|
15740
|
+
});
|
|
15741
|
+
});
|
|
15742
|
+
}
|
|
15743
|
+
function cancelTicket(token, operationNumberArray) {
|
|
15744
|
+
var payload = {
|
|
15745
|
+
operation_number: operationNumberArray
|
|
15746
|
+
};
|
|
15747
|
+
return new Promise(function(resolve, reject) {
|
|
15748
|
+
apiRequest.post("purchases/" + token + "/cancellations", payload).then(function(response) {
|
|
15749
|
+
return resolve(response);
|
|
15750
|
+
}).catch(function(_ref2) {
|
|
15751
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
15752
|
+
return reject({ code, message });
|
|
15753
|
+
});
|
|
15754
|
+
});
|
|
15755
|
+
}
|
|
15756
|
+
function getCancelledTicketStatusPoll(token, idCancellation, polling) {
|
|
15757
|
+
var id = idCancellation;
|
|
15758
|
+
var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onGetCancelStatus = polling.onGetCancelStatus;
|
|
15759
|
+
var endpoint = "purchases/" + token + "/cancellations/" + id;
|
|
15760
|
+
var pollOptions = _extends({
|
|
15761
|
+
watch: "status",
|
|
15762
|
+
expect: "success"
|
|
15763
|
+
}, polling.options || {});
|
|
15764
|
+
var poll = void 0;
|
|
15765
|
+
var startedPoll = void 0;
|
|
15766
|
+
if (init2) {
|
|
15767
|
+
poll = apiRequest.poll(endpoint, onGetCancelStatus, pollOptions);
|
|
15768
|
+
startedPoll = poll.start();
|
|
15769
|
+
}
|
|
15770
|
+
return {
|
|
15771
|
+
payload: idCancellation,
|
|
15772
|
+
polls: {
|
|
15773
|
+
data: startedPoll,
|
|
15774
|
+
abort: function abort() {
|
|
15775
|
+
return poll.abort();
|
|
15776
|
+
}
|
|
15777
|
+
}
|
|
15778
|
+
};
|
|
15779
|
+
}
|
|
15780
|
+
},
|
|
15781
|
+
/* 24 */
|
|
15782
|
+
/***/
|
|
15783
|
+
function(module2, exports2, __webpack_require__) {
|
|
15784
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15785
|
+
value: true
|
|
15786
|
+
});
|
|
15787
|
+
exports2.paymentCards = paymentCards;
|
|
15788
|
+
exports2.deleteCard = deleteCard;
|
|
15789
|
+
var _apiRequest = __webpack_require__(0);
|
|
15790
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15791
|
+
function _interopRequireWildcard(obj) {
|
|
15792
|
+
if (obj && obj.__esModule) {
|
|
15793
|
+
return obj;
|
|
15794
|
+
} else {
|
|
15795
|
+
var newObj = {};
|
|
15796
|
+
if (obj != null) {
|
|
15797
|
+
for (var key in obj) {
|
|
15798
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15799
|
+
}
|
|
15800
|
+
}
|
|
15801
|
+
newObj.default = obj;
|
|
15802
|
+
return newObj;
|
|
15803
|
+
}
|
|
15804
|
+
}
|
|
15805
|
+
function paymentCards(params) {
|
|
15806
|
+
return new Promise(function(resolve, reject) {
|
|
15807
|
+
apiRequest.post("adyen/payment_cards", params).then(function(creditCards) {
|
|
15808
|
+
return resolve(creditCards);
|
|
15809
|
+
}).catch(function(_ref) {
|
|
15810
|
+
var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
|
|
15811
|
+
return reject({ code, message });
|
|
15812
|
+
});
|
|
15813
|
+
});
|
|
15814
|
+
}
|
|
15815
|
+
function deleteCard(params) {
|
|
15816
|
+
return new Promise(function(resolve, reject) {
|
|
15817
|
+
apiRequest.post("adyen/delete_payment_card", params).then(function(response) {
|
|
15818
|
+
return resolve(response);
|
|
15819
|
+
}).catch(function(_ref2) {
|
|
15820
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
15821
|
+
return reject({ code, message });
|
|
15822
|
+
});
|
|
15823
|
+
});
|
|
15824
|
+
}
|
|
15825
|
+
},
|
|
15826
|
+
/* 25 */
|
|
15827
|
+
/***/
|
|
15828
|
+
function(module2, exports2, __webpack_require__) {
|
|
15829
|
+
Object.defineProperty(exports2, "__esModule", {
|
|
15830
|
+
value: true
|
|
15831
|
+
});
|
|
15832
|
+
exports2.getRecommendedTrips = getRecommendedTrips;
|
|
15833
|
+
exports2.createTripPriceAlerts = createTripPriceAlerts;
|
|
15834
|
+
exports2.updateTripPriceAlerts = updateTripPriceAlerts;
|
|
15835
|
+
exports2.deleteTripPriceAlerts = deleteTripPriceAlerts;
|
|
15836
|
+
exports2.createAnonymousProfile = createAnonymousProfile2;
|
|
15837
|
+
var _apiRequest = __webpack_require__(0);
|
|
15838
|
+
var apiRequest = _interopRequireWildcard(_apiRequest);
|
|
15839
|
+
function _interopRequireWildcard(obj) {
|
|
15840
|
+
if (obj && obj.__esModule) {
|
|
15841
|
+
return obj;
|
|
15842
|
+
} else {
|
|
15843
|
+
var newObj = {};
|
|
15844
|
+
if (obj != null) {
|
|
15845
|
+
for (var key in obj) {
|
|
15846
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
|
|
15847
|
+
}
|
|
15848
|
+
}
|
|
15849
|
+
newObj.default = obj;
|
|
15850
|
+
return newObj;
|
|
15851
|
+
}
|
|
15852
|
+
}
|
|
15853
|
+
var TRIP_PRICE_ALERTS = "trip_price_alerts";
|
|
15854
|
+
var ANONYMOUS_PROFILE = "anonymous_profiles/identify";
|
|
15855
|
+
function getRecommendedTrips(_ref) {
|
|
15856
|
+
var searchId = _ref.searchId, userIdentifier = _ref.userIdentifier;
|
|
15857
|
+
return new Promise(function(resolve, reject) {
|
|
15858
|
+
apiRequest.get("trip_recommendations/" + searchId + "/" + userIdentifier, { apiType: "core" }).then(function(response) {
|
|
15859
|
+
return resolve(response);
|
|
15860
|
+
}).catch(function(_ref2) {
|
|
15861
|
+
var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
|
|
15862
|
+
return reject({ code, message });
|
|
15863
|
+
});
|
|
15864
|
+
});
|
|
15865
|
+
}
|
|
15866
|
+
function createTripPriceAlerts(payload) {
|
|
15867
|
+
return new Promise(function(resolve, reject) {
|
|
15868
|
+
apiRequest.post("" + TRIP_PRICE_ALERTS, payload).then(function(response) {
|
|
15869
|
+
return resolve(response);
|
|
15870
|
+
}).catch(function(_ref3) {
|
|
15871
|
+
var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknow error" : _ref3$message;
|
|
15872
|
+
return reject({ code, message });
|
|
15873
|
+
});
|
|
15874
|
+
});
|
|
15875
|
+
}
|
|
15876
|
+
function updateTripPriceAlerts(priceAlertId, payload) {
|
|
15877
|
+
return new Promise(function(resolve, reject) {
|
|
15878
|
+
apiRequest.put(TRIP_PRICE_ALERTS + "/" + priceAlertId, payload).then(function(response) {
|
|
15879
|
+
return resolve(response);
|
|
15880
|
+
}).catch(function(_ref4) {
|
|
15881
|
+
var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknow error" : _ref4$message;
|
|
15882
|
+
return reject({ code, message });
|
|
15883
|
+
});
|
|
15884
|
+
});
|
|
15885
|
+
}
|
|
15886
|
+
function deleteTripPriceAlerts(priceAlertId) {
|
|
15887
|
+
return new Promise(function(resolve, reject) {
|
|
15888
|
+
apiRequest.deleteMethod(TRIP_PRICE_ALERTS + "/" + priceAlertId).then(function() {
|
|
15889
|
+
return resolve({ code: 200, message: "Trip Price Alert deleted" });
|
|
15890
|
+
}).catch(function(_ref5) {
|
|
15891
|
+
var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknow error" : _ref5$message;
|
|
15892
|
+
return reject({ code, message });
|
|
15893
|
+
});
|
|
15894
|
+
});
|
|
15895
|
+
}
|
|
15896
|
+
function createAnonymousProfile2(payload) {
|
|
15897
|
+
return new Promise(function(resolve, reject) {
|
|
15898
|
+
apiRequest.post(ANONYMOUS_PROFILE, payload, { apiType: "core" }).then(function(response) {
|
|
15899
|
+
return resolve(response);
|
|
15900
|
+
}).catch(function(_ref6) {
|
|
15901
|
+
var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknow error" : _ref6$message;
|
|
15902
|
+
return reject({ code, message });
|
|
15903
|
+
});
|
|
15904
|
+
});
|
|
15905
|
+
}
|
|
15906
|
+
}
|
|
15907
|
+
/******/
|
|
15908
|
+
])
|
|
15909
|
+
);
|
|
15910
|
+
});
|
|
15911
|
+
})(jsApiClient);
|
|
15912
|
+
var jsApiClientExports = jsApiClient.exports;
|
|
15913
|
+
const CreateAnonymousProfileSchema = z.object({
|
|
15914
|
+
email: z.string().email().optional(),
|
|
15915
|
+
phone: z.string().optional()
|
|
15916
|
+
}).refine((data) => data.email || data.phone, {
|
|
15917
|
+
message: "At least one of 'email' or 'phone' must be provided"
|
|
15918
|
+
});
|
|
15919
|
+
function getAnonymousProfilePayload(values) {
|
|
15920
|
+
let identifier_key = "phone";
|
|
15921
|
+
let identifier_value = values.phone || "";
|
|
15922
|
+
const details = {};
|
|
15923
|
+
if (values.email) {
|
|
15924
|
+
identifier_key = "email";
|
|
15925
|
+
identifier_value = values.email;
|
|
15926
|
+
}
|
|
15927
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
15928
|
+
if (key !== "email" && key !== identifier_key && value !== void 0) {
|
|
15929
|
+
details[key] = value;
|
|
15930
|
+
}
|
|
15931
|
+
});
|
|
15932
|
+
return {
|
|
15933
|
+
identifier_key,
|
|
15934
|
+
identifier_value,
|
|
15935
|
+
details
|
|
15936
|
+
};
|
|
15937
|
+
}
|
|
15938
|
+
async function createAnonymousProfile(payload) {
|
|
15939
|
+
try {
|
|
15940
|
+
validatorService.validateProps(payload, CreateAnonymousProfileSchema);
|
|
15941
|
+
const identifiers = [];
|
|
15942
|
+
const userFingerprintId = fingerprintService.getCachedFingerprint();
|
|
15943
|
+
const distinctId = mixpanelService.getMixpanelDistinctId();
|
|
15944
|
+
if (userFingerprintId)
|
|
15945
|
+
identifiers.push({ key: "fingerprint_id", value: userFingerprintId });
|
|
15946
|
+
if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
|
|
15947
|
+
const dataPayload = getAnonymousProfilePayload(payload);
|
|
15948
|
+
await jsApiClientExports.core.createAnonymousProfile({ ...dataPayload, identifiers });
|
|
15949
|
+
} catch (error) {
|
|
15950
|
+
console.error("Could not create anonymous profile:", error);
|
|
15951
|
+
}
|
|
15952
|
+
}
|
|
15953
|
+
const KNOWN_PROPERTIES = ["firstName", "lastName", "email", "phone"];
|
|
15954
|
+
const FINGERPRINT_PROPERTY = "Known Fingerprints";
|
|
15955
|
+
function mapProperties(properties) {
|
|
15956
|
+
const parsedProperties = {
|
|
15957
|
+
$first_name: properties == null ? void 0 : properties.firstName,
|
|
15958
|
+
$last_name: properties == null ? void 0 : properties.lastName,
|
|
15959
|
+
$email: properties == null ? void 0 : properties.email,
|
|
15960
|
+
$phone: properties == null ? void 0 : properties.phone
|
|
15961
|
+
};
|
|
15962
|
+
const additionalProperties = Object.keys(properties).reduce(
|
|
15963
|
+
(acc, key) => {
|
|
15964
|
+
if (!KNOWN_PROPERTIES.includes(key)) {
|
|
15965
|
+
acc[key] = properties[key];
|
|
15966
|
+
}
|
|
15967
|
+
return acc;
|
|
15968
|
+
},
|
|
15969
|
+
{}
|
|
15970
|
+
);
|
|
15971
|
+
return { ...parsedProperties, ...additionalProperties };
|
|
15972
|
+
}
|
|
15973
|
+
async function identify(userId, properties = {}) {
|
|
15974
|
+
try {
|
|
15975
|
+
if (!mixpanelService.isReady()) {
|
|
15976
|
+
console.error("Mixpanel is not initialized.");
|
|
15977
|
+
throw new Error("Mixpanel is not initialized.");
|
|
15978
|
+
}
|
|
15979
|
+
validatorService.parseIdentifyProps(properties);
|
|
15980
|
+
if (!userId) {
|
|
15981
|
+
console.error("User ID is required for identification.");
|
|
15982
|
+
throw new Error("User ID is required for identification.");
|
|
15983
|
+
}
|
|
15984
|
+
const mappedProps = mapProperties(properties);
|
|
15985
|
+
mixpanelService.identify(userId, mappedProps);
|
|
15986
|
+
const fingerprint = await fingerprintService.getFingerprint();
|
|
15987
|
+
if (fingerprint) {
|
|
15988
|
+
mixpanelService.attachProperty(FINGERPRINT_PROPERTY, fingerprint);
|
|
15989
|
+
}
|
|
15990
|
+
} catch (error) {
|
|
15991
|
+
console.error("Error identifying user", error);
|
|
15992
|
+
} finally {
|
|
15993
|
+
createAnonymousProfile({
|
|
15994
|
+
email: properties.email,
|
|
15995
|
+
phone: properties.phone
|
|
15996
|
+
});
|
|
15997
|
+
}
|
|
15998
|
+
}
|
|
15999
|
+
const EVENT_NAME = "Track Test";
|
|
16000
|
+
function trackTest() {
|
|
16001
|
+
trackEvent(EVENT_NAME, {});
|
|
16002
|
+
}
|
|
16003
|
+
const origin = window.location.origin;
|
|
16004
|
+
const coreAPIConfig = {
|
|
16005
|
+
sandbox: {
|
|
16006
|
+
coreUrl: "https://datalake-api-dev.reservamossaas.com/api",
|
|
16007
|
+
coreVersion: "v1",
|
|
16008
|
+
headers: {
|
|
16009
|
+
Origin: origin
|
|
16010
|
+
}
|
|
16011
|
+
},
|
|
16012
|
+
prod: {
|
|
16013
|
+
coreUrl: "https://datalake-api-dev.reservamossaas.com/api",
|
|
16014
|
+
coreVersion: "v1",
|
|
16015
|
+
headers: {
|
|
16016
|
+
Origin: origin
|
|
16017
|
+
}
|
|
16018
|
+
}
|
|
16019
|
+
};
|
|
16020
|
+
const configService = {
|
|
16021
|
+
coreAPIConfig
|
|
16022
|
+
};
|
|
16023
|
+
function onLoaded() {
|
|
16024
|
+
window.dispatchEvent(new CustomEvent("Tracker Ready"));
|
|
16025
|
+
}
|
|
16026
|
+
async function init(config) {
|
|
16027
|
+
validatorService.parseInitProps(config);
|
|
16028
|
+
const {
|
|
16029
|
+
mixpanelToken,
|
|
16030
|
+
debug = false,
|
|
16031
|
+
identificationKey,
|
|
16032
|
+
isSandbox = false,
|
|
16033
|
+
mixpanelProxyUrl,
|
|
16034
|
+
identifyProxyUrl
|
|
16035
|
+
} = config;
|
|
16036
|
+
await mixpanelService.init(mixpanelToken, debug, mixpanelProxyUrl);
|
|
16037
|
+
try {
|
|
16038
|
+
await fingerprintService.initFingerprint(
|
|
16039
|
+
identificationKey,
|
|
16040
|
+
identifyProxyUrl
|
|
16041
|
+
);
|
|
16042
|
+
} catch (error) {
|
|
16043
|
+
console.error("Error initializing identification service:", error);
|
|
16044
|
+
}
|
|
16045
|
+
const environment = isSandbox ? "sandbox" : "prod";
|
|
16046
|
+
const apiConfig = configService.coreAPIConfig[environment];
|
|
16047
|
+
jsApiClientExports.setConfig(apiConfig);
|
|
16048
|
+
onLoaded();
|
|
16049
|
+
}
|
|
16050
|
+
const analytics = {
|
|
16051
|
+
init,
|
|
16052
|
+
identify,
|
|
16053
|
+
identifiers: {
|
|
16054
|
+
getFingerprintId: fingerprintService.getCachedFingerprint,
|
|
16055
|
+
getDistinctId: mixpanelService.getMixpanelDistinctId
|
|
16056
|
+
},
|
|
16057
|
+
profiles: {
|
|
16058
|
+
createAnonymousProfile
|
|
16059
|
+
},
|
|
13463
16060
|
track: {
|
|
13464
16061
|
test: trackTest,
|
|
13465
16062
|
search: trackSearch,
|
|
@@ -13469,10 +16066,12 @@ const analytics = {
|
|
|
13469
16066
|
viewResults: trackViewResults,
|
|
13470
16067
|
passengersCreated: trackPassengersCreated,
|
|
13471
16068
|
paymentAttempt: trackPaymentAttempt,
|
|
13472
|
-
purchaseAttempt:
|
|
13473
|
-
pickedDeparture: trackSearch$
|
|
16069
|
+
purchaseAttempt: trackPurchaseAttempt,
|
|
16070
|
+
pickedDeparture: trackSearch$1,
|
|
16071
|
+
customEvent: trackCustomEvent
|
|
13474
16072
|
}
|
|
13475
16073
|
};
|
|
13476
16074
|
export {
|
|
13477
16075
|
analytics as default
|
|
13478
16076
|
};
|
|
16077
|
+
//# sourceMappingURL=browser-analytics.esm.js.map
|