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.BalanceEndpoint
balance
protected com.nexmo.client.account.PrefixPricingEndpoint
prefixPricing
protected com.nexmo.client.account.PricingEndpoint
pricing
protected com.nexmo.client.account.SecretManagementEndpoint
secret
protected com.nexmo.client.account.TopUpEndpoint
topUp
-
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 SecretResponse
createSecret(java.lang.String apiKey, java.lang.String secret)
Create a secret to be used with a specific API key.BalanceResponse
getBalance()
PrefixPricingResponse
getPrefixPrice(ServiceType type, java.lang.String prefix)
Retrieve the pricing for a specified prefix.SecretResponse
getSecret(java.lang.String apiKey, java.lang.String secretId)
Get information for a specific secret id associated to a given API key.PricingResponse
getSmsPrice(java.lang.String country)
Retrieve the SMS pricing for a specified country.PricingResponse
getVoicePrice(java.lang.String country)
Retrieve the voice pricing for a specified country.ListSecretsResponse
listSecrets(java.lang.String apiKey)
List the ID of each secret associated to the given API key.void
revokeSecret(java.lang.String apiKey, java.lang.String secretId)
Revoke a secret associated with a specific API key.void
topUp(java.lang.String transaction)
Top-up your account when you have enabled auto-reload in the dashboard.
-
-
-
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
-
-
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 java.io.IOException, NexmoClientException
- Throws:
java.io.IOException
NexmoClientException
-
getVoicePrice
public PricingResponse getVoicePrice(java.lang.String country) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.
-
getSmsPrice
public PricingResponse getSmsPrice(java.lang.String country) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.
-
getPrefixPrice
public PrefixPricingResponse getPrefixPrice(ServiceType type, java.lang.String prefix) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account API.NexmoClientException
- if there was a problem with the Nexmo request or response objects.
-
topUp
public void topUp(java.lang.String transaction) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account API.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 java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account APINexmoClientException
- if there was a problem wit hthe Nexmo request or response object indicating that the request was unsuccessful.
-
getSecret
public SecretResponse getSecret(java.lang.String apiKey, java.lang.String secretId) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account APINexmoClientException
- if there was a problem wit hthe Nexmo request or response object indicating that the request was unsuccessful.
-
createSecret
public SecretResponse createSecret(java.lang.String apiKey, java.lang.String secret) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account APINexmoClientException
- if there was a problem wit hthe Nexmo request or response object indicating that the request was unsuccessful.
-
revokeSecret
public void revokeSecret(java.lang.String apiKey, java.lang.String secretId) throws java.io.IOException, 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:
java.io.IOException
- if a network error occurred contacting the Nexmo Account APINexmoClientException
- if there was a problem wit hthe Nexmo request or response object indicating that the request was unsuccessful.
-
-