示例#1
0
        /// <summary>
        /// Update details of account associated with current API key asynchronously.
        /// </summary>
        /// <param name="account"><see cref="Account"/> with updated info.</param>
        /// <example>
        /// This example shows how to use the <see cref="AccountManagementApi.UpdateAccountAsync"/> method.
        /// <code>
        /// try
        /// {
        ///     var account = new Account
        ///     {
        ///         state = "New York",
        ///         city = "New York",
        ///         country = "USA",
        ///     };
        ///     var updatedAccount = api.UpdateAccount(account);
        ///     return updatedAccount;
        /// }
        /// catch (CloudApiException e)
        /// {
        ///     throw e;
        /// }
        /// </code>
        /// </example>
        /// <returns><see cref="Task"/> with <see cref="Account"/></returns>
        /// <exception cref="CloudApiException">CloudApiException</exception>
        public async Task <Account> UpdateAccountAsync(Account account)
        {
            var req = account.CreateUpdateRequest();

            try
            {
                var accountInfo = await AdminApi.UpdateMyAccountAsync(req);

                return(Account.Map(accountInfo));
            }
            catch (ApiException e)
            {
                throw new CloudApiException(e.ErrorCode, e.Message, e.ErrorContent);
            }
        }