from time import sleep

import requests


class NewswireApi:
    def __init__(self, api_key: str):
        self.api_key = api_key

    def newswire(self, source: str = "nyt", section: str = "world"):
        response = requests.get(
            url=f'https://api.nytimes.com/svc/news/v3/content/{source}/{section}.json',
            params={
                'api-key': self.api_key,
            },
        )

        sleep(1)
        return response.json()
