import {Api} from "./lib/api"; export * from "./lib/api" export * from "./lib/verbs" export * from "./lib/webhook" export * from "./lib/utils" export class JambonzAPI { private client: Api; private constructor(private baseUrl: string,private username: string,private password: string) { this.client = new Api({ securityWorker: (token) => { return { headers: { Authorization: `Bearer ${token}` } } },secure: true, baseURL: baseUrl }) } static async Instance(baseUrl: string, username: string, password: string): Promise> { return (await new JambonzAPI(baseUrl,username,password).init()).client } private async init(): Promise { try { this.client.setSecurityData((await this.client.auth.login({ username: this.username, password: this.password }, {secure: false})).data.token as string) } catch (error) { throw Error('Failed to login on '+ this.baseUrl + error) } return this } }