示例#1
0
        private async Task <bool> EmailExistsAsync(string email)
        {
            string normalizedEmail = email.ToLower();
            var    emails          = new List <string>();
            var    result          = new CustomerListResult();
            string startingAfter;

            result = await _client.GetJsonAsync <CustomerListResult>($"customers");

            emails.AddRange(result.Data.Select(t => t.Email.ToLower()));

            if (emails.Any(t => t == normalizedEmail))
            {
                return(true);
            }

            while (result.HasMore)
            {
                startingAfter = result.Data
                                .OrderBy(t => t.CreatedSeconds)
                                .Select(t => t.Id)
                                .First();

                result = await _client.GetJsonAsync <CustomerListResult>($"customers?starting_after={startingAfter}");

                emails.AddRange(result.Data.Select(t => t.Email.ToLower()));

                if (emails.Any(t => t == normalizedEmail))
                {
                    return(true);
                }
            }

            return(emails.Any(t => t == normalizedEmail));
        }
        public async Task <CustomerListResult> GetCustomerListAsync()
        {
            CustomerListResult customerListResult = new CustomerListResult();

            customerListResult = await _baseService.GetAsync <CustomerListResult>("/Card/GetListMobile");

            return(customerListResult);
        }