예제 #1
0
        private void OnUpdateStateTaxResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling UpdateStateTax: " + response.Error);
            }

            UpdateStateTaxData = (StateTaxResource)KnetikClient.Deserialize(response.Content, typeof(StateTaxResource), response.Headers);
            KnetikLogger.LogResponse(mUpdateStateTaxStartTime, "UpdateStateTax", string.Format("Response received successfully:\n{0}", UpdateStateTaxData));

            if (UpdateStateTaxComplete != null)
            {
                UpdateStateTaxComplete(response.ResponseCode, UpdateStateTaxData);
            }
        }
예제 #2
0
        /// <inheritdoc />
        /// <summary>
        /// Create or update a state tax &lt;b&gt;Permissions Needed:&lt;/b&gt; TAX_ADMIN
        /// </summary>
        /// <param name="countryCodeIso3">The iso3 code of the country</param>
        /// <param name="stateCode">The code of the state</param>
        /// <param name="taxResource">The tax object</param>
        public void UpdateStateTax(string countryCodeIso3, string stateCode, StateTaxResource taxResource)
        {
            // verify the required parameter 'countryCodeIso3' is set
            if (countryCodeIso3 == null)
            {
                throw new KnetikException(400, "Missing required parameter 'countryCodeIso3' when calling UpdateStateTax");
            }
            // verify the required parameter 'stateCode' is set
            if (stateCode == null)
            {
                throw new KnetikException(400, "Missing required parameter 'stateCode' when calling UpdateStateTax");
            }

            mWebCallEvent.WebPath = "/tax/countries/{country_code_iso3}/states/{state_code}";
            if (!string.IsNullOrEmpty(mWebCallEvent.WebPath))
            {
                mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json");
            }
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "country_code_iso3" + "}", KnetikClient.ParameterToString(countryCodeIso3));
            mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "state_code" + "}", KnetikClient.ParameterToString(stateCode));

            mWebCallEvent.HeaderParams.Clear();
            mWebCallEvent.QueryParams.Clear();
            mWebCallEvent.AuthSettings.Clear();
            mWebCallEvent.PostBody = null;

            mWebCallEvent.PostBody = KnetikClient.Serialize(taxResource); // http body (model) parameter

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant");

            // authentication settings
            mWebCallEvent.AuthSettings.Add("oauth2_password_grant");

            // make the HTTP request
            mUpdateStateTaxStartTime  = DateTime.Now;
            mWebCallEvent.Context     = mUpdateStateTaxResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateStateTaxStartTime, "UpdateStateTax", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }