@ariusii/intersect.ts
Version:
The Intersect Engine API Client Library based on TS.
67 lines • 2.46 kB
JavaScript
/**
* This is the GameObjects Class, it contains all the methods to handle Game Object's.
* Those actions do not require any Query Role.
* @class Chat
* @link https://docs.freemmorpgmaker.com/en-US/api/v1/endpoints/gameobjects.html
* @author AriusII
*/
export class GameObjects {
_url;
_token;
constructor(_url, _token) {
this._url = _url;
this._token = _token;
}
/**
* Grabs a list of game objects and their stored information from the server given it's type and paging information.
* @param type - The KEY type of object you want to get. (Check official doc'.)
* @param page - The page you want to get.
* @param count - The number of objects you want to get.
* @returns - The response from the server.
*/
async getList(type, page, count) {
const res = await fetch(`${this._url}/api/v1/gameobjects/${type}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._token}`
},
body: JSON.stringify({
page: page || 0,
count: count || 5
})
});
return await res.json();
}
/**
* It retrieves the config for a singular game object from the server given it's type and id.
* @param type - The KEY type of object you want to get. (Check official doc'.)
* @param id - The id of the object you want to get.
* @returns - The response from the server.
*/
async getObject(type, id) {
const res = await fetch(`${this._url}/api/v1/gameobjects/${type}/${id}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._token}`
}
});
return await res.json();
}
/**
* It retrieves the servers timing configuration and color hues for each time of day.
* @returns - The response from the server.
*/
async getTime() {
const res = await fetch(`${this._url}/api/v1/gameobjects/time`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this._token}`
}
});
return await res.json();
}
}
//# sourceMappingURL=gameobjects.js.map