Class ShortCodesClient
- Namespace
- Vonage.ShortCodes
- Assembly
- Vonage.dll
Represents a client for the Vonage US Short Codes API, enabling sending of event-based alerts and two-factor authentication messages via pre-approved short codes.
public class ShortCodesClient : IShortCodesClient
- Inheritance
-
ShortCodesClient
- Implements
- Inherited Members
Constructors
ShortCodesClient(Credentials)
Initializes a new instance of the ShortCodesClient class.
public ShortCodesClient(Credentials credentials = null)
Parameters
credentialsCredentialsOptional credentials to use for authentication.
Properties
Credentials
Gets or sets the credentials used for authenticating API requests.
public Credentials Credentials { get; set; }
Property Value
Methods
ManageOptInAsync(OptInManageRequest, Credentials)
Manages the opt-in status for a specific phone number, allowing it to receive messages from your short code.
public Task<OptInRecord> ManageOptInAsync(OptInManageRequest request, Credentials creds = null)
Parameters
requestOptInManageRequestThe request containing the phone number to manage. See OptInManageRequest.
credsCredentialsOptional credentials to override the default client credentials.
Returns
- Task<OptInRecord>
An OptInRecord containing the updated opt-in status for the phone number.
Examples
var request = new OptInManageRequest { Msisdn = "14155551234" };
var record = await client.ShortCodesClient.ManageOptInAsync(request);
Console.WriteLine($"Opt-in status: {record.OptIn}");
QueryOptInsAsync(OptInQueryRequest, Credentials)
Queries the list of phone numbers that have opted in to receive messages from your short code.
public Task<OptInSearchResponse> QueryOptInsAsync(OptInQueryRequest request, Credentials creds = null)
Parameters
requestOptInQueryRequestThe query parameters for pagination. See OptInQueryRequest.
credsCredentialsOptional credentials to override the default client credentials.
Returns
- Task<OptInSearchResponse>
An OptInSearchResponse containing the list of opted-in phone numbers.
Examples
var request = new OptInQueryRequest { Page = "1", PageSize = "10" };
var response = await client.ShortCodesClient.QueryOptInsAsync(request);
foreach (var record in response.OptInList)
{
Console.WriteLine($"MSISDN: {record.Msisdn}, Opted In: {record.OptIn}");
}
SendAlertAsync(AlertRequest, Credentials)
Sends an event-based alert message to a phone number using your pre-approved short code template.
public Task<AlertResponse> SendAlertAsync(AlertRequest request, Credentials creds = null)
Parameters
requestAlertRequestThe alert message details including recipient and template. See AlertRequest.
credsCredentialsOptional credentials to override the default client credentials.
Returns
- Task<AlertResponse>
An AlertResponse containing the message delivery status.
Examples
var request = new AlertRequest
{
To = "14155551234",
Template = "Your order #{order_id} has shipped!"
};
var response = await client.ShortCodesClient.SendAlertAsync(request);
SendTwoFactorAuthAsync(TwoFactorAuthRequest, Credentials)
Sends a two-factor authentication PIN code to a phone number using your pre-approved short code.
public Task<TwoFactorAuthResponse> SendTwoFactorAuthAsync(TwoFactorAuthRequest request, Credentials creds = null)
Parameters
requestTwoFactorAuthRequestThe two-factor authentication request details. See TwoFactorAuthRequest.
credsCredentialsOptional credentials to override the default client credentials.
Returns
- Task<TwoFactorAuthResponse>
A TwoFactorAuthResponse containing the message delivery status.
Examples
var request = new TwoFactorAuthRequest();
var response = await client.ShortCodesClient.SendTwoFactorAuthAsync(request);