예제 #1
0
        /// <inheritdoc />
        /// <summary>
        /// Create a sale &lt;b&gt;Permissions Needed:&lt;/b&gt; SALES_ADMIN
        /// </summary>
        /// <param name="catalogSale">The catalog sale object</param>
        public void CreateCatalogSale(CatalogSale catalogSale)
        {
            mWebCallEvent.WebPath = "/store/sales";
            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(catalogSale); // 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
            mCreateCatalogSaleStartTime = DateTime.Now;
            mWebCallEvent.Context       = mCreateCatalogSaleResponseContext;
            mWebCallEvent.RequestType   = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateCatalogSaleStartTime, "CreateCatalogSale", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
예제 #2
0
        private void OnUpdateCatalogSaleResponse(KnetikRestResponse response)
        {
            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new KnetikException("Error calling UpdateCatalogSale: " + response.Error);
            }

            UpdateCatalogSaleData = (CatalogSale)KnetikClient.Deserialize(response.Content, typeof(CatalogSale), response.Headers);
            KnetikLogger.LogResponse(mUpdateCatalogSaleStartTime, "UpdateCatalogSale", string.Format("Response received successfully:\n{0}", UpdateCatalogSaleData));

            if (UpdateCatalogSaleComplete != null)
            {
                UpdateCatalogSaleComplete(response.ResponseCode, UpdateCatalogSaleData);
            }
        }
예제 #3
0
        /// <inheritdoc />
        /// <summary>
        /// Update a sale &lt;b&gt;Permissions Needed:&lt;/b&gt; SALES_ADMIN
        /// </summary>
        /// <param name="id">The id of the sale</param>
        /// <param name="catalogSale">The catalog sale object</param>
        public void UpdateCatalogSale(int?id, CatalogSale catalogSale)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateCatalogSale");
            }

            mWebCallEvent.WebPath = "/store/sales/{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(catalogSale); // 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
            mUpdateCatalogSaleStartTime = DateTime.Now;
            mWebCallEvent.Context       = mUpdateCatalogSaleResponseContext;
            mWebCallEvent.RequestType   = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateCatalogSaleStartTime, "UpdateCatalogSale", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
예제 #4
0
        /// <summary>
        /// Update a sale &lt;b&gt;Permissions Needed:&lt;/b&gt; SALES_ADMIN
        /// </summary>
        /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The id of the sale</param>
        /// <param name="catalogSale">The catalog sale object (optional)</param>
        /// <returns>ApiResponse of CatalogSale</returns>
        public ApiResponse <CatalogSale> UpdateCatalogSaleWithHttpInfo(int?id, CatalogSale catalogSale = null)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling Store_SalesApi->UpdateCatalogSale");
            }

            var    localVarPath         = "/store/sales/{id}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (id != null)
            {
                localVarPathParams.Add("id", Configuration.ApiClient.ParameterToString(id));             // path parameter
            }
            if (catalogSale != null && catalogSale.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(catalogSale); // http body (model) parameter
            }
            else
            {
                localVarPostBody = catalogSale; // byte array
            }

            // authentication (oauth2_client_credentials_grant) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }
            // authentication (oauth2_password_grant) required
            // oauth required
            if (!String.IsNullOrEmpty(Configuration.AccessToken))
            {
                localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("UpdateCatalogSale", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <CatalogSale>(localVarStatusCode,
                                                 localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                 (CatalogSale)Configuration.ApiClient.Deserialize(localVarResponse, typeof(CatalogSale))));
        }
예제 #5
0
        /// <summary>
        /// Update a sale &lt;b&gt;Permissions Needed:&lt;/b&gt; SALES_ADMIN
        /// </summary>
        /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The id of the sale</param>
        /// <param name="catalogSale">The catalog sale object (optional)</param>
        /// <returns>CatalogSale</returns>
        public CatalogSale UpdateCatalogSale(int?id, CatalogSale catalogSale = null)
        {
            ApiResponse <CatalogSale> localVarResponse = UpdateCatalogSaleWithHttpInfo(id, catalogSale);

            return(localVarResponse.Data);
        }
예제 #6
0
        /// <summary>
        /// Create a sale &lt;b&gt;Permissions Needed:&lt;/b&gt; SALES_ADMIN
        /// </summary>
        /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="catalogSale">The catalog sale object (optional)</param>
        /// <returns>CatalogSale</returns>
        public CatalogSale CreateCatalogSale(CatalogSale catalogSale = null)
        {
            ApiResponse <CatalogSale> localVarResponse = CreateCatalogSaleWithHttpInfo(catalogSale);

            return(localVarResponse.Data);
        }