internal Response(int totalOptions, Option[] options, Request input, Model.Link[] links)
        {
            if (links == null) throw new ArgumentNullException("links");

            TotalOptions = totalOptions;
            Options = options;
            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.AutoComplete.Link(link.Rel, link.Href);
                        break;
                    default:
                        newLink = link;
                        break;
                }

                newLinks.Add(newLink);
            }

            Links = newLinks.ToArray();
        }
        public static async void Main()
        {
            const string address = "Silver Birches, Dunboyne";
            var autoaddressClient = new AutoaddressClient();

            var request = new Request(address: address, language: Language.EN, country: Country.IE, limit: 20, geographicAddress: false, vanityMode: false, addressElements: false, addressProfileName: null);
            var response = await autoaddressClient.AutoCompleteAsync(request);

            Console.WriteLine("response.TotalOptions = {0}", response.TotalOptions);
            Console.WriteLine("response.Options[0].DisplayName = {0}", response.Options[0].DisplayName);
        }
Esempio n. 3
0
        /// <summary>
        /// Lookup a Postcode or Address auto complete options as an asynchronous operation. Returns all available data if found.
        /// </summary>
        /// <param name="request">AutoComplete request.</param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <example>
        /// The following code example creates an AutoaddressClient and calls AutoCompleteAsync with a request.
        /// <code source="..\src\Autoaddress2.0SDK.Test\Example\AutoaddressClientAutoCompleteAsyncRequestExample1.cs" language="cs" />
        /// </example>
        public async Task <Model.AutoComplete.Response> AutoCompleteAsync(Model.AutoComplete.Request request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

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

            return(response);
        }
Esempio n. 4
0
        /// <summary>
        /// Lookup a Postcode or Address auto complete options. Returns all available data if found.
        /// </summary>
        /// <param name="request">AutoComplete request.</param>
        /// <returns>AutoComplete response.</returns>
        /// <example>
        /// The following code example creates an AutoaddressClient and calls AutoComplete with a request.
        /// <code source="..\src\Autoaddress2.0SDK.Test\Example\AutoaddressClientAutoCompleteRequestExample1.cs" language="cs" />
        /// </example>
        public Model.AutoComplete.Response AutoComplete(Model.AutoComplete.Request request)
        {
            try
            {
                return(AutoCompleteAsync(request).Result);
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    throw e.InnerException;
                }

                throw;
            }
        }