예제 #1
0
        /// <summary>
        /// Updates account summary information
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="accountSumaryInfo">An AccountSummaryInformation object</param>
        /// <returns>An AccountSummaryInformation object</returns>
        public AccountSummaryInformation PutAccountSummaryInformation(string accessToken, string apiKey, AccountSummaryInformation accountSumaryInfo)
        {
            // Construct access URL
            string url = String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.AccountSummaryInformation);

            string json = accountSumaryInfo.ToJSON();
            // Get REST response
            CUrlResponse response = RestClient.Put(url, accessToken, apiKey, json);
            if (response.HasData)
            {
                AccountSummaryInformation result = response.Get<AccountSummaryInformation>();
                return result;
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return new AccountSummaryInformation();
        }
예제 #2
0
        /// <summary>
        /// Updates account summary information
        /// </summary>
        /// <param name="accountSumaryInfo">An AccountSummaryInformation object</param>
        /// <returns>An AccountSummaryInformation object</returns>
        public AccountSummaryInformation PutAccountSummaryInformation(AccountSummaryInformation accountSumaryInfo)
        {
            if (accountSumaryInfo == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            // Construct access URL
            string url = String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.AccountSummaryInformation);

            string json = accountSumaryInfo.ToJSON();
            // Get REST response
            RawApiResponse response = RestClient.Put(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);
            try
            {
                var result = response.Get<AccountSummaryInformation>();
                return result;
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }