-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df91e20
commit 0702bf1
Showing
412 changed files
with
19,337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using Vonage.Request; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class AccountClient : IAccountClient | ||
{ | ||
public Credentials Credentials { get; set; } | ||
public AccountClient(Credentials creds = null) | ||
{ | ||
Credentials = creds; | ||
} | ||
|
||
public Balance GetAccountBalance(Credentials creds = null) | ||
{ | ||
return ApiRequest.DoGetRequestWithQueryParameters<Balance>( | ||
ApiRequest.GetBaseUriFor(typeof(AccountClient), | ||
"/account/get-balance"), | ||
ApiRequest.AuthType.Query, | ||
credentials: creds ?? Credentials); | ||
} | ||
|
||
public TopUpResult TopUpAccountBalance(TopUpRequest request, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoGetRequestWithQueryParameters<TopUpResult>( | ||
ApiRequest.GetBaseUriFor(typeof(AccountClient), "/account/top-up"), | ||
ApiRequest.AuthType.Query, | ||
request, | ||
credentials:creds ?? Credentials | ||
); | ||
} | ||
|
||
public AccountSettingsResult ChangeAccountSettings(AccountSettingsRequest request, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoPostRequestUrlContentFromObject<AccountSettingsResult> | ||
( | ||
ApiRequest.GetBaseUriFor(typeof(AccountClient), "/account/settings"), | ||
request, | ||
creds ?? Credentials | ||
); | ||
} | ||
|
||
public SecretsRequestResult RetrieveApiSecrets(string apiKey, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoGetRequestWithQueryParameters<SecretsRequestResult>( | ||
ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), | ||
ApiRequest.AuthType.Basic, | ||
credentials: creds ?? Credentials | ||
); | ||
} | ||
|
||
public Secret CreateApiSecret(CreateSecretRequest request, string apiKey, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoRequestWithJsonContent<Secret>( | ||
"POST", | ||
ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), | ||
request, | ||
ApiRequest.AuthType.Basic, | ||
creds: creds ?? Credentials | ||
); | ||
} | ||
|
||
public Secret RetrieveApiSecret(string secretId, string apiKey, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoGetRequestWithQueryParameters<Secret>( | ||
ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), | ||
ApiRequest.AuthType.Basic, | ||
credentials: creds ?? Credentials | ||
); | ||
} | ||
|
||
public bool RevokeApiSecret(string secretId, string apiKey, Credentials creds = null) | ||
{ | ||
ApiRequest.DoDeleteRequestWithUrlContent( | ||
ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), | ||
null, | ||
ApiRequest.AuthType.Basic, | ||
creds ?? Credentials | ||
); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class AccountSettingsRequest | ||
{ | ||
/// <summary> | ||
/// The URL where Vonage will send a webhook when an SMS is received to a Vonage number that does not have SMS | ||
/// handling configured. Send an empty string to unset this value. | ||
/// </summary> | ||
[JsonProperty("moCallBackUrl")] | ||
public string MoCallBackUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The URL where Vonage will send a webhook when an delivery receipt is received without a specific callback | ||
/// URL configured. Send an empty string to unset this value. | ||
/// </summary> | ||
[JsonProperty("drCallBackUrl")] | ||
public string DrCallBackUrl { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class AccountSettingsResult | ||
{ | ||
/// <summary> | ||
/// The current or updated inbound message URI | ||
/// </summary> | ||
[JsonProperty("mo-callback-url")] | ||
public string MoCallbackUrl { get; set; } | ||
|
||
/// <summary> | ||
/// The current or updated delivery receipt URI | ||
/// </summary> | ||
[JsonProperty("dr-callback-url")] | ||
public string DrCallbackurl { get; set; } | ||
|
||
/// <summary> | ||
/// The maximum number of outbound messages per second. | ||
/// </summary> | ||
[JsonProperty("max-outbound-request")] | ||
public decimal MaxOutboundRequest { get; set; } | ||
|
||
/// <summary> | ||
/// The maximum number of inbound messages per second. | ||
/// </summary> | ||
[JsonProperty("max-inbound-request")] | ||
public decimal MaxInboundRequest { get; set; } | ||
|
||
/// <summary> | ||
/// The maximum number of API calls per second. | ||
/// </summary> | ||
[JsonProperty("max-calls-per-second")] | ||
public decimal MaxCallsPerSecond { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Newtonsoft.Json; | ||
namespace Vonage.Accounts | ||
{ | ||
public class Balance | ||
{ | ||
/// <summary> | ||
/// The balance of the account, in EUR | ||
/// </summary> | ||
[JsonProperty("value")] | ||
public decimal Value { get; set; } | ||
|
||
/// <summary> | ||
/// Whether the account has auto-reloading enabled | ||
/// </summary> | ||
[JsonProperty("autoReload")] | ||
public bool AutoReload { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class CreateSecretRequest | ||
{ | ||
/// <summary> | ||
/// the new secret to be created | ||
/// The new secret must follow these rules: | ||
/// minimum 8 characters | ||
/// maximum 25 characters | ||
/// minimum 1 lower case character | ||
/// minimum 1 upper case character | ||
/// minimum 1 digit | ||
/// </summary> | ||
[JsonProperty("secret")] | ||
public string Secret { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using Vonage.Request; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public interface IAccountClient | ||
{ | ||
/// <summary> | ||
/// Retrieve the current balance of your Vonage API account | ||
/// </summary> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
Balance GetAccountBalance(Credentials creds = null); | ||
|
||
/// <summary> | ||
/// You can top up your account using this API when you have enabled auto-reload in the dashboard. | ||
/// The amount added by the top-up operation will be the same amount as was added in the payment | ||
/// when auto-reload was enabled. Your account balance is checked every 5-10 minutes and if it falls | ||
/// below the threshold and auto-reload is enabled, then it will be topped up automatically. Use this | ||
/// endpoint if you need to top up at times when your credit may be exhausted more quickly than the auto-reload may occur. | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
TopUpResult TopUpAccountBalance(TopUpRequest request, Credentials creds = null); | ||
|
||
/// <summary> | ||
/// Update the default callback URLs (where the webhooks are sent to) associated with your account: | ||
/// * Callback URL for incoming SMS messages * Callback URL for delivery receipts | ||
/// Note: that the URLs you provide must be valid and active. Vonage will check that they return a 200 OK response before the setting is saved | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
AccountSettingsResult ChangeAccountSettings(AccountSettingsRequest request, Credentials creds = null); | ||
|
||
/// <summary> | ||
/// Many of Vonage's APIs are accessed using an API key and secret. It is recommended that you change or "rotate" | ||
/// your secrets from time to time for security purposes. This section provides the API interface for achieving this. | ||
/// Note: to work on secrets for your secondary accounts, you may authenticate with your primary | ||
/// credentials and supply the secondary API keys as URL parameters to these API endpoints. | ||
/// </summary> | ||
/// <param name="apiKey"></param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
SecretsRequestResult RetrieveApiSecrets(string apiKey=null, Credentials creds = null); | ||
|
||
/// <summary> | ||
/// Createse an API Secret | ||
/// </summary> | ||
/// <param name="request"></param> | ||
/// <param name="apiKey">The Api Key to create a secret for</param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
Secret CreateApiSecret(CreateSecretRequest request, string apiKey=null, Credentials creds = null); | ||
|
||
/// <summary> | ||
/// retrieves info about an api secret at the given id | ||
/// </summary> | ||
/// <param name="secretId">the id of the secret</param> | ||
/// <param name="apiKey">Api Key the secret is for</param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
Secret RetrieveApiSecret(string secretId, string apiKey=null, Credentials creds = null); | ||
|
||
/// <summary> | ||
/// Deletes an Api Secret | ||
/// </summary> | ||
/// <param name="secretId">the id of the secret to be deleted</param> | ||
/// <param name="apiKey">the api key the secret is for</param> | ||
/// <param name="creds"></param> | ||
/// <returns></returns> | ||
bool RevokeApiSecret(string secretId, string apiKey=null, Credentials creds = null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Newtonsoft.Json; | ||
using Vonage.Common; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class Secret | ||
{ | ||
/// <summary> | ||
/// the reference link for the secret | ||
/// </summary> | ||
[JsonProperty("_links")] | ||
public HALLinks Links { get; set; } | ||
|
||
/// <summary> | ||
/// the id of the secret | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// the creation time of the secret | ||
/// </summary> | ||
[JsonProperty("created_at")] | ||
public string CreatedAt { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class SecretList | ||
{ | ||
[JsonProperty("secrets")] | ||
public Secret[] Secrets { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
using Vonage.Common; | ||
namespace Vonage.Accounts | ||
{ | ||
public class SecretsRequestResult | ||
{ | ||
/// <summary> | ||
/// reference links for the secrets | ||
/// </summary> | ||
[JsonProperty("_links")] | ||
public HALLinks Links { get; set; } | ||
|
||
/// <summary> | ||
/// the secrets | ||
/// </summary> | ||
[JsonProperty("_embedded")] | ||
public SecretList Embedded { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class TopUpRequest | ||
{ | ||
/// <summary> | ||
/// The transaction reference of the transaction when balance was added and auto-reload was enabled on your account. | ||
/// </summary> | ||
[JsonProperty("trx")] | ||
public string Trx { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Vonage.Accounts | ||
{ | ||
public class TopUpResult | ||
{ | ||
[JsonProperty("response")] | ||
public string Response { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Newtonsoft.Json; | ||
using Vonage.Applications.Capabilities; | ||
|
||
namespace Vonage.Applications | ||
{ | ||
public class Application | ||
{ | ||
/// <summary> | ||
/// The application's ID | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// Friendly identifier for your application. This is not unique | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Configuration for the products available in this application | ||
/// </summary> | ||
[JsonProperty("capabilities")] | ||
public ApplicationCapabilities Capabilities { get; set; } | ||
|
||
/// <summary> | ||
/// The keys for your application | ||
/// </summary> | ||
[JsonProperty("keys")] | ||
public Keys Keys { get; set; } | ||
} | ||
} |
Oops, something went wrong.