public async Task <GeocodeResponse> GetGeocodeAsync(
            GeocodeRequest request)
        {
            if (request is null)
            {
                return(null);
            }

            var response = await GetResponseAsync(request);

            return(JsonConvert.DeserializeObject <GeocodeResponse>(response));
        }
Esempio n. 2
0
        /// <summary>
        /// Geocode an address.
        /// </summary>
        /// <param name="request">A GeocodeRequest instance.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>GeocodeResponse</returns>
        public async Task <GeocodeResponse> GeocodeAsync(
            GeocodeRequest request,
            CancellationToken cancellationToken = default)
        {
            if (request is null)
            {
                return(InvalidResponse <GeocodeResponse>());
            }

            if (cancellationToken.IsCancellationRequested)
            {
                return(CancelledResponse2 <GeocodeResponse>());
            }

            return(await RequestAsync <GeocodeResponse>(request, cancellationToken).ConfigureAwait(false));
        }