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

Typings for the Number Insight API #373

Merged
merged 15 commits into from
Oct 15, 2020
Merged
Changes from all 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
117 changes: 117 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,122 @@ declare module '@vonage/server-sdk' {
[key: string]: any;
}

/* number-insight API */
export interface NumberInsightError extends VonageApiError {
status: NumberInsightResponseStatusCode | number;
error_text: string;
[key: string]: any;
}

export interface NumberInsightObject {
sudiptog81 marked this conversation as resolved.
Show resolved Hide resolved
level: NumberInsightLevel;
number: string;
country?: string;
cnam?: boolean;
ip?: string;
features?: string[];
callback?: string;
callback_timeout?: number;
callback_method?: string;
client_ref?: string;
'include-intermediate-callbacks'?: string;
}

export interface NumberInsightResponse {
status: NumberInsightResponseStatusCode | number;
status_message: string;
request_id: string;
international_format_number: string;
national_format_number: string;
country_code: string;
country_code_iso3: string;
country_name: string;
country_prefix: string;
request_price?: string;
refund_price?: string;
remaining_balance?: string;
current_carrier?: {
network_code?: string;
name?: string;
country?: string;
network_type?: string;
};
original_carrier?: {
network_code?: string;
name?: string;
country?: string;
network_type?: string;
};
ported?: string;
roaming?: {
status?: string;
roaming_country_code?: string;
roaming_network_code?: string;
roaming_network_name?: string;
};
caller_identity?: {
caller_type?: string;
caller_name?: string;
first_name?: string;
last_name?: string;
};
caller_name?: string;
first_name?: string;
last_name?: string;
caller_type?: NumberInsightCallerType;
lookup_outcome?: NumberInsightLookupCode;
lookup_outcome_message?: string;
valid_number?: string;
reachable?: string;
error_text?: string;
}

export interface NumberInsightWebhookRequest
extends NumberInsightResponse { }

export enum NumberInsightLookupCode {
Success = 0,
PartialSuccess = 1,
Failed = 2
}

export enum NumberInsightLevel {
Basic = "basic",
Standard = "standard",
AdvancedAsync = "advancedAsync",
AdvancedSync = "advancedSync"
}

export enum NumberInsightCallerType {
Business = "business",
Consumer = "consumer",
Unknown = "unknown"
}

export enum NumberInsightResponseStatusCode {
Success = 0,
Busy = 1,
InvalidRequest = 3,
InvalidCredentials = 4,
InternalError = 5,
PartnerQuotaExceeded = 9,
FacilityNotAllowed = 19,
LiveMobileLookupNotReturned1 = 43,
LiveMobileLookupNotReturned2 = 44,
LiveMobileLookupNotReturned3 = 45,
RequestUnparseable = 999
}

export class NumberInsight {
constructor(
credentials: CredentialsObject,
options: { [key: string]: any }
);
get(
options: NumberInsightObject,
callback?: (err?: NumberInsightError, data?: NumberInsightResponse) => void
): void;
}

/* Vonage */
export default class Vonage {
Expand All @@ -349,5 +465,6 @@ declare module '@vonage/server-sdk' {
public readonly message: Message;
public readonly media: Media;
public readonly number: Number;
public readonly numberInsight: NumberInsight;
}
}