UNPKG

mopinion-react-native-sdk

Version:

Collect in-app feedback with Mopinion for React Native. Built fully in React Native for optimal integration with your React Native app.

1 lines 1.45 kB
Object.defineProperty(exports,"__esModule",{value:true});exports.getConfig=getConfig;exports.getDeployment=getDeployment;exports.postFeedback=postFeedback;function getDeployment(deploymentID){var url=`https://deploy.mopinion.com/config/mobile/${deploymentID}`;return fetch(url,{method:'GET',headers:{Accept:'application/json','Content-Type':'application/json'}}).then(function(response){return response.json();}).then(function(response){var _response$deployment;if(response.code!==200){return[];}return(_response$deployment=response.deployment)!=null?_response$deployment:[];}).catch(function(e){return console.log(e);});}function getConfig(formKey,domain){var url=`https://cacheorcheck.mopinion.com/survey/public/json-stream?key=${formKey}&domain=${domain}`;return fetch(url,{method:'GET',headers:{Accept:'application/json','Content-Type':'application/json'}}).then(function(response){return response.json();}).then(function(response){if(response.code===404){return{};}return response;}).catch(function(e){return console.log(e);});}function postFeedback(feedback){var url='https://survey.mopinion.com/api/1/data';var data={method:'POST',body:JSON.stringify(feedback),headers:{token:feedback.token,domain:feedback.domain,'Content-Type':'application/json'}};return fetch(url,data).then(function(response){return response.json();}).then(function(response){return(response==null?void 0:response.code)===200;}).catch(function(e){return console.log(e);});}