Package com.nexmo.client.account
Class AccountClient
- java.lang.Object
-
- com.nexmo.client.AbstractClient
-
- com.nexmo.client.account.AccountClient
-
public class AccountClient extends AbstractClient
A client for talking to the Nexmo Account API. The standard way to obtain an instance of this class is to useNexmoClient.getAccountClient()()}.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.nexmo.client.account.BalanceEndpointbalanceprotected com.nexmo.client.account.PrefixPricingEndpointprefixPricingprotected com.nexmo.client.account.PricingEndpointpricingprotected com.nexmo.client.account.SecretManagementEndpointsecretprotected com.nexmo.client.account.SettingsEndpointsettingsprotected com.nexmo.client.account.TopUpEndpointtopUp-
Fields inherited from class com.nexmo.client.AbstractClient
httpWrapper
-
-
Constructor Summary
Constructors Constructor Description AccountClient(HttpWrapper httpWrapper)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecretResponsecreateSecret(java.lang.String apiKey, java.lang.String secret)Create a secret to be used with a specific API key.BalanceResponsegetBalance()PrefixPricingResponsegetPrefixPrice(ServiceType type, java.lang.String prefix)Retrieve the pricing for a specified prefix.SecretResponsegetSecret(java.lang.String apiKey, java.lang.String secretId)Get information for a specific secret id associated to a given API key.PricingResponsegetSmsPrice(java.lang.String country)Retrieve the SMS pricing for a specified country.PricingResponsegetVoicePrice(java.lang.String country)Retrieve the voice pricing for a specified country.ListSecretsResponselistSecrets(java.lang.String apiKey)List the ID of each secret associated to the given API key.voidrevokeSecret(java.lang.String apiKey, java.lang.String secretId)Revoke a secret associated with a specific API key.voidtopUp(java.lang.String transaction)Top-up your account when you have enabled auto-reload in the dashboard.SettingsResponseupdateDeliveryReceiptUrl(java.lang.String url)SettingsResponseupdateSettings(SettingsRequest request)SettingsResponseupdateSmsIncomingUrl(java.lang.String url)
-
-
-
Field Detail
-
balance
protected com.nexmo.client.account.BalanceEndpoint balance
-
pricing
protected com.nexmo.client.account.PricingEndpoint pricing
-
prefixPricing
protected com.nexmo.client.account.PrefixPricingEndpoint prefixPricing
-
topUp
protected com.nexmo.client.account.TopUpEndpoint topUp
-
secret
protected com.nexmo.client.account.SecretManagementEndpoint secret
-
settings
protected com.nexmo.client.account.SettingsEndpoint settings
-
-
Constructor Detail
-
AccountClient
public AccountClient(HttpWrapper httpWrapper)
Constructor.- Parameters:
httpWrapper- (required) shared HTTP wrapper object used for making REST calls.
-
-
Method Detail
-
getBalance
public BalanceResponse getBalance() throws NexmoResponseParseException, NexmoClientException
-
getVoicePrice
public PricingResponse getVoicePrice(java.lang.String country) throws NexmoResponseParseException, NexmoClientException
Retrieve the voice pricing for a specified country.- Parameters:
country- The two-character country code for which you would like to retrieve pricing.- Returns:
- PricingResponse object which contains the results from the API.
- Throws:
NexmoResponseParseException- if the response from the API could not be parsed.NexmoClientException- if there was a problem with the Nexmo request or response objects.
-
getSmsPrice
public PricingResponse getSmsPrice(java.lang.String country) throws NexmoResponseParseException, NexmoClientException
Retrieve the SMS pricing for a specified country.- Parameters:
country- The two-character country code for which you would like to retrieve pricing.- Returns:
- PricingResponse object which contains the results from the API.
- Throws:
NexmoResponseParseException- if the response from the API could not be parsed.NexmoClientException- if there was a problem with the Nexmo request or response objects.
-
getPrefixPrice
public PrefixPricingResponse getPrefixPrice(ServiceType type, java.lang.String prefix) throws NexmoResponseParseException, NexmoClientException
Retrieve the pricing for a specified prefix.- Parameters:
type- The type of service to retrieve pricing for.prefix- The prefix to retrieve the pricing for.- Returns:
- PrefixPricingResponse object which contains the results from the API.
- Throws:
NexmoResponseParseException- if the response from the API could not be parsed.NexmoClientException- if there was a problem with the Nexmo request or response objects.
-
topUp
public void topUp(java.lang.String transaction) throws NexmoResponseParseException, NexmoClientException
Top-up your account when you have enabled auto-reload in the dashboard. Amount added is based on your initial reload-enabled payment.- Parameters:
transaction- The ID associated with your original auto-reload transaction- Throws:
NexmoResponseParseException- if the response from the API could not be parsed.NexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
listSecrets
public ListSecretsResponse listSecrets(java.lang.String apiKey) throws NexmoResponseParseException, NexmoClientException
List the ID of each secret associated to the given API key.- Parameters:
apiKey- The API key to look up secrets for.- Returns:
- ListSecretsResponse object which contains the results from the API.
- Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
getSecret
public SecretResponse getSecret(java.lang.String apiKey, java.lang.String secretId) throws NexmoResponseParseException, NexmoClientException
Get information for a specific secret id associated to a given API key.- Parameters:
apiKey- The API key that the secret is associated to.secretId- The id of the secret to get information on.- Returns:
- SecretResponse object which contains the results from the API.
- Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
createSecret
public SecretResponse createSecret(java.lang.String apiKey, java.lang.String secret) throws NexmoResponseParseException, NexmoClientException
Create a secret to be used with a specific API key.- Parameters:
apiKey- The API key that the secret is to be used with.secret- The contents of the secret.- Returns:
- SecretResponse object which contains the created secret from the API.
- Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
revokeSecret
public void revokeSecret(java.lang.String apiKey, java.lang.String secretId) throws NexmoResponseParseException, NexmoClientException
Revoke a secret associated with a specific API key.- Parameters:
apiKey- The API key that the secret is associated to.secretId- The id of the secret to revoke.- Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
updateSmsIncomingUrl
public SettingsResponse updateSmsIncomingUrl(java.lang.String url) throws NexmoResponseParseException, NexmoClientException
- Parameters:
url- The new incoming sms webhook url to associate to your account.- Returns:
- A
SettingsResponsecontaining the newly-updated account settings. - Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
updateDeliveryReceiptUrl
public SettingsResponse updateDeliveryReceiptUrl(java.lang.String url) throws NexmoResponseParseException, NexmoClientException
- Parameters:
url- The new delivery receipt webhook url to associate to your account.- Returns:
- A
SettingsResponsecontaining the newly-updated account settings. - Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
updateSettings
public SettingsResponse updateSettings(SettingsRequest request) throws NexmoResponseParseException, NexmoClientException
- Parameters:
request- TheSettingsRequestcontaining the fields to update.- Returns:
- A
SettingsResponsecontaining the newly-updated account settings. - Throws:
NexmoResponseParseException- if a network error occurred contacting the Nexmo Account APINexmoClientException- if there was a problem with the Nexmo request or response object indicating that the request was unsuccessful.
-
-