diff --git a/CHANGELOG.md b/CHANGELOG.md index b5485b9..1df84c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ ### v2.0.0-alpha.4 - Add `Addresses` example +- Remove `BusinessIdentity` resource +- Remove `CallInformation` resource +- Remove duplicated `Credentials` resource +- Fixed `Conferences`, `Documents` and `TelephonyCredentials` method names +- Add missing resource types defs ### v2.0.0-alpha.3 diff --git a/VERSION b/VERSION index 4640d57..c4e1040 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0-alpha.3 +2.0.0-alpha.4 diff --git a/package-lock.json b/package-lock.json index 0e29439..cd13a0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "telnyx", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "telnyx", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "license": "MIT", "devDependencies": { "@eslint/js": "^9.10.0", diff --git a/package.json b/package.json index b6dd14f..b34638f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telnyx", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "Telnyx API Node SDK", "keywords": [ "telnyx", diff --git a/plop-templates/ResourceTypes.ts.hbs b/plop-templates/ResourceTypes.ts.hbs index 2e7faf1..9dd6fc0 100644 --- a/plop-templates/ResourceTypes.ts.hbs +++ b/plop-templates/ResourceTypes.ts.hbs @@ -31,20 +31,20 @@ declare module 'telnyx' { {{/if}} {{#if (ifEquals . "list")}} - type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}']['get']['responses']['200']['content']['application/json']['data']; + type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}']['get']['responses']['200']['content']['application/json']; {{/if}} {{#if (ifEquals . "create")}} - type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}']['post']['responses']['200']['content']['application/json']['data']; + type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}']['post']['responses']['200']['content']['application/json']; {{/if}} {{#if (ifEquals . "retrieve")}} - type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['get']['responses']['200']['content']['application/json']['data']; + type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['get']['responses']['200']['content']['application/json']; {{/if}} {{#if (ifEquals . "update")}} - type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['patch']['responses']['200']['content']['application/json']['data']; + type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['patch']['responses']['200']['content']['application/json']; {{/if}} {{#if (ifEquals . "del")}} - type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['delete']['responses']['200']['content']['application/json']['data']; + type {{pascalCase ../name}}{{pascalCase .}}Response = paths['{{../path}}/{{../path-param}}']['delete']['responses']['200']['content']['application/json']; {{/if}} {{/each}} diff --git a/src/resources/Brands.ts b/src/resources/Brands.ts index 6afc25a..f1f299c 100644 --- a/src/resources/Brands.ts +++ b/src/resources/Brands.ts @@ -30,16 +30,11 @@ export const Brands = TelnyxResource.extend({ urlParams: ['brandId'], }), - externalVettings: telnyxMethod({ - method: 'GET', - path: '/brand/{brandId}/externalVetting', - urlParams: ['brandId'], - }), - listExternalVettings: telnyxMethod({ method: 'GET', path: '/brand/{brandId}/externalVetting', urlParams: ['brandId'], + methodType: 'list', }), exportExternalVettings: telnyxMethod({ diff --git a/src/resources/BusinessIdentity.ts b/src/resources/BusinessIdentity.ts deleted file mode 100644 index 3cfb084..0000000 --- a/src/resources/BusinessIdentity.ts +++ /dev/null @@ -1,17 +0,0 @@ -import TelnyxResource from '../TelnyxResource'; -const telnyxMethod = TelnyxResource.method; - -export const BusinessIdentity = TelnyxResource.extend({ - path: 'business_identity', - includeBasic: ['list', 'retrieve', 'delete'], - - ListBusinessIdentities: telnyxMethod({ - method: 'GET', - path: '/business/identities', - }), - DeleteBusinessIdentity: telnyxMethod({ - method: 'DELETE', - path: '/business/identities/{id}', - urlParams: ['id'], - }), -}); diff --git a/src/resources/CallControlApplications.ts b/src/resources/CallControlApplications.ts index 7f9ce95..abfe4d5 100644 --- a/src/resources/CallControlApplications.ts +++ b/src/resources/CallControlApplications.ts @@ -34,16 +34,11 @@ function transformResponseData( export const CallControlApplications = TelnyxResource.extend({ path: 'call_control_applications', - - list: telnyxMethod({ - method: 'GET', - methodType: 'list', - - transformResponseData: transformResponseData, - }), + includeBasic: ['list', 'update'], create: telnyxMethod({ method: 'POST', + transformResponseData: transformResponseData, }), diff --git a/src/resources/CallInformation.ts b/src/resources/CallInformation.ts deleted file mode 100644 index b3af035..0000000 --- a/src/resources/CallInformation.ts +++ /dev/null @@ -1,12 +0,0 @@ -import TelnyxResource from '../TelnyxResource'; -const telnyxMethod = TelnyxResource.method; - -export const CallInformation = TelnyxResource.extend({ - path: 'call_information', - includeBasic: ['list', 'retrieve'], - - ListConnectionActiveCalls: telnyxMethod({ - method: 'GET', - path: '/connections/{connection/id}/active_calls', - }), -}); diff --git a/src/resources/CallRecordings.ts b/src/resources/CallRecordings.ts index c8a60ae..c1dac9b 100644 --- a/src/resources/CallRecordings.ts +++ b/src/resources/CallRecordings.ts @@ -3,22 +3,22 @@ const telnyxMethod = TelnyxResource.method; export const CallRecordings = TelnyxResource.extend({ path: 'recordings', - includeBasic: ['list', 'retrieve', 'del'], + includeBasic: ['list'], - GetRecordings: telnyxMethod({ + retrieve: telnyxMethod({ method: 'GET', - path: '/recordings', + path: '/{recording_id}', + urlParams: ['recording_id'], }), - DeleteRecording: telnyxMethod({ + + del: telnyxMethod({ method: 'DELETE', - path: '/recordings/{recording/id}', + path: '/{recording_id}', + urlParams: ['recording_id'], }), - DeleteRecordings: telnyxMethod({ + + bulkDel: telnyxMethod({ method: 'DELETE', path: '/recordings/actions/delete', }), - DeleteCustomStorageCredentials: telnyxMethod({ - method: 'DELETE', - path: '/custom/storage/credentials/{connection/id}', - }), }); diff --git a/src/resources/CdrUsageReports.ts b/src/resources/CdrUsageReports.ts index b905531..7561454 100644 --- a/src/resources/CdrUsageReports.ts +++ b/src/resources/CdrUsageReports.ts @@ -2,11 +2,11 @@ import TelnyxResource from '../TelnyxResource'; const telnyxMethod = TelnyxResource.method; export const CdrUsageReports = TelnyxResource.extend({ - path: 'cdr_usage_reports', - includeBasic: ['list', 'retrieve'], + path: 'reports/cdr_usage_reports', - GetUsageReportSync: telnyxMethod({ + retrieveUsageReportSync: telnyxMethod({ + path: '/sync', method: 'GET', - path: '/reports/cdr_usage_reports/sync', + urlParams: [], }), }); diff --git a/src/resources/Channelzones.ts b/src/resources/Channelzones.ts index 4c99b70..d3e092e 100644 --- a/src/resources/Channelzones.ts +++ b/src/resources/Channelzones.ts @@ -2,23 +2,35 @@ import TelnyxResource from '../TelnyxResource'; const telnyxMethod = TelnyxResource.method; export const Channelzones = TelnyxResource.extend({ - path: 'channelzones', - includeBasic: ['list', 'retrieve', 'delete'], + path: 'channel_zones', + includeBasic: ['list'], - GetChannelZone: telnyxMethod({ + update: telnyxMethod({ + method: 'PATCH', + path: '/{channel_zone_id}', + urlParams: ['channel_zone_id'], + }), + + retrieve: telnyxMethod({ method: 'GET', - path: '/channel_zones/{channel/zone/id}', + path: '/{channel_zone_id}', + urlParams: ['channel_zone_id'], }), - UnassignPhoneNumber: telnyxMethod({ - method: 'DELETE', - path: '/channel_zones/{channel/zone/id}/channel_zone_phone_numbers/{phone_number}', + + createPhoneNumber: telnyxMethod({ + method: 'POST', + path: '/{channel_zone_id}/channel_zone_phone_numbers', + urlParams: ['channel_zone_id'], }), - GetChannelZones: telnyxMethod({ + + listPhoneNumbers: telnyxMethod({ method: 'GET', - path: '/channel/zones', + path: '/{channel_zone_id}/channel_zone_phone_numbers', }), - GetPhoneNumbers: telnyxMethod({ - method: 'GET', - path: '/channel_zones/{channel_zone_id}/channel_zone_phone_numbers', + + delPhoneNumber: telnyxMethod({ + method: 'DELETE', + path: '/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}', + urlParams: ['channel_zone_id', 'phone_number'], }), }); diff --git a/src/resources/Conferences.ts b/src/resources/Conferences.ts index ace7f66..1640f17 100644 --- a/src/resources/Conferences.ts +++ b/src/resources/Conferences.ts @@ -15,7 +15,8 @@ const CONFERENCES = [ 'record_stop', 'update', 'leave', - 'resume', + 'record_resume', + 'record_pause', ]; function getSpec(conferenceId?: string) { @@ -33,7 +34,26 @@ function getSpec(conferenceId?: string) { export const Conferences = TelnyxResource.extend({ path: 'conferences', - includeBasic: ['list', 'retrieve'], + includeBasic: ['list'], + + retrieve: telnyxMethod({ + method: 'GET', + path: '/{id}', + urlParams: ['id'], + + transformResponseData: function (response, telnyx) { + return utils.addResourceToResponseData( + response, + telnyx, + 'conferences', + utils.createNestedMethods( + telnyxMethod, + CONFERENCES, + getSpec(response.data.id as string), + ), + ); + }, + }), create: telnyxMethod({ method: 'POST', diff --git a/src/resources/Connections.ts b/src/resources/Connections.ts index 6405374..f31c50f 100644 --- a/src/resources/Connections.ts +++ b/src/resources/Connections.ts @@ -1,6 +1,12 @@ import TelnyxResource from '../TelnyxResource'; +const telnyxMethod = TelnyxResource.method; export const Connections = TelnyxResource.extend({ path: 'connections', includeBasic: ['list', 'retrieve'], + + listActiveCalls: telnyxMethod({ + method: 'GET', + path: '/{connection_id}/active_calls', + }), }); diff --git a/src/resources/Credentials.ts b/src/resources/Credentials.ts deleted file mode 100644 index b1837b3..0000000 --- a/src/resources/Credentials.ts +++ /dev/null @@ -1,26 +0,0 @@ -import TelnyxResource from '../TelnyxResource'; -const telnyxMethod = TelnyxResource.method; - -export const Credentials = TelnyxResource.extend({ - path: 'credentials', - includeBasic: ['create', 'list', 'retrieve', 'delete'], - - PerformCredentialAction: telnyxMethod({ - method: 'POST', - path: '/telephony_credentials/{id}/actions/{action}', - urlParams: ['id', 'action'], - }), - FindTelephonyCredentials: telnyxMethod({ - method: 'GET', - path: '/telephony_credentials', - }), - ListTags: telnyxMethod({ - method: 'GET', - path: '/telephony/credentials/tags', - }), - DeleteTelephonyCredential: telnyxMethod({ - method: 'DELETE', - path: '/telephony_credentials/{id}', - urlParams: ['id'], - }), -}); diff --git a/src/resources/Documents.ts b/src/resources/Documents.ts index 268ed4e..ef77396 100644 --- a/src/resources/Documents.ts +++ b/src/resources/Documents.ts @@ -1,53 +1,21 @@ import TelnyxResource from '../TelnyxResource'; -import * as utils from '../utils'; -const telnyxMethod = TelnyxResource.method; - -import {ResponsePayload, TelnyxObject} from '../Types'; -function transformResponseData( - response: ResponsePayload, - telnyx: TelnyxObject, -) { - return utils.addResourceToResponseData(response, telnyx, 'documents', {}); -} +const telnyxMethod = TelnyxResource.method; export const Documents = TelnyxResource.extend({ path: 'documents', - list: telnyxMethod({ - method: 'GET', - transformResponseData: transformResponseData, - }), - update: telnyxMethod({ - method: 'PATCH', - path: '/{id}', - urlParams: ['id'], - transformResponseData: transformResponseData, - }), - del: telnyxMethod({ - method: 'DELETE', - path: '{id}', - urlParams: ['id'], - transformResponseData: transformResponseData, - }), + includeBasic: ['list', 'update', 'del', 'create', 'retrieve'], + upload: telnyxMethod({ method: 'POST', - transformResponseData: transformResponseData, }), - retrieveDocumentId: telnyxMethod({ - method: 'GET', - path: '/{id}', - urlParams: ['id'], - transformResponseData: transformResponseData, - }), - retrieveDownloadDocument: telnyxMethod({ + download: telnyxMethod({ method: 'GET', path: '/{id}/download', urlParams: ['id'], headers: { 'Content-Type': '*', }, - - transformResponseData: transformResponseData, }), }); diff --git a/src/resources/TelephonyCredentials.ts b/src/resources/TelephonyCredentials.ts index 1383aa2..79acfb3 100644 --- a/src/resources/TelephonyCredentials.ts +++ b/src/resources/TelephonyCredentials.ts @@ -24,7 +24,7 @@ function transformResponseData( ); } -const telephonyCredentialResource = { +export const TelephonyCredentials = TelnyxResource.extend({ path: 'telephony_credentials', includeBasic: ['del', 'list', 'update'], @@ -36,22 +36,21 @@ const telephonyCredentialResource = { }), retrieve: telnyxMethod({ - method: 'POST', - path: '/{id}/token', + method: 'GET', + path: '/{id}', urlParams: ['id'], transformResponseData: transformResponseData, }), - retrieveCredential: telnyxMethod({ - method: 'GET', - path: '/{id}', + createToken: telnyxMethod({ + method: 'POST', + path: '/{id}/token', urlParams: ['id'], - - transformResponseData: transformResponseData, }), -}; -export const TelephonyCredentials = TelnyxResource.extend( - telephonyCredentialResource, -); + listTags: telnyxMethod({ + method: 'GET', + path: '/tags', + }), +}); diff --git a/src/telnyx.ts b/src/telnyx.ts index 64ee5c7..e4cca98 100644 --- a/src/telnyx.ts +++ b/src/telnyx.ts @@ -29,10 +29,8 @@ import {Brands} from './resources/Brands'; import {BulkCredentials} from './resources/BulkCredentials'; import {BulkSoleProprietorCreation} from './resources/BulkSoleProprietorCreation'; import {BulkTelephonyCredentials} from './resources/BulkTelephonyCredentials'; -import {BusinessIdentity} from './resources/BusinessIdentity'; import {CallControlApplications} from './resources/CallControlApplications'; import {CallEvents} from './resources/CallEvents'; -import {CallInformation} from './resources/CallInformation'; import {CallRecordings} from './resources/CallRecordings'; import {Calls} from './resources/Calls'; import {Campaign} from './resources/Campaign'; @@ -43,7 +41,6 @@ import {ClientStateUpdate} from './resources/ClientStateUpdate'; import {Conferences} from './resources/Conferences'; import {Connections} from './resources/Connections'; import {CredentialConnections} from './resources/CredentialConnections'; -import {Credentials} from './resources/Credentials'; import {CsvDownloads} from './resources/CsvDownloads'; import {CustomerServiceRecord} from './resources/CustomerServiceRecord'; import {Debugging} from './resources/Debugging'; @@ -213,10 +210,8 @@ export function createTelnyx() { BulkCredentials, BulkSoleProprietorCreation, BulkTelephonyCredentials, - BusinessIdentity, CallControlApplications, CallEvents, - CallInformation, CallRecordings, Calls, Campaign, @@ -227,7 +222,6 @@ export function createTelnyx() { Conferences, Connections, CredentialConnections, - Credentials, CsvDownloads, CustomerServiceRecord, Debugging, diff --git a/src/test/resources/Conferences.test.ts b/src/test/resources/Conferences.test.ts index 76de361..b275da2 100644 --- a/src/test/resources/Conferences.test.ts +++ b/src/test/resources/Conferences.test.ts @@ -21,200 +21,198 @@ const CONFERENCES = [ 'stop', 'record_start', 'record_stop', + 'record_resume', + 'record_pause', 'update', 'leave', ]; const CONFERENCE_ID = '41b9acd4-f4da-4ff5-a85c-e07e90b53f46'; -describe('Calls Resource', function () { - describe('Call Conferences', function () { - const conferenceCreateData = { - name: 'Business', +describe('Call Conferences', function () { + const conferenceCreateData = { + name: 'Business', + call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', + }; + const callConferencesData = { + join: { call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', - }; - const callConferencesData = { - join: { - call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', - }, - unhold: { - call_control_ids: ['891510ac-f3e4-11e8-af5b-de00688a4901'], - }, - speak: { - language: 'en-US', - payload: 'Say this to participants', - voice: 'female', - }, - play: { - media_name: 'my_media_uploaded_to_media_storage_api', - }, - record_start: { - channels: 'single', - format: 'wav', - }, - update: { - call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', - supervisor_role: 'whisper', - }, - leave: { - call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', - }, - dial_participant: { - call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', - from: '+15555555555', - to: '+16666666666', - }, - }; + }, + unhold: { + call_control_ids: ['891510ac-f3e4-11e8-af5b-de00688a4901'], + }, + speak: { + language: 'en-US', + payload: 'Say this to participants', + voice: 'female', + }, + play: { + media_name: 'my_media_uploaded_to_media_storage_api', + }, + record_start: { + channels: 'single', + format: 'wav', + }, + update: { + call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', + supervisor_role: 'whisper', + }, + leave: { + call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', + }, + dial_participant: { + call_control_id: '891510ac-f3e4-11e8-af5b-de00688a4901', + from: '+15555555555', + to: '+16666666666', + }, + }; + + function responseFn(response: ResponsePayload) { + expect(response.data).toMatchObject({result: 'ok'}); + } + + describe('list', function () { + function responseFn(response: ResponsePayloadList) { + expect(response.data[0]).toHaveProperty('id'); + expect(response.data[0]).toHaveProperty('name'); + expect(response.data[0]).toMatchObject({record_type: 'conference'}); + } + + test('Sends the correct request', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences.list().then(responseFn); + }); + test('Sends the correct request [with specified auth]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences.list(TEST_AUTH_KEY).then(responseFn); + }); + }); + describe('retrieve', function () { function responseFn(response: ResponsePayload) { - expect(response.data).toMatchObject({result: 'ok'}); + expect(response.data).toHaveProperty('id'); + expect(response.data).toHaveProperty('name'); + expect(response.data).toMatchObject({record_type: 'conference'}); } - describe('list', function () { - function responseFn(response: ResponsePayloadList) { - expect(response.data[0]).toHaveProperty('id'); - expect(response.data[0]).toHaveProperty('name'); - expect(response.data[0]).toMatchObject({record_type: 'conference'}); - } + test('Sends the correct request', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences.retrieve(CONFERENCE_ID).then(responseFn); + }); + test('Sends the correct request [with specified auth]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences + .retrieve(CONFERENCE_ID, TEST_AUTH_KEY) + .then(responseFn); + }); + }); - test('Sends the correct request', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences.list().then(responseFn); - }); - test('Sends the correct request [with specified auth]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences.list(TEST_AUTH_KEY).then(responseFn); + describe('create', function () { + function responseFn(response: ResponsePayload) { + expect(response.data).toHaveProperty('id'); + expect(response.data).toHaveProperty('name'); + expect(response.data).toMatchObject({ + record_type: 'conference', }); + } + + test('Sends the correct request', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences.create(conferenceCreateData).then(responseFn); }); - describe('retrieve', function () { - function responseFn(response: ResponsePayload) { - expect(response.data).toHaveProperty('id'); - expect(response.data).toHaveProperty('name'); - expect(response.data).toMatchObject({record_type: 'conference'}); - } + test('Sends the correct request [with specified auth]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences + .create(conferenceCreateData, TEST_AUTH_KEY) + .then(responseFn); + }); + }); - test('Sends the correct request', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences.retrieve(CONFERENCE_ID).then(responseFn); - }); - test('Sends the correct request [with specified auth]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences - .retrieve(CONFERENCE_ID, TEST_AUTH_KEY) - .then(responseFn); + describe('participants', function () { + function responseFn(response: ResponsePayloadList) { + expect(response.data[0]).toMatchObject({ + record_type: 'participant', }); + expect(response.data[0]).toHaveProperty('conference'); + expect(response.data[0]).toHaveProperty('call_control_id'); + expect(response.data[0]).toHaveProperty('end_conference_on_exit'); + expect(response.data[0]).toHaveProperty('muted'); + expect(response.data[0]).toHaveProperty('on_hold'); + } + + test('Sends the correct request', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences + .participants(CONFERENCE_ID, {filter: {muted: true}}) + .then(responseFn); }); - describe('create', function () { - function responseFn(response: ResponsePayload) { - expect(response.data).toHaveProperty('id'); - expect(response.data).toHaveProperty('name'); - expect(response.data).toMatchObject({ - record_type: 'conference', - }); - } + test('Sends the correct request [with specified auth]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + return telnyx.conferences + .participants(CONFERENCE_ID, TEST_AUTH_KEY) + .then(responseFn); + }); + }); - test('Sends the correct request', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences.create(conferenceCreateData).then(responseFn); - }); + CONFERENCES.forEach(function (action) { + describe(action, function () { + let telnyxInstance: TelnyxObject; - test('Sends the correct request [with specified auth]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences - .create(conferenceCreateData, TEST_AUTH_KEY) - .then(responseFn); + beforeEach(() => { + // make specs independent + telnyxInstance = testUtils.getTelnyxMock(); }); - }); - - describe('participants', function () { - function responseFn(response: ResponsePayloadList) { - expect(response.data[0]).toMatchObject({ - record_type: 'participant', - }); - expect(response.data[0]).toHaveProperty('conference'); - expect(response.data[0]).toHaveProperty('call_control_id'); - expect(response.data[0]).toHaveProperty('end_conference_on_exit'); - expect(response.data[0]).toHaveProperty('muted'); - expect(response.data[0]).toHaveProperty('on_hold'); - } test('Sends the correct request', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences - .participants(CONFERENCE_ID, {filter: {muted: true}}) - .then(responseFn); + return telnyxInstance.conferences + .create(conferenceCreateData) + .then(function (response: ResponsePayload) { + const conference = response.data; + // // @ts-expect-error TODO: import .d.ts files under src/test folder + return conference[action]( + callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse + ).then(responseFn); + }); }); - test('Sends the correct request [with specified auth]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.conferences - .participants(CONFERENCE_ID, TEST_AUTH_KEY) - .then(responseFn); - }); - }); - - CONFERENCES.forEach(function (action) { - describe(action, function () { - let telnyxInstance: TelnyxObject; - - beforeEach(() => { - // make specs independent - telnyxInstance = testUtils.getTelnyxMock(); - }); - - test('Sends the correct request', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyxInstance.conferences - .create(conferenceCreateData) - .then(function (response: ResponsePayload) { - const conference = response.data; + return telnyxInstance.conferences + .create(conferenceCreateData) + .then(function (response: ResponsePayload) { + const conference = response.data; + return conference[action]( // // @ts-expect-error TODO: import .d.ts files under src/test folder - return conference[action]( - callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse - ).then(responseFn); - }); - }); - test('Sends the correct request [with specified auth]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyxInstance.conferences - .create(conferenceCreateData) - .then(function (response: ResponsePayload) { - const conference = response.data; - return conference[action]( - // // @ts-expect-error TODO: import .d.ts files under src/test folder - callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse - TEST_AUTH_KEY, - ).then(responseFn); - }); - }); - - test('Sends the correct request [with empty resource instance]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - const conference = new telnyxInstance.Conference({ - id: '891510ac-f3e4-11e8-af5b-de00688a4901', + callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse + TEST_AUTH_KEY, + ).then(responseFn); }); + }); - return conference[action]( - callConferencesData[action] || {'': ''}, - ).then( - // need to pass string due to telnyx mock parse - responseFn, - ); + test('Sends the correct request [with empty resource instance]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + const conference = new telnyxInstance.Conference({ + id: '891510ac-f3e4-11e8-af5b-de00688a4901', }); - test('Sends the correct request [with empty resource instance and specified auth]', function () { - // @ts-expect-error TODO: import .d.ts files under src/test folder - const conference = new telnyxInstance.Conference({ - id: '891510ac-f3e4-11e8-af5b-de00688a4901', - }); - return conference[action]( - // // @ts-expect-error TODO: import .d.ts files under src/test folder - callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse - TEST_AUTH_KEY, - ).then(responseFn); + return conference[action](callConferencesData[action] || {'': ''}).then( + // need to pass string due to telnyx mock parse + responseFn, + ); + }); + test('Sends the correct request [with empty resource instance and specified auth]', function () { + // @ts-expect-error TODO: import .d.ts files under src/test folder + const conference = new telnyxInstance.Conference({ + id: '891510ac-f3e4-11e8-af5b-de00688a4901', }); + + return conference[action]( + // // @ts-expect-error TODO: import .d.ts files under src/test folder + callConferencesData[action] || {'': ''}, // need to pass string due to telnyx mock parse + TEST_AUTH_KEY, + ).then(responseFn); }); }); }); diff --git a/src/test/resources/Documents.test.ts b/src/test/resources/Documents.test.ts index e9aa698..a465275 100644 --- a/src/test/resources/Documents.test.ts +++ b/src/test/resources/Documents.test.ts @@ -77,13 +77,13 @@ describe('Documents', function () { } test('Sends the correct request', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.documents.retrieveDocumentId(TEST_UUID).then(responseFn); + return telnyx.documents.retrieve(TEST_UUID).then(responseFn); }); test('Sends the correct request [with specified auth]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder return telnyx.documents - .retrieveDocumentId(TEST_UUID, TEST_AUTH_KEY) + .retrieve(TEST_UUID, TEST_AUTH_KEY) .then(responseFn); }); }); @@ -93,15 +93,13 @@ describe('Documents', function () { } test('Sends the correct request', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.documents - .retrieveDownloadDocument(TEST_UUID) - .then(responseFn); + return telnyx.documents.download(TEST_UUID).then(responseFn); }); test('Sends the correct request [with specified auth]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder return telnyx.documents - .retrieveDownloadDocument(TEST_UUID, TEST_AUTH_KEY) + .download(TEST_UUID, TEST_AUTH_KEY) .then(responseFn); }); }); diff --git a/src/test/resources/TelephonyCredentials.test.ts b/src/test/resources/TelephonyCredentials.test.ts index fcc9543..7f3f7be 100644 --- a/src/test/resources/TelephonyCredentials.test.ts +++ b/src/test/resources/TelephonyCredentials.test.ts @@ -50,10 +50,6 @@ describe('TelephonyCredentials Resource', function () { }); describe('retrieve', function () { - function responseFn(response: ResponsePayload) { - expect(response.data).not.toBeNull(); - } - describe('retrieve', function () { test('Sends the correct request', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder @@ -71,25 +67,29 @@ describe('TelephonyCredentials Resource', function () { }); }); - describe('retrieveCredential', function () { + describe('createToken', function () { + function responseFn(response: ResponsePayload) { + expect(response.data).not.toBeNull(); + } + test('Sends the correct request', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder return telnyx.telephonyCredentials - .retrieveCredential(retrieveCredentialId) + .createToken(retrieveCredentialId) .then(responseFn); }); test('Sends the correct request [with specified auth]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder return telnyx.telephonyCredentials - .retrieveCredential(retrieveCredentialId, TEST_AUTH_KEY) + .createToken(retrieveCredentialId, TEST_AUTH_KEY) .then(responseFn); }); test('Sends the correct request [with specified auth in options]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder return telnyx.telephonyCredentials - .retrieveCredential(retrieveCredentialId, {api_key: TEST_AUTH_KEY}) + .createToken(retrieveCredentialId, {api_key: TEST_AUTH_KEY}) .then(responseFn); }); }); @@ -156,13 +156,13 @@ describe('TelephonyCredentials Resource', function () { }); test('Sends the correct request [with specified auth]', function () { // @ts-expect-error TODO: import .d.ts files under src/test folder - return telnyx.telephonyCredentials - .retrieveCredential('123') - .then(function (response: ResponsePayload) { - const tc = response.data; - // @ts-expect-error TODO: import .d.ts files under src/test folder - return tc.del(TEST_AUTH_KEY).then(responseFn); - }); + return telnyx.telephonyCredentials.retrieve('123').then(function ( + response: ResponsePayload, + ) { + const tc = response.data; + // @ts-expect-error TODO: import .d.ts files under src/test folder + return tc.del(TEST_AUTH_KEY).then(responseFn); + }); }); }); }); diff --git a/types/AuthenticationProvidersResource.d.ts b/types/AuthenticationProvidersResource.d.ts new file mode 100644 index 0000000..a14c1fd --- /dev/null +++ b/types/AuthenticationProvidersResource.d.ts @@ -0,0 +1,72 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type AuthenticationProvidersListParams = + paths['/authentication_providers']['get']['parameters']['query']; + + type AuthenticationProvidersListResponse = + paths['/authentication_providers']['get']['responses']['200']['content']['application/json']; + + type AuthenticationProvidersCreateParams = + paths['/authentication_providers']['post']['requestBody']['content']['application/json']; + + type AuthenticationProvidersCreateResponse = + paths['/authentication_providers']['post']['responses']['200']['content']['application/json']; + + type AuthenticationProvidersRetrieveId = + paths['/authentication_providers/{id}']['get']['parameters']['path']['id']; + + type AuthenticationProvidersRetrieveParams = + paths['/authentication_providers/{id}']['get']['parameters']['query']; + + type AuthenticationProvidersRetrieveResponse = + paths['/authentication_providers/{id}']['get']['responses']['200']['content']['application/json']; + type AuthenticationProvidersUpdateId = + paths['/authentication_providers/{id}']['patch']['parameters']['path']['id']; + + type AuthenticationProvidersUpdateParams = + paths['/authentication_providers/{id}']['patch']['requestBody']['content']['application/json']; + + type AuthenticationProvidersUpdateResponse = + paths['/authentication_providers/{id}']['patch']['responses']['200']['content']['application/json']; + type AuthenticationProvidersDelId = + paths['/authentication_providers/{id}']['delete']['parameters']['path']['id']; + + type AuthenticationProvidersDelParams = + paths['/authentication_providers/{id}']['delete']['parameters']['query']; + + type AuthenticationProvidersDelResponse = + paths['/authentication_providers/{id}']['delete']['responses']['200']['content']['application/json']; + + class AuthenticationProvidersResource { + list( + params?: AuthenticationProvidersListParams, + options?: RequestOptions, + ): Promise>; + + create( + params: AuthenticationProvidersCreateParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: AuthenticationProvidersRetrieveId, + options?: RequestOptions, + ): Promise< + Telnyx.Response + >; + + update( + id: AuthenticationProvidersUpdateId, + params: AuthenticationProvidersUpdateParams, + options?: RequestOptions, + ): Promise>; + + del( + id: AuthenticationProvidersDelId, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/BrandsResource.d.ts b/types/BrandsResource.d.ts index 2ca6685..5bad56c 100644 --- a/types/BrandsResource.d.ts +++ b/types/BrandsResource.d.ts @@ -55,18 +55,27 @@ declare module 'telnyx' { type BrandsExportExternalVettingsPathParams = paths['/brand/{brandId}/externalVetting']['put']['parameters']['path']; + type BrandsExportExternalVettingsParams = + paths['/brand/{brandId}/externalVetting']['put']['requestBody']['content']['application/json']; + type BrandsExportExternalVettingsResponse = paths['/brand/{brandId}/externalVetting']['put']['responses']['200']['content']['application/json']; type BrandsOrderExternalVettingsPathParams = paths['/brand/{brandId}/externalVetting']['post']['parameters']['path']; + type BrandsOrderExternalVettingsParams = + paths['/brand/{brandId}/externalVetting']['post']['requestBody']['content']['application/json']; + type BrandsOrderExternalVettingsResponse = paths['/brand/{brandId}/externalVetting']['post']['responses']['200']['content']['application/json']; type BrandsRevetPathParams = paths['/brand/{brandId}/revet']['put']['parameters']['path']; + type BrandsRevetParams = + paths['/brand/{brandId}/externalVetting']['put']['requestBody']['content']['application/json']; + type BrandsRevetResponse = paths['/brand/{brandId}/revet']['put']['responses']['200']['content']['application/json']; @@ -108,11 +117,6 @@ declare module 'telnyx' { options?: RequestOptions, ): Promise>; - externalVettings( - params?: BrandsListExternalVettingsPathParams, - options?: RequestOptions, - ): Promise>; - listExternalVettings( pathParams: BrandsListExternalVettingsPathParams, options?: RequestOptions, @@ -120,16 +124,19 @@ declare module 'telnyx' { exportExternalVettings( pathParams: BrandsExportExternalVettingsPathParams, + params: BrandsExportExternalVettingsParams, options?: RequestOptions, ): Promise>; orderExternalVettings( pathParams: BrandsOrderExternalVettingsPathParams, + params: BrandsOrderExternalVettingsParams, options?: RequestOptions, ): Promise>; revet( pathParams: BrandsRevetPathParams, + params: BrandsRevetParams, options?: RequestOptions, ): Promise>; diff --git a/types/CallControlApplicationsResource.d.ts b/types/CallControlApplicationsResource.d.ts new file mode 100644 index 0000000..31292ce --- /dev/null +++ b/types/CallControlApplicationsResource.d.ts @@ -0,0 +1,93 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type CallControlApplicationsListParams = + paths['/call_control_applications']['get']['parameters']['query']; + + type CallControlApplicationsListResponse = + paths['/call_control_applications']['get']['responses']['200']['content']['application/json']; + + type CallControlApplicationsCreateParams = + paths['/call_control_applications']['post']['requestBody']['content']['application/json']; + + type CallControlApplicationsCreateResponse = + paths['/call_control_applications']['post']['responses']['201']['content']['application/json']; + + type CallControlApplicationsRetrieveId = + paths['/call_control_applications/{id}']['get']['parameters']['path']['id']; + + type CallControlApplicationsRetrieveParams = + paths['/call_control_applications/{id}']['get']['parameters']['query']; + + type CallControlApplicationsRetrieveResponse = + paths['/call_control_applications/{id}']['get']['responses']['200']['content']['application/json']; + + type CallControlApplicationsUpdateId = + paths['/call_control_applications/{id}']['patch']['parameters']['path']['id']; + + type CallControlApplicationsUpdateParams = + paths['/call_control_applications/{id}']['patch']['requestBody']['content']['application/json']; + + type CallControlApplicationsUpdateResponse = + paths['/call_control_applications/{id}']['patch']['responses']['200']['content']['application/json']; + + type CallControlApplicationsDelId = + paths['/call_control_applications/{id}']['delete']['parameters']['path']['id']; + + type CallControlApplicationsDelParams = + paths['/call_control_applications/{id}']['delete']['parameters']['query']; + + type CallControlApplicationsDelResponse = + paths['/call_control_applications/{id}']['delete']['responses']['200']['content']['application/json']; + + type CallControlApplicationsNestedMethods = { + create: MessagingProfilesResource['create']; + del: MessagingProfilesResource['del']; + }; + + class CallControlApplicationsResource { + list( + params?: CallControlApplicationsListParams, + options?: RequestOptions, + ): Promise>; + + create( + params: CallControlApplicationsCreateParams, + options?: RequestOptions, + ): Promise< + Telnyx.Response< + Telnyx.CallControlApplicationsCreateResponse & + NestedResponseData< + CallControlApplicationsCreateResponse['data'], + CallControlApplicationsNestedMethods + > + > + >; + + retrieve( + id: CallControlApplicationsRetrieveId, + options?: RequestOptions, + ): Promise< + Telnyx.Response< + Telnyx.CallControlApplicationsCreateResponse & + NestedResponseData< + CallControlApplicationsCreateResponse['data'], + CallControlApplicationsNestedMethods + > + > + >; + + update( + id: CallControlApplicationsUpdateId, + params: CallControlApplicationsUpdateParams, + options?: RequestOptions, + ): Promise>; + + del( + id: CallControlApplicationsDelId, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/CallEventsResource.d.ts b/types/CallEventsResource.d.ts new file mode 100644 index 0000000..30cc384 --- /dev/null +++ b/types/CallEventsResource.d.ts @@ -0,0 +1,18 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type CallEventsListParams = + paths['/call_events']['get']['parameters']['query']; + + type CallEventsListResponse = + paths['/call_events']['get']['responses']['200']['content']['application/json']; + + class CallEventsResource { + list( + params?: CallEventsListParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/CallRecordingsResource.d.ts b/types/CallRecordingsResource.d.ts new file mode 100644 index 0000000..960396e --- /dev/null +++ b/types/CallRecordingsResource.d.ts @@ -0,0 +1,59 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type CallRecordingsListParams = + paths['/recordings']['get']['parameters']['query']; + + type CallRecordingsListResponse = + paths['/recordings']['get']['responses']['200']['content']['application/json']; + + type CallRecordingsRetrieveId = + paths['/recordings/{recording_id}']['get']['parameters']['path']['recording_id']; + + type CallRecordingsRetrieveParams = + paths['/recordings/{recording_id}']['get']['parameters']['query']; + + type CallRecordingsRetrieveResponse = + paths['/recordings/{recording_id}']['get']['responses']['200']['content']['application/json']; + + type CallRecordingsDelId = + paths['/recordings/{recording_id}']['delete']['parameters']['path']['recording_id']; + + type CallRecordingsDelResponse = + paths['/recordings/{recording_id}']['delete']['responses']['200']['content']['application/json']; + + type CallRecordingsBulkDelParams = + paths['/recordings/actions/delete']['delete']['requestBody']['content']['application/json']; + + type CallRecordingsBulkDelResponse = + paths['/recordings/actions/delete']['delete']['responses']['204']['content']; + + class CallRecordingsResource { + list( + params?: CallRecordingsListParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: CallRecordingsRetrieveId, + options?: RequestOptions, + ): Promise>; + + del( + id: CallRecordingsDelId, + options?: RequestOptions, + ): Promise>; + + del( + id: CallRecordingsDelId, + options?: RequestOptions, + ): Promise>; + + bulkDel( + params?: CallRecordingsBulkDelParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/CdrUsageReportsResource.d.ts b/types/CdrUsageReportsResource.d.ts new file mode 100644 index 0000000..cd4e0a2 --- /dev/null +++ b/types/CdrUsageReportsResource.d.ts @@ -0,0 +1,18 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type CdrUsageReportsSyncParams = + paths['/reports/cdr_usage_reports/sync']['get']['parameters']['query']; + + type CdrUsageReportsSyncResponse = + paths['/reports/cdr_usage_reports/sync']['get']['responses']['200']['content']['application/json']; + + class CdrUsageReportsResource { + retrieveUsageReportSync( + params?: CdrUsageReportsSyncParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/ChannelzonesResource.d.ts b/types/ChannelzonesResource.d.ts new file mode 100644 index 0000000..b4e7e65 --- /dev/null +++ b/types/ChannelzonesResource.d.ts @@ -0,0 +1,92 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type ChannelzonesListParams = + paths['/channel_zones']['get']['parameters']['query']; + + type ChannelzonesListResponse = + paths['/channel_zones']['get']['responses']['200']['content']['application/json']; + + type ChannelzonesUpdateId = + paths['/channel_zones/{channel_zone_id}']['patch']['parameters']['path']['channel_zone_id']; + + type ChannelzonesUpdateParams = + paths['/channel_zones/{channel_zone_id}']['patch']['requestBody']['content']['application/json']; + + type ChannelzonesUpdateResponse = + paths['/channel_zones/{channel_zone_id}']['patch']['responses']['200']['content']['application/json']; + + type ChannelzonesRetrieveId = + paths['/channel_zones/{channel_zone_id}']['get']['parameters']['path']['channel_zone_id']; + + type ChannelzonesRetrieveParams = + paths['/channel_zones/{channel_zone_id}']['get']['parameters']['query']; + + type ChannelzonesRetrieveResponse = + paths['/channel_zones/{channel_zone_id}']['get']['responses']['200']['content']['application/json']; + + type ChannelzonesPhoneNumbersListId = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['parameters']['path']['channel_zone_id']; + + type ChannelzonesPhoneNumbersListParams = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['parameters']['query']; + + type ChannelzonesPhoneNumbersListResponse = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['get']['responses']['200']['content']['application/json']; + + type ChannelzonesPhoneNumbersCreatePathParams = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['parameters']['path']; + + type ChannelzonesPhoneNumbersCreateParams = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['requestBody']['content']['application/json']; + + type ChannelzonesPhoneNumbersCreateResponse = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers']['post']['responses']['200']['content']['application/json']; + + type ChannelzonesPhoneNumbersDeletePathParams = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}']['delete']['parameters']['path']; + + type ChannelzonesPhoneNumbersDeleteResponse = + paths['/channel_zones/{channel_zone_id}/channel_zone_phone_numbers/{phone_number}']['delete']['responses']['200']['content']; + + class ChannelzonesResource { + list( + params?: ChannelzonesListParams, + options?: RequestOptions, + ): Promise>; + + update( + id: ChannelzonesUpdateId, + params: ChannelzonesUpdateParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: ChannelzonesRetrieveId, + options?: RequestOptions, + ): Promise>; + + listPhoneNumbers( + id: ChannelzonesPhoneNumbersListId, + params?: ChannelzonesPhoneNumbersListParams, + options?: RequestOptions, + ): Promise>; + + createPhoneNumber( + pathParams: ChannelzonesPhoneNumbersCreatePathParams, + params: ChannelzonesPhoneNumbersCreateParams, + options?: RequestOptions, + ): Promise< + Telnyx.Response + >; + + delPhoneNumber( + pathParams: ChannelzonesPhoneNumbersDeletePathParams, + options?: RequestOptions, + ): Promise< + Telnyx.Response + >; + } + } +} diff --git a/types/ConferencesResource.d.ts b/types/ConferencesResource.d.ts new file mode 100644 index 0000000..c1d6a06 --- /dev/null +++ b/types/ConferencesResource.d.ts @@ -0,0 +1,202 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type ConferencesListParams = + paths['/conferences']['get']['parameters']['query']; + + type ConferencesListResponse = + paths['/conferences']['get']['responses']['200']['content']['application/json']; + + type ConferencesRetrieveId = + paths['/conferences/{id}']['get']['parameters']['path']['id']; + + type ConferencesRetrieveParams = + paths['/conferences/{id}']['get']['parameters']['query']; + + type ConferencesRetrieveResponse = + paths['/conferences/{id}']['get']['responses']['200']['content']['application/json']; + + type ConferencesCreateParams = + paths['/conferences']['post']['requestBody']['content']['application/json']; + + type ConferencesCreateResponse = + paths['/conferences']['post']['responses']['200']['content']['application/json']; + + type ConferencesJoinParams = + paths['/conferences/{id}/actions/join']['post']['requestBody']['content']['application/json']; + type ConferencesMuteParams = + paths['/conferences/{id}/actions/mute']['post']['responses']['200']['content']['application/json']; + type ConferencesUnmuteParams = + paths['/conferences/{id}/actions/unmute']['post']['responses']['200']['content']['application/json']; + type ConferencesHoldParams = + paths['/conferences/{id}/actions/hold']['post']['responses']['200']['content']['application/json']; + type ConferencesUnholdParams = + paths['/conferences/{id}/actions/unhold']['post']['responses']['200']['content']['application/json']; + type ConferencesSpeakParams = + paths['/conferences/{id}/actions/speak']['post']['responses']['200']['content']['application/json']; + type ConferencesPlayParams = + paths['/conferences/{id}/actions/play']['post']['responses']['200']['content']['application/json']; + type ConferencesStopParams = + paths['/conferences/{id}/actions/stop']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordStartParams = + paths['/conferences/{id}/actions/record_start']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordStopParams = + paths['/conferences/{id}/actions/record_stop']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordResumeParams = + paths['/conferences/{id}/actions/record_resume']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordPauseParams = + paths['/conferences/{id}/actions/record_pause']['post']['responses']['200']['content']['application/json']; + type ConferencesUpdateParams = + paths['/conferences/{id}/actions/update']['post']['responses']['200']['content']['application/json']; + type ConferencesLeaveParams = + paths['/conferences/{id}/actions/leave']['post']['responses']['200']['content']['application/json']; + + type ConferencesJoinResponse = + paths['/conferences/{id}/actions/join']['post']['responses']['200']['content']['application/json']; + type ConferencesMuteResponse = + paths['/conferences/{id}/actions/mute']['post']['responses']['200']['content']['application/json']; + type ConferencesUnmuteResponse = + paths['/conferences/{id}/actions/unmute']['post']['responses']['200']['content']['application/json']; + type ConferencesHoldResponse = + paths['/conferences/{id}/actions/hold']['post']['responses']['200']['content']['application/json']; + type ConferencesUnholdResponse = + paths['/conferences/{id}/actions/unhold']['post']['responses']['200']['content']['application/json']; + type ConferencesSpeakResponse = + paths['/conferences/{id}/actions/speak']['post']['responses']['200']['content']['application/json']; + type ConferencesPlayResponse = + paths['/conferences/{id}/actions/play']['post']['responses']['200']['content']['application/json']; + type ConferencesStopResponse = + paths['/conferences/{id}/actions/stop']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordStartResponse = + paths['/conferences/{id}/actions/record_start']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordStopResponse = + paths['/conferences/{id}/actions/record_stop']['post']['responses']['200']['content']['application/json']; + type ConferencesUpdateResponse = + paths['/conferences/{id}/actions/update']['post']['responses']['200']['content']['application/json']; + type ConferencesLeaveResponse = + paths['/conferences/{id}/actions/leave']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordResumeResponse = + paths['/conferences/{id}/actions/record_resume']['post']['responses']['200']['content']['application/json']; + type ConferencesRecordPauseResponse = + paths['/conferences/{id}/actions/record_pause']['post']['responses']['200']['content']['application/json']; + + type ConferencesParticipantsId = + paths['/conferences/{conference_id}/participants']['get']['parameters']['path']['conference_id']; + + type ConferencesParticipantsParams = + paths['/conferences/{conference_id}/participants']['get']['parameters']['query']; + + type ConferencesParticipantsResponse = + paths['/conferences/{id}']['get']['responses']['200']['content']['application/json']; + + type ConferencesNestedMethods = { + join: ConferencesResource['join']; + mute: ConferencesResource['mute']; + unmute: ConferencesResource['unmute']; + hold: ConferencesResource['hold']; + unhold: ConferencesResource['unhold']; + speak: ConferencesResource['speak']; + play: ConferencesResource['play']; + stop: ConferencesResource['stop']; + recordStart: ConferencesResource['recordStart']; + recordStop: ConferencesResource['recordStop']; + update: ConferencesResource['update']; + leave: ConferencesResource['leave']; + recordResume: ConferencesResource['recordResume']; + recordPause: ConferencesResource['recordPause']; + }; + + class ConferencesResource { + list( + params?: ConferencesListParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: ConferencesRetrieveId, + options?: RequestOptions, + ): Promise< + Telnyx.Response & + NestedResponseData< + ConferencesRetrieveResponse['data'], + ConferencesNestedMethods + > + >; + + create( + params: ConferencesCreateParams, + options?: RequestOptions, + ): Promise< + Telnyx.Response & + NestedResponseData< + ConferencesCreateResponse['data'], + ConferencesNestedMethods + > + >; + + join( + params: ConferencesJoinParams, + options?: RequestOptions, + ): Promise>; + mute( + params: ConferencesMuteParams, + options?: RequestOptions, + ): Promise>; + unmute( + params: ConferencesUnmuteParams, + options?: RequestOptions, + ): Promise>; + hold( + params: ConferencesHoldParams, + options?: RequestOptions, + ): Promise>; + unhold( + params: ConferencesUnholdParams, + options?: RequestOptions, + ): Promise>; + speak( + params: ConferencesSpeakParams, + options?: RequestOptions, + ): Promise>; + play( + params: ConferencesPlayParams, + options?: RequestOptions, + ): Promise>; + stop( + params: ConferencesStopParams, + options?: RequestOptions, + ): Promise>; + recordStart( + params: ConferencesRecordStartParams, + options?: RequestOptions, + ): Promise>; + recordStop( + params: ConferencesRecordStopParams, + options?: RequestOptions, + ): Promise>; + update( + params: ConferencesUpdateParams, + options?: RequestOptions, + ): Promise>; + leave( + params: ConferencesLeaveParams, + options?: RequestOptions, + ): Promise>; + recordResume( + params: ConferencesRecordResumeParams, + options?: RequestOptions, + ): Promise>; + recordPause( + params: ConferencesRecordPauseParams, + options?: RequestOptions, + ): Promise>; + + participants( + id: ConferencesParticipantsId, + params: ConferencesParticipantsParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/ConnectionsResource.d.ts b/types/ConnectionsResource.d.ts new file mode 100644 index 0000000..c18622a --- /dev/null +++ b/types/ConnectionsResource.d.ts @@ -0,0 +1,44 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type ConnectionsListParams = + paths['/connections']['get']['parameters']['query']; + + type ConnectionsListResponse = + paths['/connections']['get']['responses']['200']['content']['application/json']; + + type ConnectionsRetrieveId = + paths['/connections/{id}']['get']['parameters']['path']['id']; + + type ConnectionsRetrieveResponse = + paths['/connections/{id}']['get']['responses']['200']['content']['application/json']; + + type ConnectionsListActiveCallsId = + paths['/connections/{connection_id}/active_calls']['get']['parameters']['path']['connection_id']; + + type ConnectionsListActiveCallsParams = + paths['/connections/{connection_id}/active_calls']['get']['parameters']['query']; + + type ConnectionsListActiveCallsResponse = + paths['/connections/{connection_id}/active_calls']['get']['responses']['200']['content']['application/json']; + + class ConnectionsResource { + list( + params?: ConnectionsListParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: ConnectionsRetrieveId, + options?: RequestOptions, + ): Promise>; + + listActiveCalls( + id: ConnectionsListActiveCallsId, + params?: ConnectionsListActiveCallsParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/CredentialConnectionsResource.d.ts b/types/CredentialConnectionsResource.d.ts new file mode 100644 index 0000000..e7d2133 --- /dev/null +++ b/types/CredentialConnectionsResource.d.ts @@ -0,0 +1,69 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type CredentialConnectionsListParams = + paths['/credential_connections']['get']['parameters']['query']; + + type CredentialConnectionsListResponse = + paths['/credential_connections']['get']['responses']['200']['content']['application/json']; + + type CredentialConnectionsCreateParams = + paths['/credential_connections']['post']['requestBody']['content']['application/json']; + + type CredentialConnectionsCreateResponse = + paths['/credential_connections']['post']['responses']['201']['content']['application/json']; + + type CredentialConnectionsRetrieveId = + paths['/credential_connections/{id}']['get']['parameters']['path']['id']; + + type CredentialConnectionsRetrieveResponse = + paths['/credential_connections/{id}']['get']['responses']['200']['content']['application/json']; + + type CredentialConnectionsUpdateId = + paths['/credential_connections/{id}']['patch']['parameters']['path']['id']; + + type CredentialConnectionsUpdateParams = + paths['/credential_connections/{id}']['patch']['requestBody']['content']['application/json']; + + type CredentialConnectionsUpdateResponse = + paths['/credential_connections/{id}']['patch']['responses']['200']['content']['application/json']; + + type CredentialConnectionsDelId = + paths['/credential_connections/{id}']['delete']['parameters']['path']['id']; + + type CredentialConnectionsDelParams = + paths['/credential_connections/{id}']['delete']['parameters']['query']; + + type CredentialConnectionsDelResponse = + paths['/credential_connections/{id}']['delete']['responses']['200']['content']['application/json']; + + class CredentialConnectionsResource { + list( + params?: CredentialConnectionsListParams, + options?: RequestOptions, + ): Promise>; + + create( + params: CredentialConnectionsCreateParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: CredentialConnectionsRetrieveId, + options?: RequestOptions, + ): Promise>; + + update( + id: CredentialConnectionsUpdateId, + params: CredentialConnectionsUpdateParams, + options?: RequestOptions, + ): Promise>; + + del( + id: CredentialConnectionsDelId, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/DocumentLinksResource.d.ts b/types/DocumentLinksResource.d.ts new file mode 100644 index 0000000..5adf01f --- /dev/null +++ b/types/DocumentLinksResource.d.ts @@ -0,0 +1,18 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type DocumentLinksListParams = + paths['/document_links']['get']['parameters']['query']; + + type DocumentLinksListResponse = + paths['/document_links']['get']['responses']['200']['content']['application/json']; + + class DocumentLinksResource { + list( + params?: DocumentLinksListParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/DocumentsResource.d.ts b/types/DocumentsResource.d.ts new file mode 100644 index 0000000..b6519e1 --- /dev/null +++ b/types/DocumentsResource.d.ts @@ -0,0 +1,80 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type DocumentsListParams = + paths['/documents']['get']['parameters']['query']; + + type DocumentsListResponse = + paths['/documents']['get']['responses']['200']['content']['application/json']; + + type DocumentsCreateParams = + paths['/documents']['post']['requestBody']['content']['application/json']; + + type DocumentsCreateResponse = + paths['/documents']['post']['responses']['200']['content']['application/json']; + + type DocumentsRetrieveId = + paths['/documents/{id}']['get']['parameters']['path']['id']; + + type DocumentsRetrieveResponse = + paths['/documents/{id}']['get']['responses']['200']['content']['application/json']; + + type DocumentsUpdateId = + paths['/documents/{id}']['patch']['parameters']['path']['id']; + + type DocumentsUpdateParams = + paths['/documents/{id}']['patch']['requestBody']['content']['application/json']; + + type DocumentsUpdateResponse = + paths['/documents/{id}']['patch']['responses']['200']['content']['application/json']; + + type DocumentsDelId = + paths['/documents/{id}']['delete']['parameters']['path']['id']; + + type DocumentsDelParams = + paths['/documents/{id}']['delete']['parameters']['query']; + + type DocumentsDelResponse = + paths['/documents/{id}']['delete']['responses']['200']['content']['application/json']; + + type DocumentsDownloadId = + paths['/documents/{id}/download']['get']['parameters']['path']['id']; + + type DocumentsDownloadResponse = + paths['/documents/{id}/download']['get']['responses']['200']['content']['*']; + + class DocumentsResource { + list( + params?: DocumentsListParams, + options?: RequestOptions, + ): Promise>; + + create( + params: DocumentsCreateParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: DocumentsRetrieveId, + options?: RequestOptions, + ): Promise>; + + update( + id: DocumentsUpdateId, + params: DocumentsUpdateParams, + options?: RequestOptions, + ): Promise>; + + del( + id: DocumentsDelId, + options?: RequestOptions, + ): Promise>; + + download( + id: DocumentsDownloadId, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/TelephonyCredentialsResource.d.ts b/types/TelephonyCredentialsResource.d.ts new file mode 100644 index 0000000..a839f4f --- /dev/null +++ b/types/TelephonyCredentialsResource.d.ts @@ -0,0 +1,99 @@ +import {paths} from './TelnyxAPI.js'; + +declare module 'telnyx' { + namespace Telnyx { + type TelephonyCredentialsListParams = + paths['/telephony_credentials']['get']['parameters']['query']; + + type TelephonyCredentialsListResponse = + paths['/telephony_credentials']['get']['responses']['200']['content']['application/json']; + + type TelephonyCredentialsCreateParams = + paths['/telephony_credentials']['post']['requestBody']['content']['application/json']; + + type TelephonyCredentialsCreateResponse = + paths['/telephony_credentials']['post']['responses']['201']['content']['application/json']; + + type TelephonyCredentialsRetrieveId = + paths['/telephony_credentials/{id}']['get']['parameters']['path']['id']; + + type TelephonyCredentialsRetrieveParams = + paths['/telephony_credentials/{id}']['get']['parameters']['query']; + + type TelephonyCredentialsRetrieveResponse = + paths['/telephony_credentials/{id}']['get']['responses']['200']['content']['application/json']; + + type TelephonyCredentialsUpdateId = + paths['/telephony_credentials/{id}']['patch']['parameters']['path']['id']; + + type TelephonyCredentialsUpdateParams = + paths['/telephony_credentials/{id}']['patch']['requestBody']['content']['application/json']; + + type TelephonyCredentialsUpdateResponse = + paths['/telephony_credentials/{id}']['patch']['responses']['200']['content']['application/json']; + + type TelephonyCredentialsDelId = + paths['/telephony_credentials/{id}']['delete']['parameters']['path']['id']; + + type TelephonyCredentialsDelParams = + paths['/telephony_credentials/{id}']['delete']['parameters']['query']; + + type TelephonyCredentialsDelResponse = + paths['/telephony_credentials/{id}']['delete']['responses']['200']['content']['application/json']; + + type TelephonyCredentialsCreateTokenId = + paths['/telephony_credentials/{id}/token']['post']['parameters']['path']['id']; + + type TelephonyCredentialsCreateTokenParams = + paths['/telephony_credentials/{id}/token']['post']['requestBody']; + + type TelephonyCredentialsCreateTokenResponse = + paths['/telephony_credentials/{id}/token']['post']['responses']['201']['content']['text/plain']; + + type TelephonyCredentialsListTagsParams = + paths['/telephony_credentials/tags']['get']['parameters']['query']; + + type TelephonyCredentialsListTagsResponse = + paths['/telephony_credentials/tags']['get']['responses']['200']['content']['application/json']; + + class TelephonyCredentialsResource { + list( + params?: TelephonyCredentialsListParams, + options?: RequestOptions, + ): Promise>; + + create( + params: TelephonyCredentialsCreateParams, + options?: RequestOptions, + ): Promise>; + + retrieve( + id: TelephonyCredentialsRetrieveId, + options?: RequestOptions, + ): Promise>; + + update( + id: TelephonyCredentialsUpdateId, + params: TelephonyCredentialsUpdateParams, + options?: RequestOptions, + ): Promise>; + + del( + id: TelephonyCredentialsDelId, + options?: RequestOptions, + ): Promise>; + + createToken( + id: TelephonyCredentialsCreateTokenId, + options?: RequestOptions, + ): Promise< + Telnyx.Response + >; + + listTags( + params?: TelephonyCredentialsListTagsParams, + options?: RequestOptions, + ): Promise>; + } + } +} diff --git a/types/TelnyxAPI.d.ts b/types/TelnyxAPI.d.ts index 311d6e8..46f666c 100644 --- a/types/TelnyxAPI.d.ts +++ b/types/TelnyxAPI.d.ts @@ -60827,7 +60827,7 @@ export interface operations { [name: string]: unknown; }; content: { - 'application/json': components['schemas']['MdrGetSyncUsageReportResponse']; + 'application/json': components['schemas']['CdrGetSyncUsageReportResponse']; }; }; }; diff --git a/types/index.d.ts b/types/index.d.ts index 773884e..7cf4410 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -5,7 +5,7 @@ /// /// -// Resources Imports +// Resources imports /// /// /// @@ -17,6 +17,7 @@ /// /// /// +/// /// /// /// @@ -24,9 +25,20 @@ /// /// /// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// /// /// /// +/// /// // @@ -54,6 +66,7 @@ declare module 'telnyx' { aiSummarize: Telnyx.AiSummarizeResource; accessIpAddress: Telnyx.AccessIpAddressResource; accessIpRanges: Telnyx.AccessIpRangesResource; + authenticationProviders: Telnyx.AuthenticationProvidersResource; autorespConfigs: Telnyx.AutorespConfigsResource; addresses: Telnyx.AddressesResource; availablePhoneNumbers: Telnyx.AvailablePhoneNumbersResource; @@ -61,6 +74,17 @@ declare module 'telnyx' { brands: Telnyx.BrandsResource; billingGroups: Telnyx.BillingGroupsResource; calls: Telnyx.CallsResource; + callControlApplications: Telnyx.CallControlApplicationsResource; + callEvents: Telnyx.CallEventsResource; + callRecordings: Telnyx.CallRecordingsResource; + cdrUsageReports: Telnyx.CdrUsageReportsResource; + channelzones: Telnyx.ChannelzonesResource; + conferences: Telnyx.ConferencesResource; + connections: Telnyx.ConnectionsResource; + credentialConnections: Telnyx.CredentialConnectionsResource; + documentLinks: Telnyx.DocumentLinksResource; + documents: Telnyx.DocumentsResource; + telephonyCredentials: Telnyx.TelephonyCredentialsResource; messagingProfiles: Telnyx.MessagingProfilesResource; phoneNumberAssignmentByProfileResource: Telnyx.PhoneNumberAssignmentByProfileResource; storageBuckets: Telnyx.StorageBucketsResource;