UNPKG

tickethead-sdk

Version:

SDK for the Tickethead API

149 lines 6.18 kB
import { AxiosError, AxiosInstance } from 'axios'; import { AxiosCacheInstance, CacheOptions } from 'axios-cache-interceptor'; import { EventService, MyEventsEvent, MyEventsQuery } from './event'; import { OrderService } from './order'; import { TicketService } from './ticket'; import { AccountService } from './account'; import { PaymentService } from './payment'; import { BlockchainService } from './blockchain'; import { ValidatorService, ImportData, ImportDataRequest } from './validator'; import { BaseUrl } from './common'; import { AuthService } from './auth'; import { VenueService } from './venue'; import { ClusterHealth } from './common/types'; import { Jwt, RefreshableJwt } from './auth/types'; import { ICredential, ICredentialData } from './credential'; import { UploadService } from './upload/service'; import { OrderbookService } from './orderbook'; import { NftService } from './nft'; import { NotificationService } from './notification'; import { PdfService } from './pdf/service'; import { AggregatorService } from './aggregator'; import EventEmitter from 'events'; export type ApiVersion = 'v1'; export interface RetryOptions { retries?: number; retryCondition?: (error: AxiosError<any>) => boolean | Promise<boolean>; shouldResetTimeout?: boolean; retryDelay?: (retryCount: number, error: any) => number; } export interface SdkOptions { baseUrl: string | BaseUrl; version?: ApiVersion; organizer?: string; credentials?: ICredential | ICredentialData; retry?: RetryOptions; cache?: CacheOptions; camelCaseResponse?: boolean; } export type SdkEvents = 'authorizationChanged' | 'logout' | 'initialized' | 'organizerChanged' | 'tokenRefreshed' | 'tenantChanged'; /** * BAM services class. The BAM instance holds the API URLs, the authorization token * and keeps track of the API version used. */ export declare class SDK { readonly baseUrl: string | BaseUrl; readonly version: ApiVersion; auth: AuthService; account: AccountService; venue: VenueService; upload: UploadService; validator: ValidatorService; nft: NftService; pdf: PdfService; aggregator: AggregatorService; event: EventService; order: OrderService; payment: PaymentService; blockchain: BlockchainService; ticket: TicketService; orderbook: OrderbookService; notification: NotificationService; client: AxiosInstance | AxiosCacheInstance; tenantClient: AxiosInstance | AxiosCacheInstance; /** Emits `authorizationChanged`, `logout` ,`initialized`, `organizerChanged`, `tenantChanged`, `tokenRefreshed`, `credentialsExpired` */ readonly eventEmitter: EventEmitter<[never]>; private _credentials?; private _tenant?; private _organizer?; private _deviceId?; constructor(baseUrl: string | BaseUrl, version?: ApiVersion, retryOptions?: RetryOptions, cacheOptions?: CacheOptions, camelCaseResponse?: boolean); get credentials(): ICredential; get tenant(): string; /** * Sets the tenant used by tenant-specific services. * * @param tenantName Name of a tenant to be set */ set tenant(tenantName: string); get organizer(): string; get deviceId(): string; set deviceId(deviceId: string); /** * You can use the object in the response to construct JwtCredentials. */ getToken(): Jwt | RefreshableJwt; static getTokenPayload(token: string): Record<string, any>; /** * Used to store the state of the SDK. * Can be used via the build method to restore state. */ serialize(): SdkOptions; /** * Factory method for initializing the SDK. * Can be used in conjunction with the serialize method to restore state. */ static build(params: SdkOptions): Promise<SDK>; /** * Sets the organizer used on the instance. Any event, payment, reporting or websocket API call * will be made to the organizer's tenant API. * * @param organizerName Name of an organizer to be set on the instance */ useOrganizer(organizerName: string): Promise<void>; /** * Authorizes the SDK instance with a JWT obtained from the API. * For user or organizer based login supply `PasswordCredentials`. * For internal service authentication use `ServiceCredentials` with the appropriate organizer ID. * For logging in with a wallet, use `WalletCredentials` aka the private key and certificate. * For guest login use the parameterless version of `authorize`. * * @param credentials User, organizer, service or wallet credentials. * @param organizer The organizer name of the organizer for which the token is requested. */ authorize(credentials: ICredential, organizer?: string): Promise<Jwt>; /** Removes all authorization from the SDK */ logout(): void; /** Returns true if the SDK has an authorization set */ get isLoggedIn(): boolean; /** * Sets the Bearer header of the calls to the specified token. * You can also use the authorize method with JwtCredentials. * * @param jwt JWT to use for calls to the BAM services */ setAuthorization(jwt: Jwt): void; /** * Returns the status of currently used BAM services. * This includes global services and the services for the current tenant. */ health(): Promise<ClusterHealth>; /** * Returns events with secure tickets for the authorized enrolled user. * * @param req.date Filter events by `end_at` date comparing with `midnight`. Expected values are `future`, `past` and `all`. * @returns */ getMyEvents(req: MyEventsQuery): Promise<MyEventsEvent[]>; /** * Returns data that needs to be imported to the local validation server. */ getImportData(request: ImportDataRequest): Promise<ImportData>; /** * Enable sending the current version to the backend and checking against the configured minimum version * * @param version Version which is sent to the backend and checked against the minimum version. Format 'X.Y.Z' */ enableMinimumVersionCheck(version: string): void; } //# sourceMappingURL=sdk.d.ts.map