@@ -17,32 +17,115 @@ package com.vonage.client.kt
1717
1818import com.vonage.client.account.*
1919
20+ /* *
21+ * Implementation of the [Account API](https://developer.vonage.com/en/api/account).
22+ *
23+ * *Authentication method:* API key & secret.
24+ */
2025class Account internal constructor(private val client : AccountClient ) {
2126
27+ /* *
28+ * Obtains the current account remaining balance.
29+ *
30+ * @return A [BalanceResponse] object containing the current account balance.
31+ * @throws [AccountResponseException] If the balance cannot be retrieved.
32+ */
2233 fun getBalance (): BalanceResponse = client.balance
2334
35+ /* *
36+ * You can top up your account using this API when you have enabled auto-reload in the dashboard.
37+ * The amount added by the top-up operation will be the same amount as was added in the payment when
38+ * auto-reload was enabled. Your account balance is checked every 5-10 minutes and if it falls below the
39+ * threshold and auto-reload is enabled, then it will be topped up automatically. Use this method if you
40+ * need to top up at times when your credit may be exhausted more quickly than the auto-reload may occur.
41+ *
42+ * @param transactionId The top-up transaction ID.
43+ *
44+ * @throws [AccountResponseException] If the top-up operation fails.
45+ */
2446 fun topUp (transactionId : String ): Unit = client.topUp(transactionId)
2547
48+ /* *
49+ * Updates the top-level account settings. Namely, the URLs for incoming SMS and delivery receipts.
50+ *
51+ * @param incomingSmsUrl The URL to which incoming SMS messages are sent when using SMS API.
52+ * @param deliverReceiptUrl The URL to which delivery receipts are sent when using SMS API.
53+ *
54+ * @return The updated account settings.
55+ *
56+ * @throws [AccountResponseException] If the account settings could not be updated.
57+ */
2658 fun updateSettings (incomingSmsUrl : String? = null, deliverReceiptUrl : String? = null): SettingsResponse =
2759 client.updateSettings(SettingsRequest (incomingSmsUrl, deliverReceiptUrl))
2860
61+ /* *
62+ * Call this method to work with account secrets.
63+ *
64+ * @param apiKey (OPTIONAL) The account API key to manage secrets for. If not provided,
65+ * the default API key (as supplied in the top-level [Vonage] client) will be used.
66+ *
67+ * @return A [Secrets] object with methods to interact with account secrets.
68+ */
2969 fun secrets (apiKey : String? = null): Secrets = Secrets (apiKey)
3070
71+ /* *
72+ * Class for working with account secrets.
73+ *
74+ * @property apiKey The account API key to manage secrets for. If not provided,
75+ * the default API key (as supplied in the top-level [Vonage] client) will be used.
76+ */
3177 inner class Secrets internal constructor(val apiKey : String? = null ) {
3278
79+ /* *
80+ * Retrieves secrets for the account.
81+ *
82+ * @return A list of secrets details.
83+ *
84+ * @throws [AccountResponseException] If the secrets cannot be retrieved.
85+ */
3386 fun list (): List <SecretResponse > = (
3487 if (apiKey == null ) client.listSecrets()
3588 else client.listSecrets(apiKey)
3689 ).secrets
3790
91+ /* *
92+ * Creates a new secret for the account.
93+ *
94+ * @param secret The secret value to associate with the API key, which must follow these rules:
95+ * - Minimum 8 characters
96+ * - Maximum 25 characters
97+ * - Minimum 1 lower case character
98+ * - Minimum 1 upper case character
99+ * - Minimum 1 digit
100+ *
101+ * @return The created secret's metadata.
102+ *
103+ * @throws [AccountResponseException] If the secret cannot be created.
104+ */
38105 fun create (secret : String ): SecretResponse =
39106 if (apiKey == null ) client.createSecret(secret)
40107 else client.createSecret(apiKey, secret)
41108
109+ /* *
110+ * Retrieves a secret by its ID.
111+ *
112+ * @param secretId ID of the secret to retrieve.
113+ *
114+ * @return The secret's metadata.
115+ *
116+ * @throws [AccountResponseException] If the secret cannot be retrieved.
117+ */
42118 fun get (secretId : String ): SecretResponse =
43119 if (apiKey == null ) client.getSecret(secretId)
44120 else client.getSecret(apiKey, secretId)
45121
122+ /* *
123+ * Deletes a secret by its ID.
124+ *
125+ * @param secretId ID of the secret to delete.
126+ *
127+ * @throws [AccountResponseException] If the secret cannot be deleted.
128+ */
46129 fun delete (secretId : String ): Unit =
47130 if (apiKey == null ) client.revokeSecret(secretId)
48131 else client.revokeSecret(apiKey, secretId)
0 commit comments