Class: SgPostcode::Google

Inherits:
Object
  • Object
show all
Defined in:
lib/sg_postcode/services/google.rb

Constant Summary collapse

REQUEST_SERVICE_URL =

Request URL

'https://maps.googleapis.com/maps/api/geocode/json'

Instance Method Summary collapse

Constructor Details

#initialize(postcode) ⇒ Google

Returns a new instance of Google.



8
9
10
# File 'lib/sg_postcode/services/google.rb', line 8

def initialize(postcode)
  @postcode = postcode
end

Instance Method Details

#requestObject

Send Request with the postcode included as a params

Examples:

sender = SgPostcode:Google.new('238432')
sender.request


18
19
20
# File 'lib/sg_postcode/services/google.rb', line 18

def request
  RestClient.get REQUEST_SERVICE_URL, { params: { address: @postcode } }
end