class Airports::GoogleMapApi
Service to transform location to geocode
Constants
- GOOGLEMAP_URL
- SEARCH_URL
Public Class Methods
config()
click to toggle source
# File lib/movlog/googlemap_api.rb, line 15 def self.config return @config if @config @config = { key: ENV['GOOGLEMAP_KEY'] } end
config=(credentials)
click to toggle source
# File lib/movlog/googlemap_api.rb, line 10 def self.config=(credentials) @config = {} unless @config @config.update(credentials) end
geocode(location)
click to toggle source
# File lib/movlog/googlemap_api.rb, line 22 def self.geocode(location) search_response = HTTP.get( SEARCH_URL, params: { address: location, key: config[:key] } ) JSON.parse(search_response.to_s)['results'].first end