42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
|
window.addEventListener("load", async function () {
|
||
|
if (!docCookies.hasItem("token") && window.location.pathname !== "/auth/") {
|
||
|
window.location = "/auth/";
|
||
|
}
|
||
|
});
|
||
|
|
||
|
const api_provider = 'api.example.com';
|
||
|
const telegram_bot = 'example_bot';
|
||
|
|
||
|
async function getId(token) {
|
||
|
return await fetch(`https://${api_provider}/get_id?token=${token}`)
|
||
|
.then(response => response.json());
|
||
|
}
|
||
|
|
||
|
async function getBalance(token) {
|
||
|
return await fetch(`https://${api_provider}/get_balance?token=${token}`)
|
||
|
.then(response => response.json())
|
||
|
.then(value => value['balance']);
|
||
|
}
|
||
|
|
||
|
async function createCheque(token, amount, act) {
|
||
|
return await fetch(`https://${api_provider}/create_cheque?token=${token}&amount=${amount}&act=${act}`)
|
||
|
.then(response => response.json());
|
||
|
}
|
||
|
|
||
|
async function deleteCheque(token, id) {
|
||
|
return await fetch(`https://${api_provider}/delete_cheque?token=${token}&id=${id}`)
|
||
|
.then(response => response.json())
|
||
|
.then(value => value['balance']);
|
||
|
}
|
||
|
|
||
|
async function activateCheque(token, id) {
|
||
|
return await fetch(`https://${api_provider}/activate_cheque?token=${token}&id=${id}`)
|
||
|
.then(response => response.json())
|
||
|
.then(value => value['balance']);
|
||
|
}
|
||
|
|
||
|
async function chequeInfo(id) {
|
||
|
return await fetch(`https://${api_provider}/cheque_info?id=${id}`)
|
||
|
.then(response => response.json())
|
||
|
.then(value => value['info']);
|
||
|
}
|