Add endpoints for favoriting
This commit is contained in:
parent
5f1bee26cf
commit
7915ec2385
1 changed files with 26 additions and 0 deletions
|
|
@ -71,6 +71,31 @@ class Api {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
savedTeams(params: {}) {
|
||||||
|
const resourceUrl = `${this.url}/parties/favorites`
|
||||||
|
return axios.get(resourceUrl, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
saveTeam({ id, params }: { id: string, params?: {} }) {
|
||||||
|
const body = { favorite: { party_id: id } }
|
||||||
|
const resourceUrl = `${this.url}/favorites`
|
||||||
|
return axios.post(resourceUrl, body, { headers: params })
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status == 201)
|
||||||
|
appState.party.favorited = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
unsaveTeam({ id, params }: { id: string, params?: {} }) {
|
||||||
|
const body = { favorite: { party_id: id } }
|
||||||
|
const resourceUrl = `${this.url}/favorites`
|
||||||
|
return axios.delete(resourceUrl, { data: body, headers: params })
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status == 200)
|
||||||
|
appState.party.favorited = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
updateUncap(resource: 'character'|'weapon'|'summon', id: string, value: number) {
|
updateUncap(resource: 'character'|'weapon'|'summon', id: string, value: number) {
|
||||||
const pluralized = resource + 's'
|
const pluralized = resource + 's'
|
||||||
const resourceUrl = `${this.url}/${pluralized}/update_uncap`
|
const resourceUrl = `${this.url}/${pluralized}/update_uncap`
|
||||||
|
|
@ -90,5 +115,6 @@ api.createEntity( { name: 'characters' })
|
||||||
api.createEntity( { name: 'weapons' })
|
api.createEntity( { name: 'weapons' })
|
||||||
api.createEntity( { name: 'summons' })
|
api.createEntity( { name: 'summons' })
|
||||||
api.createEntity( { name: 'raids' })
|
api.createEntity( { name: 'raids' })
|
||||||
|
api.createEntity( { name: 'favorites' })
|
||||||
|
|
||||||
export default api
|
export default api
|
||||||
Loading…
Reference in a new issue