Skip to content

Commit

Permalink
fix identity resources
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Oct 11, 2024
1 parent 0f10754 commit 0026786
Show file tree
Hide file tree
Showing 20 changed files with 516 additions and 219 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Fix `Queues` resource nested methods
- Fix `PortingOrders` and `Ips` resource nested methods param names
- Update legacy skipped tests
- Fix `Verifications`, `VerifyProfiles` and `VerifiedNumbers` resources method naming and params
- Remove dupe `Verify` resource
- Update nested methods types to match param values usage

### v2.0.0-beta.0

Expand Down
2 changes: 0 additions & 2 deletions src/resources/IpConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const IpConnections = TelnyxResource.extend({
list: telnyxMethod({
method: 'GET',
methodType: 'list',

transformResponseData: transformResponseData,
}),

create: telnyxMethod({
Expand Down
93 changes: 48 additions & 45 deletions src/resources/Verifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,41 @@ const telnyxMethod = TelnyxResource.method;

import {ResponsePayload, TelnyxObject} from '../Types';

function transformResponseData(
const transformResponseData = (
response: ResponsePayload,
telnyx: TelnyxObject,
) {
return utils.addResourceToResponseData(response, telnyx, 'verification', {
sms: telnyxMethod({
) => {
return utils.addResourceToResponseData(response, telnyx, 'verifiedNumbers', {
verify: telnyxMethod({
method: 'POST',
path: '/sms',

transformResponseData: transformResponseData,
}),

call: telnyxMethod({
method: 'POST',
path: '/call',

transformResponseData: transformResponseData,
}),

flashcall: telnyxMethod({
method: 'POST',
path: '/flashcall',

transformResponseData: transformResponseData,
}),

byPhoneNumber: telnyxMethod({
method: 'GET',
path: '/verifications/by_phone_number/{phone_number}',
urlParams: ['phone_number'],
paramsValues: [response.data.id as string],
paramsNames: ['id'],
}),

verifyVerificationCodeByPhoneNumber: telnyxMethod({
method: 'POST',
path: '/by_phone_number/{phone_number}/actions/verify',
urlParams: ['phone_number'],
paramsValues: [response.data.id as string],
paramsNames: ['id'],
}),

verifyVerificationCodeById: telnyxMethod({
method: 'POST',
path: '/by_phone_number/{verification_id}/actions/verify',
path: '/{verification_id}/actions/verify',
urlParams: ['verification_id'],
paramsNames: ['verification_id'],
paramsValues: [response.data.id as string],
paramsNames: ['id'],
}),
});
}
};

export const Verifications = TelnyxResource.extend({
path: 'verifications',
includeBasic: ['update'],

callVerify: telnyxMethod({
method: 'POST',
path: '/call',
methodType: 'create',
}),

flashcallVerify: telnyxMethod({
method: 'POST',
path: '/flashcall',
methodType: 'create',
}),

smsVerify: telnyxMethod({
method: 'POST',
path: '/sms',
methodType: 'create',
}),

retrieve: telnyxMethod({
method: 'GET',
Expand All @@ -67,4 +47,27 @@ export const Verifications = TelnyxResource.extend({

transformResponseData: transformResponseData,
}),

verify: telnyxMethod({
method: 'POST',
path: '/{verification_id}/actions/verify',
urlParams: ['verification_id'],
paramsNames: ['verification_id'],
}),

listByPhoneNumber: telnyxMethod({
method: 'GET',
path: '/by_phone_number/{phone_number}',
urlParams: ['phone_number'],
paramsNames: ['phone_number'],
methodType: 'list',
}),

verifyByPhoneNumber: telnyxMethod({
method: 'POST',
path: '/by_phone_number/{phone_number}/actions/verify',
urlParams: ['phone_number'],
paramsNames: ['phone_number'],
methodType: 'create',
}),
});
49 changes: 48 additions & 1 deletion src/resources/VerifiedNumbers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
import TelnyxResource from '../TelnyxResource';
import {ResponsePayload, TelnyxObject} from '../Types';
import * as utils from '../utils';

const telnyxMethod = TelnyxResource.method;

const transformResponseData = (
response: ResponsePayload,
telnyx: TelnyxObject,
) => {
return utils.addResourceToResponseData(response, telnyx, 'verifiedNumbers', {
verify: telnyxMethod({
method: 'POST',
path: '/{phone_number}/actions/verify',
urlParams: ['phone_number'],
paramsNames: ['phone_number'],
paramsValues: [response.data.id as string],
}),
});
};

export const VerifiedNumbers = TelnyxResource.extend({
path: 'verified_numbers',
includeBasic: ['list', 'retrieve', 'del'],
includeBasic: ['list', 'del'],

retrieve: telnyxMethod({
method: 'GET',
path: '/{phone_number}',
urlParams: ['phone_number'],

transformResponseData: transformResponseData,
}),

create: telnyxMethod({
method: 'POST',

transformResponseData: transformResponseData,
}),

request: telnyxMethod({
method: 'POST',

transformResponseData: transformResponseData,
}),

verify: telnyxMethod({
method: 'POST',
path: '/{phone_number}/actions/verify',
urlParams: ['phone_number'],
paramsNames: ['phone_number'],
methodType: 'create',
}),
});
52 changes: 0 additions & 52 deletions src/resources/Verify.ts

This file was deleted.

42 changes: 5 additions & 37 deletions src/resources/VerifyProfiles.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
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, 'verifyProfiles', {
retrieveVerifyProfileMessageTemplates: telnyxMethod({
method: 'GET',
path: '/verify_profiles/templates',
}),
});
}
const telnyxMethod = TelnyxResource.method;

export const VerifyProfiles = TelnyxResource.extend({
path: 'verify_profiles',
includeBasic: ['list', 'update', 'del'],

save: telnyxMethod({
method: 'PATCH',
path: '/{verify_profile_id}',
urlParams: ['verify_profile_id'],
paramsNames: ['id'],

transformResponseData: transformResponseData,
}),
includeBasic: ['list', 'create', 'retrieve', 'update', 'del'],

retrieve: telnyxMethod({
listTemplates: telnyxMethod({
method: 'GET',
path: '/{verify_profile_id}',
urlParams: ['verify_profile_id'],
paramsNames: ['id'],

transformResponseData: transformResponseData,
}),

create: telnyxMethod({
method: 'POST',

transformResponseData: transformResponseData,
path: '/templates',
methodType: 'list',
}),
});
2 changes: 0 additions & 2 deletions src/telnyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ import {TelephonyCredentials} from './resources/TelephonyCredentials';
import {TexmlApplications} from './resources/TexmlApplications';
import {Verifications} from './resources/Verifications';
import {VerifiedNumbers} from './resources/VerifiedNumbers';
import {Verify} from './resources/Verify';
import {VerifyProfiles} from './resources/VerifyProfiles';
import {VirtualCrossConnects} from './resources/VirtualCrossConnects';
import {WdrDetailReports} from './resources/WdrDetailReports';
Expand Down Expand Up @@ -305,7 +304,6 @@ export function createTelnyx() {
TexmlApplications,
Verifications,
VerifiedNumbers,
Verify,
VerifyProfiles,
VirtualCrossConnects,
WdrDetailReports,
Expand Down
4 changes: 3 additions & 1 deletion types/AddressesResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ declare module 'telnyx' {
paths['/addresses/{id}']['delete']['responses']['200']['content']['application/json'];

type AddressesNestedMethods = {
del: AddressesResource['del'];
del(
options?: RequestOptions,
): Promise<Telnyx.Response<Telnyx.AddressesDelResponse>>;
};

class AddressesResource {
Expand Down
10 changes: 8 additions & 2 deletions types/CallControlApplicationsResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ declare module 'telnyx' {
paths['/call_control_applications/{id}']['delete']['responses']['200']['content']['application/json'];

type CallControlApplicationsNestedMethods = {
create: MessagingProfilesResource['create'];
del: MessagingProfilesResource['del'];
del(
options?: RequestOptions,
): Promise<Telnyx.Response<Telnyx.CallControlApplicationsDelResponse>>;

update(
params: CallControlApplicationsUpdateParams,
options?: RequestOptions,
): Promise<Telnyx.Response<Telnyx.CallControlApplicationsUpdateResponse>>;
};

class CallControlApplicationsResource {
Expand Down
24 changes: 14 additions & 10 deletions types/ConferencesResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,26 @@ declare module 'telnyx' {
id: ConferencesRetrieveId,
options?: RequestOptions,
): Promise<
Telnyx.Response<Telnyx.ConferencesRetrieveResponse> &
NestedResponseData<
ConferencesRetrieveResponse['data'],
ConferencesNestedMethods
>
Telnyx.Response<
Telnyx.ConferencesRetrieveResponse &
NestedResponseData<
ConferencesRetrieveResponse['data'],
ConferencesNestedMethods
>
>
>;

create(
params: ConferencesCreateParams,
options?: RequestOptions,
): Promise<
Telnyx.Response<Telnyx.ConferencesCreateResponse> &
NestedResponseData<
ConferencesCreateResponse['data'],
ConferencesNestedMethods
>
Telnyx.Response<
Telnyx.ConferencesCreateResponse &
NestedResponseData<
ConferencesCreateResponse['data'],
ConferencesNestedMethods
>
>
>;

join(
Expand Down
Loading

0 comments on commit 0026786

Please sign in to comment.