aboutsummaryrefslogtreecommitdiff
path: root/src/services/ReportingService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/ReportingService.ts')
-rw-r--r--src/services/ReportingService.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/services/ReportingService.ts b/src/services/ReportingService.ts
new file mode 100644
index 00000000..2650a703
--- /dev/null
+++ b/src/services/ReportingService.ts
@@ -0,0 +1,40 @@
+//Common moments api abstracted out here
+
+import {REPORT_ISSUE_ENDPOINT} from '../constants';
+import {Alert} from 'react-native';
+
+export const sendReport = async (
+ moment_id: string,
+ message: string,
+ token: string,
+ callback: Function,
+) => {
+ try {
+ let response = await fetch(REPORT_ISSUE_ENDPOINT, {
+ method: 'POST',
+ body: JSON.stringify({
+ resource_id: moment_id,
+ type: 'content',
+ reason: message,
+ }),
+ headers: {
+ Authorization: 'Token ' + token,
+ },
+ });
+
+ let statusCode = response.status;
+ if (statusCode === 200) {
+ Alert.alert('Marked as ' + message.split(' ')[2]);
+ } else {
+ Alert.alert('Something went wrong!', 'Please try again.');
+ }
+ callback(false);
+ } catch (error) {
+ Alert.alert('Something went wrong!', 'Please try again.');
+ console.log(
+ 'Something went wrong! 😭',
+ 'Unable able to retrieve data',
+ error,
+ );
+ }
+};