-
Notifications
You must be signed in to change notification settings - Fork 183
Vonage Pricing
Documentation / Vonage Pricing
Defined in: pricing/lib/enums/ServiceType.ts:4
Enum representing different service types for pricing information.
Enumeration Member | Value | Description | Defined in |
---|---|---|---|
SMS
|
"sms" |
SMS service. | pricing/lib/enums/ServiceType.ts:8 |
SMS_TRANSIT
|
"sms-transit" |
SMS Transit service. | pricing/lib/enums/ServiceType.ts:13 |
VOICE
|
"voice" |
Voice service. | pricing/lib/enums/ServiceType.ts:18 |
Defined in: pricing/lib/pricing.ts:39
The Pricing API allows you to retrieve pricing information for all countries and a specific service type, for a specific country and service type, or for a specific prefix and service type.
Create a standalone Pricing client
import { Pricing } from '@vonage/pricing';
const pricingClient = new Pricing({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
Create an Pricing client from the Vonage client
import { Vonage } from '@vonage/server-client';
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
const pricingClient = vonage.pricing;
new Pricing(credentials, options?): Pricing
Defined in: server-client/dist/lib/client.d.ts:35
Creates a new instance of the Client.
The authentication credentials or an authentication instance.
Optional configuration settings for the client.
protected auth: AuthInterface;
Defined in: server-client/dist/lib/client.d.ts:24
The authentication instance responsible for generating authentication headers and query parameters.
protected authType: AuthenticationType = AuthenticationType.BASIC;
Defined in: pricing/lib/pricing.ts:43
protected config: ConfigParams;
Defined in: server-client/dist/lib/client.d.ts:28
Configuration settings for the client, including default hosts for various services and other request settings.
static transformers: object;
Defined in: server-client/dist/lib/client.d.ts:11
Static property containing utility transformers.
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys: PartialTransformFunction;
omit: (keys, obj) => TransformedObject;
string
[]
snakeCaseObjectKeys: PartialTransformFunction;
addAuthenticationToRequest(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:43
Adds the appropriate authentication headers or parameters to the request based on the authentication type.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addAuthenticationToRequest
protected addBasicAuthToRequest(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:71
Adds basic authentication headers to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addJWTToRequest(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:64
Adds a JWT to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:57
Adds API key and secret to the request.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequest
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:50
Adds API key and secret to the request body.
The request options to which authentication needs to be added.
Promise
<VetchOptions
>
- The request options with the added authentication.
Client
.addQueryKeySecretToRequestBody
getConfig(): ConfigParams
Defined in: server-client/dist/lib/client.d.ts:36
listAllCountriesPricing(type): Promise<OutboundAllCountriesPricingResponse>
Defined in: pricing/lib/pricing.ts:85
Retrieves pricing information for all countries and a specific service type.
The service type.
Promise
<OutboundAllCountriesPricingResponse
>
- Pricing information for all countries.
import { ServiceType } from '@vonage/pricing';
const pricing = await pricingClient.listAllCountriesPricing(ServiceType.SMS);
for (const country in pricing.countries) {
console.log(`The current price for ${country.countryName} is ${country.defaultPrice}`);
}
listCountryPricing(type, country): Promise<OutboundCountryPricingResponse>
Defined in: pricing/lib/pricing.ts:60
Retrieves pricing information for a specific country and service type.
The service type.
string
The country for which pricing information is requested.
Promise
<OutboundCountryPricingResponse
>
- Pricing information for the specified country.
import { ServiceType } from '@vonage/pricing';
const pricing = await pricingClient.listCountryPricing(ServiceType.SMS, 'GB');
console.log(`The current price for Great Britian is ${pricing.defaultPrice}`);
listPrefixPricing(type, prefix): Promise<OutboundAllCountriesPricingResponse>
Defined in: pricing/lib/pricing.ts:108
Retrieves pricing information for a specific prefix and service type.
The service type.
string
The prefix for which pricing information is requested.
Promise
<OutboundAllCountriesPricingResponse
>
- Pricing information for the specified prefix.
import { ServiceType } from '@vonage/pricing';
const pricing = await pricingClient.listPrefixPricing(ServiceType.SMS, '44');
console.log(`The current price for Great Britian is ${pricing.defaultPrice}`);
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:168
Parses the response based on its content type.
• T
The expected type of the parsed response data.
The request options.
Response
The raw response from the request.
Promise
<VetchResponse
<T
>>
- The parsed response.
protected prepareBody(request): undefined | string
Defined in: server-client/dist/lib/client.d.ts:158
Prepares the body for the request based on the content type.
The request options.
undefined
| string
- The prepared request body as a string or undefined.
protected prepareRequest(request): Promise<VetchOptions>
Defined in: server-client/dist/lib/client.d.ts:151
Prepares the request with necessary headers, authentication, and query parameters.
The initial request options.
Promise
<VetchOptions
>
- The modified request options.
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:78
Sends a DELETE request to the specified URL.
• T
string
The URL endpoint for the DELETE request.
Promise
<VetchResponse
<T
>>
- The response from the DELETE request.
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:86
Sends a POST request with form data to the specified URL.
• T
string
The URL endpoint for the POST request.
Record
<string
, undefined
| string
>
Optional payload containing form data to send with the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:94
Sends a GET request to the specified URL with optional query parameters.
• T
string
The URL endpoint for the GET request.
Optional query parameters to append to the URL. These should be compatible with Node's URLSearchParams.
Promise
<VetchResponse
<T
>>
- The response from the GET request.
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:104
Sends a PATCH request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PATCH request.
Optional payload to be sent as the body of the PATCH request.
Promise
<VetchResponse
<T
>>
- The response from the PATCH request.
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:114
Sends a POST request to the specified URL with an optional payload.
• T
string
The URL endpoint for the POST request.
Optional payload to be sent as the body of the POST request.
Promise
<VetchResponse
<T
>>
- The response from the POST request.
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:124
Sends a PUT request to the specified URL with an optional payload.
• T
string
The URL endpoint for the PUT request.
Optional payload to be sent as the body of the PUT request.
Promise
<VetchResponse
<T
>>
- The response from the PUT request.
sendRequest<T>(request): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:144
Sends a request adding necessary headers, handling authentication, and parsing the response.
• T
The options defining the request, including URL, method, headers, and data.
Promise
<VetchResponse
<T
>>
- The parsed response from the request.
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
Defined in: server-client/dist/lib/client.d.ts:135
Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.
• T
The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).
string
The URL endpoint for the request.
Optional payload to be sent as the body of the request, JSON-encoded.
Promise
<VetchResponse
<T
>>
- The response from the request.
type Network = object;
Defined in: pricing/lib/types/Network.ts:4
Type representing a network within a specific country's pricing information.
currency: string;
The currency used for prices for this network
mcc: string;
The Mobile Country Code (MCC) of the operator
mnc: string;
The Mobile Network Code (MNC) of the operator
networkCode: string;
The Mobile Country Code and Mobile Network Code combined to give a unique reference for the operator
networkName: string;
The company/organizational name of the operator
price: string;
The cost to send a message or make a call on this network.
type: string;
The type of network
type OutboundAllCountriesPricingResponse = object;
Defined in: pricing/lib/types/Response/OutboundAllCountriesPricingResponse.ts:6
Type representing the response for pricing information of all countries.
count: number;
The number of countries in the response.
countries: OutboundCountryPricingResponse[];
An array of objects containing pricing information for individual countries.
type OutboundCountryPricingResponse = object;
Defined in: pricing/lib/types/Response/OutboundCountryPricingResponse.ts:5
Type representing the response for pricing information of a specific country.
countryCode: string;
Two-letter country code.
countryDisplayName: string;
Readable country name.
countryName: string;
Readable country name.
currency: string;
The currency that your account is being billed in.
defaultPrice: string;
The default price for services in this country.
dialingPrefix: string;
The dialing prefix for this country.
networks: Network[];
An array of network objects representing different networks in this country.
type PricingClassParameters = AuthParams & VetchOptions & object;
Defined in: pricing/lib/types/PricingClassParameters.ts:7
Type representing parameters for a pricing class, including authentication and Vetch options.
optional auth: AuthInterface;
An optional authentication interface.
- The authentication interface if provided, otherwise undefined.
type PricingResponse<T> = VetchResponse<T>;
Defined in: pricing/lib/types/PricingResponse.ts:3
• T