示例#1
0
        /// <summary>
        /// Verify that the address supplied matches the Eircode supplied as an asynchronous operation.
        /// </summary>
        /// <param name="request">VerifyAddress request.</param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <example>
        /// The following code example creates an AutoaddressClient and calls VerifyAddressAsync with a request.
        /// <code source="..\src\Autoaddress2.0SDK.Test\Example\AutoaddressClientVerifyAddressAsyncRequestExample1.cs" language="cs" />
        /// </example>
        public async Task <Model.VerifyAddress.Response> VerifyAddressAsync(Model.VerifyAddress.Request request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            Uri requestUri = GetRequestUri(_licenceKey, request.Txn, _autoaddressConfig.ApiBaseAddress, Version, VerifyAddressMethod, request);
            var response   = await GetResponseAsync <Model.VerifyAddress.Response>(request, requestUri);

            return(response);
        }
        public static void Main()
        {
            const string address = "8 Silver Birches, Dunboyne";
            const string postcode = "A86VC04";
            var autoaddressClient = new AutoaddressClient();

            var request = new Request(postcode: postcode, address: address, language: Language.EN, country: Country.IE, geographicAddress: false, vanityMode: false);
            var response = autoaddressClient.VerifyAddress(request);

            Console.WriteLine("response.Result = {0}", response.Result);
            Console.WriteLine("response.MatchLevel = {0}", response.MatchLevel);
            Console.WriteLine("response.AddressType = {0}", response.AddressType);
            Console.WriteLine("response.AddressId = {0}", response.AddressId);
            Console.WriteLine("response.Postcode = {0}", response.Postcode);
            Console.WriteLine("response.PostalAddress = {0}", string.Join(",", response.PostalAddress));
        }
示例#3
0
        /// <summary>
        /// Verify that the address supplied matches the Eircode supplied.
        /// </summary>
        /// <param name="request">VerifyAddress request.</param>
        /// <returns>VerifyAddress response.</returns>
        /// <example>
        /// The following code example creates an AutoaddressClient and calls VerifyAddress with a request.
        /// <code source="..\src\Autoaddress2.0SDK.Test\Example\AutoaddressClientVerifyAddressRequestExample1.cs" language="cs" />
        /// </example>
        public Model.VerifyAddress.Response VerifyAddress(Model.VerifyAddress.Request request)
        {
            try
            {
                return(VerifyAddressAsync(request).Result);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    throw e.InnerException;
                }

                throw;
            }
        }
        internal Response(ReturnCode result,
                          string[] postalAddress,
                          string[] geographicAddress,
                          string[] vanityAddress,
                          string postcode,
                          int? addressId,
                          AddressType? addressType,
                          MatchLevel? matchLevel,
                          Request input,
                          Model.Link[] links)
        {
            if (links == null) throw new ArgumentNullException("links");

            Result = result;
            PostalAddress = postalAddress;
            GeographicAddress = geographicAddress;
            VanityAddress = vanityAddress;
            Postcode = postcode;
            AddressId = addressId;
            AddressType = addressType;
            MatchLevel = matchLevel;
            Input = input;
            
            var newLinks = new List<Model.Link>();

            foreach (Model.Link link in links)
            {
                Model.Link newLink;

                switch (link.Rel)
                {
                    case "self":
                        newLink = new Model.VerifyAddress.Link(link.Rel, link.Href);
                        break;
                    default:
                        newLink = link;
                        break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }