UNPKG

@msg91comm/sendotp-react-native

Version:
61 lines (55 loc) 1.2 kB
import { apiUrls } from './api.url'; /** * @param url * @param body * @returns {Promise<any>} * @private */ function postAPI(url, body) { return fetch(url, { method: "POST", body: JSON.stringify(body), headers:{ "Content-Type" : 'application/json' } }).then(response => response.json()); } function getAPI(url) { return fetch(url, { method: "GET", headers:{ "Content-Type" : 'application/json' } }).then(response => response.json()); } export class ApiService { /** * @param body * @returns {Promise<any>} */ static async sendOTP(body) { return postAPI(apiUrls.sendOTP, body); } /** * @param body * @returns {Promise<any>} */ static async verifyOTP(body) { return postAPI(apiUrls.verifyOTP, body); } /** * @param body * @returns {Promise<any>} */ static async retryOTP(body) { return postAPI(apiUrls.retryOTP, body); } /** * @param widgetId * @param tokenAuth * @returns {Promise<any>} */ static async getWidgetProcess(widgetId: string,tokenAuth: string) { return getAPI(apiUrls.getWidgetProcess.replace(':widgetId',widgetId).replace(':tokenAuth',tokenAuth)); } }