Esempio n. 1
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = AttributeFactory.UpdateAttribute(handler : handler,  attribute :  attribute,  attributeFQN :  attributeFQN,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<Attribute/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.Core.Extensible.Attribute UpdateAttribute(ServiceClientMessageHandler handler,
                                                                                   Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string attributeFQN, 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.Customer.Accountattributedefinition.AttributeClient.UpdateAttributeClient(
                attribute:  attribute, attributeFQN:  attributeFQN, responseFields:  responseFields);

            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;
                }
                return(null);
            }
            return(ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                                         ? (apiClient.Result())
                                         : null);
        }
Esempio n. 2
0
        public virtual Mozu.Api.Contracts.Core.Extensible.Attribute UpdateAttribute(Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string attributeFQN, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute> response;
            var client = Mozu.Api.Clients.Commerce.Orders.Attributedefinition.AttributeClient.UpdateAttributeClient(attribute, attributeFQN, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attributeFQN">Fully qualified name for an attribute.</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="attribute"></param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.Core.Extensible.Attribute"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateAttribute( attribute,  attributeFQN,  responseFields);
        ///   var attributeClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute> UpdateAttributeClient(Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string attributeFQN, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Customer.Accountattributedefinition.AttributeUrl.UpdateAttributeUrl(attributeFQN, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.Core.Extensible.Attribute>(attribute);

            return(mozuClient);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attributeFQN">Fully qualified name for an attribute.</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="attribute">Properties of an attribute used to describe customers or orders.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.Core.Extensible.Attribute"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var attribute = new Attribute();
        ///   var attribute = await attribute.UpdateAttributeAsync( attribute,  attributeFQN,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.Core.Extensible.Attribute> UpdateAttributeAsync(Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string attributeFQN, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute> response;
            var client = Mozu.Api.Clients.Commerce.Orders.Attributedefinition.AttributeClient.UpdateAttributeClient(attribute, attributeFQN, responseFields);

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

            return(await response.ResultAsync());
        }
Esempio n. 5
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="attribute">Properties of an attribute used to describe customers or orders.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.Core.Extensible.Attribute"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=CreateAttribute( attribute,  responseFields);
        ///   var attributeClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute> CreateAttributeClient(Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Orders.Attributedefinition.AttributeUrl.CreateAttributeUrl(responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.Core.Extensible.Attribute>(attribute);

            return(mozuClient);
        }
Esempio n. 6
0
        /// <summary>
        /// Create and save a new attribute. These attributes are used in products and product options.
        /// </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="attribute">Properties of an attribute used to describe customers or orders.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.Core.Extensible.Attribute"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var attribute = new Attribute();
        ///   var attribute = await attribute.CreateAttributeAsync( attribute,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.Core.Extensible.Attribute> CreateAttributeAsync(Mozu.Api.Contracts.Core.Extensible.Attribute attribute, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.Core.Extensible.Attribute> response;
            var client = Mozu.Api.Clients.Commerce.Orders.Attributedefinition.AttributeClient.CreateAttributeClient(attribute, responseFields);

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

            return(await response.ResultAsync());
        }