Ejemplo n.º 1
0
        public async Task <IResponse <CustomerResponse> > UpdateCustomerAsync(CustomerCreateOption customerCreateOption, AccessToken accessToken)
        {
            Urls.BaseUrl = _settings.GetConfigSetting <string>(SettingKeys.Integration.DTCM.BaseUrl);

            IRequestCreateOptions <CustomerCreateOption> requestCreateOptions = new RequestCreateOptions <CustomerCreateOption>();

            requestCreateOptions.Content = customerCreateOption;
            requestCreateOptions.Header  = new Dictionary <string, string>()
            {
                { "Token", $"{accessToken.Token}" }
            };
            requestCreateOptions.UserAgent = "zoonga.com (http://www.zoonga.com/)";

            IHttpResponse httpResponse = await HttpWebRequestProviders <CustomerCreateOption> .PutBearerWebRequestProvider(string.Format(Urls.LookUpCustomer, customerCreateOption.ID, customerCreateOption.SellerCode), requestCreateOptions).ConfigureAwait(false);

            if (!string.IsNullOrWhiteSpace(httpResponse.Response))
            {
                CustomerResponse customerResponse = Mapper <CustomerResponse> .MapJsonStringToObject(httpResponse.Response);

                return(GetResponse(true, customerResponse));
            }
            else
            {
                _logger.Log(LogCategory.Error, new Exception("Failed to update customer", httpResponse.WebException));
            }
            return(GetResponse(false, null));
        }