import { RequestApi, Tink as TinkRequestModel } from '../requests'; import { ApiKeys, TinkLinkQuery } from '../types'; import { USER_LITERAL, Keys } from './entities'; import { Store } from './store'; export class TinkModel { private _requestModel: any; private _store: Store; constructor(requestApi: RequestApi, store: Store) { this._requestModel = requestApi[ApiKeys.TINK]; this._store = store; } async link(query: TinkLinkQuery) { return (this._requestModel).link(query); } async login(code: string) { const data = await (this._requestModel).login(code); if (data && data.user && data.user.id) { this._store.set(Keys.userLiteral, { [USER_LITERAL]: data.user.id, }); } return data; } } type TinkRelations = {}; export type TinkType = TinkModel & TinkRelations;