lib/services/search.rb in Active-0.0.28 vs lib/services/search.rb in Active-0.0.29
- old
+ new
@@ -28,11 +28,11 @@
"activities"
end
end
class Search
- attr_accessor :api_key, :start_date, :end_date, :location, :channels, :keywords, :search, :radius, :limit, :sort, :page, :offset, :latitude, :longitude,
+ attr_accessor :api_key, :start_date, :end_date, :location, :channels, :split_media_type, :keywords, :search, :radius, :limit, :sort, :page, :offset, :latitude, :longitude,
:view, :facet, :sort, :num_results, :asset_ids, :dma, :city, :state, :country, :bounding_box
attr_reader :results, :endIndex, :pageSize, :searchTime, :numberOfResults, :end_point, :meta
SEARCH_URL = "http://search.active.com"
@@ -41,10 +41,11 @@
def initialize(data={})
self.api_key = data[:api_key] || ""
self.location = data[:location]
self.zips = data[:zips] || []
self.channels = data[:channels] || []
+ self.split_media_type= data[:split_media_type] || []
self.keywords = data[:keywords] || []
self.radius = data[:radius] || nil
self.limit = data[:limit] || "10"
self.sort = data[:sort] || Sort.DATE_ASC
self.page = data[:page] || "1"
@@ -132,10 +133,12 @@
if Categories.CHANNELS.include?(c)
channel_keys << Categories.CHANNELS[c]
end
end
meta_data = channel_keys.collect { |channel| "meta:channel=#{Search.double_encode_channel(channel)}" }.join("+OR+")
+ # SPLIT MEDIA TYPE
+ meta_data += split_media_type.collect { |type| "+meta:splitMediaType=#{Search.double_encode_channel(type)}" }.join("+OR+")
# ASSET IDS
unless asset_ids.empty?
meta_data += "+AND+" unless meta_data == ""
temp_ids = []
asset_ids.each do |id|
@@ -265,9 +268,13 @@
# = Keywords =
# Keywords can be set like this
# Search.new({:keywords => "Dog,Cat,Cow"})
# Search.new({:keywords => %w(Dog Cat Cow)})
# Search.new({:keywords => ["Dog","Cat","Cow"]})
+ #
+ # = Channels and MediaType =
+ # Search.new({:channels => [:running], :split_media_type => ["5k"]})
+ # for a list of channels and splitMediaTypes please see http://developer.active.com/docs/Activecom_Search_API_Reference
#
# = Location =
# The location will be set in this order and will override other values. For example is you set a zip code and a location only the zip will be used.
#
# 1 Look for zip codes
\ No newline at end of file