@memori.ai/memori-api-client
Version:
React library to integrate a Memori in your app or website
100 lines • 3.81 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const apiFetcher_1 = require("../apiFetcher");
function buildTextEnteredBody(params) {
const { text, dateUTC, place } = params;
const body = { text };
if (dateUTC != null && dateUTC !== '') {
body.dateUTC = dateUTC;
}
if (place != null && typeof place === 'object') {
const placeBody = {};
if (place.placeName != null)
placeBody.placeName = place.placeName;
if (place.latitude != null)
placeBody.latitude = place.latitude;
if (place.longitude != null)
placeBody.longitude = place.longitude;
if (place.uncertaintyKm != null)
placeBody.uncertaintyKm = place.uncertaintyKm;
if (Object.keys(placeBody).length > 0) {
body.place = placeBody;
}
}
return body;
}
exports.default = (apiUrl) => ({
postTextEnteredEvent: async ({ sessionId, text, dateUTC, place, }) => (0, apiFetcher_1.apiFetcher)(`/TextEnteredEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: buildTextEnteredBody({ text, dateUTC, place }),
}),
postEnterTextAsync: async ({ sessionId, text, dateUTC, place, }) => (0, apiFetcher_1.apiFetcher)(`/TextEnteredEventAsync/${sessionId}`, {
method: 'POST',
apiUrl,
body: buildTextEnteredBody({ text, dateUTC, place }),
}),
postTextEnteredEventExtended: async ({ sessionId, text, questionsAndAnswersHistory, }) => (0, apiFetcher_1.apiFetcher)(`/ExtendedTextEnteredEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: {
text,
questionsAndAnswersHistory,
},
}),
postExtendedEnterTextAsync: async ({ sessionId, text, questionsAndAnswersHistory, }) => (0, apiFetcher_1.apiFetcher)(`/ExtendedEnterTextAsync/${sessionId}`, {
method: 'POST',
apiUrl,
body: {
text,
questionsAndAnswersHistory,
},
}),
postPlaceChangedEvent: async ({ sessionId, placeName, latitude, longitude, uncertaintyKm, }) => (0, apiFetcher_1.apiFetcher)(`/PlaceChangedEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: {
placeName,
latitude,
longitude,
uncertaintyKm,
},
}),
postDateChangedEvent: async (sessionId, date) => (0, apiFetcher_1.apiFetcher)(`/DateChangedEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: { date },
}),
postTagChangedEvent: async (sessionId, tag) => (0, apiFetcher_1.apiFetcher)(`/TagChangedEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: { tag },
}),
postTimeoutEvent: async (sessionId) => (0, apiFetcher_1.apiFetcher)(`/TimeoutEvent/${sessionId}`, {
method: 'POST',
apiUrl,
}),
postMediumSelectedEvent: async (sessionId, medium) => (0, apiFetcher_1.apiFetcher)(`/MediumSelectedEvent/${sessionId}`, {
method: 'POST',
apiUrl,
body: { medium },
}),
postMediumDeselectedEvent: async (sessionID, mediumID) => (0, apiFetcher_1.apiFetcher)(`/MediumDeselectedEvent/${sessionID}`, {
method: 'POST',
apiUrl,
body: { mediumID },
}),
postDateSelectedEvent: async (sessionId) => (0, apiFetcher_1.apiFetcher)(`/DateSelectedEvent/${sessionId}`, {
method: 'GET',
apiUrl,
}),
postPlaceSelectedEvent: async (sessionId) => (0, apiFetcher_1.apiFetcher)(`/PlaceSelectedEvent/${sessionId}`, {
method: 'GET',
apiUrl,
}),
postTagSelectedEvent: async (sessionId) => (0, apiFetcher_1.apiFetcher)(`/TagSelectedEvent/${sessionId}`, {
method: 'GET',
apiUrl,
}),
});
//# sourceMappingURL=dialog.js.map