export type DataEventCallback<D> = (data: D) => void;

export type ErrorEventCallback = (event: Error) => void;

export interface PlatformEventEmitter extends NodeJS.EventEmitter {
  on<D>(event: 'data', callback: DataEventCallback<D>): this;
  on(event: 'end', callback: () => void): this;
  on(event: 'error', callback: ErrorEventCallback): this;
}

export class PlatformApiError extends Error {
  constructor(message: string, readonly response: Response) {
    super(message);
    this.name = 'PlatformApiError';
  }
}
