Ejemplo n.º 1
0
        /// <summary>
        /// Updates the details of the specified target rule.
        /// <example>
        ///  <code>
        /// var result = TargetRuleFactory.UpdateTargetRule(handler : handler,  targetRule :  targetRule,  code :  code,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<TargetRule/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ShippingAdmin.TargetRule UpdateTargetRule(ServiceClientMessageHandler handler,
                                                                                   Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, string code, string responseFields = null,
                                                                                   HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
        {
            SetSdKparameters();
            var currentClassName  = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.WriteLine(currentMethodName + '.' + currentMethodName);
            var apiClient = Mozu.Api.Clients.Commerce.TargetRuleClient.UpdateTargetRuleClient(
                targetRule:  targetRule, code:  code, responseFields:  responseFields);

            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                {
                    throw customException;
                }
                return(null);
            }
            return(ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                                         ? (apiClient.Result())
                                         : null);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = TargetRuleFactory.ValidateTargetRule(handler : handler,  targetRule :  targetRule,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<void/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static void ValidateTargetRule(ServiceClientMessageHandler handler,
                                              Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule,
                                              HttpStatusCode expectedCode = HttpStatusCode.NoContent, HttpStatusCode successCode = HttpStatusCode.NoContent)
        {
            SetSdKparameters();
            var currentClassName  = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Debug.WriteLine(currentMethodName + '.' + currentMethodName);
            var apiClient = Mozu.Api.Clients.Commerce.TargetRuleClient.ValidateTargetRuleClient(
                targetRule:  targetRule);

            try
            {
                apiClient.WithContext(handler.ApiContext).ExecuteAsync(default(CancellationToken)).Wait();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                {
                    throw customException;
                }
            }
            var noResponse = ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                                         ? (apiClient.Result())
                                         : null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Validates the details of a target rule.
        /// </summary>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the target rule you want to validate.</param>
        /// <returns>
        ///
        /// </returns>
        /// <example>
        /// <code>
        ///   var targetrule = new TargetRule();
        ///   await targetrule.ValidateTargetRuleAsync( targetRule);
        /// </code>
        /// </example>
        public virtual async Task ValidateTargetRuleAsync(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule)
        {
            MozuClient response;
            var        client = Mozu.Api.Clients.Commerce.TargetRuleClient.ValidateTargetRuleClient(targetRule);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the target rule you want to validate.</param>
        /// <returns>
        ///
        /// </returns>
        /// <example>
        /// <code>
        ///   var targetrule = new TargetRule();
        ///   await targetrule.ValidateTargetRuleAsync( targetRule);
        /// </code>
        /// </example>
        public virtual async Task ValidateTargetRuleAsync(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, CancellationToken ct = default(CancellationToken))
        {
            MozuClient response;
            var        client = Mozu.Api.Clients.Commerce.TargetRuleClient.ValidateTargetRuleClient(targetRule);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync(ct).ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        public virtual void ValidateTargetRule(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule)
        {
            MozuClient response;
            var        client = Mozu.Api.Clients.Commerce.TargetRuleClient.ValidateTargetRuleClient(targetRule);

            client.WithContext(_apiContext);
            response = client.Execute();
        }
Ejemplo n.º 6
0
        public virtual Mozu.Api.Contracts.ShippingAdmin.TargetRule UpdateTargetRule(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, string code, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.TargetRule> response;
            var client = Mozu.Api.Clients.Commerce.TargetRuleClient.UpdateTargetRuleClient(targetRule, code, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the target rule you want to validate.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=ValidateTargetRule( targetRule);
        ///mozuClient.WithBaseAddress(url).Execute();
        /// </code>
        /// </example>
        public static MozuClient ValidateTargetRuleClient(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule)
        {
            var          url        = Mozu.Api.Urls.Commerce.TargetRuleUrl.ValidateTargetRuleUrl();
            const string verb       = "POST";
            var          mozuClient = new MozuClient()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ShippingAdmin.TargetRule>(targetRule);

            return(mozuClient);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code">User-defined code that uniqely identifies the channel group.</param>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the updated target rule.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ShippingAdmin.TargetRule"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var targetrule = new TargetRule();
        ///   var targetRule = await targetrule.UpdateTargetRuleAsync( targetRule,  code,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ShippingAdmin.TargetRule> UpdateTargetRuleAsync(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, string code, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.TargetRule> response;
            var client = Mozu.Api.Clients.Commerce.TargetRuleClient.UpdateTargetRuleClient(targetRule, code, responseFields);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync(ct).ConfigureAwait(false);

            return(await response.ResultAsync());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new target rule.
        /// </summary>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the new target rule.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ShippingAdmin.TargetRule"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var targetrule = new TargetRule();
        ///   var targetRule = await targetrule.CreateTargetRuleAsync( targetRule,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ShippingAdmin.TargetRule> CreateTargetRuleAsync(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.TargetRule> response;
            var client = Mozu.Api.Clients.Commerce.TargetRuleClient.CreateTargetRuleClient(targetRule, responseFields);

            client.WithContext(_apiContext);
            response = await client.ExecuteAsync();

            return(await response.ResultAsync());
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="responseFields">Filtering syntax appended to an API call to increase or decrease the amount of data returned inside a JSON object. This parameter should only be used to retrieve data. Attempting to update data using this parameter may cause data loss.</param>
        /// <param name="dataViewMode">{<see cref="Mozu.Api.DataViewMode"/>}</param>
        /// <param name="targetRule">The details of the new target rule.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ShippingAdmin.TargetRule"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=CreateTargetRule( targetRule,  responseFields);
        ///   var targetRuleClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ShippingAdmin.TargetRule> CreateTargetRuleClient(Mozu.Api.Contracts.ShippingAdmin.TargetRule targetRule, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.TargetRuleUrl.CreateTargetRuleUrl(responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ShippingAdmin.TargetRule>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ShippingAdmin.TargetRule>(targetRule);

            return(mozuClient);
        }