Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added typings for VoiceAPI#364 #379

Merged
merged 4 commits into from
Nov 2, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 129 additions & 3 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ declare module '@vonage/server-sdk' {
AccountNotEnabledForHTTP = '11',
MessageTooLong = '12',
InvalidSignature = '14',
InvalidSenderAddress = '15',
InvalidToAddress = '15',
InvalidNetworkCode = '22',
InvalidCallbackURL = '23',
NonWhitelistedDestination = '29',
Expand Down Expand Up @@ -98,7 +98,7 @@ declare module '@vonage/server-sdk' {
}

export type SendSms = (
sender: string,
To: string,
recipient: string,
message: string,
opts: Partial<SendSmsOptions>,
Expand Down Expand Up @@ -134,7 +134,7 @@ declare module '@vonage/server-sdk' {
export interface RequestObject {
brand: string;
number: string;
sender_id?: string;
To_id?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are updates to the messages interface, move the above changes into a separate PR. Thanks!

country?: string;
code_length?: number;
lg?: string;
Expand Down Expand Up @@ -205,11 +205,137 @@ declare module '@vonage/server-sdk' {
[key: string]: any;
}

/* voice API */
export interface To{
type: string;
number: string;
dtmfAnswer?: string;
}

export interface From{
type: string;
number: string;
}

export interface CallsResponse {
count: number;
page_size: number;
record_index: number;
_links: CallDetailLinks;
_embedded: CallDetailEmbedded;
}

export interface CallDetailLinks {
self: CallDetailsSelf;
}

export interface CallDetailsSelf {
href: string;
}

export interface CallDetailEmbedded {
calls: CallDetailCall[];
}

export interface CallDetailCall {
_links: CallDetailLinks;
uuid: string;
conversation_uuid: string;
to: To;
from: From;
status: string;
direction: string;
rate: string;
price: string;
duration: string;
start_time: Date;
end_time: Date;
network: string;
}

export interface OutboundCallRequest{
answer_url?: string[];
ncco?: Ncco[];
status: string;
to: To[];
from: From;
event_url: string[];
machine_detection: string;
}

export interface Ncco {
action: string;
text: string;
}

export interface OutboundCallResponse{
uuid: string;
status: string;
direction: string;
conversation_uuid: string;
}

export interface CallDetailResponse {
_links: CallDetailLinks;
uuid: string;
conversation_uuid: string;
to: To;
from: From;
status: string;
direction: string;
rate: string;
price: string;
duration: string;
start_time: Date;
end_time: Date;
network: string;
}

export interface InProgressCallRequest {
action: string;
destination?: Destination;
}

export interface Destination {
type: string;
ncco?: Ncco[];
url?: string[];
}

export interface StreamAudioInCallRequest {
stream_url: string[];
level?: string;
}

export interface ModifyInProgressCallResponse {
message: string;
uuid: string;
}

export interface TextToSpeechRequest {
text: string;
level?: string;
}

export interface DTMFRequest {
digits: number;
}

export class Voice {
constructor(credentials: CredentialsObject, options: { [key: string]: any });
sendTTSMessage(recipient: To, message: TextToSpeechRequest, options: CredentialsObject, callback: (data: ModifyInProgressCallResponse) => void ): void;
sendTTSPromptWithCapture(recipient: To, message: TextToSpeechRequest, maxDigits: Number, callback: (data: ModifyInProgressCallResponse) => void ): void;
sendTTSPromptWithConfirm(recipient: To, message: TextToSpeechRequest, maxDigits: Number, pinCode: string, byeText: string, failedText: string, callback: (data: ModifyInProgressCallResponse) => void ): void;
call(recipient: To, answerUrl: string, opts: OutboundCallRequest, callback: (data: OutboundCallResponse) => void): void;
__proto__: any;
[key: string]: any;
}

/* Vonage */
export default class Vonage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voice class will need to be exported in the default class as well.

constructor(credentials: CredentialsObject, options?: { [key: string]: any });
public readonly verify: Verify;
public readonly message: Message;
public readonly voice: Voice;
}
}