Exemplo n.º 1
0
        /// <inheritdoc />
        /// <summary>
        /// Create a fulfillment type &lt;b&gt;Permissions Needed:&lt;/b&gt; FULFILLMENT_ADMIN
        /// </summary>
        /// <param name="type">The fulfillment type</param>
        public void CreateFulfillmentType(FulfillmentType type)
        {
            mWebCallEvent.WebPath = "/store/fulfillment/types";
            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(type); // 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
            mCreateFulfillmentTypeStartTime = DateTime.Now;
            mWebCallEvent.Context           = mCreateFulfillmentTypeResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.POST;

            KnetikLogger.LogRequest(mCreateFulfillmentTypeStartTime, "CreateFulfillmentType", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
        void grdProduct_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            Button btnAddProduct = (Button)e.Row.FindControl("btnAddProduct");

            if (btnAddProduct == null)
            {
                return;
            }

            string[] pair = btnAddProduct.CommandArgument.Split('|');
            if (pair.Length != 2)
            {
                return;
            }
            if (pair[0].Length != 36)
            {
                return;
            }

            Guid            productGuid     = new Guid(pair[0]);
            FulfillmentType fulfillmentType = Product.FulfillmentTypeFromString(pair[1]);

            if (fulfillmentType != FulfillmentType.Download)
            {
                btnAddProduct.Attributes.Add("onclick", GetClientScriptForButton(productGuid, fulfillmentType, Guid.Empty));
            }
        }
Exemplo n.º 3
0
        private static byte ConvertFulfillmentTypeToByte(FulfillmentType fulfillmentType)
        {
            switch (fulfillmentType)
            {
            case FulfillmentType.None:
                return(3);

            case FulfillmentType.Download:
                return(1);

            case FulfillmentType.PhysicalShipment:
                return(2);
            }

            return(3);
        }
        private void ShowFulfillmentTermsPanel(Guid productGuid, FulfillmentType fulfillmentType)
        {
            pnlDownloadTerms.Visible = true;
            pnlGrid.Visible          = false;
            hdnFulfillmentType.Value = ((byte)fulfillmentType).ToString();
            hdnProductGuid.Value     = productGuid.ToString();

            Product product = new Product(productGuid);

            lblProduct.Text = product.Name;

            using (IDataReader reader = FullfillDownloadTerms.GetAll(store.Guid))
            {
                ddFulfillTerms.DataSource = reader;
                ddFulfillTerms.DataBind();
            }
        }
        void grdProduct_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //this should only fire for download products at leastif javascript is enabled

            if (e.CommandName != "addProduct")
            {
                return;
            }

            string[] pair = e.CommandArgument.ToString().Split('|');
            if (pair.Length != 2)
            {
                return;
            }
            if (pair[0].Length != 36)
            {
                return;
            }

            Guid            productGuid     = new Guid(pair[0]);
            FulfillmentType fulfillmentType = Product.FulfillmentTypeFromString(pair[1]);


            switch (fulfillmentType)
            {
            case FulfillmentType.None:
            case FulfillmentType.PhysicalShipment:

                //TODO add product to offer as backup if javascript is disabled



                break;

            case FulfillmentType.Download:
                ShowFulfillmentTermsPanel(productGuid, fulfillmentType);
                break;
            }

            pnlPicker.Update();
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        /// <summary>
        /// Update a fulfillment type &lt;b&gt;Permissions Needed:&lt;/b&gt; FULFILLMENT_ADMIN
        /// </summary>
        /// <param name="id">The id</param>
        /// <param name="fulfillmentType">The fulfillment type</param>
        public void UpdateFulfillmentType(int?id, FulfillmentType fulfillmentType)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new KnetikException(400, "Missing required parameter 'id' when calling UpdateFulfillmentType");
            }

            mWebCallEvent.WebPath = "/store/fulfillment/types/{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(fulfillmentType); // 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
            mUpdateFulfillmentTypeStartTime = DateTime.Now;
            mWebCallEvent.Context           = mUpdateFulfillmentTypeResponseContext;
            mWebCallEvent.RequestType       = KnetikRequestType.PUT;

            KnetikLogger.LogRequest(mUpdateFulfillmentTypeStartTime, "UpdateFulfillmentType", "Sending server request...");
            KnetikGlobalEventSystem.Publish(mWebCallEvent);
        }
 private string GetClientScriptForButton(Guid productGuid, FulfillmentType fulfillmentType, Guid fulfillmentTermsGuid)
 {
     return("top.window.AddProduct('" + productGuid.ToString()
            + "','" + ((byte)fulfillmentType).ToString()
            + "','" + fulfillmentTermsGuid.ToString() + "');  return false;");
 }
Exemplo n.º 8
0
        public static string GetFulfillmentTypeLabel(FulfillmentType fulfillmentType)
        {
            switch (fulfillmentType)
            {
                case FulfillmentType.Download:
                    return WebStoreResources.FullfillmentTypeEnumDownload;

                case FulfillmentType.PhysicalShipment:
                    return WebStoreResources.FullfillmentTypeEnumShipped;

                case FulfillmentType.None:
                    return WebStoreResources.FullfillmentTypeEnumNone;

            }

            return WebStoreResources.FullfillmentTypeEnumNone;
        }
        private void ShowFulfillmentTermsPanel(Guid productGuid, FulfillmentType fulfillmentType)
        {
            pnlDownloadTerms.Visible = true;
            pnlGrid.Visible = false;
            hdnFulfillmentType.Value = ((byte)fulfillmentType).ToString();
            hdnProductGuid.Value = productGuid.ToString();

            Product product = new Product(productGuid);
            lblProduct.Text = product.Name;

            using (IDataReader reader = FullfillDownloadTerms.GetAll(store.Guid))
            {
                ddFulfillTerms.DataSource = reader;
                ddFulfillTerms.DataBind();
            }
        }
 private string GetClientScriptForButton(Guid productGuid, FulfillmentType fulfillmentType, Guid fulfillmentTermsGuid)
 {
     return "top.window.AddProduct('" + productGuid.ToString()
         + "','" + ((byte)fulfillmentType).ToString()
         + "','" + fulfillmentTermsGuid.ToString() + "');  return false;";
 }
Exemplo n.º 11
0
        private static byte ConvertFulfillmentTypeToByte(FulfillmentType fulfillmentType)
        {
            switch (fulfillmentType)
            {
                case FulfillmentType.None:
                    return 3;

                case FulfillmentType.Download:
                    return 1;

                case FulfillmentType.PhysicalShipment:
                    return 2;

            }

            return 3;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Update a fulfillment type &lt;b&gt;Permissions Needed:&lt;/b&gt; FULFILLMENT_ADMIN
        /// </summary>
        /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The fulfillment id</param>
        /// <param name="fulfillmentType">The fulfillment type (optional)</param>
        /// <returns>ApiResponse of Object(void)</returns>
        public ApiResponse <Object> UpdateFulfillmentTypeWithHttpInfo(int?id, FulfillmentType fulfillmentType = null)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling FulfillmentApi->UpdateFulfillmentType");
            }

            var    localVarPath         = "/store/fulfillment/types/{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 (fulfillmentType != null && fulfillmentType.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(fulfillmentType); // http body (model) parameter
            }
            else
            {
                localVarPostBody = fulfillmentType; // 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("UpdateFulfillmentType", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
Exemplo n.º 13
0
 /// <summary>
 /// Update a fulfillment type &lt;b&gt;Permissions Needed:&lt;/b&gt; FULFILLMENT_ADMIN
 /// </summary>
 /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="id">The fulfillment id</param>
 /// <param name="fulfillmentType">The fulfillment type (optional)</param>
 /// <returns></returns>
 public void UpdateFulfillmentType(int?id, FulfillmentType fulfillmentType = null)
 {
     UpdateFulfillmentTypeWithHttpInfo(id, fulfillmentType);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Create a fulfillment type &lt;b&gt;Permissions Needed:&lt;/b&gt; FULFILLMENT_ADMIN
        /// </summary>
        /// <exception cref="com.knetikcloud.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="type">The fulfillment type (optional)</param>
        /// <returns>FulfillmentType</returns>
        public FulfillmentType CreateFulfillmentType(FulfillmentType type = null)
        {
            ApiResponse <FulfillmentType> localVarResponse = CreateFulfillmentTypeWithHttpInfo(type);

            return(localVarResponse.Data);
        }