@sharplygroup/xtb-api-js
Version:
A module for interacting with the XTB API
58 lines • 1.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerOperations = void 0;
class ServerOperations {
wsManager;
constructor(wsManager) {
this.wsManager = wsManager;
}
/**
* Returns current time on trading server.
* @returns {Promise<any>} // TODO: Create IServerTimeResponse interface
*/
async getServerTime() {
const response = await this.wsManager.sendCommand({
command: "getServerTime",
arguments: {},
});
if (!response.status || !response.returnData) {
throw new Error(response.errorDescr || "Failed to get server time");
}
return {
status: response.status,
returnData: response.returnData,
};
}
/**
* Returns the current API version.
* @returns {Promise<any>} // TODO: Create IVersionResponse interface
*/
async getVersion() {
const response = await this.wsManager.sendCommand({
command: "getVersion",
arguments: {},
});
if (!response.status || !response.returnData) {
throw new Error(response.errorDescr || "Failed to get version");
}
return {
status: response.status,
returnData: response.returnData,
};
}
/**
* Regularly calling this function is enough to refresh the internal state of all the components in the system.
* @returns {Promise<void>}
*/
async ping() {
const response = await this.wsManager.sendCommand({
command: "ping",
arguments: {},
});
if (!response.status) {
throw new Error(response.errorDescr || "Ping failed");
}
}
}
exports.ServerOperations = ServerOperations;
//# sourceMappingURL=ServerOperations.js.map