示例#1
0
        /// <summary>
        /// Returns a list of mini-venues partially matching the search term, near the location in an asynchronous operation
        /// </summary>
        /// <param name="term">A search term to be applied against titles. Must be at least 3 characters long.</param>
        /// <param name="location">A string naming a place in the world</param>
        /// <param name="limit">Number of results to return</param>
        /// <exception cref="ArgumentOutOfRangeException">If term is not at least 3 characters long</exception>
        /// <exception cref="ArgumentNullException">If location is null or empty</exception>
        /// <exception cref="HttpRequestException">If location could not be found</exception>
        /// <returns><c ref="MiniVenuesResponse" /> which contain Meta information about status code of the response and list of mini-venues</returns>
        public async Task <MiniVenuesResponse> GetVenueSuggestionsAsync(string term, string location, int limit = 30)
        {
            if (term.Length < 3)
            {
                throw new ArgumentOutOfRangeException(paramName: nameof(term));
            }

            if (string.IsNullOrEmpty(location))
            {
                throw new ArgumentNullException(paramName: nameof(location));
            }

            var invoker = WebServiceInvoker <MiniVenuesResponse> .Create(_httpClient, new Uri(
                                                                             URI_BASE +
                                                                             SUGGEST_COMPLETION +
                                                                             string.Format(CLIENT_ID, _clientId) +
                                                                             string.Format(CLIENT_SECRET, _clientSecret) +
                                                                             string.Format(NEAR, location) +
                                                                             string.Format(QUERY, term) +
                                                                             string.Format(LIMIT, limit) +
                                                                             VERSION +
                                                                             MODE
                                                                             ));

            return(await invoker.InvokeWebService());
        }
示例#2
0
        /// <summary>
        /// Create and initialize object to handle WebService invoking
        /// </summary>
        /// <param name="httpClient">Client to communicate through</param>
        /// <param name="serviceUri">Uri of the request</param>
        /// <returns>Initialized WebServiceInvoker object</returns>
        public static WebServiceInvoker <T> Create(HttpClient httpClient, Uri serviceUri)
        {
            var invoker = new WebServiceInvoker <T> {
                _httpClient = httpClient
            };

            invoker._httpClient.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
            invoker._serviceUri = serviceUri;

            return(invoker);
        }
示例#3
0
        /// <summary>
        /// Returns a complete venue matching given id in an asynchronous operation
        /// </summary>
        /// <param name="id">ID of venue to retrieve</param>
        /// <exception cref="ArgumentNullException">If id is null or empty</exception>
        /// <returns><c ref="VenueResponse" /> which contain Meta information about status code of the response and a complete venue</returns>
        public async Task <VenueResponse> GetVenueAsync(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(paramName: nameof(id));
            }

            var invoker = WebServiceInvoker <VenueResponse> .Create(_httpClient, new Uri(
                                                                        URI_BASE +
                                                                        id + "?" +
                                                                        string.Format(CLIENT_ID, _clientId) +
                                                                        string.Format(CLIENT_SECRET, _clientSecret) +
                                                                        VERSION +
                                                                        MODE
                                                                        ));

            return(await invoker.InvokeWebService());
        }