diff --git a/.fern/metadata.json b/.fern/metadata.json index 36b72ee..abf731c 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,5 +1,5 @@ { - "cliVersion": "4.28.0", + "cliVersion": "4.29.0", "generatorName": "fernapi/fern-python-sdk", "generatorVersion": "4.64.0", "generatorConfig": { @@ -10,6 +10,6 @@ "exported_filename": "client.py" } }, - "originGitCommit": "ea3775d5199c3ed3efc0866eb726d2ed2141aeba", - "sdkVersion": "2.0.0" + "originGitCommit": "bbd2054c67ad246b017399f96faf58cf6737bf01", + "sdkVersion": "3.0.0" } \ No newline at end of file diff --git a/.fernignore b/.fernignore index 4b8e914..7515e17 100644 --- a/.fernignore +++ b/.fernignore @@ -15,4 +15,5 @@ test-mock-mode.sh mypy.ini # CI/CD -.github/workflows/ci.yml \ No newline at end of file +.github/workflows/ci.yml +changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..b44607d --- /dev/null +++ b/changelog.md @@ -0,0 +1,5 @@ +## 3.0.0 - 2026-03-16 +* The aggregation API client has been renamed and reorganized for better clarity. The `client.aggregation` property is now `client.aggregation_count`, and methods have been simplified from `count_get`/`count_post` to `get`/`post`. All response types have been renamed to match. Update your code: replace `client.aggregation.count_get()` with `client.aggregation_count.get()` and `client.aggregation.count_post()` with `client.aggregation_count.post()`. +* Method names have been simplified across all client modules. Methods like `latest_headlines_get()`, `search_by_link_post()`, and `authors_get()` are now renamed to `get()` and `post()`. Update your code to use the new method names: replace `client.latest_headlines.latest_headlines_get()` with `client.latest_headlines.get()`, and similarly for all other affected methods. Response type names have also changed from service-prefixed to verb-prefixed patterns. +* Type alias names have been renamed for consistency: `SearchGetResponse` is now `GetSearchResponse`, `SearchPostResponse` is now `PostSearchResponse`, and `LatestHeadlinesPostResponse` is now `PostLatestHeadlinesResponse`. Update any direct imports or type annotations to use the new names. + diff --git a/pyproject.toml b/pyproject.toml index 8cfa4f0..3e43154 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ dynamic = ["version"] [tool.poetry] name = "newscatcher-sdk" -version = "2.0.0" +version = "3.0.0" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 1d8fdb2..8bc22eb 100644 --- a/reference.md +++ b/reference.md @@ -1,6 +1,6 @@ # Reference ## Search -
client.search.get(...) -> SearchGetResponse +
client.search.get(...) -> GetSearchResponse
@@ -651,7 +651,7 @@ To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-ap
-
client.search.post(...) -> SearchPostResponse +
client.search.post(...) -> PostSearchResponse
@@ -1174,7 +1174,7 @@ client.search.post(
## LatestHeadlines -
client.latest_headlines.latest_headlines_get(...) -> LatestHeadlinesGetResponse +
client.latest_headlines.get(...) -> GetLatestHeadlinesResponse
@@ -1209,7 +1209,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.latest_headlines.latest_headlines_get( +client.latest_headlines.get( when="7d", by_parse_date=True, lang="en,es", @@ -1709,7 +1709,7 @@ To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-ap
-
client.latest_headlines.latest_headlines_post(...) -> LatestHeadlinesPostResponse +
client.latest_headlines.post(...) -> PostLatestHeadlinesResponse
@@ -1744,7 +1744,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.latest_headlines.latest_headlines_post( +client.latest_headlines.post( when="7d", page_size=1, ) @@ -2128,7 +2128,7 @@ client.latest_headlines.latest_headlines_post(
## BreakingNews -
client.breaking_news.breaking_news_get(...) -> BreakingNewsResponseDto +
client.breaking_news.get(...) -> BreakingNewsResponseDto
@@ -2163,7 +2163,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.breaking_news.breaking_news_get( +client.breaking_news.get( ranked_only=True, from_rank=100, to_rank=100, @@ -2371,7 +2371,7 @@ client.breaking_news.breaking_news_get(
-
client.breaking_news.breaking_news_post(...) -> BreakingNewsResponseDto +
client.breaking_news.post(...) -> BreakingNewsResponseDto
@@ -2406,7 +2406,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.breaking_news.breaking_news_post( +client.breaking_news.post( sort_by="relevancy", ranked_only=True, top_n_articles=1, @@ -2599,7 +2599,7 @@ client.breaking_news.breaking_news_post(
## Authors -
client.authors.get(...) -> AuthorsGetResponse +
client.authors.get(...) -> GetAuthorsResponse
@@ -3127,7 +3127,7 @@ To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-ap
-
client.authors.post(...) -> AuthorsPostResponse +
client.authors.post(...) -> PostAuthorsResponse
@@ -3545,7 +3545,7 @@ client.authors.post(
## SearchByLink -
client.search_by_link.search_by_link_get(...) -> SearchResponseDto +
client.search_by_link.get(...) -> SearchResponseDto
@@ -3581,7 +3581,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.search_by_link.search_by_link_get( +client.search_by_link.get( ids="5f8d0d55b6e45e00179c6e7e", links="https://nytimes.com/article1,https://bbc.com/article2", from_=datetime.datetime.fromisoformat("2024-07-01T00:00:00+00:00"), @@ -3681,7 +3681,7 @@ The article link or list of article links to search for. To specify multiple lin
-
client.search_by_link.search_by_link_post(...) -> SearchResponseDto +
client.search_by_link.post(...) -> SearchResponseDto
@@ -3716,7 +3716,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.search_by_link.search_by_link_post( +client.search_by_link.post( links="https://www.reuters.com/business/energy/oil-prices-up-after-israeli-attacks-oversupply-caps-gains-2025-09-10/", ) @@ -4163,8 +4163,8 @@ client.sources.post(
-## Aggregation -
client.aggregation.count_get(...) -> AggregationCountGetResponse +## AggregationCount +
client.aggregation_count.get(...) -> GetAggregationCountResponse
@@ -4200,7 +4200,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.aggregation.count_get( +client.aggregation_count.get( q="\"supply chain\" AND Amazon NOT China", search_in="title_content, title_content_translated", predefined_sources="top 50 US, top 20 GB", @@ -4680,7 +4680,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod
-
client.aggregation.count_post(...) -> AggregationCountPostResponse +
client.aggregation_count.post(...) -> PostAggregationCountResponse
@@ -4715,7 +4715,7 @@ client = NewscatcherApi( environment=NewscatcherApiEnvironment.DEFAULT, ) -client.aggregation.count_post( +client.aggregation_count.post( q="\"supply chain\" AND Amazon NOT China", aggregation_by="day", ) diff --git a/src/newscatcher/__init__.py b/src/newscatcher/__init__.py index d36abec..de52f6e 100644 --- a/src/newscatcher/__init__.py +++ b/src/newscatcher/__init__.py @@ -120,21 +120,28 @@ UnauthorizedError, UnprocessableEntityError, ) - from . import aggregation, authors, breaking_news, latest_headlines, search, search_by_link, sources, subscription - from .aggregation import AggregationCountGetResponse, AggregationCountPostResponse - from .authors import AuthorsGetResponse, AuthorsPostResponse + from . import ( + aggregation_count, + authors, + breaking_news, + latest_headlines, + search, + search_by_link, + sources, + subscription, + ) + from .aggregation_count import GetAggregationCountResponse, PostAggregationCountResponse + from .authors import GetAuthorsResponse, PostAuthorsResponse from .client import AsyncNewscatcherApi, NewscatcherApi from .environment import NewscatcherApiEnvironment - from .latest_headlines import LatestHeadlinesGetResponse, LatestHeadlinesPostResponse - from .search import SearchGetResponse, SearchPostResponse + from .latest_headlines import GetLatestHeadlinesResponse, PostLatestHeadlinesResponse + from .search import GetSearchResponse, PostSearchResponse from .version import __version__ _dynamic_imports: typing.Dict[str, str] = { "AdditionalDomainInfo": ".types", "AdditionalDomainInfoEntity": ".types", "AdditionalSourceInfo": ".types", "AggregationBy": ".types", - "AggregationCountGetResponse": ".aggregation", - "AggregationCountPostResponse": ".aggregation", "AggregationCountResponseDto": ".types", "AggregationCountResponseDtoAggregations": ".types", "AggregationItem": ".types", @@ -150,8 +157,6 @@ "ArticlesDto": ".types", "AsyncNewscatcherApi": ".client", "AuthorName": ".types", - "AuthorsGetResponse": ".authors", - "AuthorsPostResponse": ".authors", "BadRequestError": ".errors", "BaseSearchResponseDto": ".types", "BreakingNewsArticleEntity": ".types", @@ -179,6 +184,10 @@ "ForbiddenError": ".errors", "From": ".types", "FromRank": ".types", + "GetAggregationCountResponse": ".aggregation_count", + "GetAuthorsResponse": ".authors", + "GetLatestHeadlinesResponse": ".latest_headlines", + "GetSearchResponse": ".search", "HasNlp": ".types", "IabTags": ".types", "Ids": ".types", @@ -192,8 +201,6 @@ "IsOpinion": ".types", "IsPaidContent": ".types", "Lang": ".types", - "LatestHeadlinesGetResponse": ".latest_headlines", - "LatestHeadlinesPostResponse": ".latest_headlines", "Links": ".types", "LocEntityName": ".types", "MiscEntityName": ".types", @@ -217,15 +224,17 @@ "PageSize": ".types", "ParentUrl": ".types", "PerEntityName": ".types", + "PostAggregationCountResponse": ".aggregation_count", + "PostAuthorsResponse": ".authors", + "PostLatestHeadlinesResponse": ".latest_headlines", + "PostSearchResponse": ".search", "PredefinedSources": ".types", "PublishedDatePrecision": ".types", "Q": ".types", "RankedOnly": ".types", "RequestTimeoutError": ".errors", "RobotsCompliant": ".types", - "SearchGetResponse": ".search", "SearchIn": ".types", - "SearchPostResponse": ".search", "SearchResponseDto": ".types", "SentimentScores": ".types", "SortBy": ".types", @@ -251,7 +260,7 @@ "WordCountMax": ".types", "WordCountMin": ".types", "__version__": ".version", - "aggregation": ".aggregation", + "aggregation_count": ".aggregation_count", "authors": ".authors", "breaking_news": ".breaking_news", "latest_headlines": ".latest_headlines", @@ -288,8 +297,6 @@ def __dir__(): "AdditionalDomainInfoEntity", "AdditionalSourceInfo", "AggregationBy", - "AggregationCountGetResponse", - "AggregationCountPostResponse", "AggregationCountResponseDto", "AggregationCountResponseDtoAggregations", "AggregationItem", @@ -305,8 +312,6 @@ def __dir__(): "ArticlesDto", "AsyncNewscatcherApi", "AuthorName", - "AuthorsGetResponse", - "AuthorsPostResponse", "BadRequestError", "BaseSearchResponseDto", "BreakingNewsArticleEntity", @@ -334,6 +339,10 @@ def __dir__(): "ForbiddenError", "From", "FromRank", + "GetAggregationCountResponse", + "GetAuthorsResponse", + "GetLatestHeadlinesResponse", + "GetSearchResponse", "HasNlp", "IabTags", "Ids", @@ -347,8 +356,6 @@ def __dir__(): "IsOpinion", "IsPaidContent", "Lang", - "LatestHeadlinesGetResponse", - "LatestHeadlinesPostResponse", "Links", "LocEntityName", "MiscEntityName", @@ -372,15 +379,17 @@ def __dir__(): "PageSize", "ParentUrl", "PerEntityName", + "PostAggregationCountResponse", + "PostAuthorsResponse", + "PostLatestHeadlinesResponse", + "PostSearchResponse", "PredefinedSources", "PublishedDatePrecision", "Q", "RankedOnly", "RequestTimeoutError", "RobotsCompliant", - "SearchGetResponse", "SearchIn", - "SearchPostResponse", "SearchResponseDto", "SentimentScores", "SortBy", @@ -406,7 +415,7 @@ def __dir__(): "WordCountMax", "WordCountMin", "__version__", - "aggregation", + "aggregation_count", "authors", "breaking_news", "latest_headlines", diff --git a/src/newscatcher/aggregation/__init__.py b/src/newscatcher/aggregation_count/__init__.py similarity index 80% rename from src/newscatcher/aggregation/__init__.py rename to src/newscatcher/aggregation_count/__init__.py index 22a6c09..5acdb97 100644 --- a/src/newscatcher/aggregation/__init__.py +++ b/src/newscatcher/aggregation_count/__init__.py @@ -6,10 +6,10 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .types import AggregationCountGetResponse, AggregationCountPostResponse + from .types import GetAggregationCountResponse, PostAggregationCountResponse _dynamic_imports: typing.Dict[str, str] = { - "AggregationCountGetResponse": ".types", - "AggregationCountPostResponse": ".types", + "GetAggregationCountResponse": ".types", + "PostAggregationCountResponse": ".types", } @@ -34,4 +34,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["AggregationCountGetResponse", "AggregationCountPostResponse"] +__all__ = ["GetAggregationCountResponse", "PostAggregationCountResponse"] diff --git a/src/newscatcher/aggregation/client.py b/src/newscatcher/aggregation_count/client.py similarity index 97% rename from src/newscatcher/aggregation/client.py rename to src/newscatcher/aggregation_count/client.py index 84cce0f..b771554 100644 --- a/src/newscatcher/aggregation/client.py +++ b/src/newscatcher/aggregation_count/client.py @@ -49,30 +49,30 @@ from ..types.to_rank import ToRank from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin -from .raw_client import AsyncRawAggregationClient, RawAggregationClient -from .types.aggregation_count_get_response import AggregationCountGetResponse -from .types.aggregation_count_post_response import AggregationCountPostResponse +from .raw_client import AsyncRawAggregationCountClient, RawAggregationCountClient +from .types.get_aggregation_count_response import GetAggregationCountResponse +from .types.post_aggregation_count_response import PostAggregationCountResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class AggregationClient: +class AggregationCountClient: def __init__(self, *, client_wrapper: SyncClientWrapper): - self._raw_client = RawAggregationClient(client_wrapper=client_wrapper) + self._raw_client = RawAggregationCountClient(client_wrapper=client_wrapper) @property - def with_raw_response(self) -> RawAggregationClient: + def with_raw_response(self) -> RawAggregationCountClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- - RawAggregationClient + RawAggregationCountClient """ return self._raw_client - def count_get( + def get( self, *, q: Q, @@ -121,7 +121,7 @@ def count_get( not_iptc_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AggregationCountGetResponse: + ) -> GetAggregationCountResponse: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -264,7 +264,7 @@ def count_get( Returns ------- - AggregationCountGetResponse + GetAggregationCountResponse A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. Examples @@ -276,7 +276,7 @@ def count_get( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.aggregation.count_get( + client.aggregation_count.get( q='"supply chain" AND Amazon NOT China', search_in="title_content, title_content_translated", predefined_sources="top 50 US, top 20 GB", @@ -326,7 +326,7 @@ def count_get( robots_compliant=True, ) """ - _response = self._raw_client.count_get( + _response = self._raw_client.get( q=q, aggregation_by=aggregation_by, search_in=search_in, @@ -376,7 +376,7 @@ def count_get( ) return _response.data - def count_post( + def post( self, *, q: Q, @@ -425,7 +425,7 @@ def count_post( not_iptc_tags: typing.Optional[NotIptcTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AggregationCountPostResponse: + ) -> PostAggregationCountResponse: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -526,7 +526,7 @@ def count_post( Returns ------- - AggregationCountPostResponse + PostAggregationCountResponse A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. Examples @@ -536,12 +536,12 @@ def count_post( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.aggregation.count_post( + client.aggregation_count.post( q='"supply chain" AND Amazon NOT China', aggregation_by="day", ) """ - _response = self._raw_client.count_post( + _response = self._raw_client.post( q=q, aggregation_by=aggregation_by, search_in=search_in, @@ -592,22 +592,22 @@ def count_post( return _response.data -class AsyncAggregationClient: +class AsyncAggregationCountClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._raw_client = AsyncRawAggregationClient(client_wrapper=client_wrapper) + self._raw_client = AsyncRawAggregationCountClient(client_wrapper=client_wrapper) @property - def with_raw_response(self) -> AsyncRawAggregationClient: + def with_raw_response(self) -> AsyncRawAggregationCountClient: """ Retrieves a raw implementation of this client that returns raw responses. Returns ------- - AsyncRawAggregationClient + AsyncRawAggregationCountClient """ return self._raw_client - async def count_get( + async def get( self, *, q: Q, @@ -656,7 +656,7 @@ async def count_get( not_iptc_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AggregationCountGetResponse: + ) -> GetAggregationCountResponse: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -799,7 +799,7 @@ async def count_get( Returns ------- - AggregationCountGetResponse + GetAggregationCountResponse A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. Examples @@ -815,7 +815,7 @@ async def count_get( async def main() -> None: - await client.aggregation.count_get( + await client.aggregation_count.get( q='"supply chain" AND Amazon NOT China', search_in="title_content, title_content_translated", predefined_sources="top 50 US, top 20 GB", @@ -868,7 +868,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.count_get( + _response = await self._raw_client.get( q=q, aggregation_by=aggregation_by, search_in=search_in, @@ -918,7 +918,7 @@ async def main() -> None: ) return _response.data - async def count_post( + async def post( self, *, q: Q, @@ -967,7 +967,7 @@ async def count_post( not_iptc_tags: typing.Optional[NotIptcTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AggregationCountPostResponse: + ) -> PostAggregationCountResponse: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -1068,7 +1068,7 @@ async def count_post( Returns ------- - AggregationCountPostResponse + PostAggregationCountResponse A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. Examples @@ -1083,7 +1083,7 @@ async def count_post( async def main() -> None: - await client.aggregation.count_post( + await client.aggregation_count.post( q='"supply chain" AND Amazon NOT China', aggregation_by="day", ) @@ -1091,7 +1091,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.count_post( + _response = await self._raw_client.post( q=q, aggregation_by=aggregation_by, search_in=search_in, diff --git a/src/newscatcher/aggregation/raw_client.py b/src/newscatcher/aggregation_count/raw_client.py similarity index 98% rename from src/newscatcher/aggregation/raw_client.py rename to src/newscatcher/aggregation_count/raw_client.py index 42a6568..542cbe8 100644 --- a/src/newscatcher/aggregation/raw_client.py +++ b/src/newscatcher/aggregation_count/raw_client.py @@ -63,19 +63,19 @@ from ..types.to_rank import ToRank from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin -from .types.aggregation_count_get_response import AggregationCountGetResponse -from .types.aggregation_count_post_response import AggregationCountPostResponse +from .types.get_aggregation_count_response import GetAggregationCountResponse +from .types.post_aggregation_count_response import PostAggregationCountResponse from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) -class RawAggregationClient: +class RawAggregationCountClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def count_get( + def get( self, *, q: Q, @@ -124,7 +124,7 @@ def count_get( not_iptc_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[AggregationCountGetResponse]: + ) -> HttpResponse[GetAggregationCountResponse]: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -267,7 +267,7 @@ def count_get( Returns ------- - HttpResponse[AggregationCountGetResponse] + HttpResponse[GetAggregationCountResponse] A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. """ _response = self._client_wrapper.httpx_client.request( @@ -325,9 +325,9 @@ def count_get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AggregationCountGetResponse, + GetAggregationCountResponse, parse_obj_as( - type_=AggregationCountGetResponse, # type: ignore + type_=GetAggregationCountResponse, # type: ignore object_=_response.json(), ), ) @@ -418,7 +418,7 @@ def count_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def count_post( + def post( self, *, q: Q, @@ -467,7 +467,7 @@ def count_post( not_iptc_tags: typing.Optional[NotIptcTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[AggregationCountPostResponse]: + ) -> HttpResponse[PostAggregationCountResponse]: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -568,7 +568,7 @@ def count_post( Returns ------- - HttpResponse[AggregationCountPostResponse] + HttpResponse[PostAggregationCountResponse] A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. """ _response = self._client_wrapper.httpx_client.request( @@ -656,9 +656,9 @@ def count_post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AggregationCountPostResponse, + PostAggregationCountResponse, parse_obj_as( - type_=AggregationCountPostResponse, # type: ignore + type_=PostAggregationCountResponse, # type: ignore object_=_response.json(), ), ) @@ -750,11 +750,11 @@ def count_post( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) -class AsyncRawAggregationClient: +class AsyncRawAggregationCountClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def count_get( + async def get( self, *, q: Q, @@ -803,7 +803,7 @@ async def count_get( not_iptc_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[AggregationCountGetResponse]: + ) -> AsyncHttpResponse[GetAggregationCountResponse]: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -946,7 +946,7 @@ async def count_get( Returns ------- - AsyncHttpResponse[AggregationCountGetResponse] + AsyncHttpResponse[GetAggregationCountResponse] A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. """ _response = await self._client_wrapper.httpx_client.request( @@ -1004,9 +1004,9 @@ async def count_get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AggregationCountGetResponse, + GetAggregationCountResponse, parse_obj_as( - type_=AggregationCountGetResponse, # type: ignore + type_=GetAggregationCountResponse, # type: ignore object_=_response.json(), ), ) @@ -1097,7 +1097,7 @@ async def count_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def count_post( + async def post( self, *, q: Q, @@ -1146,7 +1146,7 @@ async def count_post( not_iptc_tags: typing.Optional[NotIptcTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[AggregationCountPostResponse]: + ) -> AsyncHttpResponse[PostAggregationCountResponse]: """ Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. @@ -1247,7 +1247,7 @@ async def count_post( Returns ------- - AsyncHttpResponse[AggregationCountPostResponse] + AsyncHttpResponse[PostAggregationCountResponse] A successful response containing aggregation count results that match the search criteria. If no matches, returns a failed aggregation response according to the defined schema. """ _response = await self._client_wrapper.httpx_client.request( @@ -1335,9 +1335,9 @@ async def count_post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AggregationCountPostResponse, + PostAggregationCountResponse, parse_obj_as( - type_=AggregationCountPostResponse, # type: ignore + type_=PostAggregationCountResponse, # type: ignore object_=_response.json(), ), ) diff --git a/src/newscatcher/aggregation/types/__init__.py b/src/newscatcher/aggregation_count/types/__init__.py similarity index 74% rename from src/newscatcher/aggregation/types/__init__.py rename to src/newscatcher/aggregation_count/types/__init__.py index ca0dbea..357edfe 100644 --- a/src/newscatcher/aggregation/types/__init__.py +++ b/src/newscatcher/aggregation_count/types/__init__.py @@ -6,11 +6,11 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .aggregation_count_get_response import AggregationCountGetResponse - from .aggregation_count_post_response import AggregationCountPostResponse + from .get_aggregation_count_response import GetAggregationCountResponse + from .post_aggregation_count_response import PostAggregationCountResponse _dynamic_imports: typing.Dict[str, str] = { - "AggregationCountGetResponse": ".aggregation_count_get_response", - "AggregationCountPostResponse": ".aggregation_count_post_response", + "GetAggregationCountResponse": ".get_aggregation_count_response", + "PostAggregationCountResponse": ".post_aggregation_count_response", } @@ -35,4 +35,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["AggregationCountGetResponse", "AggregationCountPostResponse"] +__all__ = ["GetAggregationCountResponse", "PostAggregationCountResponse"] diff --git a/src/newscatcher/aggregation/types/aggregation_count_get_response.py b/src/newscatcher/aggregation_count/types/get_aggregation_count_response.py similarity index 82% rename from src/newscatcher/aggregation/types/aggregation_count_get_response.py rename to src/newscatcher/aggregation_count/types/get_aggregation_count_response.py index 9be1093..48fff48 100644 --- a/src/newscatcher/aggregation/types/aggregation_count_get_response.py +++ b/src/newscatcher/aggregation_count/types/get_aggregation_count_response.py @@ -5,4 +5,4 @@ from ...types.aggregation_count_response_dto import AggregationCountResponseDto from ...types.failed_aggregation_count_response_dto import FailedAggregationCountResponseDto -AggregationCountGetResponse = typing.Union[AggregationCountResponseDto, FailedAggregationCountResponseDto] +GetAggregationCountResponse = typing.Union[AggregationCountResponseDto, FailedAggregationCountResponseDto] diff --git a/src/newscatcher/aggregation/types/aggregation_count_post_response.py b/src/newscatcher/aggregation_count/types/post_aggregation_count_response.py similarity index 82% rename from src/newscatcher/aggregation/types/aggregation_count_post_response.py rename to src/newscatcher/aggregation_count/types/post_aggregation_count_response.py index b8488a9..d8fdb5f 100644 --- a/src/newscatcher/aggregation/types/aggregation_count_post_response.py +++ b/src/newscatcher/aggregation_count/types/post_aggregation_count_response.py @@ -5,4 +5,4 @@ from ...types.aggregation_count_response_dto import AggregationCountResponseDto from ...types.failed_aggregation_count_response_dto import FailedAggregationCountResponseDto -AggregationCountPostResponse = typing.Union[AggregationCountResponseDto, FailedAggregationCountResponseDto] +PostAggregationCountResponse = typing.Union[AggregationCountResponseDto, FailedAggregationCountResponseDto] diff --git a/src/newscatcher/authors/__init__.py b/src/newscatcher/authors/__init__.py index 151c122..787bb3c 100644 --- a/src/newscatcher/authors/__init__.py +++ b/src/newscatcher/authors/__init__.py @@ -6,8 +6,8 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .types import AuthorsGetResponse, AuthorsPostResponse -_dynamic_imports: typing.Dict[str, str] = {"AuthorsGetResponse": ".types", "AuthorsPostResponse": ".types"} + from .types import GetAuthorsResponse, PostAuthorsResponse +_dynamic_imports: typing.Dict[str, str] = {"GetAuthorsResponse": ".types", "PostAuthorsResponse": ".types"} def __getattr__(attr_name: str) -> typing.Any: @@ -31,4 +31,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["AuthorsGetResponse", "AuthorsPostResponse"] +__all__ = ["GetAuthorsResponse", "PostAuthorsResponse"] diff --git a/src/newscatcher/authors/client.py b/src/newscatcher/authors/client.py index 3014a97..8b3f4d0 100644 --- a/src/newscatcher/authors/client.py +++ b/src/newscatcher/authors/client.py @@ -49,8 +49,8 @@ from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin from .raw_client import AsyncRawAuthorsClient, RawAuthorsClient -from .types.authors_get_response import AuthorsGetResponse -from .types.authors_post_response import AuthorsPostResponse +from .types.get_authors_response import GetAuthorsResponse +from .types.post_authors_response import PostAuthorsResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -119,7 +119,7 @@ def get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AuthorsGetResponse: + ) -> GetAuthorsResponse: """ Searches for articles written by a specified author. You can filter results by language, country, source, and more. @@ -277,7 +277,7 @@ def get( Returns ------- - AuthorsGetResponse + GetAuthorsResponse Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. Examples @@ -436,7 +436,7 @@ def post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AuthorsPostResponse: + ) -> PostAuthorsResponse: """ Searches for articles by author. You can filter results by language, country, source, and more. @@ -535,7 +535,7 @@ def post( Returns ------- - AuthorsPostResponse + PostAuthorsResponse Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. Examples @@ -662,7 +662,7 @@ async def get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AuthorsGetResponse: + ) -> GetAuthorsResponse: """ Searches for articles written by a specified author. You can filter results by language, country, source, and more. @@ -820,7 +820,7 @@ async def get( Returns ------- - AuthorsGetResponse + GetAuthorsResponse Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. Examples @@ -986,7 +986,7 @@ async def post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AuthorsPostResponse: + ) -> PostAuthorsResponse: """ Searches for articles by author. You can filter results by language, country, source, and more. @@ -1085,7 +1085,7 @@ async def post( Returns ------- - AuthorsPostResponse + PostAuthorsResponse Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. Examples diff --git a/src/newscatcher/authors/raw_client.py b/src/newscatcher/authors/raw_client.py index 714aaec..3892765 100644 --- a/src/newscatcher/authors/raw_client.py +++ b/src/newscatcher/authors/raw_client.py @@ -62,8 +62,8 @@ from ..types.to_rank import ToRank from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin -from .types.authors_get_response import AuthorsGetResponse -from .types.authors_post_response import AuthorsPostResponse +from .types.get_authors_response import GetAuthorsResponse +from .types.post_authors_response import PostAuthorsResponse from pydantic import ValidationError # this is used as the default value for optional parameters @@ -122,7 +122,7 @@ def get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[AuthorsGetResponse]: + ) -> HttpResponse[GetAuthorsResponse]: """ Searches for articles written by a specified author. You can filter results by language, country, source, and more. @@ -280,7 +280,7 @@ def get( Returns ------- - HttpResponse[AuthorsGetResponse] + HttpResponse[GetAuthorsResponse] Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. """ _response = self._client_wrapper.httpx_client.request( @@ -337,9 +337,9 @@ def get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AuthorsGetResponse, + GetAuthorsResponse, parse_obj_as( - type_=AuthorsGetResponse, # type: ignore + type_=GetAuthorsResponse, # type: ignore object_=_response.json(), ), ) @@ -478,7 +478,7 @@ def post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[AuthorsPostResponse]: + ) -> HttpResponse[PostAuthorsResponse]: """ Searches for articles by author. You can filter results by language, country, source, and more. @@ -577,7 +577,7 @@ def post( Returns ------- - HttpResponse[AuthorsPostResponse] + HttpResponse[PostAuthorsResponse] Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. """ _response = self._client_wrapper.httpx_client.request( @@ -670,9 +670,9 @@ def post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AuthorsPostResponse, + PostAuthorsResponse, parse_obj_as( - type_=AuthorsPostResponse, # type: ignore + type_=PostAuthorsResponse, # type: ignore object_=_response.json(), ), ) @@ -816,7 +816,7 @@ async def get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[AuthorsGetResponse]: + ) -> AsyncHttpResponse[GetAuthorsResponse]: """ Searches for articles written by a specified author. You can filter results by language, country, source, and more. @@ -974,7 +974,7 @@ async def get( Returns ------- - AsyncHttpResponse[AuthorsGetResponse] + AsyncHttpResponse[GetAuthorsResponse] Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. """ _response = await self._client_wrapper.httpx_client.request( @@ -1031,9 +1031,9 @@ async def get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AuthorsGetResponse, + GetAuthorsResponse, parse_obj_as( - type_=AuthorsGetResponse, # type: ignore + type_=GetAuthorsResponse, # type: ignore object_=_response.json(), ), ) @@ -1172,7 +1172,7 @@ async def post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[AuthorsPostResponse]: + ) -> AsyncHttpResponse[PostAuthorsResponse]: """ Searches for articles by author. You can filter results by language, country, source, and more. @@ -1271,7 +1271,7 @@ async def post( Returns ------- - AsyncHttpResponse[AuthorsPostResponse] + AsyncHttpResponse[PostAuthorsResponse] Authors search response containing a list of authors that match the search criteria. If no matches, returns a failed search response according to the defined schema. """ _response = await self._client_wrapper.httpx_client.request( @@ -1364,9 +1364,9 @@ async def post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - AuthorsPostResponse, + PostAuthorsResponse, parse_obj_as( - type_=AuthorsPostResponse, # type: ignore + type_=PostAuthorsResponse, # type: ignore object_=_response.json(), ), ) diff --git a/src/newscatcher/authors/types/__init__.py b/src/newscatcher/authors/types/__init__.py index 3766d81..f9e7308 100644 --- a/src/newscatcher/authors/types/__init__.py +++ b/src/newscatcher/authors/types/__init__.py @@ -6,11 +6,11 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .authors_get_response import AuthorsGetResponse - from .authors_post_response import AuthorsPostResponse + from .get_authors_response import GetAuthorsResponse + from .post_authors_response import PostAuthorsResponse _dynamic_imports: typing.Dict[str, str] = { - "AuthorsGetResponse": ".authors_get_response", - "AuthorsPostResponse": ".authors_post_response", + "GetAuthorsResponse": ".get_authors_response", + "PostAuthorsResponse": ".post_authors_response", } @@ -35,4 +35,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["AuthorsGetResponse", "AuthorsPostResponse"] +__all__ = ["GetAuthorsResponse", "PostAuthorsResponse"] diff --git a/src/newscatcher/authors/types/authors_get_response.py b/src/newscatcher/authors/types/get_authors_response.py similarity index 78% rename from src/newscatcher/authors/types/authors_get_response.py rename to src/newscatcher/authors/types/get_authors_response.py index 29b7e23..548cfbb 100644 --- a/src/newscatcher/authors/types/authors_get_response.py +++ b/src/newscatcher/authors/types/get_authors_response.py @@ -5,4 +5,4 @@ from ...types.failed_authors_response_dto import FailedAuthorsResponseDto from ...types.search_response_dto import SearchResponseDto -AuthorsGetResponse = typing.Union[SearchResponseDto, FailedAuthorsResponseDto] +GetAuthorsResponse = typing.Union[SearchResponseDto, FailedAuthorsResponseDto] diff --git a/src/newscatcher/authors/types/authors_post_response.py b/src/newscatcher/authors/types/post_authors_response.py similarity index 78% rename from src/newscatcher/authors/types/authors_post_response.py rename to src/newscatcher/authors/types/post_authors_response.py index 79c0bb2..bb14b38 100644 --- a/src/newscatcher/authors/types/authors_post_response.py +++ b/src/newscatcher/authors/types/post_authors_response.py @@ -5,4 +5,4 @@ from ...types.failed_authors_response_dto import FailedAuthorsResponseDto from ...types.search_response_dto import SearchResponseDto -AuthorsPostResponse = typing.Union[SearchResponseDto, FailedAuthorsResponseDto] +PostAuthorsResponse = typing.Union[SearchResponseDto, FailedAuthorsResponseDto] diff --git a/src/newscatcher/base_client.py b/src/newscatcher/base_client.py index 4869cb1..26dc4e8 100644 --- a/src/newscatcher/base_client.py +++ b/src/newscatcher/base_client.py @@ -10,7 +10,7 @@ from .environment import NewscatcherApiEnvironment if typing.TYPE_CHECKING: - from .aggregation.client import AggregationClient, AsyncAggregationClient + from .aggregation_count.client import AggregationCountClient, AsyncAggregationCountClient from .authors.client import AsyncAuthorsClient, AuthorsClient from .breaking_news.client import AsyncBreakingNewsClient, BreakingNewsClient from .latest_headlines.client import AsyncLatestHeadlinesClient, LatestHeadlinesClient @@ -96,7 +96,7 @@ def __init__( self._authors: typing.Optional[AuthorsClient] = None self._search_by_link: typing.Optional[SearchByLinkClient] = None self._sources: typing.Optional[SourcesClient] = None - self._aggregation: typing.Optional[AggregationClient] = None + self._aggregation_count: typing.Optional[AggregationCountClient] = None self._subscription: typing.Optional[SubscriptionClient] = None @property @@ -148,12 +148,12 @@ def sources(self): return self._sources @property - def aggregation(self): - if self._aggregation is None: - from .aggregation.client import AggregationClient # noqa: E402 + def aggregation_count(self): + if self._aggregation_count is None: + from .aggregation_count.client import AggregationCountClient # noqa: E402 - self._aggregation = AggregationClient(client_wrapper=self._client_wrapper) - return self._aggregation + self._aggregation_count = AggregationCountClient(client_wrapper=self._client_wrapper) + return self._aggregation_count @property def subscription(self): @@ -240,7 +240,7 @@ def __init__( self._authors: typing.Optional[AsyncAuthorsClient] = None self._search_by_link: typing.Optional[AsyncSearchByLinkClient] = None self._sources: typing.Optional[AsyncSourcesClient] = None - self._aggregation: typing.Optional[AsyncAggregationClient] = None + self._aggregation_count: typing.Optional[AsyncAggregationCountClient] = None self._subscription: typing.Optional[AsyncSubscriptionClient] = None @property @@ -292,12 +292,12 @@ def sources(self): return self._sources @property - def aggregation(self): - if self._aggregation is None: - from .aggregation.client import AsyncAggregationClient # noqa: E402 + def aggregation_count(self): + if self._aggregation_count is None: + from .aggregation_count.client import AsyncAggregationCountClient # noqa: E402 - self._aggregation = AsyncAggregationClient(client_wrapper=self._client_wrapper) - return self._aggregation + self._aggregation_count = AsyncAggregationCountClient(client_wrapper=self._client_wrapper) + return self._aggregation_count @property def subscription(self): diff --git a/src/newscatcher/breaking_news/client.py b/src/newscatcher/breaking_news/client.py index ac47861..61158f3 100644 --- a/src/newscatcher/breaking_news/client.py +++ b/src/newscatcher/breaking_news/client.py @@ -46,7 +46,7 @@ def with_raw_response(self) -> RawBreakingNewsClient: """ return self._raw_client - def breaking_news_get( + def get( self, *, sort_by: typing.Optional[SortBy] = None, @@ -131,7 +131,7 @@ def breaking_news_get( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.breaking_news.breaking_news_get( + client.breaking_news.get( ranked_only=True, from_rank=100, to_rank=100, @@ -153,7 +153,7 @@ def breaking_news_get( content_sentiment_max=0.5, ) """ - _response = self._raw_client.breaking_news_get( + _response = self._raw_client.get( sort_by=sort_by, ranked_only=ranked_only, from_rank=from_rank, @@ -178,7 +178,7 @@ def breaking_news_get( ) return _response.data - def breaking_news_post( + def post( self, *, sort_by: typing.Optional[SortBy] = OMIT, @@ -263,13 +263,13 @@ def breaking_news_post( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.breaking_news.breaking_news_post( + client.breaking_news.post( sort_by="relevancy", ranked_only=True, top_n_articles=1, ) """ - _response = self._raw_client.breaking_news_post( + _response = self._raw_client.post( sort_by=sort_by, ranked_only=ranked_only, from_rank=from_rank, @@ -310,7 +310,7 @@ def with_raw_response(self) -> AsyncRawBreakingNewsClient: """ return self._raw_client - async def breaking_news_get( + async def get( self, *, sort_by: typing.Optional[SortBy] = None, @@ -400,7 +400,7 @@ async def breaking_news_get( async def main() -> None: - await client.breaking_news.breaking_news_get( + await client.breaking_news.get( ranked_only=True, from_rank=100, to_rank=100, @@ -425,7 +425,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.breaking_news_get( + _response = await self._raw_client.get( sort_by=sort_by, ranked_only=ranked_only, from_rank=from_rank, @@ -450,7 +450,7 @@ async def main() -> None: ) return _response.data - async def breaking_news_post( + async def post( self, *, sort_by: typing.Optional[SortBy] = OMIT, @@ -540,7 +540,7 @@ async def breaking_news_post( async def main() -> None: - await client.breaking_news.breaking_news_post( + await client.breaking_news.post( sort_by="relevancy", ranked_only=True, top_n_articles=1, @@ -549,7 +549,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.breaking_news_post( + _response = await self._raw_client.post( sort_by=sort_by, ranked_only=ranked_only, from_rank=from_rank, diff --git a/src/newscatcher/breaking_news/raw_client.py b/src/newscatcher/breaking_news/raw_client.py index 69b177f..2e22a80 100644 --- a/src/newscatcher/breaking_news/raw_client.py +++ b/src/newscatcher/breaking_news/raw_client.py @@ -48,7 +48,7 @@ class RawBreakingNewsClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def breaking_news_get( + def get( self, *, sort_by: typing.Optional[SortBy] = None, @@ -249,7 +249,7 @@ def breaking_news_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def breaking_news_post( + def post( self, *, sort_by: typing.Optional[SortBy] = OMIT, @@ -459,7 +459,7 @@ class AsyncRawBreakingNewsClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def breaking_news_get( + async def get( self, *, sort_by: typing.Optional[SortBy] = None, @@ -660,7 +660,7 @@ async def breaking_news_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def breaking_news_post( + async def post( self, *, sort_by: typing.Optional[SortBy] = OMIT, diff --git a/src/newscatcher/core/client_wrapper.py b/src/newscatcher/core/client_wrapper.py index b501203..1322fa2 100644 --- a/src/newscatcher/core/client_wrapper.py +++ b/src/newscatcher/core/client_wrapper.py @@ -27,12 +27,12 @@ def get_headers(self) -> typing.Dict[str, str]: import platform headers: typing.Dict[str, str] = { - "User-Agent": "newscatcher-sdk/1.4.1", + "User-Agent": "newscatcher-sdk/3.0.0", "X-Fern-Language": "Python", "X-Fern-Runtime": f"python/{platform.python_version()}", "X-Fern-Platform": f"{platform.system().lower()}/{platform.release()}", "X-Fern-SDK-Name": "newscatcher-sdk", - "X-Fern-SDK-Version": "1.4.1", + "X-Fern-SDK-Version": "3.0.0", **(self.get_custom_headers() or {}), } headers["x-api-token"] = self.api_key diff --git a/src/newscatcher/latest_headlines/__init__.py b/src/newscatcher/latest_headlines/__init__.py index 327d1f2..f73c8bd 100644 --- a/src/newscatcher/latest_headlines/__init__.py +++ b/src/newscatcher/latest_headlines/__init__.py @@ -6,10 +6,10 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .types import LatestHeadlinesGetResponse, LatestHeadlinesPostResponse + from .types import GetLatestHeadlinesResponse, PostLatestHeadlinesResponse _dynamic_imports: typing.Dict[str, str] = { - "LatestHeadlinesGetResponse": ".types", - "LatestHeadlinesPostResponse": ".types", + "GetLatestHeadlinesResponse": ".types", + "PostLatestHeadlinesResponse": ".types", } @@ -34,4 +34,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["LatestHeadlinesGetResponse", "LatestHeadlinesPostResponse"] +__all__ = ["GetLatestHeadlinesResponse", "PostLatestHeadlinesResponse"] diff --git a/src/newscatcher/latest_headlines/client.py b/src/newscatcher/latest_headlines/client.py index 4577079..c9df15d 100644 --- a/src/newscatcher/latest_headlines/client.py +++ b/src/newscatcher/latest_headlines/client.py @@ -50,8 +50,8 @@ from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin from .raw_client import AsyncRawLatestHeadlinesClient, RawLatestHeadlinesClient -from .types.latest_headlines_get_response import LatestHeadlinesGetResponse -from .types.latest_headlines_post_response import LatestHeadlinesPostResponse +from .types.get_latest_headlines_response import GetLatestHeadlinesResponse +from .types.post_latest_headlines_response import PostLatestHeadlinesResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -72,7 +72,7 @@ def with_raw_response(self) -> RawLatestHeadlinesClient: """ return self._raw_client - def latest_headlines_get( + def get( self, *, when: typing.Optional[When] = None, @@ -121,7 +121,7 @@ def latest_headlines_get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> LatestHeadlinesGetResponse: + ) -> GetLatestHeadlinesResponse: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -281,7 +281,7 @@ def latest_headlines_get( Returns ------- - LatestHeadlinesGetResponse + GetLatestHeadlinesResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -291,7 +291,7 @@ def latest_headlines_get( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.latest_headlines.latest_headlines_get( + client.latest_headlines.get( when="7d", by_parse_date=True, lang="en,es", @@ -337,7 +337,7 @@ def latest_headlines_get( robots_compliant=True, ) """ - _response = self._raw_client.latest_headlines_get( + _response = self._raw_client.get( when=when, by_parse_date=by_parse_date, sort_by=sort_by, @@ -387,7 +387,7 @@ def latest_headlines_get( ) return _response.data - def latest_headlines_post( + def post( self, *, when: typing.Optional[When] = OMIT, @@ -435,7 +435,7 @@ def latest_headlines_post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> LatestHeadlinesPostResponse: + ) -> PostLatestHeadlinesResponse: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -534,7 +534,7 @@ def latest_headlines_post( Returns ------- - LatestHeadlinesPostResponse + PostLatestHeadlinesResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -544,12 +544,12 @@ def latest_headlines_post( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.latest_headlines.latest_headlines_post( + client.latest_headlines.post( when="7d", page_size=1, ) """ - _response = self._raw_client.latest_headlines_post( + _response = self._raw_client.post( when=when, by_parse_date=by_parse_date, lang=lang, @@ -614,7 +614,7 @@ def with_raw_response(self) -> AsyncRawLatestHeadlinesClient: """ return self._raw_client - async def latest_headlines_get( + async def get( self, *, when: typing.Optional[When] = None, @@ -663,7 +663,7 @@ async def latest_headlines_get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> LatestHeadlinesGetResponse: + ) -> GetLatestHeadlinesResponse: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -823,7 +823,7 @@ async def latest_headlines_get( Returns ------- - LatestHeadlinesGetResponse + GetLatestHeadlinesResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -838,7 +838,7 @@ async def latest_headlines_get( async def main() -> None: - await client.latest_headlines.latest_headlines_get( + await client.latest_headlines.get( when="7d", by_parse_date=True, lang="en,es", @@ -887,7 +887,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.latest_headlines_get( + _response = await self._raw_client.get( when=when, by_parse_date=by_parse_date, sort_by=sort_by, @@ -937,7 +937,7 @@ async def main() -> None: ) return _response.data - async def latest_headlines_post( + async def post( self, *, when: typing.Optional[When] = OMIT, @@ -985,7 +985,7 @@ async def latest_headlines_post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> LatestHeadlinesPostResponse: + ) -> PostLatestHeadlinesResponse: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -1084,7 +1084,7 @@ async def latest_headlines_post( Returns ------- - LatestHeadlinesPostResponse + PostLatestHeadlinesResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -1099,7 +1099,7 @@ async def latest_headlines_post( async def main() -> None: - await client.latest_headlines.latest_headlines_post( + await client.latest_headlines.post( when="7d", page_size=1, ) @@ -1107,7 +1107,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.latest_headlines_post( + _response = await self._raw_client.post( when=when, by_parse_date=by_parse_date, lang=lang, diff --git a/src/newscatcher/latest_headlines/raw_client.py b/src/newscatcher/latest_headlines/raw_client.py index 223b7d3..2bb0e6e 100644 --- a/src/newscatcher/latest_headlines/raw_client.py +++ b/src/newscatcher/latest_headlines/raw_client.py @@ -63,8 +63,8 @@ from ..types.when import When from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin -from .types.latest_headlines_get_response import LatestHeadlinesGetResponse -from .types.latest_headlines_post_response import LatestHeadlinesPostResponse +from .types.get_latest_headlines_response import GetLatestHeadlinesResponse +from .types.post_latest_headlines_response import PostLatestHeadlinesResponse from pydantic import ValidationError # this is used as the default value for optional parameters @@ -75,7 +75,7 @@ class RawLatestHeadlinesClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def latest_headlines_get( + def get( self, *, when: typing.Optional[When] = None, @@ -124,7 +124,7 @@ def latest_headlines_get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[LatestHeadlinesGetResponse]: + ) -> HttpResponse[GetLatestHeadlinesResponse]: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -284,7 +284,7 @@ def latest_headlines_get( Returns ------- - HttpResponse[LatestHeadlinesGetResponse] + HttpResponse[GetLatestHeadlinesResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = self._client_wrapper.httpx_client.request( @@ -342,9 +342,9 @@ def latest_headlines_get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - LatestHeadlinesGetResponse, + GetLatestHeadlinesResponse, parse_obj_as( - type_=LatestHeadlinesGetResponse, # type: ignore + type_=GetLatestHeadlinesResponse, # type: ignore object_=_response.json(), ), ) @@ -435,7 +435,7 @@ def latest_headlines_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def latest_headlines_post( + def post( self, *, when: typing.Optional[When] = OMIT, @@ -483,7 +483,7 @@ def latest_headlines_post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[LatestHeadlinesPostResponse]: + ) -> HttpResponse[PostLatestHeadlinesResponse]: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -582,7 +582,7 @@ def latest_headlines_post( Returns ------- - HttpResponse[LatestHeadlinesPostResponse] + HttpResponse[PostLatestHeadlinesResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = self._client_wrapper.httpx_client.request( @@ -675,9 +675,9 @@ def latest_headlines_post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - LatestHeadlinesPostResponse, + PostLatestHeadlinesResponse, parse_obj_as( - type_=LatestHeadlinesPostResponse, # type: ignore + type_=PostLatestHeadlinesResponse, # type: ignore object_=_response.json(), ), ) @@ -773,7 +773,7 @@ class AsyncRawLatestHeadlinesClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def latest_headlines_get( + async def get( self, *, when: typing.Optional[When] = None, @@ -822,7 +822,7 @@ async def latest_headlines_get( custom_tags: typing.Optional[str] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[LatestHeadlinesGetResponse]: + ) -> AsyncHttpResponse[GetLatestHeadlinesResponse]: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -982,7 +982,7 @@ async def latest_headlines_get( Returns ------- - AsyncHttpResponse[LatestHeadlinesGetResponse] + AsyncHttpResponse[GetLatestHeadlinesResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = await self._client_wrapper.httpx_client.request( @@ -1040,9 +1040,9 @@ async def latest_headlines_get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - LatestHeadlinesGetResponse, + GetLatestHeadlinesResponse, parse_obj_as( - type_=LatestHeadlinesGetResponse, # type: ignore + type_=GetLatestHeadlinesResponse, # type: ignore object_=_response.json(), ), ) @@ -1133,7 +1133,7 @@ async def latest_headlines_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def latest_headlines_post( + async def post( self, *, when: typing.Optional[When] = OMIT, @@ -1181,7 +1181,7 @@ async def latest_headlines_post( custom_tags: typing.Optional[CustomTags] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[LatestHeadlinesPostResponse]: + ) -> AsyncHttpResponse[PostLatestHeadlinesResponse]: """ Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. @@ -1280,7 +1280,7 @@ async def latest_headlines_post( Returns ------- - AsyncHttpResponse[LatestHeadlinesPostResponse] + AsyncHttpResponse[PostLatestHeadlinesResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = await self._client_wrapper.httpx_client.request( @@ -1373,9 +1373,9 @@ async def latest_headlines_post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - LatestHeadlinesPostResponse, + PostLatestHeadlinesResponse, parse_obj_as( - type_=LatestHeadlinesPostResponse, # type: ignore + type_=PostLatestHeadlinesResponse, # type: ignore object_=_response.json(), ), ) diff --git a/src/newscatcher/latest_headlines/types/__init__.py b/src/newscatcher/latest_headlines/types/__init__.py index 10e8792..e560069 100644 --- a/src/newscatcher/latest_headlines/types/__init__.py +++ b/src/newscatcher/latest_headlines/types/__init__.py @@ -6,11 +6,11 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .latest_headlines_get_response import LatestHeadlinesGetResponse - from .latest_headlines_post_response import LatestHeadlinesPostResponse + from .get_latest_headlines_response import GetLatestHeadlinesResponse + from .post_latest_headlines_response import PostLatestHeadlinesResponse _dynamic_imports: typing.Dict[str, str] = { - "LatestHeadlinesGetResponse": ".latest_headlines_get_response", - "LatestHeadlinesPostResponse": ".latest_headlines_post_response", + "GetLatestHeadlinesResponse": ".get_latest_headlines_response", + "PostLatestHeadlinesResponse": ".post_latest_headlines_response", } @@ -35,4 +35,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["LatestHeadlinesGetResponse", "LatestHeadlinesPostResponse"] +__all__ = ["GetLatestHeadlinesResponse", "PostLatestHeadlinesResponse"] diff --git a/src/newscatcher/latest_headlines/types/latest_headlines_get_response.py b/src/newscatcher/latest_headlines/types/get_latest_headlines_response.py similarity index 79% rename from src/newscatcher/latest_headlines/types/latest_headlines_get_response.py rename to src/newscatcher/latest_headlines/types/get_latest_headlines_response.py index c34caf0..0b6e952 100644 --- a/src/newscatcher/latest_headlines/types/latest_headlines_get_response.py +++ b/src/newscatcher/latest_headlines/types/get_latest_headlines_response.py @@ -5,4 +5,4 @@ from ...types.clustered_search_response_dto import ClusteredSearchResponseDto from ...types.search_response_dto import SearchResponseDto -LatestHeadlinesGetResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] +GetLatestHeadlinesResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] diff --git a/src/newscatcher/latest_headlines/types/latest_headlines_post_response.py b/src/newscatcher/latest_headlines/types/post_latest_headlines_response.py similarity index 79% rename from src/newscatcher/latest_headlines/types/latest_headlines_post_response.py rename to src/newscatcher/latest_headlines/types/post_latest_headlines_response.py index 7cb713c..34351a9 100644 --- a/src/newscatcher/latest_headlines/types/latest_headlines_post_response.py +++ b/src/newscatcher/latest_headlines/types/post_latest_headlines_response.py @@ -5,4 +5,4 @@ from ...types.clustered_search_response_dto import ClusteredSearchResponseDto from ...types.search_response_dto import SearchResponseDto -LatestHeadlinesPostResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] +PostLatestHeadlinesResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] diff --git a/src/newscatcher/search/__init__.py b/src/newscatcher/search/__init__.py index 3c584ee..deeb7d9 100644 --- a/src/newscatcher/search/__init__.py +++ b/src/newscatcher/search/__init__.py @@ -6,8 +6,8 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .types import SearchGetResponse, SearchPostResponse -_dynamic_imports: typing.Dict[str, str] = {"SearchGetResponse": ".types", "SearchPostResponse": ".types"} + from .types import GetSearchResponse, PostSearchResponse +_dynamic_imports: typing.Dict[str, str] = {"GetSearchResponse": ".types", "PostSearchResponse": ".types"} def __getattr__(attr_name: str) -> typing.Any: @@ -31,4 +31,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["SearchGetResponse", "SearchPostResponse"] +__all__ = ["GetSearchResponse", "PostSearchResponse"] diff --git a/src/newscatcher/search/client.py b/src/newscatcher/search/client.py index bb7082c..4d73d8a 100644 --- a/src/newscatcher/search/client.py +++ b/src/newscatcher/search/client.py @@ -62,8 +62,8 @@ from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin from .raw_client import AsyncRawSearchClient, RawSearchClient -from .types.search_get_response import SearchGetResponse -from .types.search_post_response import SearchPostResponse +from .types.get_search_response import GetSearchResponse +from .types.post_search_response import PostSearchResponse # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -145,7 +145,7 @@ def get( exclude_duplicates: typing.Optional[ExcludeDuplicates] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> SearchGetResponse: + ) -> GetSearchResponse: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -335,7 +335,7 @@ def get( Returns ------- - SearchGetResponse + GetSearchResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -531,7 +531,7 @@ def post( exclude_duplicates: typing.Optional[ExcludeDuplicates] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SearchPostResponse: + ) -> PostSearchResponse: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -656,7 +656,7 @@ def post( Returns ------- - SearchPostResponse + PostSearchResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -810,7 +810,7 @@ async def get( exclude_duplicates: typing.Optional[ExcludeDuplicates] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> SearchGetResponse: + ) -> GetSearchResponse: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -1000,7 +1000,7 @@ async def get( Returns ------- - SearchGetResponse + GetSearchResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples @@ -1203,7 +1203,7 @@ async def post( exclude_duplicates: typing.Optional[ExcludeDuplicates] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> SearchPostResponse: + ) -> PostSearchResponse: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -1328,7 +1328,7 @@ async def post( Returns ------- - SearchPostResponse + PostSearchResponse A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. Examples diff --git a/src/newscatcher/search/raw_client.py b/src/newscatcher/search/raw_client.py index 2eca68a..ad5a825 100644 --- a/src/newscatcher/search/raw_client.py +++ b/src/newscatcher/search/raw_client.py @@ -75,8 +75,8 @@ from ..types.to_rank import ToRank from ..types.word_count_max import WordCountMax from ..types.word_count_min import WordCountMin -from .types.search_get_response import SearchGetResponse -from .types.search_post_response import SearchPostResponse +from .types.get_search_response import GetSearchResponse +from .types.post_search_response import PostSearchResponse from pydantic import ValidationError # this is used as the default value for optional parameters @@ -148,7 +148,7 @@ def get( exclude_duplicates: typing.Optional[ExcludeDuplicates] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[SearchGetResponse]: + ) -> HttpResponse[GetSearchResponse]: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -338,7 +338,7 @@ def get( Returns ------- - HttpResponse[SearchGetResponse] + HttpResponse[GetSearchResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = self._client_wrapper.httpx_client.request( @@ -408,9 +408,9 @@ def get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - SearchGetResponse, + GetSearchResponse, parse_obj_as( - type_=SearchGetResponse, # type: ignore + type_=GetSearchResponse, # type: ignore object_=_response.json(), ), ) @@ -562,7 +562,7 @@ def post( exclude_duplicates: typing.Optional[ExcludeDuplicates] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[SearchPostResponse]: + ) -> HttpResponse[PostSearchResponse]: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -687,7 +687,7 @@ def post( Returns ------- - HttpResponse[SearchPostResponse] + HttpResponse[PostSearchResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = self._client_wrapper.httpx_client.request( @@ -797,9 +797,9 @@ def post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - SearchPostResponse, + PostSearchResponse, parse_obj_as( - type_=SearchPostResponse, # type: ignore + type_=PostSearchResponse, # type: ignore object_=_response.json(), ), ) @@ -956,7 +956,7 @@ async def get( exclude_duplicates: typing.Optional[ExcludeDuplicates] = None, robots_compliant: typing.Optional[RobotsCompliant] = None, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[SearchGetResponse]: + ) -> AsyncHttpResponse[GetSearchResponse]: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -1146,7 +1146,7 @@ async def get( Returns ------- - AsyncHttpResponse[SearchGetResponse] + AsyncHttpResponse[GetSearchResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = await self._client_wrapper.httpx_client.request( @@ -1216,9 +1216,9 @@ async def get( try: if 200 <= _response.status_code < 300: _data = typing.cast( - SearchGetResponse, + GetSearchResponse, parse_obj_as( - type_=SearchGetResponse, # type: ignore + type_=GetSearchResponse, # type: ignore object_=_response.json(), ), ) @@ -1370,7 +1370,7 @@ async def post( exclude_duplicates: typing.Optional[ExcludeDuplicates] = OMIT, robots_compliant: typing.Optional[RobotsCompliant] = OMIT, request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[SearchPostResponse]: + ) -> AsyncHttpResponse[PostSearchResponse]: """ Searches for articles based on specified criteria such as keywords, language, country, source, and more. @@ -1495,7 +1495,7 @@ async def post( Returns ------- - AsyncHttpResponse[SearchPostResponse] + AsyncHttpResponse[PostSearchResponse] A successful response containing articles that match the search criteria. When `clustering_enabled` is `true`, returns a Clustered Articles Response. Otherwise, returns a Search Response. """ _response = await self._client_wrapper.httpx_client.request( @@ -1605,9 +1605,9 @@ async def post( try: if 200 <= _response.status_code < 300: _data = typing.cast( - SearchPostResponse, + PostSearchResponse, parse_obj_as( - type_=SearchPostResponse, # type: ignore + type_=PostSearchResponse, # type: ignore object_=_response.json(), ), ) diff --git a/src/newscatcher/search/types/__init__.py b/src/newscatcher/search/types/__init__.py index 5dbeefd..1817922 100644 --- a/src/newscatcher/search/types/__init__.py +++ b/src/newscatcher/search/types/__init__.py @@ -6,11 +6,11 @@ from importlib import import_module if typing.TYPE_CHECKING: - from .search_get_response import SearchGetResponse - from .search_post_response import SearchPostResponse + from .get_search_response import GetSearchResponse + from .post_search_response import PostSearchResponse _dynamic_imports: typing.Dict[str, str] = { - "SearchGetResponse": ".search_get_response", - "SearchPostResponse": ".search_post_response", + "GetSearchResponse": ".get_search_response", + "PostSearchResponse": ".post_search_response", } @@ -35,4 +35,4 @@ def __dir__(): return sorted(lazy_attrs) -__all__ = ["SearchGetResponse", "SearchPostResponse"] +__all__ = ["GetSearchResponse", "PostSearchResponse"] diff --git a/src/newscatcher/search/types/search_get_response.py b/src/newscatcher/search/types/get_search_response.py similarity index 78% rename from src/newscatcher/search/types/search_get_response.py rename to src/newscatcher/search/types/get_search_response.py index 11c7ebe..222abfb 100644 --- a/src/newscatcher/search/types/search_get_response.py +++ b/src/newscatcher/search/types/get_search_response.py @@ -5,4 +5,4 @@ from ...types.clustered_search_response_dto import ClusteredSearchResponseDto from ...types.search_response_dto import SearchResponseDto -SearchGetResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] +GetSearchResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] diff --git a/src/newscatcher/search/types/search_post_response.py b/src/newscatcher/search/types/post_search_response.py similarity index 78% rename from src/newscatcher/search/types/search_post_response.py rename to src/newscatcher/search/types/post_search_response.py index a454ec9..ae9bbaa 100644 --- a/src/newscatcher/search/types/search_post_response.py +++ b/src/newscatcher/search/types/post_search_response.py @@ -5,4 +5,4 @@ from ...types.clustered_search_response_dto import ClusteredSearchResponseDto from ...types.search_response_dto import SearchResponseDto -SearchPostResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] +PostSearchResponse = typing.Union[SearchResponseDto, ClusteredSearchResponseDto] diff --git a/src/newscatcher/search_by_link/client.py b/src/newscatcher/search_by_link/client.py index 2c2e184..8a00433 100644 --- a/src/newscatcher/search_by_link/client.py +++ b/src/newscatcher/search_by_link/client.py @@ -33,7 +33,7 @@ def with_raw_response(self) -> RawSearchByLinkClient: """ return self._raw_client - def search_by_link_get( + def get( self, *, ids: typing.Optional[str] = None, @@ -87,7 +87,7 @@ def search_by_link_get( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.search_by_link.search_by_link_get( + client.search_by_link.get( ids="5f8d0d55b6e45e00179c6e7e", links="https://nytimes.com/article1,https://bbc.com/article2", from_=datetime.datetime.fromisoformat( @@ -101,7 +101,7 @@ def search_by_link_get( robots_compliant=True, ) """ - _response = self._raw_client.search_by_link_get( + _response = self._raw_client.get( ids=ids, links=links, from_=from_, @@ -113,7 +113,7 @@ def search_by_link_get( ) return _response.data - def search_by_link_post( + def post( self, *, ids: typing.Optional[Ids] = OMIT, @@ -175,11 +175,11 @@ def search_by_link_post( client = NewscatcherApi( api_key="YOUR_API_KEY", ) - client.search_by_link.search_by_link_post( + client.search_by_link.post( links="https://www.reuters.com/business/energy/oil-prices-up-after-israeli-attacks-oversupply-caps-gains-2025-09-10/", ) """ - _response = self._raw_client.search_by_link_post( + _response = self._raw_client.post( ids=ids, links=links, from_=from_, @@ -207,7 +207,7 @@ def with_raw_response(self) -> AsyncRawSearchByLinkClient: """ return self._raw_client - async def search_by_link_get( + async def get( self, *, ids: typing.Optional[str] = None, @@ -265,7 +265,7 @@ async def search_by_link_get( async def main() -> None: - await client.search_by_link.search_by_link_get( + await client.search_by_link.get( ids="5f8d0d55b6e45e00179c6e7e", links="https://nytimes.com/article1,https://bbc.com/article2", from_=datetime.datetime.fromisoformat( @@ -282,7 +282,7 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.search_by_link_get( + _response = await self._raw_client.get( ids=ids, links=links, from_=from_, @@ -294,7 +294,7 @@ async def main() -> None: ) return _response.data - async def search_by_link_post( + async def post( self, *, ids: typing.Optional[Ids] = OMIT, @@ -361,14 +361,14 @@ async def search_by_link_post( async def main() -> None: - await client.search_by_link.search_by_link_post( + await client.search_by_link.post( links="https://www.reuters.com/business/energy/oil-prices-up-after-israeli-attacks-oversupply-caps-gains-2025-09-10/", ) asyncio.run(main()) """ - _response = await self._raw_client.search_by_link_post( + _response = await self._raw_client.post( ids=ids, links=links, from_=from_, diff --git a/src/newscatcher/search_by_link/raw_client.py b/src/newscatcher/search_by_link/raw_client.py index f0751d8..f6f66fc 100644 --- a/src/newscatcher/search_by_link/raw_client.py +++ b/src/newscatcher/search_by_link/raw_client.py @@ -36,7 +36,7 @@ class RawSearchByLinkClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper - def search_by_link_get( + def get( self, *, ids: typing.Optional[str] = None, @@ -191,7 +191,7 @@ def search_by_link_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - def search_by_link_post( + def post( self, *, ids: typing.Optional[Ids] = OMIT, @@ -365,7 +365,7 @@ class AsyncRawSearchByLinkClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper - async def search_by_link_get( + async def get( self, *, ids: typing.Optional[str] = None, @@ -520,7 +520,7 @@ async def search_by_link_get( ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) - async def search_by_link_post( + async def post( self, *, ids: typing.Optional[Ids] = OMIT,