lib/postrank-api/api.rb in postrank-api-0.1.3 vs lib/postrank-api/api.rb in postrank-api-0.2.0

- old
+ new

@@ -43,37 +43,36 @@ http = get("#{V2_API_BASE}/feed/", req) parse(http.response) end - def recommendations(feeds, opts = {}) + def recommendations(feeds, opts = {}) req = { :query => { :appkey => @appkey, :num => opts[:num] || 10 }, - :body => build_body(feeds, 'feed') + :body => build_body(feeds, 'feed') } http = post("#{V2_API_BASE}/recommend", req) parse(http.response) end def metrics_versioned(posts, opts = {}) + opts[:start_time] ||= 'yesterday' + opts[:end_time] ||= 'today' - start_time = opts[:start] || 'yesterday' - end_time = opts[:end] || 'today' - - req = { + req = { :query => { :appkey => @appkey, - :min_time => Chronic.parse(start_time).to_i, - :max_time => Chronic.parse(end_time).to_i + :min_time => Chronic.parse(opts[:start_time]).to_i, + :max_time => Chronic.parse(opts[:start_time]).to_i }, :body => build_body( posts, 'post_hash') } - + http = post("#{V2_API_BASE}/entry/metrics/historic", req) parse(http.response) end def postrank(urls, feeds = [], opts = {}) @@ -130,11 +129,12 @@ req = { :query => { :appkey => @appkey, :start_time => Chronic.parse(opts[:start_time]).to_i, - :end_time => Chronic.parse(opts[:end_time]).to_i + :end_time => Chronic.parse(opts[:end_time]).to_i, + :mode => opts[:mode] }, :body => build_body(domains, 'domain') } http = post("#{V2_API_BASE}/domain/activity", req) @@ -204,7 +204,7 @@ EM.stop end end http end + end end -end \ No newline at end of file