2021-10-08 10:23:06 +05:30
|
|
|
// import fetch from "node-fetch";
|
|
|
|
|
|
2021-10-15 09:41:43 +05:30
|
|
|
export async function getStats(username: string, credentials: string){
|
|
|
|
|
const url = "https://habitica.com/export/userdata.json"
|
2021-10-08 10:23:06 +05:30
|
|
|
const response = fetch(url, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"x-client": username.concat("-testAPI"),
|
|
|
|
|
"x-api-user": username,
|
|
|
|
|
"x-api-key": credentials,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
return (response)
|
|
|
|
|
}
|
2021-10-12 19:48:33 -07:00
|
|
|
|
2021-10-15 09:41:43 +05:30
|
|
|
export async function scoreTask(username: string, credentials: string, taskID: string, direction: string) {
|
|
|
|
|
const url = "https://habitica.com/api/v3/tasks/".concat(taskID).concat("/score/").concat(direction)
|
2021-10-12 19:48:33 -07:00
|
|
|
const response = fetch(url, {
|
2021-10-15 09:41:43 +05:30
|
|
|
method: 'POST',
|
2021-10-12 19:48:33 -07:00
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"x-client": username.concat("-testAPI"),
|
|
|
|
|
"x-api-user": username,
|
|
|
|
|
"x-api-key": credentials,
|
2021-10-15 09:41:43 +05:30
|
|
|
}
|
2021-10-12 19:48:33 -07:00
|
|
|
})
|
2021-10-15 09:41:43 +05:30
|
|
|
return(response)
|
2021-10-12 19:48:33 -07:00
|
|
|
}
|