|
| 1 | +import axios from 'axios'; |
| 2 | +import { BACKEND_URL } from 'envConstants'; |
| 3 | + |
| 4 | +export interface organizationBody { |
| 5 | + name: string; |
| 6 | + description: string; |
| 7 | +} |
| 8 | + |
| 9 | +export const deleteOrg = async ( |
| 10 | + authorizationToken: string, |
| 11 | + orgName: string |
| 12 | +) => { |
| 13 | + const url = BACKEND_URL + '/api/protected/org/delete/' + orgName; |
| 14 | + const respnse = await axios.delete(url, { |
| 15 | + headers: { |
| 16 | + Accept: 'application/json', |
| 17 | + Authorization: `Bearer ${authorizationToken}`, |
| 18 | + }, |
| 19 | + }); |
| 20 | + return respnse; |
| 21 | +}; |
| 22 | + |
| 23 | +export const addOrg = async ( |
| 24 | + authorizationToken: string, |
| 25 | + org: organizationBody |
| 26 | +) => { |
| 27 | + const url = BACKEND_URL + '/api/protected/org/add'; |
| 28 | + const respnse = await axios.post(url, org, { |
| 29 | + headers: { |
| 30 | + Accept: 'application/json', |
| 31 | + Authorization: `Bearer ${authorizationToken}`, |
| 32 | + }, |
| 33 | + }); |
| 34 | + return respnse; |
| 35 | +}; |
| 36 | + |
| 37 | +export const updateOrg = async ( |
| 38 | + authorizationToken: string, |
| 39 | + orgName: string, |
| 40 | + org: organizationBody |
| 41 | +) => { |
| 42 | + const url = BACKEND_URL + '/api/protected/org/update/' + orgName; |
| 43 | + const response = await axios.put(url, org, { |
| 44 | + headers: { |
| 45 | + Accept: 'application/json', |
| 46 | + Authorization: `Bearer ${authorizationToken}`, |
| 47 | + }, |
| 48 | + }); |
| 49 | + |
| 50 | + return response; |
| 51 | +}; |
| 52 | + |
| 53 | +export const addOrgMembers = async ( |
| 54 | + authorizationToken: string, |
| 55 | + orgName: string, |
| 56 | + members: string[] |
| 57 | +) => { |
| 58 | + const url = BACKEND_URL + '/api/protected/org/addMembers/' + orgName; |
| 59 | + const respnse = await axios.post( |
| 60 | + url, |
| 61 | + { |
| 62 | + members: members, |
| 63 | + }, |
| 64 | + { |
| 65 | + headers: { |
| 66 | + Accept: 'application/json', |
| 67 | + Authorization: `Bearer ${authorizationToken}`, |
| 68 | + }, |
| 69 | + } |
| 70 | + ); |
| 71 | + |
| 72 | + return respnse; |
| 73 | +}; |
| 74 | + |
| 75 | +export const removeOrgMembers = async ( |
| 76 | + authorizationToken: string, |
| 77 | + orgName: string, |
| 78 | + members: string[] |
| 79 | +) => { |
| 80 | + const url = BACKEND_URL + '/api/protected/org/removeMembers/' + orgName; |
| 81 | + const response = axios.delete(url, { |
| 82 | + headers: { |
| 83 | + Accept: 'application/json', |
| 84 | + Authorization: `Bearer ${authorizationToken}`, |
| 85 | + }, |
| 86 | + data: { |
| 87 | + members: members, |
| 88 | + }, |
| 89 | + }); |
| 90 | + return response; |
| 91 | +}; |
| 92 | + |
| 93 | +export const changeOrgMembersStatus = async ( |
| 94 | + authorizationToken: string, |
| 95 | + orgName: string, |
| 96 | + orgMemberStatus: { [key: string]: string } |
| 97 | +) => { |
| 98 | + const url = BACKEND_URL + '/api/protected/org/removeMembers/'; |
| 99 | + const respnse = await axios.put( |
| 100 | + url, |
| 101 | + { |
| 102 | + orgMemberStatus: orgMemberStatus, |
| 103 | + }, |
| 104 | + { |
| 105 | + headers: { |
| 106 | + Accept: 'application/json', |
| 107 | + Authorization: `Bearer ${authorizationToken}`, |
| 108 | + }, |
| 109 | + } |
| 110 | + ); |
| 111 | + |
| 112 | + return respnse; |
| 113 | +}; |
| 114 | + |
| 115 | +export const setArcheiveStatus = async ( |
| 116 | + authorizationToken: string, |
| 117 | + orgName: string, |
| 118 | + archeiveStatus: { [key: string]: boolean } |
| 119 | +) => { |
| 120 | + const url = BACKEND_URL + '/api/protected/org/setArcheiveStatus/' + orgName; |
| 121 | + const respnse = await axios.put( |
| 122 | + url, |
| 123 | + { |
| 124 | + archeiveStatus: archeiveStatus, |
| 125 | + }, |
| 126 | + { |
| 127 | + headers: { |
| 128 | + Accept: 'application/json', |
| 129 | + Authorization: `Bearer ${authorizationToken}`, |
| 130 | + }, |
| 131 | + } |
| 132 | + ); |
| 133 | + return respnse; |
| 134 | +}; |
| 135 | + |
| 136 | +export const setBookmarkStatus = async ( |
| 137 | + authorizationToken: string, |
| 138 | + orgName: string, |
| 139 | + bookmarkStatus: { [key: string]: boolean } |
| 140 | +) => { |
| 141 | + const url = BACKEND_URL + '/api/protected/org/setBookmarkStatus/' + orgName; |
| 142 | + const respnse = await axios.put( |
| 143 | + url, |
| 144 | + { |
| 145 | + bookmarkStatus: bookmarkStatus, |
| 146 | + }, |
| 147 | + { |
| 148 | + headers: { |
| 149 | + Accept: 'application/json', |
| 150 | + Authorization: `Bearer ${authorizationToken}`, |
| 151 | + }, |
| 152 | + } |
| 153 | + ); |
| 154 | + |
| 155 | + return respnse; |
| 156 | +}; |
| 157 | + |
| 158 | +export const getOrgMembers = async ( |
| 159 | + authorizationToken: string, |
| 160 | + orgName: string |
| 161 | +) => { |
| 162 | + const url = BACKEND_URL + '/api/protected/org/getMembers/' + orgName; |
| 163 | + |
| 164 | + const respnse = await axios.get(url, { |
| 165 | + headers: { |
| 166 | + Accept: 'application/json', |
| 167 | + Authorization: `Bearer ${authorizationToken}`, |
| 168 | + }, |
| 169 | + }); |
| 170 | + return respnse; |
| 171 | +}; |
| 172 | + |
| 173 | +export const getOrgProjects = async ( |
| 174 | + authorizationToken: string, |
| 175 | + orgName: string |
| 176 | +) => { |
| 177 | + const url = BACKEND_URL + '/api/protected/org/getProjects/' + orgName; |
| 178 | + const respnse = await axios.get(url, { |
| 179 | + headers: { |
| 180 | + Accept: 'application/json', |
| 181 | + Authorization: `Bearer ${authorizationToken}`, |
| 182 | + }, |
| 183 | + }); |
| 184 | + return respnse; |
| 185 | +}; |
| 186 | + |
| 187 | +export const getOrg = async (authorizationToken: string, orgName: string) => { |
| 188 | + const url = BACKEND_URL + '/api/protected/org/getProjects/' + orgName; |
| 189 | + const respnse = await axios.get(url, { |
| 190 | + headers: { |
| 191 | + Accept: 'application/json', |
| 192 | + Authorization: `Bearer ${authorizationToken}`, |
| 193 | + }, |
| 194 | + }); |
| 195 | + return respnse; |
| 196 | +}; |
| 197 | + |
| 198 | +export const getAllOrgs = async (authorizationToken: string) => { |
| 199 | + const url = BACKEND_URL + '/api/protected/org/getAllOrg'; |
| 200 | + const respnse = await axios.get(url, { |
| 201 | + headers: { |
| 202 | + Accept: 'application/json', |
| 203 | + Authorization: `Bearer ${authorizationToken}`, |
| 204 | + }, |
| 205 | + }); |
| 206 | + return respnse; |
| 207 | +}; |
0 commit comments