Class: DiffbotClient::Article
- Inherits:
-
Object
- Object
- DiffbotClient::Article
- 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() = {:query => {:token => 'b395cbccaede5e80b564633092bda889'}.merge!()} unless error_response = invalid_params?([:query]) response = self.class.get('/v2/article',) 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
22 23 24 25 26 27 |
# File 'lib/diffbot_client/article.rb', line 22 def invalid_params?() = nil = {:error => "Not authorized API token.",:errorCode => 401} if [:token].nil? = {:error => "Missing url query string argument",:errorCode => 500} if [:url].nil? end |