Skip to content

Commit

Permalink
fix porting types
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Oct 28, 2024
1 parent ed1d0f5 commit b113497
Show file tree
Hide file tree
Showing 18 changed files with 568 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add `CONTRIBUTING.md` guidelines
- Update `README.md`
- Fix `tranformResponseData` misusage on `list` resource methods
- Update stale types on Portability, Porting and Portout resources methods

### v2.0.0-beta.3

Expand Down
1 change: 0 additions & 1 deletion src/resources/NumberPortouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const NumberPortouts = TelnyxResource.extend({
method: 'GET',
path: '/{id}/supporting_documents',
urlParams: ['id'],
transformResponseData: transformResponseData,
}),
createListOfSupportingDocuments: telnyxMethod({
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions src/resources/PortabilityChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const telnyxMethod = TelnyxResource.method;

export const PortabilityChecks = TelnyxResource.extend({
path: 'portability_checks',
includeBasic: ['create'],

run: telnyxMethod({
method: 'POST',
Expand Down
7 changes: 7 additions & 0 deletions src/resources/PortingEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ export const PortingEvents = TelnyxResource.extend({
path: 'porting/events',
includeBasic: ['list', 'retrieve'],

show: telnyxMethod({
method: 'GET',
path: '/{id}',
urlParams: ['id'],
methodType: 'retrieve',
}),

republish: telnyxMethod({
method: 'POST',
path: '/{id}/republish',
Expand Down
15 changes: 15 additions & 0 deletions src/resources/PortingLoaConfigurations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import TelnyxResource from '../TelnyxResource';

const telnyxMethod = TelnyxResource.method;

export const PortingLoaConfigurations = TelnyxResource.extend({
path: 'porting/loa_configurations',
includeBasic: ['list', 'create', 'retrieve', 'del', 'update'],

preview: telnyxMethod({
method: 'GET',
path: '/{id}/preview',
urlParams: ['id'],
methodType: 'retrieve',
}),
});
209 changes: 193 additions & 16 deletions src/resources/PortingOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,48 @@ function transformResponseData(
paramsValues: [response.data.id as string],
paramsNames: ['portingOrderId'],
}),

activate: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/activate',
urlParams: ['porting_order_id'],
paramsValues: [response.data.id as string],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

cancel: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/activate',
urlParams: ['porting_order_id'],
paramsValues: [response.data.id as string],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

confirm: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/activate',
urlParams: ['porting_order_id'],
paramsValues: [response.data.id as string],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

share: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/activate',
urlParams: ['porting_order_id'],
paramsValues: [response.data.id as string],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),
});
}

export const PortingOrders = TelnyxResource.extend({
path: 'porting_orders',

list: telnyxMethod({
method: 'GET',
methodType: 'list',
}),
includeBasic: ['list', 'del', 'update'],

create: telnyxMethod({
method: 'POST',
Expand All @@ -55,49 +87,194 @@ export const PortingOrders = TelnyxResource.extend({
methodType: 'list',
}),

listActivationJobs: telnyxMethod({
listPhoneNumberConfigurations: telnyxMethod({
method: 'GET',
path: '/{id}/activation_jobs',
path: '/phone_number_configurations',
methodType: 'list',
urlParams: ['id'],
}),

cancelOrder: telnyxMethod({
createPhoneNumberConfigurations: telnyxMethod({
method: 'POST',
path: '/{orderId}/actions/cancel',
urlParams: ['orderId'],
paramsNames: ['orderId'],
path: '/phone_number_configurations',
methodType: 'create',
}),

listActivationJobs: telnyxMethod({
method: 'GET',
path: '/{id}/activation_jobs',
methodType: 'list',
urlParams: ['id'],
}),

retrieveActivationJob: telnyxMethod({
method: 'GET',
path: '/{id}/activation_jobs/{activationJobId}',
urlParams: ['id', 'activationJobId'],
paramsNames: ['id', 'activationJobId'],
}),

listAllowedFocWindows: telnyxMethod({
method: 'GET',
path: '/{id}/allowed_foc_windows',
methodType: 'list',
urlParams: ['id'],
}),

listAdditionalDocuments: telnyxMethod({
method: 'GET',
path: '/{id}/additional_documents',
methodType: 'list',
urlParams: ['id'],
}),

createAdditionalDocuments: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/additional_documents',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

delAdditionalDocuments: telnyxMethod({
method: 'DELETE',
path: '/{porting_order_id}/additional_documents/{additional_document_id}',
urlParams: ['porting_order_id', 'additional_document_id'],
paramsNames: ['porting_order_id', 'additional_document_id'],
}),

retrieveLoaTemplate: telnyxMethod({
method: 'GET',
path: '/{id}/loa_template',
urlParams: ['id'],
methodType: 'retrieve',
}),

confirmOrder: telnyxMethod({
activate: telnyxMethod({
method: 'POST',
path: '/{id}/actions/confirm',
urlParams: ['id'],
path: '/{porting_order_id}/actions/activate',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

cancel: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/cancel',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

confirm: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/confirm',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

share: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/actions/share',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
methodType: 'create',
}),

createComment: telnyxMethod({
method: 'POST',
path: '/{id}/comments',
path: '/{porting_order_id}/comments',
methodType: 'create',
urlParams: ['id'],
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
}),

listComments: telnyxMethod({
method: 'GET',
path: '/{id}/comments',
methodType: 'list',
urlParams: ['id'],
}),

listRequirements: telnyxMethod({
method: 'GET',
path: '/{id}/requirements',
methodType: 'list',
urlParams: ['id'],
}),

listVerificationCodes: telnyxMethod({
method: 'GET',
path: '/{id}/verification_codes',
methodType: 'list',
urlParams: ['id'],
}),

retrieveSubRequest: telnyxMethod({
method: 'GET',
path: '/{id}/sub_request',
methodType: 'retrieve',
urlParams: ['id'],
}),

sendVerificationCode: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/verification_codes/send',
methodType: 'create',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
}),

verifyVerificationCode: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/verification_codes/verify',
methodType: 'create',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
}),

listPhoneNumberBlocks: telnyxMethod({
method: 'GET',
path: '/{porting_order_id}/phone_number_blocks',
methodType: 'list',
urlParams: ['porting_order_id'],
}),

createPhoneNumberBlock: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/phone_number_blocks',
methodType: 'create',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
}),

delPhoneNumberBlock: telnyxMethod({
method: 'DELETE',
path: '/{porting_order_id}/phone_number_blocks/{id}',
urlParams: ['porting_order_id', 'id'],
paramsNames: ['porting_order_id', 'id'],
}),

listPhoneNumberExtensions: telnyxMethod({
method: 'GET',
path: '/{porting_order_id}/phone_number_extensions',
methodType: 'list',
urlParams: ['porting_order_id'],
}),

createPhoneNumberExtension: telnyxMethod({
method: 'POST',
path: '/{porting_order_id}/phone_number_extensions',
methodType: 'create',
urlParams: ['porting_order_id'],
paramsNames: ['porting_order_id'],
}),

delPhoneNumberExtension: telnyxMethod({
method: 'DELETE',
path: '/{porting_order_id}/phone_number_extensions/{id}',
urlParams: ['porting_order_id', 'id'],
paramsNames: ['porting_order_id', 'id'],
}),
});
6 changes: 6 additions & 0 deletions src/resources/PortingReports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import TelnyxResource from '../TelnyxResource';

export const PortingReports = TelnyxResource.extend({
path: 'porting/reports',
includeBasic: ['list', 'create', 'retrieve'],
});
4 changes: 4 additions & 0 deletions src/telnyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ import {PhoneNumbersSlim} from './resources/PhoneNumbersSlim';
import {PhoneNumbersVoice} from './resources/PhoneNumbersVoice';
import {PortabilityChecks} from './resources/PortabilityChecks';
import {PortingEvents} from './resources/PortingEvents';
import {PortingLoaConfigurations} from './resources/PortingLoaConfigurations';
import {PortingReports} from './resources/PortingReports';
import {PortoutEvents} from './resources/PortoutEvents';
import {PortingOrders} from './resources/PortingOrders';
import {PortingPhoneNumbers} from './resources/PortingPhoneNumbers';
Expand Down Expand Up @@ -272,7 +274,9 @@ export function createTelnyx() {
PortingEvents,
PortoutEvents,
PortabilityChecks,
PortingLoaConfigurations,
PortingOrders,
PortingReports,
PortingPhoneNumbers,
PortoutRequests,
PresignedObjectUrls,
Expand Down
16 changes: 16 additions & 0 deletions src/test/resources/PortabilityChecks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ describe('PortabilityChecks Resource', function () {
phone_numbers: ['+15555555555', '+16666666667'],
};

describe('create', function () {
test('Sends the correct request', function () {
// @ts-expect-error TODO: import .d.ts files under src/test folder
return telnyx.portabilityChecks
.create(portabilityChecksParams)
.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.portabilityChecks
.create(portabilityChecksParams, TEST_AUTH_KEY)
.then(responseFn);
});
});

describe('run', function () {
test('Sends the correct request', function () {
// @ts-expect-error TODO: import .d.ts files under src/test folder
Expand Down
Loading

0 comments on commit b113497

Please sign in to comment.