Please keep in mind that prices are present but incorrect. Also note that in cases of very short view height, tall modals appear underneath the header hamburger menu. This is endemic to all such situations, and not specific to these cards.
67 lines
No EOL
1.9 KiB
JavaScript
67 lines
No EOL
1.9 KiB
JavaScript
import axios from "axios";
|
|
import analyticsMixIn from "@/mixins/analytics-mixin.js";
|
|
import { useMainStore } from "@/store";
|
|
|
|
import { applicationConfig } from "@/constants/application-config.js";
|
|
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
|
|
import { headerKeys } from "@/constants/header-keys";
|
|
|
|
export default {
|
|
callHttpClient({ method, endpoint, payload, logApiCall = true}) {
|
|
return new Promise((resolve, reject) => {
|
|
const store = useMainStore();
|
|
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
|
|
const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "SelfService" });
|
|
const headers = {
|
|
[headerKeys.EXPERIMENT]: JSON.stringify(store.experimentSettings),
|
|
};
|
|
|
|
axios({
|
|
method: method,
|
|
url: cfDistroUrl + endpoint,
|
|
data: payloadAndAnalyticsData,
|
|
crossDomain: true,
|
|
responseType: 'json',
|
|
headers: headers,
|
|
})
|
|
.then((response) => {
|
|
if (logApiCall) {
|
|
analyticsMixIn.methods.pushEventToGA(
|
|
GaCategories.API_RESPONSE,
|
|
GaActions.RESULT,
|
|
`${GaLabels.SUCCESS}_${endpoint}`,
|
|
true
|
|
);
|
|
}
|
|
return resolve(response);
|
|
},
|
|
error => {
|
|
console.error(error);
|
|
return reject(error.response);
|
|
}
|
|
);
|
|
});
|
|
},
|
|
|
|
//used for mocked services
|
|
async mockCallHttpClient(method, endpoint) {
|
|
return new Promise((resolve, reject) => {
|
|
axios({
|
|
method: method,
|
|
url: endpoint,
|
|
crossDomain: true,
|
|
responseType: {}
|
|
})
|
|
.then((response) => {
|
|
return resolve(response);
|
|
},
|
|
error => {
|
|
console.error(error);
|
|
return reject(error.response);
|
|
}
|
|
);
|
|
});
|
|
|
|
|
|
}
|
|
}; |