public void Construct() { var service = new GooglePlacesApiService(GoogleApiSettings.Builder.WithApiKey("testkey").Build()); service.Should() .BeOfType <GooglePlacesApiService>(); }
public SimpleFormViewModel(INavigation navigation) { _navigation = navigation; var settings = GoogleApiSettings.Builder.WithApiKey(Environment.GetEnvironmentVariable("GOOGLE_PLACES_API_KEY")).Build(); _api = new GooglePlacesApiService(settings); }
public void ThrowWhenPlaceIdIsNullOrEmpty(string input) { var service = new GooglePlacesApiService(GoogleApiSettings.Builder.WithApiKey("testkey").Build()); var action = new Func <Task>(async() => await service.GetDetailsAsync(input, service.GetSessionToken())); action.Should() .Throw <ArgumentNullException>() .WithMessage($"Value cannot be null.{Environment.NewLine}Parameter name: placeId"); }
public DomainFinder() { _google_api_key = ConfigurationManager.AppSettings.Get("google_api"); _settings = GoogleApiSettings.Builder .WithApiKey(_google_api_key) .WithType(PlaceTypes.Establishment) .WithDetailLevel(DetailLevel.Contact) .Build(); _service = new GooglePlacesApiService(_settings); }
public SimpleFormDetailViewModel(string placeId, string sessionToken) { _placeId = placeId; var settings = GoogleApiSettings.Builder.WithApiKey(Environment.GetEnvironmentVariable("GOOGLE_PLACES_API_KEY")).WithSessionToken(sessionToken).Build(); _api = new GooglePlacesApiService(settings); Details = Task.Run(async() => await GetPlaceDetailsAsync()).Result; Task.Run(() => GetPhotoAsync(Details.Place.Photos[0].PhotoReference)); }
static async Task Main(string[] args) { var settings = GooglePlacesApi.Models.GoogleApiSettings.Builder .WithApiKey(Environment.GetEnvironmentVariable("GOOGLE_PLACES_API_KEY")) .WithType(GooglePlacesApi.Models.PlaceTypes.GeoCode) .Build(); var service = new GooglePlacesApiService(settings); var result = await service.GetPredictionsAsync("new y") .ConfigureAwait(false); if (result != null && result.Status.Equals("OK") && result.Items != null) { //foreach(var item in result.Items) //{ // Console.WriteLine("=========== PREDICTION ==========="); // Console.WriteLine(item.Description); // var details = await service.GetDetailsAsync(item.PlaceId) // .ConfigureAwait(false); // if(details != null) // { // Console.WriteLine("=========== DETAILS ==========="); // Console.WriteLine($"Id: {details.Place.Id}"); // Console.WriteLine($"PlaceId: {details.Place.PlaceId}"); // Console.WriteLine($"FormattedAddress: {details.Place.FormattedAddress}"); // Console.WriteLine($"Icon: {details.Place.Icon}"); // Console.WriteLine($"Icon: {details.Place.Reference}"); // } //} var item = result.Items.FirstOrDefault(); Console.WriteLine("=========== PREDICTION ==========="); Console.WriteLine(item.Description); var details = await service.GetDetailsAsync(item.PlaceId, service.GetSessionToken()) .ConfigureAwait(false); if (details != null) { Console.WriteLine("=========== DETAILS ==========="); Console.WriteLine($"Id: {details.Place.Id}"); Console.WriteLine($"PlaceId: {details.Place.PlaceId}"); Console.WriteLine($"FormattedAddress: {details.Place.FormattedAddress}"); Console.WriteLine($"Icon: {details.Place.Icon}"); Console.WriteLine($"Icon: {details.Place.Reference}"); } } }
public MainForm() { InitializeComponent(); _log = new LoggerConfiguration() .WriteTo.Console() .MinimumLevel.Debug() .CreateLogger(); _googlePlacesApiService = new GooglePlacesApiService(PlacesApiUrl, ApiKey); _googlePlacesResponseAssembler = new GooglePlacesResponseAssembler(GeocodingApiUrl, ApiKey); _debounceDispatcher = new DebounceDispatcher(500); _searchSuggestions = new List <SearchSuggestion>(); }
public async Task GetDetailsAsync() { var settings = GoogleApiSettings.Builder .WithApiKey(Environment.GetEnvironmentVariable("GOOGLE_PLACES_API_KEY")) .WithLogger(_refitLogger) .WithType(PlaceTypes.GeoCode) .Build(); var service = new GooglePlacesApiService(settings); var predictions = await service.GetPredictionsAsync("new y") .ConfigureAwait(false); var details = await service.GetDetailsAsync(predictions.Items.FirstOrDefault().PlaceId, service.GetSessionToken()) .ConfigureAwait(false); details.Should() .NotBeNull(); details.Place .Should() .NotBeNull(); }
public async Task GetPredictionsAsync() { var settings = GoogleApiSettings.Builder .WithApiKey(Environment.GetEnvironmentVariable("GOOGLE_PLACES_API_KEY")) .WithLogger(_refitLogger) .WithType(PlaceTypes.GeoCode) .Build(); var service = new GooglePlacesApiService(settings); var result = await service.GetPredictionsAsync("new y") .ConfigureAwait(false); result.Should() .NotBeNull(); result.Status .Should() .Be("OK"); result.Items .Should() .NotBeNullOrEmpty(); }