Esempio n. 1
0
        public async Task <CreateCustomerResponse> CreateCustomer(CreateCustomerRequest customer)
        {
            var body = new CreateCustomersRequest();

            body.Customers.Add(customer);

            var response = await CreateCustomers(body);

            return(new CreateCustomerResponse
            {
                Message = response.Message,
                Customer = response.Customers.FirstOrDefault()
            });
        }
Esempio n. 2
0
        public async Task <CreateCustomersResponse> CreateCustomers(CreateCustomersRequest customers)
        {
            try
            {
                return(await starkBankChargeClient.CreateCustomersAsync(customers));
            }
            catch (ApiException ex)
            {
                using (logger.BeginScope($"Criar cliente"))
                {
                    logger.LogCritical(ex, "Ocorreu erro ao tentar criar cliente.");
                    logger.LogError($"Resposta do StarkBank: {ex.Content}");
                };

                throw;
            }
        }
Esempio n. 3
0
        public void CustomersApi_CreateCustomer()
        {
            CustomersApi api = new CustomersApi(BaseUrl, apiToken, apiKey);

            CreateCustomersRequest req = new CreateCustomersRequest();

            req.BirthDate = DateTime.Today.AddYears(-30);
            req.Email     = "*****@*****.**";
            req.Fullname  = "Teste moip client 4";
            req.OwnId     = "3";
            req.Phone     = new PhoneDto()
            {
                AreaCode    = 11,
                CountryCode = 55,
                Number      = 98985959
            };
            req.ShippingAddress = new AddressDto()
            {
                City         = "Sao Paulo",
                Complement   = "A",
                Country      = "BR",
                District     = "SP",
                State        = "SP",
                Street       = "Sao paullo",
                StreetNumber = "12",
                ZipCode      = "09090170"
            };
            req.TaxDocument = new DocumentDto()
            {
                Number = "95672830013",
                Type   = DocumentType.CPF
            };



            var retorno = api.CreateCustomer(req);

            Assert.IsNotNull(retorno);
            Assert.IsNotNull(retorno.Id);
        }