Class: DiffbotClient::Article

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/diffbot_client/article.rb

Instance Method Summary collapse

Instance Method Details

#get(options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/diffbot_client/article.rb', line 8

def get(options)
	  options = {:query => {:token => 'b395cbccaede5e80b564633092bda889'}.merge!(options)}
	  unless error_response = invalid_params?(options[:query])
 response = self.class.get('/v2/article',options)
    if response.success?
      JSON.parse(response.body)
    else
      JSON.parse({:error => "Failed to fetch the content from the url", :errorCode => 500})  
    end
	  else
 JSON.parse(error_response)
	  end
end

#invalid_params?(options) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/diffbot_client/article.rb', line 22

def invalid_params?(options)
  error_message = nil
  error_message = {:error => "Not authorized API token.",:errorCode => 401} if options[:token].nil?
  error_message = {:error => "Missing url query string argument",:errorCode => 500} if options[:url].nil?
  error_message
end