Пример #1
0
        /// <summary>
        ///
        /// <example>
        ///  <code>
        /// var result = B2BAccountFactory.UpdateUser(handler : handler,  user :  user,  accountId :  accountId,  userId :  userId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode);
        /// var optionalCasting = ConvertClass<B2BUser/>(result);
        /// return optionalCasting;
        ///  </code>
        /// </example>
        /// </summary>
        public static Mozu.Api.Contracts.Customer.B2BUser UpdateUser(ServiceClientMessageHandler handler,
                                                                     Mozu.Api.Contracts.Customer.B2BUser user, int accountId, string userId, 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.B2BAccountClient.UpdateUserClient(
                user:  user, accountId:  accountId, userId:  userId, 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);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountId">Unique identifier of the customer account.</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="userId">Unique identifier of the user whose tenant scopes you want to retrieve.</param>
        /// <param name="user"></param>
        /// <returns>
        ///  <see cref="Mozu.Api.MozuClient" />{<see cref="Mozu.Api.Contracts.Customer.B2BUser"/>}
        /// </returns>
        /// <example>
        /// <code>
        ///   var mozuClient=UpdateUser( user,  accountId,  userId,  responseFields);
        ///   var b2BUserClient = mozuClient.WithBaseAddress(url).Execute().Result();
        /// </code>
        /// </example>
        public static MozuClient <Mozu.Api.Contracts.Customer.B2BUser> UpdateUserClient(Mozu.Api.Contracts.Customer.B2BUser user, int accountId, string userId, string responseFields = null)
        {
            var          url        = Mozu.Api.Urls.Commerce.Customer.B2BAccountUrl.UpdateUserUrl(accountId, userId, responseFields);
            const string verb       = "PUT";
            var          mozuClient = new MozuClient <Mozu.Api.Contracts.Customer.B2BUser>()
                                      .WithVerb(verb).WithResourceUrl(url)
                                      .WithBody <Mozu.Api.Contracts.Customer.B2BUser>(user);

            return(mozuClient);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="responseFields"></param>
        /// <param name="userId"></param>
        /// <param name="user"></param>
        /// <returns>
        /// <see cref="Mozu.Api.Contracts.Customer.B2BUser"/>
        /// </returns>
        /// <example>
        /// <code>
        ///   var b2baccount = new B2BAccount();
        ///   var b2BUser = await b2baccount.UpdateUserAsync( user,  accountId,  userId,  responseFields);
        /// </code>
        /// </example>
        public virtual async Task <Mozu.Api.Contracts.Customer.B2BUser> UpdateUserAsync(Mozu.Api.Contracts.Customer.B2BUser user, int accountId, string userId, string responseFields = null, CancellationToken ct = default(CancellationToken))
        {
            MozuClient <Mozu.Api.Contracts.Customer.B2BUser> response;
            var client = Mozu.Api.Clients.Commerce.Customer.B2BAccountClient.UpdateUserClient(user, accountId, userId, responseFields);

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

            return(await response.ResultAsync());
        }