コード例 #1
0
        /// <summary>
        /// Creates a new subscription that notifies the customer when the product specified in the request is available in the active inventory of the defined location.
        /// </summary>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="inStockNotificationSubscription">Properties of a push notification to which the shopper subscribes. This notification sends the shopper an alert when a new product or a product previously out of stock becomes available in the specified location's active product inventory.</param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.Customer.InStockNotificationSubscription"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var instocknotificationsubscription = new InStockNotificationSubscription();
        ///   var inStockNotificationSubscription = await instocknotificationsubscription.AddInStockNotificationSubscriptionAsync( inStockNotificationSubscription,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.Customer.InStockNotificationSubscription> AddInStockNotificationSubscriptionAsync(Mozu.Api.Contracts.Customer.InStockNotificationSubscription inStockNotificationSubscription, string responseFields = null)
        {
            MozuClient <Mozu.Api.Contracts.Customer.InStockNotificationSubscription> response;
            var client = Mozu.Api.Clients.Commerce.InStockNotificationSubscriptionClient.AddInStockNotificationSubscriptionClient(inStockNotificationSubscription, responseFields);

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

            return(await response.ResultAsync());
        }
コード例 #2
0
        /// <summary>
        /// Creates a new subscription that notifies the customer when the product specified in the request is available in the active inventory of the defined location.
        /// </summary>
        /// <param name="responseFields">Use this field to include those fields which are not included by default.</param>
        /// <param name="inStockNotificationSubscription">Properties of a push notification to which the shopper subscribes. This notification sends the shopper an alert when a new product or a product previously out of stock becomes available in the specified location's active product inventory.</param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.Customer.InStockNotificationSubscription"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=AddInStockNotificationSubscription( inStockNotificationSubscription,  responseFields);
        ///   var inStockNotificationSubscriptionClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.Customer.InStockNotificationSubscription> AddInStockNotificationSubscriptionClient(Mozu.Api.Contracts.Customer.InStockNotificationSubscription inStockNotificationSubscription, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.InStockNotificationSubscriptionUrl.AddInStockNotificationSubscriptionUrl(responseFields);
            const string verb       = "POST";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.Customer.InStockNotificationSubscription>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.Customer.InStockNotificationSubscription>(inStockNotificationSubscription);

            return(mozuClient);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new subscription that notifies the customer when the product specified in the request is available in the active inventory of the defined location.
        /// <example>
        ///  <code>
        /// var result = InStockNotificationSubscriptionFactory.AddInStockNotificationSubscription(handler : handler,  inStockNotificationSubscription :  inStockNotificationSubscription,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<InStockNotificationSubscription/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.Customer.InStockNotificationSubscription AddInStockNotificationSubscription(ServiceClientMessageHandler handler,
                                                                                                                     Mozu.Api.Contracts.Customer.InStockNotificationSubscription inStockNotificationSubscription, string responseFields = null,
                                                                                                                     HttpStatusCode expectedCode = HttpStatusCode.Created, HttpStatusCode successCode = HttpStatusCode.Created)
        {
            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.InStockNotificationSubscriptionClient.AddInStockNotificationSubscriptionClient(
                inStockNotificationSubscription:  inStockNotificationSubscription, 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);
        }