From c1cf62109d56c1442b7c410fbd7a8ba9c8ce9d36 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 5 Oct 2020 21:53:00 +0530 Subject: [PATCH 01/10] added typings for number-insight api --- .prettierrc | 6 ++ package-lock.json | 6 +- package.json | 4 +- typings/index.d.ts | 263 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 218 insertions(+), 61 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..952b2fb4 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "tabWidth": 4, + "useTabs": false, + "singleQuote": false, + "proseWrap": "preserve" +} diff --git a/package-lock.json b/package-lock.json index 05e13a17..394d227c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7253,9 +7253,9 @@ "dev": true }, "prettier": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.3.tgz", - "integrity": "sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", + "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, "process-nextick-args": { diff --git a/package.json b/package.json index 9db2caae..845efaa3 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "@babel/plugin-proposal-object-rest-spread": "^7.10.4", "@babel/preset-env": "^7.10.4", "@babel/register": "^7.10.5", - "babel-plugin-istanbul": "^6.0.0", "babel-plugin-add-module-exports": "^1.0.4", + "babel-plugin-istanbul": "^6.0.0", "bluebird": "^3.5.3", "body-parser": "^1.18.3", "chai": "^3.5.0", @@ -62,7 +62,7 @@ "mocha": "^7.2.0", "nodemon": "^2.0.4", "nyc": "^15.1.0", - "prettier": "^1.16.3", + "prettier": "^1.19.1", "sinon": "^1.17.4", "sinon-chai": "^2.8.0", "sinon-expect": "^0.3.0" diff --git a/typings/index.d.ts b/typings/index.d.ts index f937a880..d5544d7c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -10,7 +10,7 @@ * CheckResponse -> VerifyCheckResponse */ -declare module '@vonage/server-sdk' { +declare module "@vonage/server-sdk" { /* general */ export interface CredentialsObject { apiKey: string; @@ -20,8 +20,8 @@ declare module '@vonage/server-sdk' { } export interface VonageApiError { - body: { [key: string]: any }; - headers?: { [key: string]: any }; + body: { [key: string]: any }; + headers?: { [key: string]: any }; } export interface ParserError { @@ -33,80 +33,83 @@ declare module '@vonage/server-sdk' { /* message API */ export enum MessageRequestResponseStatusCode { - Success = '0', - Throttled = '1', - MissingParameters = '2', - InvalidParameters = '3', - InvalidCredentials = '4', - InternalError = '5', - InvalidMessage = '6', - NumberBarred = '7', - PartnerAccountBarred = '8', - PartnerQuotaViolation = '9', - TooManyExistingBinds = '10', - AccountNotEnabledForHTTP = '11', - MessageTooLong = '12', - InvalidSignature = '14', - InvalidSenderAddress = '15', - InvalidNetworkCode = '22', - InvalidCallbackURL = '23', - NonWhitelistedDestination = '29', - SignatureAndAPISecretDisallowed = '32', - NumberDeActivated = '33', + Success = "0", + Throttled = "1", + MissingParameters = "2", + InvalidParameters = "3", + InvalidCredentials = "4", + InternalError = "5", + InvalidMessage = "6", + NumberBarred = "7", + PartnerAccountBarred = "8", + PartnerQuotaViolation = "9", + TooManyExistingBinds = "10", + AccountNotEnabledForHTTP = "11", + MessageTooLong = "12", + InvalidSignature = "14", + InvalidSenderAddress = "15", + InvalidNetworkCode = "22", + InvalidCallbackURL = "23", + NonWhitelistedDestination = "29", + SignatureAndAPISecretDisallowed = "32", + NumberDeActivated = "33" } export interface MessageRequestResponseSuccess { - to: string, - 'message-id': string, - status: MessageRequestResponseStatusCode, - 'remaining-balance': string, - 'message-price': string, - 'network': string, - 'account-ref': string, + to: string; + "message-id": string; + status: MessageRequestResponseStatusCode; + "remaining-balance": string; + "message-price": string; + network: string; + "account-ref": string; } export interface MessageError { status: MessageRequestResponseStatusCode; - 'error-text': string; + "error-text": string; } - + export interface MessageRequestResponse { - 'message-count': number; - messages: (MessageRequestResponseSuccess | MessageError)[]; + "message-count": number; + messages: (MessageRequestResponseSuccess | MessageError)[]; } - + export interface SendSmsOptions { from: string; to: string; text?: string; sig?: string; ttl?: number; - 'status-report-req'?: boolean; + "status-report-req"?: boolean; callback?: string; - 'message-class'?: number; + "message-class"?: number; type?: string; vcard?: string | any; vcal?: string | any; body?: string; udh?: string; - 'protocol-id'?: number; + "protocol-id"?: number; title?: string; url?: string; validity?: string; - 'client-ref'?: string; - 'account-ref'?: string; + "client-ref"?: string; + "account-ref"?: string; } - + export type SendSms = ( - sender: string, - recipient: string, - message: string, - opts: Partial, - callback: (err: MessageError, data: MessageRequestResponse) => void + sender: string, + recipient: string, + message: string, + opts: Partial, + callback: (err: MessageError, data: MessageRequestResponse) => void ) => void; - + export class Message { - constructor(credentials: CredentialsObject, options: { [key: string]: any }); + constructor( + credentials: CredentialsObject, + options: { [key: string]: any } + ); sendSms: SendSms; /** @@ -119,7 +122,7 @@ declare module '@vonage/server-sdk' { shortcodeMarketing: any; search: any; searchRejections: any; - + __proto__: any; [key: string]: any; } @@ -164,7 +167,7 @@ declare module '@vonage/server-sdk' { WrongVerificationCode = "11", TooManyRequests = "12", NoMoreEvents = "13", - NoRequestFound = "14", + NoRequestFound = "14" } export interface ControlObject { @@ -179,7 +182,7 @@ declare module '@vonage/server-sdk' { export enum ControlResponseStatusCode { Success = "0", - CancelOrTriggerNextEvent = "19", + CancelOrTriggerNextEvent = "19" } export interface CheckObject { @@ -197,19 +200,167 @@ declare module '@vonage/server-sdk' { } export class Verify { - constructor(credentials: CredentialsObject, options: { [key: string]: any }); - request(request: RequestObject, callback: (err: VerifyError, data: RequestResponse) => void): void; - control(request: ControlObject, callback: (err: VerifyError, data: ControlResponse) => void): void; - check(request: CheckObject, callback: (err: VerifyError, data: CheckResponse) => void): void; + constructor( + credentials: CredentialsObject, + options: { [key: string]: any } + ); + request( + request: RequestObject, + callback: (err: VerifyError, data: RequestResponse) => void + ): void; + control( + request: ControlObject, + callback: (err: VerifyError, data: ControlResponse) => void + ): void; + check( + request: CheckObject, + callback: (err: VerifyError, data: CheckResponse) => void + ): void; __proto__: any; [key: string]: any; } + /* number-insight API */ + export interface NumberInsightError extends VonageApiError { + status: + | NumberInsightResponseStatusCode + | AdvancedNumberInsightResponseStatusCode + | string; + error_text: string; + [key: string]: any; + } + + export interface NumberInsightObject { + level: NumberInsightLevel; + number: string; + country?: string; + cnam?: boolean; + callback?: string; + ip?: string; + } + + export interface NumberInsightResponse { + status: + | NumberInsightResponseStatusCode + | AdvancedNumberInsightResponseStatusCode + | 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 AdvancedNumberInsightWebhook { + // TODO: Typings + } + + 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 + } + + export enum AdvancedNumberInsightResponseStatusCode { + 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( + request: NumberInsightObject, + callback: ( + err: NumberInsightError, + data: NumberInsightResponse + ) => void + ): void; + __proto__: any; + [key: string]: any; + } /* Vonage */ export default class Vonage { - constructor(credentials: CredentialsObject, options?: { [key: string]: any }); + constructor( + credentials: CredentialsObject, + options?: { [key: string]: any } + ); public readonly verify: Verify; public readonly message: Message; + public readonly numberInsight: NumberInsight; } } From a4266bd741f7c0b5828167ee44820a056b17b053 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 5 Oct 2020 22:02:41 +0530 Subject: [PATCH 02/10] added .prettierignore to take care of linting fail on ci --- .prettierignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..80c6a8cb --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +src +lib +test \ No newline at end of file From 4e6bbe8a9db4702e360d4cee6b48d25b115d0041 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Tue, 6 Oct 2020 07:52:30 +0530 Subject: [PATCH 03/10] added number-insight webhook interface and cleaned up status codes --- typings/index.d.ts | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index d5544d7c..2f61433a 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -222,10 +222,7 @@ declare module "@vonage/server-sdk" { /* number-insight API */ export interface NumberInsightError extends VonageApiError { - status: - | NumberInsightResponseStatusCode - | AdvancedNumberInsightResponseStatusCode - | string; + status: NumberInsightResponseStatusCode | number; error_text: string; [key: string]: any; } @@ -240,10 +237,7 @@ declare module "@vonage/server-sdk" { } export interface NumberInsightResponse { - status: - | NumberInsightResponseStatusCode - | AdvancedNumberInsightResponseStatusCode - | number; + status: NumberInsightResponseStatusCode | number; status_message: string; request_id: string; international_format_number: string; @@ -291,9 +285,8 @@ declare module "@vonage/server-sdk" { error_text?: string; } - export interface AdvancedNumberInsightWebhook { - // TODO: Typings - } + export interface NumberInsightWebhookRequest + extends NumberInsightResponse {} export enum NumberInsightLookupCode { Success = 0, @@ -315,15 +308,6 @@ declare module "@vonage/server-sdk" { } export enum NumberInsightResponseStatusCode { - Success = 0, - Busy = 1, - InvalidRequest = 3, - InvalidCredentials = 4, - InternalError = 5, - PartnerQuotaExceeded = 9 - } - - export enum AdvancedNumberInsightResponseStatusCode { Success = 0, Busy = 1, InvalidRequest = 3, From 4861d347d25bc00c1d5176e3a6ba8d88b27da15f Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Tue, 6 Oct 2020 08:44:00 +0530 Subject: [PATCH 04/10] rename request to options per src/NumberInsight.js --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 2f61433a..4449dc3f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -327,7 +327,7 @@ declare module "@vonage/server-sdk" { options: { [key: string]: any } ); get( - request: NumberInsightObject, + options: NumberInsightObject, callback: ( err: NumberInsightError, data: NumberInsightResponse From 05feeac78b0f9bc4dfc99e4766390643acdce4f0 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 12 Oct 2020 19:45:20 +0530 Subject: [PATCH 05/10] reverted prettier changes --- .prettierignore | 3 --- .prettierrc | 6 ------ 2 files changed, 9 deletions(-) delete mode 100644 .prettierignore delete mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 80c6a8cb..00000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -src -lib -test \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 952b2fb4..00000000 --- a/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "tabWidth": 4, - "useTabs": false, - "singleQuote": false, - "proseWrap": "preserve" -} From 5ac78c21733772ed4b46c83f964a7866b1c10296 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 12 Oct 2020 19:48:34 +0530 Subject: [PATCH 06/10] fixed merge conflicts with the media api typings --- typings/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typings/index.d.ts b/typings/index.d.ts index 3a11fe41..6de9fd94 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -333,6 +333,7 @@ declare module "@vonage/server-sdk" { data: NumberInsightResponse ) => void ): void; + } /* Media API */ export interface MediaSearchRequestObject { From fd823b6be0b665e7c7c82cf4929c0269ba69d32b Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 12 Oct 2020 20:06:23 +0530 Subject: [PATCH 07/10] downgraded prettier --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b905754..9e9a799d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7253,9 +7253,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.3.tgz", + "integrity": "sha512-kn/GU6SMRYPxUakNXhpP0EedT/KmaPzr0H5lIsDogrykbaxOpOfAFfk5XA7DZrJyMAv1wlMV3CPcZruGXVVUZw==", "dev": true }, "process-nextick-args": { diff --git a/package.json b/package.json index f06c6855..88c669e3 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "mocha": "^7.2.0", "nodemon": "^2.0.4", "nyc": "^15.1.0", - "prettier": "^1.19.1", + "prettier": "^1.16.3", "sinon": "^1.17.4", "sinon-chai": "^2.8.0", "sinon-expect": "^0.3.0" From 59be67ea51ff5a47cc773eec2145d0bdca33658e Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Mon, 12 Oct 2020 20:07:43 +0530 Subject: [PATCH 08/10] restored order of babel-plugin-istanbul --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88c669e3..a6cc8861 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,8 @@ "@babel/plugin-proposal-object-rest-spread": "^7.10.4", "@babel/preset-env": "^7.10.4", "@babel/register": "^7.10.5", - "babel-plugin-add-module-exports": "^1.0.4", "babel-plugin-istanbul": "^6.0.0", + "babel-plugin-add-module-exports": "^1.0.4", "bluebird": "^3.5.3", "body-parser": "^1.18.3", "chai": "^3.5.0", From 63d6c2f93711b224d9db7ef9d4a39bd0e5667714 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Thu, 15 Oct 2020 15:06:45 +0530 Subject: [PATCH 09/10] feat: add number insight typings --- typings/index.d.ts | 326 ++++++++++++++++++++++++++------------------- 1 file changed, 188 insertions(+), 138 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 6de9fd94..44bc2499 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -10,7 +10,7 @@ * CheckResponse -> VerifyCheckResponse */ -declare module "@vonage/server-sdk" { +declare module '@vonage/server-sdk' { /* general */ export interface CredentialsObject { apiKey: string; @@ -20,8 +20,8 @@ declare module "@vonage/server-sdk" { } export interface VonageApiError { - body: { [key: string]: any }; - headers?: { [key: string]: any }; + body: { [key: string]: any }; + headers?: { [key: string]: any }; } export interface ParserError { @@ -33,83 +33,80 @@ declare module "@vonage/server-sdk" { /* message API */ export enum MessageRequestResponseStatusCode { - Success = "0", - Throttled = "1", - MissingParameters = "2", - InvalidParameters = "3", - InvalidCredentials = "4", - InternalError = "5", - InvalidMessage = "6", - NumberBarred = "7", - PartnerAccountBarred = "8", - PartnerQuotaViolation = "9", - TooManyExistingBinds = "10", - AccountNotEnabledForHTTP = "11", - MessageTooLong = "12", - InvalidSignature = "14", - InvalidSenderAddress = "15", - InvalidNetworkCode = "22", - InvalidCallbackURL = "23", - NonWhitelistedDestination = "29", - SignatureAndAPISecretDisallowed = "32", - NumberDeActivated = "33" + Success = '0', + Throttled = '1', + MissingParameters = '2', + InvalidParameters = '3', + InvalidCredentials = '4', + InternalError = '5', + InvalidMessage = '6', + NumberBarred = '7', + PartnerAccountBarred = '8', + PartnerQuotaViolation = '9', + TooManyExistingBinds = '10', + AccountNotEnabledForHTTP = '11', + MessageTooLong = '12', + InvalidSignature = '14', + InvalidSenderAddress = '15', + InvalidNetworkCode = '22', + InvalidCallbackURL = '23', + NonWhitelistedDestination = '29', + SignatureAndAPISecretDisallowed = '32', + NumberDeActivated = '33', } export interface MessageRequestResponseSuccess { - to: string; - "message-id": string; - status: MessageRequestResponseStatusCode; - "remaining-balance": string; - "message-price": string; - network: string; - "account-ref": string; + to: string, + 'message-id': string, + status: MessageRequestResponseStatusCode, + 'remaining-balance': string, + 'message-price': string, + 'network': string, + 'account-ref': string, } export interface MessageError { status: MessageRequestResponseStatusCode; - "error-text": string; + 'error-text': string; } - + export interface MessageRequestResponse { - "message-count": number; - messages: (MessageRequestResponseSuccess | MessageError)[]; + 'message-count': number; + messages: (MessageRequestResponseSuccess | MessageError)[]; } - + export interface SendSmsOptions { from: string; to: string; text?: string; sig?: string; ttl?: number; - "status-report-req"?: boolean; + 'status-report-req'?: boolean; callback?: string; - "message-class"?: number; + 'message-class'?: number; type?: string; vcard?: string | any; vcal?: string | any; body?: string; udh?: string; - "protocol-id"?: number; + 'protocol-id'?: number; title?: string; url?: string; validity?: string; - "client-ref"?: string; - "account-ref"?: string; + 'client-ref'?: string; + 'account-ref'?: string; } - + export type SendSms = ( - sender: string, - recipient: string, - message: string, - opts: Partial, - callback: (err: MessageError, data: MessageRequestResponse) => void + sender: string, + recipient: string, + message: string, + opts: Partial, + callback: (err: MessageError, data: MessageRequestResponse) => void ) => void; - + export class Message { - constructor( - credentials: CredentialsObject, - options: { [key: string]: any } - ); + constructor(credentials: CredentialsObject, options: { [key: string]: any }); sendSms: SendSms; /** @@ -122,7 +119,7 @@ declare module "@vonage/server-sdk" { shortcodeMarketing: any; search: any; searchRejections: any; - + __proto__: any; [key: string]: any; } @@ -167,7 +164,7 @@ declare module "@vonage/server-sdk" { WrongVerificationCode = "11", TooManyRequests = "12", NoMoreEvents = "13", - NoRequestFound = "14" + NoRequestFound = "14", } export interface ControlObject { @@ -182,7 +179,7 @@ declare module "@vonage/server-sdk" { export enum ControlResponseStatusCode { Success = "0", - CancelOrTriggerNextEvent = "19" + CancelOrTriggerNextEvent = "19", } export interface CheckObject { @@ -200,21 +197,145 @@ declare module "@vonage/server-sdk" { } export class Verify { + constructor(credentials: CredentialsObject, options: { [key: string]: any }); + request(request: RequestObject, callback: (err: VerifyError, data: RequestResponse) => void): void; + control(request: ControlObject, callback: (err: VerifyError, data: ControlResponse) => void): void; + check(request: CheckObject, callback: (err: VerifyError, data: CheckResponse) => void): void; + __proto__: any; + [key: string]: any; + } + + /* Media API */ + export interface MediaSearchRequestObject { + order: string; + page_index: number; + page_size: number; + start_time: string; + end_time: string; + } + + export interface MediaLinkObject { + self: { + href: string; + }; + first: { + href: string; + }; + last: { + href: string; + }; + } + + export interface MediaSearchResponseObject { + page_size: number; + page_index: number; + _links: MediaLinkObject; + count: number; + _embedded: { + media: [MediaResponseObject] + }; + } + + + export interface MediaResponseObject { + id: string; + original_file_name: string; + mime_type: string; + account_id: string; + store_id: string; + max_downloads_allowed: number; + times_downloaded: number; + etag: string; + media_size: number; + time_created: string; + time_last_updated: string; + public: boolean; + metadata_primary: string; + metadata_secondary: string; + } + + export interface MediaUpdateRequest { + public: boolean; + metadata_primary: string; + metadata_secondary: string; + title: string; + description: string; + mime_type: string; + max_downloads_allowed: number; + } + + export class Media { + constructor(credentials: CredentialsObject, options: { [key: string]: any }); + search(request: MediaSearchRequestObject, callback: (err: VonageApiError, data: MediaSearchResponseObject) => void): void; + delete(id: string, callback: (err: VonageApiError) => void): void; + get(id: string, callback: (err: VonageApiError, data: MediaResponseObject) => void): void; + update(id: string, request: MediaUpdateRequest, callback: (err: VonageApiError) => void): void; + __proto__: any; + [key: string]: any; + } + + /* number API */ + export interface INumberResponse { + 'error-code': string; + 'error-code-label': string; + } + + export interface INumber { + country: string; + msisdn: string; + moHttpUrl: string; + type: string; + cost: string; + features: string[]; + messagesCallbackType: string; + messagesCallbackValue: string; + voiceCallbackType: string; + voiceCallbackValue: string; + } + + export interface getNumberResponse { + count: number; + numbers: Omit, 'cost'>[]; + } + + export interface searchNumberResponse { + count: number; + numbers: Pick, 'country' | 'msisdn' | 'type' | 'cost' | 'features'>[]; + } + + export class Number { constructor( credentials: CredentialsObject, options: { [key: string]: any } ); - request( - request: RequestObject, - callback: (err: VerifyError, data: RequestResponse) => void + getPricing(): void; + getPhonePricing(): void; + get( + options: { [key: string]: any } | ((error?: INumberResponse, response?: getNumberResponse) => void), + callback?: (error?: INumberResponse, response?: getNumberResponse) => void + ): void; + search( + countryCode?: string, + pattern?: unknown, + callback?: (error?: INumberResponse, response?: searchNumberResponse) => void + ): void; + buy( + countryCode?: string, + msisdn?: string, + targetApiKey?: string | ((error?: INumberResponse, response?: INumberResponse) => void), + callback?: (error?: INumberResponse, response?: INumberResponse) => void ): void; - control( - request: ControlObject, - callback: (err: VerifyError, data: ControlResponse) => void + cancel( + countryCode?: string, + msisdn?: string, + targetApiKey?: string | ((error?: INumberResponse, response?: INumberResponse) => void), + callback?: (error?: INumberResponse, response?: INumberResponse) => void ): void; - check( - request: CheckObject, - callback: (err: VerifyError, data: CheckResponse) => void + update( + countryCode?: string, + msisdn?: string, + params?: string | ((error?: INumberResponse, response?: INumberResponse) => void), + callback?: (error?: INumberResponse, response?: INumberResponse) => void ): void; __proto__: any; [key: string]: any; @@ -286,7 +407,7 @@ declare module "@vonage/server-sdk" { } export interface NumberInsightWebhookRequest - extends NumberInsightResponse {} + extends NumberInsightResponse { } export enum NumberInsightLookupCode { Success = 0, @@ -335,84 +456,13 @@ declare module "@vonage/server-sdk" { ): void; } - /* Media API */ - export interface MediaSearchRequestObject { - order: string; - page_index: number; - page_size: number; - start_time: string; - end_time: string; - } - - export interface MediaLinkObject { - self: { - href: string; - }; - first: { - href: string; - }; - last: { - href: string; - }; - } - - export interface MediaSearchResponseObject { - page_size: number; - page_index: number; - _links: MediaLinkObject; - count: number; - _embedded: { - media: [MediaResponseObject] - }; - } - - - export interface MediaResponseObject { - id: string; - original_file_name: string; - mime_type: string; - account_id: string; - store_id: string; - max_downloads_allowed: number; - times_downloaded: number; - etag: string; - media_size: number; - time_created: string; - time_last_updated: string; - public: boolean; - metadata_primary: string; - metadata_secondary: string; - } - - export interface MediaUpdateRequest { - public: boolean; - metadata_primary: string; - metadata_secondary: string; - title: string; - description: string; - mime_type: string; - max_downloads_allowed: number; - } - - export class Media { - constructor(credentials: CredentialsObject, options: { [key: string]: any }); - search(request: MediaSearchRequestObject, callback: (err: VonageApiError, data: MediaSearchResponseObject) => void): void; - delete(id: string, callback: (err: VonageApiError) => void): void; - get(id: string, callback: (err: VonageApiError, data: MediaResponseObject) => void): void; - update(id: string, request: MediaUpdateRequest, callback: (err: VonageApiError) => void): void; - __proto__: any; - [key: string]: any; - } - /* Vonage */ export default class Vonage { - constructor( - credentials: CredentialsObject, - options?: { [key: string]: any } - ); + constructor(credentials: CredentialsObject, options?: { [key: string]: any }); public readonly verify: Verify; public readonly message: Message; - public readonly numberInsight: NumberInsight; public readonly media: Media; + public readonly number: Number; + public readonly numberInsight: NumberInsight; } } From 12e5761ee8378467802cef8684a66916d50e1dc3 Mon Sep 17 00:00:00 2001 From: Sudipto Ghosh Date: Thu, 15 Oct 2020 15:40:06 +0530 Subject: [PATCH 10/10] fix: add missing options for NumberInsightObject --- typings/index.d.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 44bc2499..fa764661 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -353,8 +353,13 @@ declare module '@vonage/server-sdk' { number: string; country?: string; cnam?: boolean; - callback?: string; ip?: string; + features?: string[]; + callback?: string; + callback_timeout?: number; + callback_method?: string; + client_ref?: string; + 'include-intermediate-callbacks'?: string; } export interface NumberInsightResponse { @@ -449,10 +454,7 @@ declare module '@vonage/server-sdk' { ); get( options: NumberInsightObject, - callback: ( - err: NumberInsightError, - data: NumberInsightResponse - ) => void + callback?: (err?: NumberInsightError, data?: NumberInsightResponse) => void ): void; }