forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorg_environment_variable.service.js
More file actions
47 lines (39 loc) · 1.52 KB
/
org_environment_variable.service.js
File metadata and controls
47 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import config from 'config';
import { authHeader, handleResponse } from '@/_helpers';
export const orgEnvironmentVariableService = {
getVariables,
getVariablesFromPublicApp,
create,
update,
deleteVariable,
};
function getVariables() {
const requestOptions = { method: 'GET', headers: authHeader(), credentials: 'include' };
return fetch(`${config.apiUrl}/organization-variables`, requestOptions).then(handleResponse);
}
function getVariablesFromPublicApp(slug) {
const requestOptions = { method: 'GET' };
return fetch(`${config.apiUrl}/organization-variables/${slug}`, requestOptions).then(handleResponse);
}
function create(variable_name, value, variable_type, encrypted) {
const body = {
variable_name,
value,
variable_type,
encrypted,
};
const requestOptions = { method: 'POST', headers: authHeader(), credentials: 'include', body: JSON.stringify(body) };
return fetch(`${config.apiUrl}/organization-variables`, requestOptions).then(handleResponse);
}
function update(id, variable_name, value) {
const body = {
variable_name,
value,
};
const requestOptions = { method: 'PATCH', headers: authHeader(), credentials: 'include', body: JSON.stringify(body) };
return fetch(`${config.apiUrl}/organization-variables/${id}`, requestOptions).then(handleResponse);
}
function deleteVariable(id) {
const requestOptions = { method: 'DELETE', headers: authHeader(), credentials: 'include' };
return fetch(`${config.apiUrl}/organization-variables/${id}`, requestOptions).then(handleResponse);
}