UNPKG

@codebluelife/cbl-base

Version:
36 lines (35 loc) 1.24 kB
class AccountInterface { accountId; constructor(accountId) { this.accountId = accountId; } } Object.keys(exports["cbl-base"].GetAccountCalls()).forEach((method) => { AccountInterface.prototype[method] = function (...args) { return exports["cbl-base"].CallAccount(this.accountId, method, ...args); }; }); AccountInterface.prototype.toString = function () { return JSON.stringify(this, null, 2); }; function CreateAccountInstance(account) { if (!account) return; return new AccountInterface(account.accountId); } export async function GetAccount(accountId) { const account = await exports["cbl-base"].GetAccount(accountId); return CreateAccountInstance(account); } export async function GetCharacterAccount(charId) { const account = await exports["cbl-base"].GetCharacterAccount(charId); return CreateAccountInstance(account); } export async function GetGroupAccount(groupName) { const account = await exports["cbl-base"].GetGroupAccount(groupName); return CreateAccountInstance(account); } export async function CreateAccount(owner, label) { const account = await exports["cbl-base"].CreateAccount(owner, label); return CreateAccountInstance(account); }