Skip to content

Commit

Permalink
update resources method names and missing d types
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Oct 3, 2024
1 parent 0a90d88 commit e477fe9
Show file tree
Hide file tree
Showing 36 changed files with 1,177 additions and 347 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-alpha.3
2.0.0-alpha.4
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 5 additions & 5 deletions plop-templates/ResourceTypes.ts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
7 changes: 1 addition & 6 deletions src/resources/Brands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
17 changes: 0 additions & 17 deletions src/resources/BusinessIdentity.ts

This file was deleted.

9 changes: 2 additions & 7 deletions src/resources/CallControlApplications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),

Expand Down
12 changes: 0 additions & 12 deletions src/resources/CallInformation.ts

This file was deleted.

20 changes: 10 additions & 10 deletions src/resources/CallRecordings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
}),
});
8 changes: 4 additions & 4 deletions src/resources/CdrUsageReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
}),
});
36 changes: 24 additions & 12 deletions src/resources/Channelzones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}),
});
24 changes: 22 additions & 2 deletions src/resources/Conferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const CONFERENCES = [
'record_stop',
'update',
'leave',
'resume',
'record_resume',
'record_pause',
];

function getSpec(conferenceId?: string) {
Expand All @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/resources/Connections.ts
Original file line number Diff line number Diff line change
@@ -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',
}),
});
26 changes: 0 additions & 26 deletions src/resources/Credentials.ts

This file was deleted.

40 changes: 4 additions & 36 deletions src/resources/Documents.ts
Original file line number Diff line number Diff line change
@@ -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,
}),
});
Loading

0 comments on commit e477fe9

Please sign in to comment.