import { RequestApi, RequestApiOptions } from '../requests'; import { Store, Data } from './store'; import { UserModel, UserType } from './user'; import { BankModel, BankType } from './bank'; import { RawModel, RawType } from './raw'; import { SessionModel, SessionType } from './sessions'; import { AddressModel, AddressType } from './address'; import { CreditModel, CreditType } from './credit'; import { FormModel, FormType } from './form'; import { KycModel, KycType } from './kyc'; import { LoanPartModel, LoanPartType } from './loan-part'; import { PersonModel, PersonType } from './person'; import { TinkLoanModel, TinkLoanType } from './tink-loan'; import { TinkModel, TinkType } from './tink'; import { EventTopic } from './event-topic'; import { CountryModel, EmploymentTypeModel, GenderModel, MarketModel, CurrencyModel, CreditTypeModel, KycSourceModel, KycPurposeModel, } from './enums'; import { ApiKeys } from '../types'; export class ModelApi { private _requestApi: RequestApi; private _store: Store; public [ApiKeys.ADDRESSES]: AddressType; public [ApiKeys.BANKS]: BankType; public [ApiKeys.CREDITS]: CreditType; public [ApiKeys.FORMS]: FormType; public [ApiKeys.KYCS]: KycType; public [ApiKeys.LOANPARTS]: LoanPartType; public [ApiKeys.PERSONS]: PersonType; public [ApiKeys.RAW]: RawType; public [ApiKeys.SESSIONS]: SessionType; public [ApiKeys.TINK]: TinkType; public [ApiKeys.TINKLOANS]: TinkLoanType; public [ApiKeys.USERS]: UserType; public [ApiKeys.COUNTRIES]: CountryModel; public [ApiKeys.CREDIT_TYPES]: CreditTypeModel; public [ApiKeys.CURRENCIES]: CurrencyModel; public [ApiKeys.EMPLOYMENT_TYPES]: EmploymentTypeModel; public [ApiKeys.GENDERS]: GenderModel; public [ApiKeys.KYC_PURPOSES]: KycPurposeModel; public [ApiKeys.KYC_SOURCES]: KycSourceModel; public [ApiKeys.MARKETS]: MarketModel; constructor(reqOpts: RequestApiOptions, eventBus: EventTopic) { this._requestApi = new RequestApi(reqOpts); this._store = new Store(eventBus); this[ApiKeys.ADDRESSES] = ( new AddressModel(this._requestApi, this._store) ); this[ApiKeys.BANKS] = ( new BankModel(this._requestApi, this._store) ); this[ApiKeys.CREDITS] = ( new CreditModel(this._requestApi, this._store) ); this[ApiKeys.FORMS] = ( new FormModel(this._requestApi, this._store) ); this[ApiKeys.KYCS] = new KycModel(this._requestApi, this._store); this[ApiKeys.LOANPARTS] = ( new LoanPartModel(this._requestApi, this._store) ); this[ApiKeys.PERSONS] = ( new PersonModel(this._requestApi, this._store) ); this[ApiKeys.RAW] = new RawModel(this._requestApi); this[ApiKeys.SESSIONS] = new SessionModel(this._requestApi); this[ApiKeys.TINK] = new TinkModel(this._requestApi, this._store); this[ApiKeys.TINKLOANS] = ( new TinkLoanModel(this._requestApi, this._store) ); this[ApiKeys.USERS] = ( new UserModel(this._requestApi, this._store) ); this[ApiKeys.COUNTRIES] = new CountryModel(this._requestApi, this._store); this[ApiKeys.CREDIT_TYPES] = new CreditTypeModel( this._requestApi, this._store, ); this[ApiKeys.CURRENCIES] = new CurrencyModel(this._requestApi, this._store); this[ApiKeys.EMPLOYMENT_TYPES] = new EmploymentTypeModel( this._requestApi, this._store, ); this[ApiKeys.GENDERS] = new GenderModel(this._requestApi, this._store); this[ApiKeys.KYC_PURPOSES] = new KycPurposeModel( this._requestApi, this._store, ); this[ApiKeys.KYC_SOURCES] = new KycSourceModel( this._requestApi, this._store, ); this[ApiKeys.MARKETS] = new MarketModel(this._requestApi, this._store); } resetStore(initData?: Data) { return this._store.reset(initData); } }