import { ModelClient, isAPIError, getErrorMessage } from '../client/model-client'; import { Context, PatchedContext } from './context'; export class ContextClient extends ModelClient { pluralName = 'contexts'; 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); } }