UNPKG

1.67 kBJavaScriptView Raw
1import * as RED from './service';
2import { parameters } from './endPoints';
3import * as Globals from './globals';
4
5const endpoints = {
6 GetPermissions: 'api/user/get/permissions',
7 RequestUploadEndpoint: 'api/user/request/upload/endpoint',
8 CompleteUpload: 'api/user/complete/upload',
9 GetResources: 'api/user/get/resources',
10 DeleteResources: 'api/user/delete/resource',
11 EmitMessage: 'api/user/emit/message',
12 GetNotifications: 'api/user/get/notifications',
13 GetWebRTC: 'api/user/get/web/rtc',
14}
15
16var formatjson = '?format=json';
17var userservice = RED.createRedService(Globals.DEFAULT_URL);
18
19export default {
20 getWebRTC: async () => {
21 return userservice.get(endpoints.GetWebRTC);
22 },
23 getPermissions: async () => {
24 return userservice.get(parameters(endpoints.GetPermissions));
25 },
26 requestUploadEndpoint: async (ops) => {
27 var body = JSON.stringify(ops);
28 return userservice.post(endpoints.RequestUploadEndpoint, body);
29 },
30 completeUpload: async (ops) => {
31 var body = JSON.stringify(ops);
32 return userservice.post(endpoints.CompleteUpload, body);
33 },
34 getResources: async req => {
35 var body = JSON.stringify(req);
36
37 return userservice.post(endpoints.GetResources, body);
38 },
39 getNotifications: async (signature) => {
40 return userservice.get(parameters(endpoints.GetNotifications, signature));
41 },
42 deleteResource: async id => {
43 return userservice.delete(parameters(endpoints.DeleteResources, id));
44 },
45 emitMessage: async (to, body) => {
46 return userservice.post(parameters(endpoints.EmitMessage, to), body);
47 }
48}
\No newline at end of file