Beispiel #1
0
        /// <inheritdoc />
        /// <summary>
        /// Create a vendor &lt;b&gt;Permissions Needed:&lt;/b&gt; VENDORS_ADMIN
        /// </summary>
        /// <param name="vendor">The vendor</param>
        public void CreateVendor(VendorResource vendor)
        {
            mWebCallEvent.WebPath = "/vendors";
            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(vendor); // 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
            mCreateVendorStartTime    = DateTime.Now;
            mWebCallEvent.Context     = mCreateVendorResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateVendorStartTime, "CreateVendor", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
Beispiel #2
0
        /// <inheritdoc />
        /// <summary>
        /// Update a vendor &lt;b&gt;Permissions Needed:&lt;/b&gt; VENDORS_ADMIN
        /// </summary>
        /// <param name="id">The id of the vendor</param>
        /// <param name="vendor">The vendor</param>
        public void UpdateVendor(int?id, VendorResource vendor)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateVendor");
            }

            mWebCallEvent.WebPath = "/vendors/{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(vendor); // 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
            mUpdateVendorStartTime    = DateTime.Now;
            mWebCallEvent.Context     = mUpdateVendorResponseContext;
            mWebCallEvent.RequestType = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateVendorStartTime, "UpdateVendor", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }