lib/gnip_api/search.rb in gnip_api-1.2.0 vs lib/gnip_api/search.rb in gnip_api-1.2.1

- old
+ new

@@ -2,39 +2,36 @@ # # Retrive counts with a provided rule module GnipApi class Search - attr_reader :adapter - - def initialize params={} - @adapter = GnipApi::Adapter.new - @label = params[:label] || GnipApi.config.label - end - def activities options={} required_options?(options) payload = construct_activities_payload(options) request = GnipApi::Request.new_post(activities_endpoint, payload) - data = adapter.post(request) + data = fetch_data(request) return parse_activities_response(data) end def counts options={} required_options?(options) payload = construct_counts_payload(options) request = GnipApi::Request.new_post(count_endpoint, payload) - data = adapter.post(request) + data = fetch_data(request) return parse_counts_response(data) end private + def fetch_data(request) + request.execute! + end + def count_endpoint - GnipApi::Endpoints.search_counts(@label) + GnipApi::Endpoints.search_counts end def activities_endpoint - GnipApi::Endpoints.search_activities(@label) + GnipApi::Endpoints.search_activities end def required_options [:rule] end