Fix API calls.
This commit is contained in:
parent
55925383b7
commit
caf4c7fddf
|
@ -367,19 +367,27 @@ const fetchMutes = ({credentials}) => {
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const joinGroup = ({id, credentials}) => {
|
const fetchGroup = ({ groupName }) => {
|
||||||
const url = `${GROUP_JOINING_URL}/id.json`
|
const url = `${GROUP_URL}/${groupName}.json`
|
||||||
|
|
||||||
|
return fetch(url).then((data) => data.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
const joinGroup = ({groupName, credentials}) => {
|
||||||
|
const url = `${GROUP_JOINING_URL}/${groupName}.json`
|
||||||
|
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
headers: authHeaders(credentials)
|
headers: authHeaders(credentials),
|
||||||
|
method: 'POST'
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const leaveGroup = ({id, credentials}) => {
|
const leaveGroup = ({groupName, credentials}) => {
|
||||||
const url = `${GROUP_LEAVING_URL}/id.json`
|
const url = `${GROUP_LEAVING_URL}/${groupName}.json`
|
||||||
|
|
||||||
return fetch(url, {
|
return fetch(url, {
|
||||||
headers: authHeaders(credentials)
|
headers: authHeaders(credentials),
|
||||||
|
method: 'POST'
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,8 +414,14 @@ const fetchMemberships = ({id, credentials}) => {
|
||||||
}).then((data) => data.json())
|
}).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchMembers = (id) => {
|
const fetchMembers = ({ groupName }) => {
|
||||||
const url = `${GROUP_MEMBERS_URL}/${id}.json`
|
const url = `${GROUP_MEMBERS_URL}/${groupName}.json`
|
||||||
|
|
||||||
|
return fetch(url).then((data) => data.json())
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchIsMember = ({id, groupName}) => {
|
||||||
|
const url = `${GROUP_IS_MEMBER_URL}?user_id=${id}&group_name=${groupName}`
|
||||||
|
|
||||||
return fetch(url).then((data) => data.json())
|
return fetch(url).then((data) => data.json())
|
||||||
}
|
}
|
||||||
|
@ -439,11 +453,13 @@ const apiService = {
|
||||||
updateProfile,
|
updateProfile,
|
||||||
updateBanner,
|
updateBanner,
|
||||||
externalProfile,
|
externalProfile,
|
||||||
|
fetchGroup,
|
||||||
joinGroup,
|
joinGroup,
|
||||||
leaveGroup,
|
leaveGroup,
|
||||||
createGroup,
|
createGroup,
|
||||||
fetchMemberships,
|
fetchMemberships,
|
||||||
fetchMembers
|
fetchMembers,
|
||||||
|
fetchIsMember
|
||||||
}
|
}
|
||||||
|
|
||||||
export default apiService
|
export default apiService
|
||||||
|
|
|
@ -50,20 +50,28 @@ const backendInteractorService = (credentials) => {
|
||||||
return apiService.setUserMute({id, muted, credentials})
|
return apiService.setUserMute({id, muted, credentials})
|
||||||
}
|
}
|
||||||
|
|
||||||
const joinGroup = (id) => {
|
const fetchGroup = ({ groupName }) => {
|
||||||
return apiService.joinGroup({id, credentials})
|
return apiService.fetchGroup({ groupName })
|
||||||
}
|
}
|
||||||
|
|
||||||
const leaveGroup = (id) => {
|
const joinGroup = ({ groupName }) => {
|
||||||
return apiService.leaveGroup({id, credentials})
|
return apiService.joinGroup({groupName, credentials})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchMemberships = (id) => {
|
const leaveGroup = ({ groupName }) => {
|
||||||
|
return apiService.leaveGroup({groupName, credentials})
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchMemberships = ({ id }) => {
|
||||||
return apiService.fetchMemberships({id, credentials})
|
return apiService.fetchMemberships({id, credentials})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchMembers = (id) => {
|
const fetchMembers = ({ groupName }) => {
|
||||||
return apiService.fetchMemberships({id, credentials})
|
return apiService.fetchMembers({ groupName })
|
||||||
|
}
|
||||||
|
|
||||||
|
const fetchIsMember = ({id, groupName}) => {
|
||||||
|
return apiService.fetchIsMember({id, groupName})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createGroup = (params) => apiService.createGroup({params, credentials})
|
const createGroup = (params) => apiService.createGroup({params, credentials})
|
||||||
|
@ -99,11 +107,13 @@ const backendInteractorService = (credentials) => {
|
||||||
updateBanner,
|
updateBanner,
|
||||||
updateProfile,
|
updateProfile,
|
||||||
externalProfile,
|
externalProfile,
|
||||||
|
fetchGroup,
|
||||||
joinGroup,
|
joinGroup,
|
||||||
leaveGroup,
|
leaveGroup,
|
||||||
createGroup,
|
createGroup,
|
||||||
fetchMemberships,
|
fetchMemberships,
|
||||||
fetchMembers
|
fetchMembers,
|
||||||
|
fetchIsMember
|
||||||
}
|
}
|
||||||
|
|
||||||
return backendInteractorServiceInstance
|
return backendInteractorServiceInstance
|
||||||
|
|
Loading…
Reference in New Issue