Class: Google::GoogleApi
- Inherits:
-
Object
- Object
- Google::GoogleApi
- Defined in:
- lib/Time_Traveler/google_api.rb
Overview
Service for all Google API calls
Constant Summary collapse
- Google_URL =
Setting the URL and parameters
'https://maps.googleapis.com/maps/api/'- Search_Type =
'distancematrix'- Return_Type =
'json'- Google_API_URL =
URI.join(Google_URL, "#{Search_Type}/", "#{Return_Type}")
Instance Attribute Summary collapse
-
#google_data ⇒ Object
readonly
Search_URL = URI.join(Google_API_URL, “#Parms”).
Class Method Summary collapse
- .analysis(posting_id) ⇒ Object
- .config ⇒ Object
- .config=(credentials) ⇒ Object
- .distanceInfo(origins, dest, mode) ⇒ Object
Instance Attribute Details
#google_data ⇒ Object (readonly)
Search_URL = URI.join(Google_API_URL, “#Parms”)
12 13 14 |
# File 'lib/Time_Traveler/google_api.rb', line 12 def google_data @google_data end |
Class Method Details
.analysis(posting_id) ⇒ Object
23 24 25 |
# File 'lib/Time_Traveler/google_api.rb', line 23 def self.analysis(posting_id) fb_resource(posting_id) end |
.config ⇒ Object
18 19 20 21 |
# File 'lib/Time_Traveler/google_api.rb', line 18 def self.config return @config if @config @config = { googlemap_id: ENV['GOOGLE_API'] } end |
.config=(credentials) ⇒ Object
14 15 16 |
# File 'lib/Time_Traveler/google_api.rb', line 14 def self.config=(credentials) @config ? @config.update(credentials) : @config = credentials end |
.distanceInfo(origins, dest, mode) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/Time_Traveler/google_api.rb', line 27 def self.distanceInfo(origins, dest, mode) return @distance if @distance distanceDetail = HTTP.get(Google_API_URL, params: { key: config['googlemap_id'], origins: origins, destinations: dest, mode: mode }) distance_data = JSON.load(distanceDetail.to_s)['rows'][0]['elements'] end |