Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Jul 14, 2024
1 parent f9661aa commit 3d34f2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as API from '@midday-ai/engine/resources/index';

export interface ClientOptions {
/**
* Defaults to process.env['MIDDAY_BEARER_TOKEN'].
* Defaults to process.env['MIDDAY_API_KEY'].
*/
bearerToken?: string | undefined;

Expand Down Expand Up @@ -80,7 +80,7 @@ export class Midday extends Core.APIClient {
/**
* API Client for interfacing with the Midday API.
*
* @param {string | undefined} [opts.bearerToken=process.env['MIDDAY_BEARER_TOKEN'] ?? undefined]
* @param {string | undefined} [opts.bearerToken=process.env['MIDDAY_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['MIDDAY_BASE_URL'] ?? https://engine.midday.ai] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
Expand All @@ -91,12 +91,12 @@ export class Midday extends Core.APIClient {
*/
constructor({
baseURL = Core.readEnv('MIDDAY_BASE_URL'),
bearerToken = Core.readEnv('MIDDAY_BEARER_TOKEN'),
bearerToken = Core.readEnv('MIDDAY_API_KEY'),
...opts
}: ClientOptions = {}) {
if (bearerToken === undefined) {
throw new Errors.MiddayError(
"The MIDDAY_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Midday client with an bearerToken option, like new Midday({ bearerToken: 'My Bearer Token' }).",
"The MIDDAY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Midday client with an bearerToken option, like new Midday({ bearerToken: 'My Bearer Token' }).",
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ describe('instantiate client', () => {

test('with environment variable arguments', () => {
// set options via env var
process.env['MIDDAY_BEARER_TOKEN'] = 'My Bearer Token';
process.env['MIDDAY_API_KEY'] = 'My Bearer Token';
const client = new Midday();
expect(client.bearerToken).toBe('My Bearer Token');
});

test('with overriden environment variable arguments', () => {
// set options via env var
process.env['MIDDAY_BEARER_TOKEN'] = 'another My Bearer Token';
process.env['MIDDAY_API_KEY'] = 'another My Bearer Token';
const client = new Midday({ bearerToken: 'My Bearer Token' });
expect(client.bearerToken).toBe('My Bearer Token');
});
Expand Down

0 comments on commit 3d34f2b

Please sign in to comment.