import { ModelClient, isAPIError, getErrorMessage } from '../client/model-client'; import { Source } from './source'; export class SourceClient extends ModelClient { pluralName = 'sources'; async byName(name: string): Promise { const url = `/${this.version}/${this.pluralName}`; const response = await this.client.get(url, { params: { name } }); if (isAPIError(response.data)) { throw new Error(getErrorMessage(response.data)); } return this.validate(response.data); } }