This commit is contained in:
2024-02-01 12:58:17 +01:00
15 changed files with 127 additions and 51 deletions

View File

@ -78,7 +78,7 @@ class Client
/**
* The only right way to determine is the user is logged
* @returns {Boolean}
* @returns {Promise<Boolean>}
*/
async isAuthentificate()
{
@ -91,7 +91,7 @@ class Client
* Send a GET request to %uri%
* @param {String} uri
* @param {*} data
* @returns {Response}
* @returns {Promise<Response>}
*/
async _get(uri, data)
{
@ -106,7 +106,7 @@ class Client
* Send a POST request
* @param {String} uri
* @param {*} data
* @returns {Response}
* @returns {Promise<Response>}
*/
async _post(uri, data)
{
@ -115,7 +115,8 @@ class Client
headers: {
"Content-Type": "application/json",
"X-CSRFToken": getCookie("csrftoken"),
},
'Accept-Language': this.lang.currentLang,
},
body: JSON.stringify(data),
});
return response;
@ -125,7 +126,7 @@ class Client
* Send a DELETE request
* @param {String} uri
* @param {String} data
* @returns {Response}
* @returns {Promise<Response>}
*/
async _delete(uri, data)
{
@ -144,7 +145,7 @@ class Client
* Send a PATCH request with json
* @param {String} uri
* @param {*} data
* @returns {Response}
* @returns {Promise<Response>}
*/
async _patch_json(uri, data)
{
@ -163,7 +164,7 @@ class Client
* Send a PATCH request with file
* @param {String} uri
* @param {*} file
* @returns {Response}
* @returns {Promise<Response>}
*/
async _patch_file(uri, file)
{
@ -179,7 +180,7 @@ class Client
/**
* Change logged state. Use It if you recv an 403 error
* @param {Boolean} state
* @param {Promise<?>} state
* @returns
*/
async _update_logged(state)
@ -211,7 +212,7 @@ class Client
* Loggin the user
* @param {String} username
* @param {String} password
* @returns
* @returns {Promise<Response>}
*/
async login(username, password)
{
@ -224,6 +225,7 @@ class Client
/**
* Logout the user
* @returns {Promise<?>}
*/
async logout()
{
@ -233,7 +235,7 @@ class Client
/**
* Determine if the user is logged. NEVER USE IT, USE isAuthentificated()
* @returns {Boolean}
* @returns {Promise<Boolean>}
*/
async _test_logged()
{