Пример #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));
        }
Пример #2
0
        public async Task <Customer> Create(bool skipAddToCreatedList = false, CustomerCreateOption options = null)
        {
            var obj = await Service.CreateAsync(new Customer()
            {
                FirstName = FirstName,
                LastName  = LastName,
                Email     = Guid.NewGuid().ToString() + "@example.com",
                Addresses = new List <Address>()
                {
                    new Address()
                    {
                        Address1     = "123 4th Street",
                        City         = "Minneapolis",
                        Province     = "Minnesota",
                        ProvinceCode = "MN",
                        Zip          = "55401",
                        Phone        = "555-555-5555",
                        FirstName    = "John",
                        LastName     = "Doe",
                        Company      = "Tomorrow Corporation",
                        Country      = "United States",
                        CountryCode  = "US",
                        Default      = true,
                    }
                },
                VerifiedEmail = true,
                Note          = Note,
                State         = "enabled"
            }, options);

            if (!skipAddToCreatedList)
            {
                Created.Add(obj);
            }

            return(obj);
        }