UNPKG

softchatjs-react-native

Version:

React native UI SDK for softchatjs-core. Create a free account at: https://www.softchatjs.com

71 lines (70 loc) 2.58 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/api/index.tsx var api_exports = {}; __export(api_exports, { CREATE_SESSION: () => CREATE_SESSION, GET_CONVERSATIONS: () => GET_CONVERSATIONS, GET_EMOJIS: () => GET_EMOJIS, GET_MESSAGES: () => GET_MESSAGES, UPLOAD_MEDIA: () => UPLOAD_MEDIA }); module.exports = __toCommonJS(api_exports); var API = "https://i6h8uzuwvf.execute-api.eu-west-2.amazonaws.com/staging"; var chatApi = async (endpoint, body, method, token) => { const res = await fetch(endpoint, { headers: { "Cache-Control": "no-cache", "accessToken": token ? token : "" }, mode: "cors", cache: "no-cache", body: method === "POST" ? JSON.stringify(body) : null, method }); const response = await res.json(); if (typeof response === "object" && response && "success" in response) { return response; } return { ...response, success: false }; }; async function CREATE_SESSION({ userId }) { console.log("got"); return await chatApi(`${API}${"/auth/session" /* CREATE_SESSION */}`, { userId }, "POST"); } async function GET_CONVERSATIONS(token, userId) { return await chatApi(`${API}${"/conversations" /* CONVERSATIONS */}/${userId}`, {}, "GET", token); } async function GET_MESSAGES(token, conversationId) { return await chatApi(`${API}${"/messages" /* MESSAGES */}/${conversationId}`, {}, "GET", token); } async function GET_EMOJIS(token) { return await chatApi(`${API}${"/gifs/trending" /* EMOJIS */}`, {}, "GET", token); } async function UPLOAD_MEDIA(token, data) { return await chatApi(`${API}${"/upload" /* UPLOAD */}`, data, "POST", token); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { CREATE_SESSION, GET_CONVERSATIONS, GET_EMOJIS, GET_MESSAGES, UPLOAD_MEDIA }); //# sourceMappingURL=index.js.map