Module: Sem4r::GeoLocationAccountExtension

Included in:
Account
Defined in:
lib/sem4r/geo_location/geo_location_account_extension.rb

Instance Method Summary collapse

Instance Method Details

#geo_location(c1 = nil, c2 = nil, c3 = nil) ⇒ Object

Call geolocation adwords service

Examples:

.geo_location("Roma", "IT")
.geo_location("Via Conca del Naviglio", "Milano", "IT")
.geo_location( geoLocationSelector )


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sem4r/geo_location/geo_location_account_extension.rb', line 36

def geo_location(c1 = nil, c2 = nil, c3 = nil)
  if c1.class != GeoLocationSelector
    selector = GeoLocationSelector.new
    selector.address do
      if c3
        address c1
        city c2
        country c3
      else
        city c1
        country c2
      end
    end
  else
    selector = c1
  end

  soap_message = service.geo_location.get(credentials, selector.to_xml)
  add_counters(soap_message.counters)
  # cost = REXML::XPath.first( soap_message.response, "//getResponse/rval/cost")
  # cost.text.to_i
end