コード例 #1
0
        public long EnsureCustomerExists(OrderPayload payload)
        {
            var existing = _customerApi.Search($"email:{payload.CustomerEmail}");
            var results  = existing.DeserializeFromJson <CustomerList>().customers;

            if (results.Count == 0)
            {
                var newCustomerJson = _customerApi.Create(payload.CustomerJson);
                return(newCustomerJson.DeserializeFromJson <CustomerParent>().customer.id);
            }
            else
            {
                return(results.First().id);
            }
        }