95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/cryptocoins.rb', line 95
def self.search(secret_key, options = {})
request = {query: {language: 'en',
sortBy: 'popularity',
apiKey: secret_key,
from: Date.today.prev_day.strftime('%Y-%m-%d'),
to: Date.today.strftime('%Y-%m-%d'),
q: '+bitcoin',
pageSize: '100'}}
options.each do |key, value|
request[:query][key] = value if request[:query][key]
end
request[:query].merge!(sources: options[:sources]) if options[:sources]
return HTTParty.get('https://newsapi.org/v2/everything?', request)['articles']
end
|