Class: NewsApi::NewsApiRepository
- Inherits:
-
BaseRepository
- Object
- BaseRepository
- NewsApi::NewsApiRepository
- Defined in:
- lib/metonym/lib/repositories/news_api_repository.rb
Instance Method Summary collapse
- #everything(query:) ⇒ Object
-
#initialize(api_key) ⇒ NewsApiRepository
constructor
A new instance of NewsApiRepository.
- #sources(query:) ⇒ Object
- #top_headlines(query:) ⇒ Object
Methods inherited from BaseRepository
Constructor Details
#initialize(api_key) ⇒ NewsApiRepository
Returns a new instance of NewsApiRepository.
5 6 7 8 |
# File 'lib/metonym/lib/repositories/news_api_repository.rb', line 5 def initialize(api_key) @news_api_key = api_key @uri = 'https://newsapi.org/v2/' end |
Instance Method Details
#everything(query:) ⇒ Object
10 11 12 |
# File 'lib/metonym/lib/repositories/news_api_repository.rb', line 10 def everything(query:) request(@uri, query: query, resource: 'everything') end |
#sources(query:) ⇒ Object
18 19 20 |
# File 'lib/metonym/lib/repositories/news_api_repository.rb', line 18 def sources(query:) request(@uri, query: query, resource: 'sources') end |
#top_headlines(query:) ⇒ Object
14 15 16 |
# File 'lib/metonym/lib/repositories/news_api_repository.rb', line 14 def top_headlines(query:) request(@uri, query: query, resource: 'top-headlines') end |