UNPKG

bam-ticketing-sdk

Version:

SDK for B.A.M Ticketing API

32 lines (30 loc) 836 B
import { UserPassword, ICredential, JwtCredentials, ServiceAccessData, WalletCredentials, ServiceCredentials, PasswordCredentials, CredentialType, ICredentialData, } from '..' import { ApiKeyCredentials } from './api-key-credentials' export class CredentialFactory { static build(data: ICredentialData): ICredential { switch (data.type) { case CredentialType.Password: return new PasswordCredentials(data.credentials as UserPassword) case CredentialType.Wallet: return new WalletCredentials(data.keyPair) case CredentialType.Service: return new ServiceCredentials(data.credentials as ServiceAccessData) case CredentialType.ApiKey: return new ApiKeyCredentials(data.jwt.token) case CredentialType.Guest: case CredentialType.Jwt: default: return new JwtCredentials(data.jwt) } } }