UNPKG

ggez-banking-sdk

Version:

A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.

54 lines (53 loc) 1.85 kB
import { CookiesHelper } from "../helper/storage/cookiesHelper"; import { AccountProxy, AuthProxy, BlockchainProxy, LimitedProxy, OrderProxy, OrganizationProxy, ProgramProxy, PromotionProxy, TransactionProxy, UserProxy, } from "./proxy"; import { DefaultClientContextProvider } from "./context"; class API { context; account; auth; blockchain; limited; order; organization; program; promotion; transaction; user; cookiesHelper; constructor(config, errorHandler) { this.cookiesHelper = new CookiesHelper(config.programId, config.domain, errorHandler); this.context = new DefaultClientContextProvider({ baseUrl: config.baseUrl, nodeUrl: config.nodeUrl, programId: config.programId, lang: config.lang, }); const proxyData = { context: this.context, errorHandler, cookiesHelper: this.cookiesHelper, }; this.auth = new AuthProxy(proxyData); this.account = new AccountProxy(proxyData); this.blockchain = new BlockchainProxy(proxyData); this.order = new OrderProxy(proxyData); this.limited = new LimitedProxy(proxyData); this.organization = new OrganizationProxy(proxyData); this.program = new ProgramProxy(proxyData); this.promotion = new PromotionProxy(proxyData); this.transaction = new TransactionProxy(proxyData); this.user = new UserProxy(proxyData); } async logout() { try { const deviceId = await this.cookiesHelper.getDeviceId(); if (deviceId) { await this.user.logoutDevice({ id: deviceId }); } } finally { await this.cookiesHelper.clearCredentialCookies(); } } } export { API };