Ejemplo n.º 1
0
        public static Lookup MapToUSStreetLookup(Address address)
        {
            var lookup = new Lookup()
            {
                Street        = address.Street1,
                Street2       = address.Street2,
                City          = address.City,
                State         = address.State,
                ZipCode       = address.Zip,
                MatchStrategy = Lookup.STRICT,
                MaxCandidates = 5
            };

            return(lookup);
        }
Ejemplo n.º 2
0
        public static bool ValidateAddress(string address, string city, string state, string zip)
        {
            var authId    = Environment.GetEnvironmentVariable("SMARTY_AUTH_ID", EnvironmentVariableTarget.Machine);
            var authToken = Environment.GetEnvironmentVariable("SMARTY_AUTH_TOKEN", EnvironmentVariableTarget.Machine);

            var client = new ClientBuilder(authId, authToken).BuildUsStreetApiClient();

            var lookup = new SmartyStreets.USStreetApi.Lookup
            {
                Street        = address,
                City          = city,
                State         = state,
                ZipCode       = zip,
                MatchStrategy = SmartyStreets.USStreetApi.Lookup.STRICT
            };

            try
            {
                client.Send(lookup);
            }
            catch (SmartyException ex)
            {
                //handle exceptions
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            catch (IOException ex)
            {
                //handle exceptions
                Console.WriteLine(ex.StackTrace);
            }

            var candidates = lookup.Result;

            if (candidates.Count == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 3
0
 public void Send(Lookup lookup)
 {
     this.Send(new Batch {
         lookup
     });
 }