lib/services/search.rb in Active-0.0.11 vs lib/services/search.rb in Active-0.0.12

- old
+ new

@@ -28,11 +28,11 @@ end end class Search attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset, :latitude, :longitude, - :view, :facet, :sort, :num_results, :asset_ids + :view, :facet, :sort, :num_results, :asset_ids, :dma attr_reader :results, :endIndex, :pageSize, :searchTime, :numberOfResults, :end_point, :meta SEARCH_URL = "http://search.active.com" DEFAULT_TIMEOUT = 60 @@ -56,10 +56,11 @@ self.end_date = data[:end_date] || "+" self.asset_ids = data[:asset_ids] || [] self.asset_id = data[:asset_id] || "" self.latitude = data[:latitude] self.longitude = data[:longitude] + self.dma = data[:dma] end # Example # Search.search( {:zips => "92121, 92078, 92114"} ) # or @@ -127,14 +128,19 @@ end # LOCATION # 1 Look for zip codes # 2 Look for lat lng # 3 Look for a formatted string "San Diego, CA, US" + # 4 Look for a dma if not @zips.empty? loc_str = @zips.join(",") elsif @latitude and @longitude loc_str = "#{@latitude};#{@longitude}" + elsif @dma + loc_str = "" + meta_data += "+AND+" unless meta_data == "" + meta_data += "meta:dma=#{Search.double_encode_channel(@dma)}" else loc_str = @location end @@ -205,9 +211,12 @@ # 2 Look for lat lng # Search.search( {:latitude=>"37.785895", :longitude=>"-122.40638"} ) # # 3 Look for a formatted string "San Diego, CA, US" # Search.search( {:location = "San Diego, CA, US"} ) + # + # 4 Look for a DMA + # Search.new({:dma=>"San Francisco - Oakland - San Jose"}) # # = How to look at the results = # # # http://developer.active.com/docs/Activecom_Search_API_Reference \ No newline at end of file