Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Mar 27, 2024
1 parent c47e029 commit f60bcd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
15 changes: 4 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import * as qs from 'qs';
import * as API from 'retell-sdk/resources/index';

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

/**
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
Expand Down Expand Up @@ -79,7 +76,7 @@ export class Retell extends Core.APIClient {
/**
* API Client for interfacing with the Retell API.
*
* @param {string | undefined} [opts.apiKey=process.env['ORG_AUTH_TOKEN'] ?? undefined]
* @param {string} opts.apiKey
* @param {string} [opts.baseURL=process.env['RETELL_BASE_URL'] ?? https://api.retellai.com] - 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 @@ -88,14 +85,10 @@ export class Retell extends Core.APIClient {
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
*/
constructor({
baseURL = Core.readEnv('RETELL_BASE_URL'),
apiKey = Core.readEnv('ORG_AUTH_TOKEN'),
...opts
}: ClientOptions = {}) {
constructor({ baseURL = Core.readEnv('RETELL_BASE_URL'), apiKey, ...opts }: ClientOptions) {
if (apiKey === undefined) {
throw new Errors.RetellError(
"The ORG_AUTH_TOKEN environment variable is missing or empty; either provide it, or instantiate the Retell client with an apiKey option, like new Retell({ apiKey: 'My API Key' }).",
"Missing required client option apiKey; you need to instantiate the Retell client with an apiKey option, like new Retell({ apiKey: 'My API Key' }).",
);
}

Expand Down
14 changes: 0 additions & 14 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,6 @@ describe('instantiate client', () => {
const client2 = new Retell({ apiKey: 'My API Key' });
expect(client2.maxRetries).toEqual(2);
});

test('with environment variable arguments', () => {
// set options via env var
process.env['ORG_AUTH_TOKEN'] = 'My API Key';
const client = new Retell();
expect(client.apiKey).toBe('My API Key');
});

test('with overriden environment variable arguments', () => {
// set options via env var
process.env['ORG_AUTH_TOKEN'] = 'another My API Key';
const client = new Retell({ apiKey: 'My API Key' });
expect(client.apiKey).toBe('My API Key');
});
});

describe('request building', () => {
Expand Down

0 comments on commit f60bcd6

Please sign in to comment.