Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #27

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class Retell extends Core.APIClient {
constructor({ baseURL = Core.readEnv('RETELL_BASE_URL'), apiKey, ...opts }: ClientOptions) {
if (apiKey === undefined) {
throw new Errors.RetellError(
"Missing required client option apiKey; you need to 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: 'YOUR_RETELL_API_KEY' }).",
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Retell from 'retell-sdk';
import { Response } from 'node-fetch';

const retell = new Retell({
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Retell from 'retell-sdk';
import { Response } from 'node-fetch';

const retell = new Retell({
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/llm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Retell from 'retell-sdk';
import { Response } from 'node-fetch';

const retell = new Retell({
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/api-resources/phone-number.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Retell from 'retell-sdk';
import { Response } from 'node-fetch';

const retell = new Retell({
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

Expand Down
42 changes: 24 additions & 18 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('instantiate client', () => {
const client = new Retell({
baseURL: 'http://localhost:5000/',
defaultHeaders: { 'X-My-Default-Header': '2' },
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
});

test('they are used in the request', () => {
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('instantiate client', () => {
const client = new Retell({
baseURL: 'http://localhost:5000/',
defaultQuery: { apiVersion: 'foo' },
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
});
expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo');
});
Expand All @@ -64,7 +64,7 @@ describe('instantiate client', () => {
const client = new Retell({
baseURL: 'http://localhost:5000/',
defaultQuery: { apiVersion: 'foo', hello: 'world' },
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
});
expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo&hello=world');
});
Expand All @@ -73,7 +73,7 @@ describe('instantiate client', () => {
const client = new Retell({
baseURL: 'http://localhost:5000/',
defaultQuery: { hello: 'world' },
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
});
expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo');
});
Expand All @@ -82,7 +82,7 @@ describe('instantiate client', () => {
test('custom fetch', async () => {
const client = new Retell({
baseURL: 'http://localhost:5000/',
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
fetch: (url) => {
return Promise.resolve(
new Response(JSON.stringify({ url, custom: true }), {
Expand All @@ -99,7 +99,7 @@ describe('instantiate client', () => {
test('custom signal', async () => {
const client = new Retell({
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
apiKey: 'My API Key',
apiKey: 'YOUR_RETELL_API_KEY',
fetch: (...args) => {
return new Promise((resolve, reject) =>
setTimeout(
Expand All @@ -124,12 +124,18 @@ describe('instantiate client', () => {

describe('baseUrl', () => {
test('trailing slash', () => {
const client = new Retell({ baseURL: 'http://localhost:5000/custom/path/', apiKey: 'My API Key' });
const client = new Retell({
baseURL: 'http://localhost:5000/custom/path/',
apiKey: 'YOUR_RETELL_API_KEY',
});
expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo');
});

test('no trailing slash', () => {
const client = new Retell({ baseURL: 'http://localhost:5000/custom/path', apiKey: 'My API Key' });
const client = new Retell({
baseURL: 'http://localhost:5000/custom/path',
apiKey: 'YOUR_RETELL_API_KEY',
});
expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo');
});

Expand All @@ -138,41 +144,41 @@ describe('instantiate client', () => {
});

test('explicit option', () => {
const client = new Retell({ baseURL: 'https://example.com', apiKey: 'My API Key' });
const client = new Retell({ baseURL: 'https://example.com', apiKey: 'YOUR_RETELL_API_KEY' });
expect(client.baseURL).toEqual('https://example.com');
});

test('env variable', () => {
process.env['RETELL_BASE_URL'] = 'https://example.com/from_env';
const client = new Retell({ apiKey: 'My API Key' });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY' });
expect(client.baseURL).toEqual('https://example.com/from_env');
});

test('empty env variable', () => {
process.env['RETELL_BASE_URL'] = ''; // empty
const client = new Retell({ apiKey: 'My API Key' });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY' });
expect(client.baseURL).toEqual('https://api.retellai.com');
});

test('blank env variable', () => {
process.env['RETELL_BASE_URL'] = ' '; // blank
const client = new Retell({ apiKey: 'My API Key' });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY' });
expect(client.baseURL).toEqual('https://api.retellai.com');
});
});

test('maxRetries option is correctly set', () => {
const client = new Retell({ maxRetries: 4, apiKey: 'My API Key' });
const client = new Retell({ maxRetries: 4, apiKey: 'YOUR_RETELL_API_KEY' });
expect(client.maxRetries).toEqual(4);

// default
const client2 = new Retell({ apiKey: 'My API Key' });
const client2 = new Retell({ apiKey: 'YOUR_RETELL_API_KEY' });
expect(client2.maxRetries).toEqual(2);
});
});

describe('request building', () => {
const client = new Retell({ apiKey: 'My API Key' });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY' });

describe('Content-Length', () => {
test('handles multi-byte characters', () => {
Expand Down Expand Up @@ -214,7 +220,7 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new Retell({ apiKey: 'My API Key', timeout: 10, fetch: testFetch });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY', timeout: 10, fetch: testFetch });

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
expect(count).toEqual(2);
Expand All @@ -241,7 +247,7 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new Retell({ apiKey: 'My API Key', fetch: testFetch });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY', fetch: testFetch });

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
expect(count).toEqual(2);
Expand All @@ -268,7 +274,7 @@ describe('retries', () => {
return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } });
};

const client = new Retell({ apiKey: 'My API Key', fetch: testFetch });
const client = new Retell({ apiKey: 'YOUR_RETELL_API_KEY', fetch: testFetch });

expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 });
expect(count).toEqual(2);
Expand Down