/// <inheritdoc /> /// <summary> /// Create a shipping template Shipping Templates define a type of shipping and the properties they have. /// </summary> /// <param name="shippingTemplateResource">The new shipping template</param> public void CreateShippingTemplate(ItemTemplateResource shippingTemplateResource) { mWebCallEvent.WebPath = "/store/shipping/templates"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(shippingTemplateResource); // 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 mCreateShippingTemplateStartTime = DateTime.Now; mWebCallEvent.Context = mCreateShippingTemplateResponseContext; mWebCallEvent.RequestType = KnetikRequestType.POST; KnetikLogger.LogRequest(mCreateShippingTemplateStartTime, "CreateShippingTemplate", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
private void OnUpdateShippingTemplateResponse(KnetikRestResponse response) { if (!string.IsNullOrEmpty(response.Error)) { throw new KnetikException("Error calling UpdateShippingTemplate: " + response.Error); } UpdateShippingTemplateData = (ItemTemplateResource)KnetikClient.Deserialize(response.Content, typeof(ItemTemplateResource), response.Headers); KnetikLogger.LogResponse(mUpdateShippingTemplateStartTime, "UpdateShippingTemplate", string.Format("Response received successfully:\n{0}", UpdateShippingTemplateData)); if (UpdateShippingTemplateComplete != null) { UpdateShippingTemplateComplete(response.ResponseCode, UpdateShippingTemplateData); } }
/// <inheritdoc /> /// <summary> /// Update a shipping template <b>Permissions Needed:</b> TEMPLATE_ADMIN /// </summary> /// <param name="id">The id of the template</param> /// <param name="shippingTemplateResource">The shipping template resource object</param> public void UpdateShippingTemplate(string id, ItemTemplateResource shippingTemplateResource) { // verify the required parameter 'id' is set if (id == null) { throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateShippingTemplate"); } mWebCallEvent.WebPath = "/store/shipping/templates/{id}"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{" + "id" + "}", KnetikClient.ParameterToString(id)); mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(shippingTemplateResource); // 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 mUpdateShippingTemplateStartTime = DateTime.Now; mWebCallEvent.Context = mUpdateShippingTemplateResponseContext; mWebCallEvent.RequestType = KnetikRequestType.PUT; KnetikLogger.LogRequest(mUpdateShippingTemplateStartTime, "UpdateShippingTemplate", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }