Sha256: ba6916e1f0447b65db5459b8ac253c7fba1ff0d5ec37f856c4f1cf2c7619637a
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
require 'koine/google_maps_client/version' require 'rest-client' require 'json' module Koine class GoogleMapsClient BASE_URL = 'https://maps.googleapis.com/maps/api' def initialize(api_key: nil, http_client: RestClient) @http_client = http_client @api_key = api_key end def geocode(address:) get('/geocode/json', address: address) end def get(uri, params = {}) to_hash do http_client.get(url_for(uri), params: params.merge(key: api_key)) end end private def url_for(uri) "#{BASE_URL}#{uri}" end def to_hash response = yield JSON.parse(response.body) end attr_reader :http_client attr_reader :api_key end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
koine-google_maps_client-0.1.0 | lib/koine/google_maps_client.rb |