class NewsMonitor::API

Public Class Methods

new(options={}) click to toggle source
# File lib/news_monitor/api.rb, line 11
def initialize(options={})
  @auth = {}
  @auth[:username] = options.fetch :username, ENV['NEWSMONITOR_USERNAME']
  @auth[:password] = options.fetch :password, ENV['NEWSMONITOR_PASSWORD']
end

Public Instance Methods

find_article(article_id, options={}) click to toggle source
# File lib/news_monitor/api.rb, line 26
def find_article(article_id, options={})
  options.merge! basic_auth: @auth
  response = get "/article/#{article_id}", options
  Article.parse(response)
end
find_cluster(cluster_id, options={}) click to toggle source
# File lib/news_monitor/api.rb, line 32
def find_cluster(cluster_id, options={})
  options.merge! basic_auth: @auth
  response = get "/cluster/#{cluster_id}", options
  Cluster.parse response['results'].first
end

Private Instance Methods

get(path, options) click to toggle source
# File lib/news_monitor/api.rb, line 40
def get(path, options)
  self.class.get(path, options).parsed_response
end