Example #1
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = CarrierConfigurationFactory.UpdateConfiguration(handler : handler,  carrierConfiguration :  carrierConfiguration,  carrierId :  carrierId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<CarrierConfiguration/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration UpdateConfiguration(ServiceClientMessageHandler handler,
                                                                                                Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration carrierConfiguration, string carrierId, 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.Shipping.Admin.CarrierConfigurationClient.UpdateConfigurationClient(
                carrierConfiguration:  carrierConfiguration, carrierId:  carrierId, 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);
        }
        /// <summary>
        /// Updates the details of the specified carrier configuration.
        /// </summary>
        /// <param name="carrierId">The unique identifier of the carrier.</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="carrierConfiguration">Properties of a carrier configured in the shipping admin.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var carrierconfiguration = new CarrierConfiguration();
        ///   var carrierConfiguration = await carrierconfiguration.UpdateConfigurationAsync( carrierConfiguration,  carrierId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> UpdateConfigurationAsync(Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration carrierConfiguration, string carrierId, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> response;
            var client = Mozu.Api.Clients.Commerce.Shipping.Admin.CarrierConfigurationClient.UpdateConfigurationClient(carrierConfiguration, carrierId, responseFields);

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

            return(await response.ResultAsync());
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="carrierId">The unique identifier of the carrier.</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="carrierConfiguration">Properties of a carrier configured in the shipping admin.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var carrierconfiguration = new CarrierConfiguration();
        ///   var carrierConfiguration = await carrierconfiguration.CreateConfigurationAsync( carrierConfiguration,  carrierId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> CreateConfigurationAsync(Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration carrierConfiguration, string carrierId, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> response;
            var client = Mozu.Api.Clients.Commerce.Shipping.Admin.CarrierConfigurationClient.CreateConfigurationClient(carrierConfiguration, carrierId, responseFields);

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

            return(await response.ResultAsync());
        }
        public virtual Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration CreateConfiguration(Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration carrierConfiguration, string carrierId, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> response;
            var client = Mozu.Api.Clients.Commerce.Shipping.Admin.CarrierConfigurationClient.CreateConfigurationClient(carrierConfiguration, carrierId, responseFields);

            client.WithContext(_apiContext);
            response = client.Execute();
            return(response.Result());
        }
Example #5
0
        /// <summary>
        /// Creates a new carrier configuration.
        /// </summary>
        /// <param name="carrierId">The unique identifier of the carrier.</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="carrierConfiguration">Properties of a carrier configured in the shipping admin.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=CreateConfiguration( carrierConfiguration,  carrierId,  responseFields);
        ///   var carrierConfigurationClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration> CreateConfigurationClient(Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration carrierConfiguration, string carrierId, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Shipping.Admin.CarrierConfigurationUrl.CreateConfigurationUrl(carrierId, responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.ShippingAdmin.CarrierConfiguration>(carrierConfiguration);

            return(mozuClient);
        }