From ed08703b48290ef7d16e5bc497404c29087a44c5 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 20:22:31 +0000 Subject: [PATCH] SDK regeneration --- .fern/metadata.json | 10 + .github/workflows/ci.yml | 4 + build.gradle | 17 +- reference.md | 2740 ++++------------- .../api/AsyncNewscatcherApiClient.java | 38 +- .../api/AsyncNewscatcherApiClientBuilder.java | 24 + .../newscatcher/api/NewscatcherApiClient.java | 38 +- .../api/NewscatcherApiClientBuilder.java | 24 + .../newscatcher/api/core/ClientOptions.java | 48 +- .../newscatcher/api/core/ConsoleLogger.java | 51 + .../com/newscatcher/api/core/ILogger.java | 38 + .../com/newscatcher/api/core/LogConfig.java | 98 + .../com/newscatcher/api/core/LogLevel.java | 36 + .../java/com/newscatcher/api/core/Logger.java | 97 + .../api/core/LoggingInterceptor.java | 104 + .../api/core/NewscatcherApiApiException.java | 4 +- .../api/core/NullableNonemptyFilter.java | 5 +- .../newscatcher/api/core/ObjectMappers.java | 9 + .../newscatcher/api/core/RequestOptions.java | 41 +- .../api/core/RetryInterceptor.java | 118 +- .../api/core/Rfc2822DateTimeDeserializer.java | 25 + .../com/newscatcher/api/core/SseEvent.java | 114 + .../newscatcher/api/core/SseEventParser.java | 228 ++ .../java/com/newscatcher/api/core/Stream.java | 297 +- .../requests/AggregationGetRequest.java | 2501 --------------- ...ationGetRequestPublishedDatePrecision.java | 26 - .../types/AggregationGetRequestSortBy.java | 26 - .../AggregationCountClient.java} | 28 +- .../AsyncAggregationCountClient.java} | 31 +- .../AsyncRawAggregationCountClient.java} | 73 +- .../RawAggregationCountClient.java} | 67 +- .../requests/GetAggregationCountRequest.java | 1775 +++++++++++ .../PostAggregationCountRequest.java} | 122 +- .../types/GetAggregationCountResponse.java} | 27 +- .../types/PostAggregationCountResponse.java} | 27 +- .../resources/authors/AsyncAuthorsClient.java | 16 +- .../authors/AsyncRawAuthorsClient.java | 65 +- .../api/resources/authors/AuthorsClient.java | 16 +- .../resources/authors/RawAuthorsClient.java | 62 +- ...GetRequest.java => GetAuthorsRequest.java} | 922 +----- ...stRequest.java => PostAuthorsRequest.java} | 120 +- ...thorsGetRequestPublishedDatePrecision.java | 26 - .../types/AuthorsGetRequestSortBy.java | 26 - ...tResponse.java => GetAuthorsResponse.java} | 24 +- ...Response.java => PostAuthorsResponse.java} | 24 +- .../breakingnews/AsyncBreakingNewsClient.java | 46 +- .../AsyncRawBreakingNewsClient.java | 86 +- .../breakingnews/BreakingNewsClient.java | 42 +- .../breakingnews/RawBreakingNewsClient.java | 81 +- ...quest.java => GetBreakingNewsRequest.java} | 286 +- ...uest.java => PostBreakingNewsRequest.java} | 110 +- .../types/BreakingNewsGetRequestSortBy.java | 26 - ...t.java => AsyncLatestHeadlinesClient.java} | 48 +- ...ava => AsyncRawLatestHeadlinesClient.java} | 101 +- ...Client.java => LatestHeadlinesClient.java} | 44 +- ...ent.java => RawLatestHeadlinesClient.java} | 91 +- ...st.java => GetLatestHeadlinesRequest.java} | 479 +-- ...t.java => PostLatestHeadlinesRequest.java} | 79 +- ...e.java => GetLatestHeadlinesResponse.java} | 24 +- ...HeadlinesGetRequestClusteringVariable.java | 26 - ....java => PostLatestHeadlinesResponse.java} | 24 +- .../search/AsyncRawSearchClient.java | 73 +- .../resources/search/AsyncSearchClient.java | 24 +- .../api/resources/search/RawSearchClient.java | 67 +- .../api/resources/search/SearchClient.java | 24 +- ...hGetRequest.java => GetSearchRequest.java} | 1296 ++------ ...ostRequest.java => PostSearchRequest.java} | 120 +- ...etResponse.java => GetSearchResponse.java} | 24 +- ...tResponse.java => PostSearchResponse.java} | 24 +- .../SearchGetRequestClusteringVariable.java | 26 - .../types/SearchGetRequestNewsDomainType.java | 30 - ...earchGetRequestPublishedDatePrecision.java | 26 - .../search/types/SearchGetRequestSortBy.java | 26 - .../AsyncRawSearchByLinkClient.java} | 86 +- .../searchbylink/AsyncSearchByLinkClient.java | 85 + .../RawSearchByLinkClient.java} | 85 +- .../searchbylink/SearchByLinkClient.java | 84 + .../requests/GetSearchByLinkRequest.java} | 53 +- .../requests/PostSearchByLinkRequest.java} | 28 +- .../searchlink/AsyncSearchLinkClient.java | 73 - .../searchlink/SearchLinkClient.java | 70 - .../AsyncRawSearchsimilarClient.java | 457 --- .../AsyncSearchsimilarClient.java | 60 - .../searchsimilar/RawSearchsimilarClient.java | 393 --- .../searchsimilar/SearchsimilarClient.java | 57 - .../requests/SearchSimilarGetRequest.java | 2473 --------------- .../requests/SearchSimilarPostRequest.java | 1504 --------- ...milarGetRequestPublishedDatePrecision.java | 26 - .../types/SearchSimilarGetRequestSortBy.java | 26 - .../types/SearchSimilarGetResponse.java | 97 - .../types/SearchSimilarPostResponse.java | 97 - .../sources/AsyncRawSourcesClient.java | 67 +- .../resources/sources/AsyncSourcesClient.java | 26 +- .../resources/sources/RawSourcesClient.java | 67 +- .../api/resources/sources/SourcesClient.java | 26 +- ...GetRequest.java => GetSourcesRequest.java} | 140 +- ...stRequest.java => PostSourcesRequest.java} | 26 +- .../SourcesGetRequestNewsDomainType.java | 30 - .../AsyncRawSubscriptionClient.java | 46 +- .../subscription/RawSubscriptionClient.java | 44 +- .../api/types/AdditionalDomainInfoEntity.java | 10 + .../api/types/AdditionalSourceInfo.java | 59 +- .../newscatcher/api/types/AggregationBy.java | 83 +- .../types/AggregationCountResponseDto.java | 32 +- ...regationCountResponseDtoAggregations.java} | 26 +- .../api/types/AggregationItem.java | 18 +- .../api/types/AllLinksDataItem.java | 195 ++ .../types/{Theme.java => AllLinksText.java} | 24 +- .../newscatcher/api/types/ArticleEntity.java | 402 ++- ...nalists.java => ArticleEntityAuthors.java} | 24 +- ...ors.java => ArticleEntityJournalists.java} | 24 +- .../api/types/BaseSearchResponseDto.java | 16 + .../api/types/BreakingNewsArticleEntity.java | 454 ++- ... => BreakingNewsArticleEntityAuthors.java} | 37 +- .../BreakingNewsArticleEntityJournalists.java | 99 + .../api/types/BreakingNewsEventEntity.java | 24 +- .../api/types/BreakingNewsResponseDto.java | 16 + .../newscatcher/api/types/ClusterEntity.java | 24 +- .../api/types/ClusteredArticlesDto.java | 24 +- .../api/types/ClusteredSearchResponseDto.java | 24 +- .../api/types/ClusteringVariable.java | 83 +- .../java/com/newscatcher/api/types/Error.java | 16 + .../FailedAggregationCountResponseDto.java | 16 + .../api/types/FailedAuthorsResponseDto.java | 16 + .../types/FailedSearchSimilarResponseDto.java | 339 -- .../newscatcher/api/types/IArticleEntity.java | 82 - .../api/types/NamedEntityListItem.java | 10 + .../newscatcher/api/types/NewsDomainType.java | 104 +- .../newscatcher/api/types/NlpDataEntity.java | 14 +- .../api/types/PublishedDatePrecision.java | 26 - .../api/types/SearchResponseDto.java | 16 + .../api/types/SearchSimilarResponseDto.java | 339 -- .../api/types/SentimentScores.java | 10 + .../api/types/SimilarArticleEntity.java | 1693 ---------- .../api/types/SimilarDocument.java | 213 -- .../com/newscatcher/api/types/SortBy.java | 82 +- .../com/newscatcher/api/types/SourceInfo.java | 16 + .../api/types/SourcesResponseDto.java | 32 +- .../api/types/SubscriptionResponseDto.java | 16 + .../newscatcher/api/types/TimeFrameCount.java | 16 + .../java/com/newscatcher/api/StreamTest.java | 46 +- 141 files changed, 7562 insertions(+), 17029 deletions(-) create mode 100644 .fern/metadata.json create mode 100644 src/main/java/com/newscatcher/api/core/ConsoleLogger.java create mode 100644 src/main/java/com/newscatcher/api/core/ILogger.java create mode 100644 src/main/java/com/newscatcher/api/core/LogConfig.java create mode 100644 src/main/java/com/newscatcher/api/core/LogLevel.java create mode 100644 src/main/java/com/newscatcher/api/core/Logger.java create mode 100644 src/main/java/com/newscatcher/api/core/LoggingInterceptor.java create mode 100644 src/main/java/com/newscatcher/api/core/Rfc2822DateTimeDeserializer.java create mode 100644 src/main/java/com/newscatcher/api/core/SseEvent.java create mode 100644 src/main/java/com/newscatcher/api/core/SseEventParser.java delete mode 100644 src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationGetRequest.java delete mode 100644 src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestPublishedDatePrecision.java delete mode 100644 src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestSortBy.java rename src/main/java/com/newscatcher/api/resources/{aggregation/AggregationClient.java => aggregationcount/AggregationCountClient.java} (54%) rename src/main/java/com/newscatcher/api/resources/{aggregation/AsyncAggregationClient.java => aggregationcount/AsyncAggregationCountClient.java} (54%) rename src/main/java/com/newscatcher/api/resources/{aggregation/AsyncRawAggregationClient.java => aggregationcount/AsyncRawAggregationCountClient.java} (88%) rename src/main/java/com/newscatcher/api/resources/{aggregation/RawAggregationClient.java => aggregationcount/RawAggregationCountClient.java} (88%) create mode 100644 src/main/java/com/newscatcher/api/resources/aggregationcount/requests/GetAggregationCountRequest.java rename src/main/java/com/newscatcher/api/resources/{aggregation/requests/AggregationPostRequest.java => aggregationcount/requests/PostAggregationCountRequest.java} (92%) rename src/main/java/com/newscatcher/api/resources/{aggregation/types/AggregationPostResponse.java => aggregationcount/types/GetAggregationCountResponse.java} (70%) rename src/main/java/com/newscatcher/api/resources/{aggregation/types/AggregationGetResponse.java => aggregationcount/types/PostAggregationCountResponse.java} (70%) rename src/main/java/com/newscatcher/api/resources/authors/requests/{AuthorsGetRequest.java => GetAuthorsRequest.java} (55%) rename src/main/java/com/newscatcher/api/resources/authors/requests/{AuthorsPostRequest.java => PostAuthorsRequest.java} (92%) delete mode 100644 src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestPublishedDatePrecision.java delete mode 100644 src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestSortBy.java rename src/main/java/com/newscatcher/api/resources/authors/types/{AuthorsGetResponse.java => GetAuthorsResponse.java} (76%) rename src/main/java/com/newscatcher/api/resources/authors/types/{AuthorsPostResponse.java => PostAuthorsResponse.java} (76%) rename src/main/java/com/newscatcher/api/resources/breakingnews/requests/{BreakingNewsGetRequest.java => GetBreakingNewsRequest.java} (50%) rename src/main/java/com/newscatcher/api/resources/breakingnews/requests/{BreakingNewsPostRequest.java => PostBreakingNewsRequest.java} (85%) delete mode 100644 src/main/java/com/newscatcher/api/resources/breakingnews/types/BreakingNewsGetRequestSortBy.java rename src/main/java/com/newscatcher/api/resources/latestheadlines/{AsyncLatestheadlinesClient.java => AsyncLatestHeadlinesClient.java} (51%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/{AsyncRawLatestheadlinesClient.java => AsyncRawLatestHeadlinesClient.java} (84%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/{LatestheadlinesClient.java => LatestHeadlinesClient.java} (53%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/{RawLatestheadlinesClient.java => RawLatestHeadlinesClient.java} (84%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/requests/{LatestHeadlinesGetRequest.java => GetLatestHeadlinesRequest.java} (63%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/requests/{LatestHeadlinesPostRequest.java => PostLatestHeadlinesRequest.java} (94%) rename src/main/java/com/newscatcher/api/resources/latestheadlines/types/{LatestHeadlinesGetResponse.java => GetLatestHeadlinesResponse.java} (75%) delete mode 100644 src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetRequestClusteringVariable.java rename src/main/java/com/newscatcher/api/resources/latestheadlines/types/{LatestHeadlinesPostResponse.java => PostLatestHeadlinesResponse.java} (75%) rename src/main/java/com/newscatcher/api/resources/search/requests/{SearchGetRequest.java => GetSearchRequest.java} (50%) rename src/main/java/com/newscatcher/api/resources/search/requests/{SearchPostRequest.java => PostSearchRequest.java} (94%) rename src/main/java/com/newscatcher/api/resources/search/types/{SearchGetResponse.java => GetSearchResponse.java} (77%) rename src/main/java/com/newscatcher/api/resources/search/types/{SearchPostResponse.java => PostSearchResponse.java} (76%) delete mode 100644 src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestClusteringVariable.java delete mode 100644 src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestNewsDomainType.java delete mode 100644 src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestPublishedDatePrecision.java delete mode 100644 src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestSortBy.java rename src/main/java/com/newscatcher/api/resources/{searchlink/AsyncRawSearchLinkClient.java => searchbylink/AsyncRawSearchByLinkClient.java} (84%) create mode 100644 src/main/java/com/newscatcher/api/resources/searchbylink/AsyncSearchByLinkClient.java rename src/main/java/com/newscatcher/api/resources/{searchlink/RawSearchLinkClient.java => searchbylink/RawSearchByLinkClient.java} (78%) create mode 100644 src/main/java/com/newscatcher/api/resources/searchbylink/SearchByLinkClient.java rename src/main/java/com/newscatcher/api/resources/{searchlink/requests/SearchUrlGetRequest.java => searchbylink/requests/GetSearchByLinkRequest.java} (77%) rename src/main/java/com/newscatcher/api/resources/{searchlink/requests/SearchUrlPostRequest.java => searchbylink/requests/PostSearchByLinkRequest.java} (91%) delete mode 100644 src/main/java/com/newscatcher/api/resources/searchlink/AsyncSearchLinkClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchlink/SearchLinkClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncRawSearchsimilarClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncSearchsimilarClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/RawSearchsimilarClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/SearchsimilarClient.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarGetRequest.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarPostRequest.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestPublishedDatePrecision.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestSortBy.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetResponse.java delete mode 100644 src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarPostResponse.java rename src/main/java/com/newscatcher/api/resources/sources/requests/{SourcesGetRequest.java => GetSourcesRequest.java} (68%) rename src/main/java/com/newscatcher/api/resources/sources/requests/{SourcesPostRequest.java => PostSourcesRequest.java} (93%) delete mode 100644 src/main/java/com/newscatcher/api/resources/sources/types/SourcesGetRequestNewsDomainType.java rename src/main/java/com/newscatcher/api/types/{Aggregations.java => AggregationCountResponseDtoAggregations.java} (69%) create mode 100644 src/main/java/com/newscatcher/api/types/AllLinksDataItem.java rename src/main/java/com/newscatcher/api/types/{Theme.java => AllLinksText.java} (76%) rename src/main/java/com/newscatcher/api/types/{Journalists.java => ArticleEntityAuthors.java} (73%) rename src/main/java/com/newscatcher/api/types/{Authors.java => ArticleEntityJournalists.java} (72%) rename src/main/java/com/newscatcher/api/types/{NotTheme.java => BreakingNewsArticleEntityAuthors.java} (70%) create mode 100644 src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityJournalists.java delete mode 100644 src/main/java/com/newscatcher/api/types/FailedSearchSimilarResponseDto.java delete mode 100644 src/main/java/com/newscatcher/api/types/IArticleEntity.java delete mode 100644 src/main/java/com/newscatcher/api/types/PublishedDatePrecision.java delete mode 100644 src/main/java/com/newscatcher/api/types/SearchSimilarResponseDto.java delete mode 100644 src/main/java/com/newscatcher/api/types/SimilarArticleEntity.java delete mode 100644 src/main/java/com/newscatcher/api/types/SimilarDocument.java diff --git a/.fern/metadata.json b/.fern/metadata.json new file mode 100644 index 0000000..dfe97e3 --- /dev/null +++ b/.fern/metadata.json @@ -0,0 +1,10 @@ +{ + "cliVersion": "4.29.0", + "generatorName": "fernapi/fern-java-sdk", + "generatorVersion": "3.44.1", + "generatorConfig": { + "publish-to": "central" + }, + "originGitCommit": "bbd2054c67ad246b017399f96faf58cf6737bf01", + "sdkVersion": "2.0.0" +} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cba5f8..1f32646 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,10 @@ name: ci on: [push] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + jobs: compile: runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index db40ee9..19a4cb8 100644 --- a/build.gradle +++ b/build.gradle @@ -14,10 +14,10 @@ repositories { } dependencies { - api 'com.squareup.okhttp3:okhttp:4.12.0' - api 'com.fasterxml.jackson.core:jackson-databind:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2' + api 'com.squareup.okhttp3:okhttp:5.2.1' + api 'com.fasterxml.jackson.core:jackson-databind:2.18.6' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.6' + api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.6' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2' @@ -47,7 +47,7 @@ java { group = 'com.newscatcherapi' -version = '1.2.0' +version = '2.0.0' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'com.newscatcherapi' artifactId = 'newscatcher-sdk' - version = '1.2.0' + version = '2.0.0' from components.java pom { name = 'newscatcher' @@ -121,9 +121,10 @@ sonatypeCentralUpload { } signing { - def signingKeyId = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + def signingKeyId = "$System.env.MAVEN_SIGNATURE_KID" + def signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD" - useInMemoryPgpKeys(signingKeyId, signingPassword) + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) sign publishing.publications.maven } diff --git a/reference.md b/reference.md index f517199..80466b9 100644 --- a/reference.md +++ b/reference.md @@ -1,6 +1,6 @@ # Reference ## Search -
client.search.get() -> SearchGetResponse +
client.search.get() -> GetSearchResponse
@@ -12,7 +12,7 @@
-Searches for articles based on specified criteria such as keyword, language, country, source, and more. +Searches for articles based on specified criteria such as keywords, language, country, source, and more.
@@ -28,23 +28,66 @@ Searches for articles based on specified criteria such as keyword, language, cou ```java client.search().get( - SearchGetRequest + GetSearchRequest .builder() - .q("technology AND (Apple OR Microsoft) NOT Google") + .q("\"supply chain\" AND Amazon NOT China") .searchIn("title_content, title_content_translated") .includeTranslationFields(true) - .predefinedSources("top 100 US, top 5 GB") - .from(OffsetDateTime.parse("2024-07-01T00:00:00Z")) - .to(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + .predefinedSources("top 50 US, top 20 GB") + .sourceName("sport,tech") + .sources("nytimes.com,finance.yahoo.com") + .notSources("cnn.com,wsj.com") + .lang("en,es") + .notLang("fr,de") + .countries("US,CA") + .notCountries("UK,FR") + .notAuthorName("John Doe, Jane Doe") + .from( + From.of(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + ) + .to( + To.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + ) + .publishedDatePrecision("full") + .byParseDate(true) + .rankedOnly(true) + .fromRank(100) + .toRank(100) + .isHeadline(true) + .isOpinion(true) + .isPaidContent(false) + .parentUrl("wsj.com/politics,wsj.com/tech") + .allLinks("https://aiindex.stanford.edu/report,https://www.stateof.ai") + .allDomainLinks("who.int,nih.gov") + .allLinksText("Nvidia,Tesla") + .additionalDomainInfo(true) + .isNewsDomain(true) + .newsType("General News Outlets,Tech News and Updates") + .wordCountMin(300) + .wordCountMax(1000) + .page(2) + .pageSize(50) + .clusteringEnabled(true) + .clusteringThreshold(0.6f) .includeNlpData(true) .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") + .theme("Finance,Tech") + .notTheme("Crime,Sports") + .orgEntityName("\"Apple Inc\" OR Microsoft") + .perEntityName("\"Elon Musk\" OR \"Jeff Bezos\"") + .locEntityName("\"San Francisco\" OR \"New York City\"") + .miscEntityName("AWS OR \"Microsoft Azure\"") + .titleSentimentMin(-0.5f) + .titleSentimentMax(0.5f) + .contentSentimentMin(-0.5f) + .contentSentimentMax(0.5f) .iptcTags("20000199,20000209") .notIptcTags("20000205,20000209") .iabTags("Business,Events") .notIabTags("Agriculture,Metals") - .customTags("Tag1,Tag2,Tag3") + .customTags("Tag1,Tag2") + .excludeDuplicates(true) + .robotsCompliant(true) .build() ); ``` @@ -62,17 +105,6 @@ client.search().get(
**q:** `String` - -The keyword(s) to search for in articles. Query syntax supports logical operators (`AND`, `OR`, `NOT`) and wildcards: - -- For an exact match, use double quotes. For example, `"technology news"`. -- Use `*` to search for any keyword. -- Use `+` to include and `-` to exclude specific words or phrases. - For example, `+Apple`, `-Google`. -- Use `AND`, `OR`, and `NOT` to refine search results. - For example, `technology AND (Apple OR Microsoft) NOT Google`. - -For more details, see [Advanced querying](/docs/v3/documentation/guides-and-concepts/advanced-querying).
@@ -100,13 +132,9 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc Predefined top news sources per country. -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. +Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` +Multiple countries with the number of top sources can be specified as a comma-separated string. @@ -118,8 +146,6 @@ Examples: Word or phrase to search within the source names. To specify multiple values, use a comma-separated string. -Example: `"sport, tech"` - **Note**: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like `"sport"` or `"new york times"`. For example, `"sport"` returns sources such as `"Motorsport"`, `"Dot Esport"`, and `"Tuttosport"`. @@ -128,13 +154,7 @@ Example: `"sport, tech"`
-**sources:** `Optional` - -One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string. - -Examples: -- `"nytimes.com"` -- `"theguardian.com, finance.yahoo.com"` +**sources:** `Optional` — One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string.
@@ -142,11 +162,7 @@ Examples:
-**notSources:** `Optional` - -The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - -Example: `"cnn.com, wsj.com"` +**notSources:** `Optional` — The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.
@@ -156,11 +172,9 @@ Example: `"cnn.com, wsj.com"` **lang:** `Optional` -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. +The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. -Example: `"en, es"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -172,9 +186,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The language(s) to exclude from the search. The accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To exclude multiple languages, use a comma-separated string. -Example: `"fr, de"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -186,9 +198,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. -Example: `"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -200,9 +210,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over The publisher location countries to exclude from the search. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To exclude multiple countries, use a comma-separated string. -Example:`"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -210,11 +218,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over
-**notAuthorName:** `Optional` - -The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - -Example: `"John Doe, Jane Doe"` +**notAuthorName:** `Optional` — The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.
@@ -222,18 +226,7 @@ Example: `"John Doe, Jane Doe"`
-**from:** `Optional` - -The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `7 day ago`, `today` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**from:** `Optional`
@@ -241,18 +234,7 @@ Formats with examples:
-**to:** `Optional` - -The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `1 day ago`, `now` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**to:** `Optional`
@@ -260,12 +242,7 @@ Formats with examples:
-**publishedDatePrecision:** `Optional` - -The precision of the published date. There are three types: -- `full`: The day and time of an article is correctly identified with the appropriate timezone. -- `timezone unknown`: The day and time of an article is correctly identified without timezone. -- `date`: Only the day is identified without an exact time. +**publishedDatePrecision:** `Optional`
@@ -273,7 +250,7 @@ The precision of the published date. There are three types:
-**byParseDate:** `Optional` — If true, the `from_` and `to_` parameters use article parse dates instead of published dates. Additionally, the `parse_date` variable is added to the output for each article object. +**byParseDate:** `Optional`
@@ -281,12 +258,7 @@ The precision of the published date. There are three types:
-**sortBy:** `Optional` - -The sorting order of the results. Possible values are: -- `relevancy`: The most relevant results first. -- `date`: The most recently published results first. -- `rank`: The results from the highest-ranked sources first. +**sortBy:** `Optional`
@@ -294,7 +266,7 @@ The sorting order of the results. Possible values are:
-**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. +**rankedOnly:** `Optional`
@@ -302,7 +274,7 @@ The sorting order of the results. Possible values are:
-**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**fromRank:** `Optional`
@@ -310,7 +282,7 @@ The sorting order of the results. Possible values are:
-**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**toRank:** `Optional`
@@ -318,7 +290,7 @@ The sorting order of the results. Possible values are:
-**isHeadline:** `Optional` — If true, only returns articles that were posted on the home page of a given news domain. +**isHeadline:** `Optional`
@@ -326,7 +298,7 @@ The sorting order of the results. Possible values are:
-**isOpinion:** `Optional` — If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. +**isOpinion:** `Optional`
@@ -334,7 +306,7 @@ The sorting order of the results. Possible values are:
-**isPaidContent:** `Optional` — If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. +**isPaidContent:** `Optional`
@@ -342,11 +314,7 @@ The sorting order of the results. Possible values are:
-**parentUrl:** `Optional` - -The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - -Example: `"wsj.com/politics, wsj.com/tech"` +**parentUrl:** `Optional` — The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.
@@ -358,9 +326,7 @@ Example: `"wsj.com/politics, wsj.com/tech"` The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. -Example: `"https://aiindex.stanford.edu/report, https://www.stateof.ai"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -372,9 +338,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. -Example: `"who.int, nih.gov"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -382,12 +346,13 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**additionalDomainInfo:** `Optional` +**allLinksText:** `Optional` -If true, includes additional domain information in the response for each article: -- `is_news_domain`: Boolean indicating if the source is a news domain. -- `news_domain_type`: Type of news domain (e.g., `"Original Content"`). -- `news_type`: Category of news (e.g., `"News and Blogs"`). +The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + +**Note**: When this parameter is used, the response includes the `all_links_data` field with detailed link information. + +To learn more, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url).
@@ -395,7 +360,7 @@ If true, includes additional domain information in the response for each article
-**isNewsDomain:** `Optional` — If true, filters results to include only news domains. +**additionalDomainInfo:** `Optional`
@@ -403,14 +368,15 @@ If true, includes additional domain information in the response for each article
-**newsDomainType:** `Optional` +**isNewsDomain:** `Optional` + +
+
+ +
+
-Filters results based on the news domain type. Possible values are: -- `Original Content`: Sources that produce their own content. -- `Aggregator`: Sources that collect content from various other sources. -- `Press Releases`: Sources primarily publishing press releases. -- `Republisher`: Sources that republish content from other sources. -- `Other`: Sources that don't fit into main categories. +**newsDomainType:** `Optional`
@@ -422,9 +388,7 @@ Filters results based on the news domain type. Possible values are: Filters results based on the news type. Multiple types can be specified using a comma-separated string. -Example: `"General News Outlets,Tech News and Updates"` - -For a complete list of available news types, see [Enumerated parameters > News type](/docs/v3/api-reference/overview/enumerated-parameters#news-type-news-type). +For a complete list of available news types, see [Enumerated parameters > News type](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#news-type-news-type). @@ -432,7 +396,7 @@ For a complete list of available news types, see [Enumerated parameters > News t
-**wordCountMin:** `Optional` — The minimum number of words an article must contain. To be used for avoiding articles with small content. +**wordCountMin:** `Optional`
@@ -440,7 +404,7 @@ For a complete list of available news types, see [Enumerated parameters > News t
-**wordCountMax:** `Optional` — The maximum number of words an article can contain. To be used for avoiding articles with large content. +**wordCountMax:** `Optional`
@@ -449,10 +413,6 @@ For a complete list of available news types, see [Enumerated parameters > News t
**page:** `Optional` - -The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - -For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets).
@@ -460,7 +420,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -469,10 +429,6 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
**clusteringEnabled:** `Optional` - -Determines whether to group similar articles into clusters. If true, the API returns clustered results. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles).
@@ -480,16 +436,7 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
-**clusteringVariable:** `Optional` - -Specifies which part of the article to use for determining similarity when clustering. - -Possible values are: -- `content`: Uses the full article content (default). -- `title`: Uses only the article title. -- `summary`: Uses the article summary. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles). +**clusteringVariable:** `Optional`
@@ -498,15 +445,6 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
**clusteringThreshold:** `Optional` - -Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles. - -Examples: -- `0.3`: Results in larger, more diverse clusters. -- `0.6`: Balances cluster size and article similarity (default). -- `0.9`: Creates smaller, tightly related clusters. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles).
@@ -531,16 +469,6 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`.
@@ -549,14 +477,6 @@ Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`
**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -565,14 +485,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**orgEntityName:** `Optional` - -Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Apple, Microsoft"` - -**Note**: The `ORG_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -581,14 +493,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**perEntityName:** `Optional` - -Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Elon Musk, Jeff Bezos"` - -**Note**: The `PER_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -597,14 +501,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**locEntityName:** `Optional` - -Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"California, New York"` - -**Note**: The `LOC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -613,14 +509,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**miscEntityName:** `Optional` - -Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Bitcoin, Blockchain"` - -**Note**: The `MISC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -629,17 +517,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -648,17 +525,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -667,17 +533,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -686,17 +541,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -708,8 +552,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. -Example: `"20000199, 20000209"` - **Note**: The `iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). @@ -722,9 +564,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **notIptcTags:** `Optional` -Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - -Example: `"20000205, 20000209"` +Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. **Note**: The `not_iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -738,9 +578,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **iabTags:** `Optional` -Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - -Example: `"Business, Events"` +Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. **Note**: The `iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -754,9 +592,7 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c **notIabTags:** `Optional` -Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - -Example: `"Agriculture, Metals"` +Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. **Note**: The `not_iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -772,11 +608,11 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: -- `custom_tags.taxonomy=Tag1,Tag2,Tag3`, where `taxonomy` is the taxonomy name and `Tag1,Tag2,Tag3` is a comma-separated list of tags. +- `custom_tags.taxonomy=Tag1,Tag2`, where `taxonomy` is the taxonomy name and `Tag1,Tag2` is a comma-separated list of tag names. -Example: `custom_tags.industry="Manufacturing, Supply Chain, Logistics"` +Example: `custom_tags.industry="Manufacturing,Logistics"` -To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/custom-tags). +To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-api/guides-and-concepts/custom-tags). @@ -785,10 +621,6 @@ To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/
**excludeDuplicates:** `Optional` - -If true, excludes duplicate and highly similar articles from the search results. If false, returns all relevant articles, including duplicates. - -To learn more, see [Articles deduplication](/docs/v3/documentation/guides-and-concepts/articles-deduplication).
@@ -796,7 +628,7 @@ To learn more, see [Articles deduplication](/docs/v3/documentation/guides-and-co
-**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. +**robotsCompliant:** `Optional`
@@ -808,7 +640,7 @@ To learn more, see [Articles deduplication](/docs/v3/documentation/guides-and-co
-
client.search.post(request) -> SearchPostResponse +
client.search.post(request) -> PostSearchResponse
@@ -820,7 +652,7 @@ To learn more, see [Articles deduplication](/docs/v3/documentation/guides-and-co
-Searches for articles based on specified criteria such as keyword, language, country, source, and more. +Searches for articles based on specified criteria such as keywords, language, country, source, and more.
@@ -836,23 +668,10 @@ Searches for articles based on specified criteria such as keyword, language, cou ```java client.search().post( - SearchPostRequest + PostSearchRequest .builder() - .q("renewable energy") - .predefinedSources( - PredefinedSources.of() - ) - .lang( - Lang.of() - ) - .from( - From.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - ) - .to( - To.of(OffsetDateTime.parse("2024-06-30T00:00:00Z")) - ) - .additionalDomainInfo(true) - .isNewsDomain(true) + .q("\"supply chain\" AND Amazon NOT China") + .pageSize(1) .build() ); ``` @@ -981,7 +800,7 @@ client.search().post(
-**publishedDatePrecision:** `Optional` +**publishedDatePrecision:** `Optional`
@@ -1077,6 +896,14 @@ client.search().post(
+**allLinksText:** `Optional` + +
+
+ +
+
+ **additionalDomainInfo:** `Optional`
@@ -1181,7 +1008,7 @@ client.search().post(
-**theme:** `Optional` +**theme:** `Optional`
@@ -1189,7 +1016,7 @@ client.search().post(
-**notTheme:** `Optional` +**notTheme:** `Optional`
@@ -1322,7 +1149,7 @@ client.search().post(
## LatestHeadlines -
client.latestheadlines.get() -> LatestHeadlinesGetResponse +
client.latestHeadlines.get() -> GetLatestHeadlinesResponse
@@ -1349,20 +1176,52 @@ Retrieves the latest headlines for the specified time period. You can filter res
```java -client.latestheadlines().get( - LatestHeadlinesGetRequest +client.latestHeadlines().get( + GetLatestHeadlinesRequest .builder() - .predefinedSources("top 100 US, top 5 GB") + .when("7d") + .byParseDate(true) + .lang("en,es") + .notLang("fr,de") + .countries("US,CA") + .notCountries("UK,FR") + .predefinedSources("top 50 US, top 20 GB") + .sources("nytimes.com,finance.yahoo.com") + .notSources("cnn.com,wsj.com") + .notAuthorName("John Doe, Jane Doe") + .rankedOnly(true) + .isHeadline(true) + .isOpinion(true) + .isPaidContent(false) + .parentUrl("wsj.com/politics,wsj.com/tech") + .allLinks("https://aiindex.stanford.edu/report,https://www.stateof.ai") + .allDomainLinks("who.int,nih.gov") + .allLinksText("Nvidia,Tesla") + .wordCountMin(300) + .wordCountMax(1000) + .page(2) + .pageSize(50) + .clusteringEnabled(true) + .clusteringThreshold(0.6f) .includeTranslationFields(true) .includeNlpData(true) .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") + .theme("Finance,Tech") + .notTheme("Crime,Sports") + .orgEntityName("\"Apple Inc\" OR Microsoft") + .perEntityName("\"Elon Musk\" OR \"Jeff Bezos\"") + .locEntityName("\"San Francisco\" OR \"New York City\"") + .miscEntityName("AWS OR \"Microsoft Azure\"") + .titleSentimentMin(-0.5f) + .titleSentimentMax(0.5f) + .contentSentimentMin(-0.5f) + .contentSentimentMax(0.5f) .iptcTags("20000199,20000209") .notIptcTags("20000205,20000209") .iabTags("Business,Events") .notIabTags("Agriculture,Metals") - .customTags("Tag1,Tag2,Tag3") + .customTags("Tag1,Tag2") + .robotsCompliant(true) .build() ); ``` @@ -1380,14 +1239,14 @@ client.latestheadlines().get(
**when:** `Optional` + +
+
-The time period for which you want to get the latest headlines. +
+
-Format examples: -- `7d`: Last seven days -- `30d`: Last 30 days -- `1h`: Last hour -- `24h`: Last 24 hours +**byParseDate:** `Optional`
@@ -1395,7 +1254,7 @@ Format examples:
-**byParseDate:** `Optional` — If true, the `from_` and `to_` parameters use article parse dates instead of published dates. Additionally, the `parse_date` variable is added to the output for each article object. +**sortBy:** `Optional`
@@ -1405,11 +1264,9 @@ Format examples: **lang:** `Optional` -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. - -Example: `"en, es"` +The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -1421,9 +1278,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The language(s) to exclude from the search. The accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To exclude multiple languages, use a comma-separated string. -Example: `"fr, de"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -1435,9 +1290,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. -Example: `"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -1449,9 +1302,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over The publisher location countries to exclude from the search. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To exclude multiple countries, use a comma-separated string. -Example:`"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -1463,13 +1314,9 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over Predefined top news sources per country. -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. +Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` +Multiple countries with the number of top sources can be specified as a comma-separated string. @@ -1477,13 +1324,7 @@ Examples:
-**sources:** `Optional` - -One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string. - -Examples: -- `"nytimes.com"` -- `"theguardian.com, finance.yahoo.com"` +**sources:** `Optional` — One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string.
@@ -1491,11 +1332,7 @@ Examples:
-**notSources:** `Optional` - -The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - -Example: `"cnn.com, wsj.com"` +**notSources:** `Optional` — The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.
@@ -1503,11 +1340,7 @@ Example: `"cnn.com, wsj.com"`
-**notAuthorName:** `Optional` - -The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - -Example: `"John Doe, Jane Doe"` +**notAuthorName:** `Optional` — The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.
@@ -1515,7 +1348,7 @@ Example: `"John Doe, Jane Doe"`
-**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. +**rankedOnly:** `Optional`
@@ -1523,7 +1356,7 @@ Example: `"John Doe, Jane Doe"`
-**isHeadline:** `Optional` — If true, only returns articles that were posted on the home page of a given news domain. +**isHeadline:** `Optional`
@@ -1531,7 +1364,7 @@ Example: `"John Doe, Jane Doe"`
-**isOpinion:** `Optional` — If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. +**isOpinion:** `Optional`
@@ -1539,7 +1372,7 @@ Example: `"John Doe, Jane Doe"`
-**isPaidContent:** `Optional` — If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. +**isPaidContent:** `Optional`
@@ -1547,11 +1380,7 @@ Example: `"John Doe, Jane Doe"`
-**parentUrl:** `Optional` - -The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - -Example: `"wsj.com/politics, wsj.com/tech"` +**parentUrl:** `Optional` — The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.
@@ -1563,9 +1392,7 @@ Example: `"wsj.com/politics, wsj.com/tech"` The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. -Example: `"https://aiindex.stanford.edu/report, https://www.stateof.ai"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -1577,9 +1404,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. -Example: `"who.int, nih.gov"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -1587,7 +1412,13 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMin:** `Optional` — The minimum number of words an article must contain. To be used for avoiding articles with small content. +**allLinksText:** `Optional` + +The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + +**Note**: When this parameter is used, the response includes the `all_links_data` field with detailed link information. + +To learn more, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url).
@@ -1595,7 +1426,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMax:** `Optional` — The maximum number of words an article can contain. To be used for avoiding articles with large content. +**wordCountMin:** `Optional`
@@ -1603,11 +1434,15 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**page:** `Optional` +**wordCountMax:** `Optional` + +
+
-The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. +
+
-For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets). +**page:** `Optional`
@@ -1615,7 +1450,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -1624,10 +1459,6 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
**clusteringEnabled:** `Optional` - -Determines whether to group similar articles into clusters. If true, the API returns clustered results. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles).
@@ -1635,16 +1466,7 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
-**clusteringVariable:** `Optional` - -Specifies which part of the article to use for determining similarity when clustering. - -Possible values are: -- `content`: Uses the full article content (default). -- `title`: Uses only the article title. -- `summary`: Uses the article summary. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles). +**clusteringVariable:** `Optional`
@@ -1653,15 +1475,6 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
**clusteringThreshold:** `Optional` - -Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles. - -Examples: -- `0.3`: Results in larger, more diverse clusters. -- `0.6`: Balances cluster size and article similarity (default). -- `0.9`: Creates smaller, tightly related clusters. - -To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-concepts/clustering-news-articles).
@@ -1694,16 +1507,6 @@ To learn more, see [Clustering news articles](/docs/v3/documentation/guides-and-
**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`.
@@ -1712,14 +1515,6 @@ Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`
**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -1728,14 +1523,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**orgEntityName:** `Optional` - -Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Apple, Microsoft"` - -**Note**: The `ORG_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -1744,14 +1531,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**perEntityName:** `Optional` - -Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Elon Musk, Jeff Bezos"` - -**Note**: The `PER_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -1760,14 +1539,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**locEntityName:** `Optional` - -Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"California, New York"` - -**Note**: The `LOC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -1776,14 +1547,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**miscEntityName:** `Optional` - -Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Bitcoin, Blockchain"` - -**Note**: The `MISC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -1792,17 +1555,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -1811,17 +1563,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -1830,17 +1571,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -1849,17 +1579,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -1871,8 +1590,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. -Example: `"20000199, 20000209"` - **Note**: The `iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). @@ -1885,9 +1602,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **notIptcTags:** `Optional` -Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - -Example: `"20000205, 20000209"` +Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. **Note**: The `not_iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -1901,9 +1616,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **iabTags:** `Optional` -Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - -Example: `"Business, Events"` +Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. **Note**: The `iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -1917,9 +1630,7 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c **notIabTags:** `Optional` -Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - -Example: `"Agriculture, Metals"` +Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. **Note**: The `not_iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -1935,11 +1646,11 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: -- `custom_tags.taxonomy=Tag1,Tag2,Tag3`, where `taxonomy` is the taxonomy name and `Tag1,Tag2,Tag3` is a comma-separated list of tags. +- `custom_tags.taxonomy=Tag1,Tag2`, where `taxonomy` is the taxonomy name and `Tag1,Tag2` is a comma-separated list of tag names. -Example: `custom_tags.industry="Manufacturing, Supply Chain, Logistics"` +Example: `custom_tags.industry="Manufacturing,Logistics"` -To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/custom-tags). +To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-api/guides-and-concepts/custom-tags). @@ -1947,7 +1658,7 @@ To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/
-**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. +**robotsCompliant:** `Optional`
@@ -1959,7 +1670,7 @@ To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/
-
client.latestheadlines.post(request) -> LatestHeadlinesPostResponse +
client.latestHeadlines.post(request) -> PostLatestHeadlinesResponse
@@ -1986,17 +1697,11 @@ Retrieves the latest headlines for the specified time period. You can filter res
```java -client.latestheadlines().post( - LatestHeadlinesPostRequest +client.latestHeadlines().post( + PostLatestHeadlinesRequest .builder() - .lang( - Lang.of("en") - ) - .predefinedSources( - PredefinedSources.of() - ) - .isOpinion(false) - .pageSize(10) + .when("7d") + .pageSize(1) .build() ); ``` @@ -2149,6 +1854,14 @@ client.latestheadlines().post(
+**allLinksText:** `Optional` + +
+
+ +
+
+ **wordCountMin:** `Optional`
@@ -2229,7 +1942,7 @@ client.latestheadlines().post(
-**theme:** `Optional` +**theme:** `Optional`
@@ -2237,7 +1950,7 @@ client.latestheadlines().post(
-**notTheme:** `Optional` +**notTheme:** `Optional`
@@ -2361,8 +2074,8 @@ client.latestheadlines().post(
-## Breaking News -
client.breakingNews.breakingNewsGet() -> BreakingNewsResponseDto +## BreakingNews +
client.breakingNews.get() -> BreakingNewsResponseDto
@@ -2389,15 +2102,28 @@ Retrieves breaking news articles and sorts them based on specified criteria.
```java -client.breakingNews().breakingNewsGet( - BreakingNewsGetRequest +client.breakingNews().get( + GetBreakingNewsRequest .builder() + .rankedOnly(true) + .fromRank(100) + .toRank(100) + .page(2) + .pageSize(50) .topNArticles(5) .includeTranslationFields(true) .includeNlpData(true) .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") + .theme("Finance,Tech") + .notTheme("Crime,Sports") + .orgEntityName("\"Apple Inc\" OR Microsoft") + .perEntityName("\"Elon Musk\" OR \"Jeff Bezos\"") + .locEntityName("\"San Francisco\" OR \"New York City\"") + .miscEntityName("AWS OR \"Microsoft Azure\"") + .titleSentimentMin(-0.5f) + .titleSentimentMax(0.5f) + .contentSentimentMin(-0.5f) + .contentSentimentMax(0.5f) .build() ); ``` @@ -2414,12 +2140,7 @@ client.breakingNews().breakingNewsGet(
-**sortBy:** `Optional` - -The sorting order of the results. Possible values are: -- `relevancy`: The most relevant results first. -- `date`: The most recently published results first. -- `rank`: The results from the highest-ranked sources first. +**sortBy:** `Optional`
@@ -2427,7 +2148,7 @@ The sorting order of the results. Possible values are:
-**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. +**rankedOnly:** `Optional`
@@ -2435,7 +2156,7 @@ The sorting order of the results. Possible values are:
-**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**fromRank:** `Optional`
@@ -2443,7 +2164,7 @@ The sorting order of the results. Possible values are:
-**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**toRank:** `Optional`
@@ -2452,10 +2173,6 @@ The sorting order of the results. Possible values are:
**page:** `Optional` - -The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - -For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets).
@@ -2463,7 +2180,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -2504,16 +2221,6 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`.
@@ -2522,14 +2229,6 @@ Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`
**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -2538,14 +2237,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**orgEntityName:** `Optional` - -Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Apple, Microsoft"` - -**Note**: The `ORG_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -2554,14 +2245,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**perEntityName:** `Optional` - -Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Elon Musk, Jeff Bezos"` - -**Note**: The `PER_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -2570,14 +2253,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**locEntityName:** `Optional` - -Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"California, New York"` - -**Note**: The `LOC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -2586,14 +2261,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**miscEntityName:** `Optional` - -Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Bitcoin, Blockchain"` - -**Note**: The `MISC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -2602,17 +2269,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -2621,17 +2277,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -2640,17 +2285,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -2659,25 +2293,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
- - -
-
- -**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.
@@ -2689,7 +2304,7 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
-
client.breakingNews.breakingNewsPost(request) -> BreakingNewsResponseDto +
client.breakingNews.post(request) -> BreakingNewsResponseDto
@@ -2716,13 +2331,12 @@ Retrieves breaking news articles and sorts them based on specified criteria.
```java -client.breakingNews().breakingNewsPost( - BreakingNewsPostRequest +client.breakingNews().post( + PostBreakingNewsRequest .builder() .sortBy(SortBy.RELEVANCY) - .page(1) - .pageSize(100) - .includeNlpData(true) + .rankedOnly(true) + .topNArticles(1) .build() ); ``` @@ -2819,7 +2433,7 @@ client.breakingNews().breakingNewsPost(
-**theme:** `Optional` +**theme:** `Optional`
@@ -2827,7 +2441,7 @@ client.breakingNews().breakingNewsPost(
-**notTheme:** `Optional` +**notTheme:** `Optional`
@@ -2891,15 +2505,7 @@ client.breakingNews().breakingNewsPost(
-**contentSentientMax:** `Optional` - -
-
- -
-
- -**robotsCompliant:** `Optional` +**contentSentimentMax:** `Optional`
@@ -2912,7 +2518,7 @@ client.breakingNews().breakingNewsPost(
## Authors -
client.authors.get() -> AuthorsGetResponse +
client.authors.get() -> GetAuthorsResponse
@@ -2940,23 +2546,55 @@ Searches for articles written by a specified author. You can filter results by l ```java client.authors().get( - AuthorsGetRequest + GetAuthorsRequest .builder() .authorName("Jane Smith") - .predefinedSources("top 100 US, top 5 GB") - .from(OffsetDateTime.parse("2024-07-01T00:00:00Z")) - .to(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + .notAuthorName("John Doe, Jane Doe") + .predefinedSources("top 50 US, top 20 GB") + .sources("nytimes.com,finance.yahoo.com") + .notSources("cnn.com,wsj.com") + .lang("en,es") + .notLang("fr,de") + .countries("US,CA") + .notCountries("UK,FR") + .from( + From.of(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + ) + .to( + To.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + ) + .publishedDatePrecision("full") + .byParseDate(true) + .rankedOnly(true) + .fromRank(100) + .toRank(100) + .isHeadline(true) + .isOpinion(true) + .isPaidContent(false) + .parentUrl("wsj.com/politics,wsj.com/tech") + .allLinks("https://aiindex.stanford.edu/report,https://www.stateof.ai") + .allDomainLinks("who.int,nih.gov") + .allLinksText("Nvidia,Tesla") + .wordCountMin(300) + .wordCountMax(1000) + .page(2) + .pageSize(50) .includeTranslationFields(true) .includeNlpData(true) .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") - .nerName("Tesla") + .theme("Finance,Tech") + .notTheme("Crime,Sports") + .nerName("Tesla,Amazon") + .titleSentimentMin(-0.5f) + .titleSentimentMax(0.5f) + .contentSentimentMin(-0.5f) + .contentSentimentMax(0.5f) .iptcTags("20000199,20000209") .notIptcTags("20000205,20000209") .iabTags("Business,Events") .notIabTags("Agriculture,Metals") - .customTags("Tag1,Tag2,Tag3") + .customTags("Tag1,Tag2") + .robotsCompliant(true) .build() ); ``` @@ -2973,7 +2611,7 @@ client.authors().get(
-**authorName:** `String` — The name of the author to search for. This parameter returns exact matches only. +**authorName:** `String`
@@ -2981,11 +2619,7 @@ client.authors().get(
-**notAuthorName:** `Optional` - -The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - -Example: `"John Doe, Jane Doe"` +**notAuthorName:** `Optional` — The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.
@@ -2997,13 +2631,9 @@ Example: `"John Doe, Jane Doe"` Predefined top news sources per country. -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. +Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` +Multiple countries with the number of top sources can be specified as a comma-separated string.
@@ -3011,13 +2641,7 @@ Examples:
-**sources:** `Optional` - -One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string. - -Examples: -- `"nytimes.com"` -- `"theguardian.com, finance.yahoo.com"` +**sources:** `Optional` — One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string.
@@ -3025,11 +2649,7 @@ Examples:
-**notSources:** `Optional` - -The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - -Example: `"cnn.com, wsj.com"` +**notSources:** `Optional` — The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.
@@ -3039,11 +2659,9 @@ Example: `"cnn.com, wsj.com"` **lang:** `Optional` -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. +The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. -Example: `"en, es"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -3055,9 +2673,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The language(s) to exclude from the search. The accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To exclude multiple languages, use a comma-separated string. -Example: `"fr, de"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -3069,9 +2685,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. -Example: `"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -3083,9 +2697,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over The publisher location countries to exclude from the search. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To exclude multiple countries, use a comma-separated string. -Example:`"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -3093,18 +2705,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over
-**from:** `Optional` - -The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `7 day ago`, `today` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**from:** `Optional`
@@ -3112,18 +2713,7 @@ Formats with examples:
-**to:** `Optional` - -The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `1 day ago`, `now` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**to:** `Optional`
@@ -3131,12 +2721,7 @@ Formats with examples:
-**publishedDatePrecision:** `Optional` - -The precision of the published date. There are three types: -- `full`: The day and time of an article is correctly identified with the appropriate timezone. -- `timezone unknown`: The day and time of an article is correctly identified without timezone. -- `date`: Only the day is identified without an exact time. +**publishedDatePrecision:** `Optional`
@@ -3144,7 +2729,7 @@ The precision of the published date. There are three types:
-**byParseDate:** `Optional` — If true, the `from_` and `to_` parameters use article parse dates instead of published dates. Additionally, the `parse_date` variable is added to the output for each article object. +**byParseDate:** `Optional`
@@ -3152,12 +2737,7 @@ The precision of the published date. There are three types:
-**sortBy:** `Optional` - -The sorting order of the results. Possible values are: -- `relevancy`: The most relevant results first. -- `date`: The most recently published results first. -- `rank`: The results from the highest-ranked sources first. +**sortBy:** `Optional`
@@ -3165,7 +2745,7 @@ The sorting order of the results. Possible values are:
-**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. +**rankedOnly:** `Optional`
@@ -3173,7 +2753,7 @@ The sorting order of the results. Possible values are:
-**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**fromRank:** `Optional`
@@ -3181,7 +2761,7 @@ The sorting order of the results. Possible values are:
-**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**toRank:** `Optional`
@@ -3189,7 +2769,7 @@ The sorting order of the results. Possible values are:
-**isHeadline:** `Optional` — If true, only returns articles that were posted on the home page of a given news domain. +**isHeadline:** `Optional`
@@ -3197,7 +2777,7 @@ The sorting order of the results. Possible values are:
-**isOpinion:** `Optional` — If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. +**isOpinion:** `Optional`
@@ -3205,7 +2785,7 @@ The sorting order of the results. Possible values are:
-**isPaidContent:** `Optional` — If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. +**isPaidContent:** `Optional`
@@ -3213,11 +2793,7 @@ The sorting order of the results. Possible values are:
-**parentUrl:** `Optional` - -The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - -Example: `"wsj.com/politics, wsj.com/tech"` +**parentUrl:** `Optional` — The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.
@@ -3229,9 +2805,7 @@ Example: `"wsj.com/politics, wsj.com/tech"` The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. -Example: `"https://aiindex.stanford.edu/report, https://www.stateof.ai"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -3243,9 +2817,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. -Example: `"who.int, nih.gov"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -3253,7 +2825,13 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMin:** `Optional` — The minimum number of words an article must contain. To be used for avoiding articles with small content. +**allLinksText:** `Optional` + +The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + +**Note**: When this parameter is used, the response includes the `all_links_data` field with detailed link information. + +To learn more, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url).
@@ -3261,7 +2839,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMax:** `Optional` — The maximum number of words an article can contain. To be used for avoiding articles with large content. +**wordCountMin:** `Optional`
@@ -3269,11 +2847,15 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**page:** `Optional` +**wordCountMax:** `Optional` + +
+
-The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. +
+
-For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets). +**page:** `Optional`
@@ -3281,7 +2863,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -3314,16 +2896,6 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`.
@@ -3332,14 +2904,6 @@ Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`
**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -3348,10 +2912,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**nerName:** `Optional` - -The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string. - -Example: `"Tesla, Amazon"`
@@ -3360,17 +2920,6 @@ Example: `"Tesla, Amazon"`
**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -3379,17 +2928,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -3398,17 +2936,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -3417,17 +2944,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -3439,8 +2955,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. -Example: `"20000199, 20000209"` - **Note**: The `iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). @@ -3453,9 +2967,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **notIptcTags:** `Optional` -Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - -Example: `"20000205, 20000209"` +Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. **Note**: The `not_iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -3469,9 +2981,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **iabTags:** `Optional` -Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - -Example: `"Business, Events"` +Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. **Note**: The `iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -3485,9 +2995,7 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c **notIabTags:** `Optional` -Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - -Example: `"Agriculture, Metals"` +Inverse of the `iab_tags` parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. **Note**: The `not_iab_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -3503,11 +3011,11 @@ To learn more, see the [IAB Content taxonomy](https://iabtechlab.com/standards/c Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: -- `custom_tags.taxonomy=Tag1,Tag2,Tag3`, where `taxonomy` is the taxonomy name and `Tag1,Tag2,Tag3` is a comma-separated list of tags. +- `custom_tags.taxonomy=Tag1,Tag2`, where `taxonomy` is the taxonomy name and `Tag1,Tag2` is a comma-separated list of tag names. -Example: `custom_tags.industry="Manufacturing, Supply Chain, Logistics"` +Example: `custom_tags.industry="Manufacturing,Logistics"` -To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/custom-tags). +To learn more, see the [Custom tags](https://www.newscatcherapi.com/docs/news-api/guides-and-concepts/custom-tags). @@ -3515,7 +3023,7 @@ To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/
-**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. +**robotsCompliant:** `Optional`
@@ -3527,7 +3035,7 @@ To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/
-
client.authors.post(request) -> AuthorsPostResponse +
client.authors.post(request) -> PostAuthorsResponse
@@ -3555,21 +3063,9 @@ Searches for articles by author. You can filter results by language, country, so ```java client.authors().post( - AuthorsPostRequest + PostAuthorsRequest .builder() - .authorName("Joanna Stern") - .sources( - Sources.of() - ) - .lang( - Lang.of("en") - ) - .from( - From.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - ) - .to( - To.of(OffsetDateTime.parse("2024-06-30T00:00:00Z")) - ) + .authorName("David Muir") .build() ); ``` @@ -3674,7 +3170,7 @@ client.authors().post(
-**publishedDatePrecision:** `Optional` +**publishedDatePrecision:** `Optional`
@@ -3770,6 +3266,14 @@ client.authors().post(
+**allLinksText:** `Optional` + +
+
+ +
+
+ **wordCountMin:** `Optional`
@@ -3826,7 +3330,7 @@ client.authors().post(
-**theme:** `Optional` +**theme:** `Optional`
@@ -3834,7 +3338,7 @@ client.authors().post(
-**notTheme:** `Optional` +**notTheme:** `Optional`
@@ -3934,8 +3438,8 @@ client.authors().post(
-## SearchLink -
client.searchLink.searchUrlGet() -> SearchResponseDto +## SearchByLink +
client.searchByLink.get() -> SearchResponseDto
@@ -3962,15 +3466,20 @@ Searches for articles based on specified links or IDs. You can filter results by
```java -client.searchLink().searchUrlGet( - SearchUrlGetRequest +client.searchByLink().get( + GetSearchByLinkRequest .builder() + .ids("5f8d0d55b6e45e00179c6e7e") + .links("https://nytimes.com/article1,https://bbc.com/article2") .from( From.of(OffsetDateTime.parse("2024-07-01T00:00:00Z")) ) .to( To.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) ) + .page(2) + .pageSize(50) + .robotsCompliant(true) .build() ); ``` @@ -3991,8 +3500,6 @@ client.searchLink().searchUrlGet( The Newscatcher article ID (corresponds to the `_id` field in API response) or a list of article IDs to search for. To specify multiple IDs, use a comma-separated string. -Example: `"1234567890abcdef, abcdef1234567890"` - **Caution**: You can use either the `links` or the `ids` parameter, but not both at the same time.
@@ -4003,9 +3510,7 @@ Example: `"1234567890abcdef, abcdef1234567890"` **links:** `Optional` -The article link or list of article links to search for. To specify multiple links, use a comma-separated string. - -Example: `"https://example.com/article1, https://example.com/article2"` +The article link or list of article links to search for. To specify multiple links, use a comma-separated string. **Caution**: You can use either the `links` or the `ids` parameter, but not both at the same time. @@ -4032,10 +3537,6 @@ Example: `"https://example.com/article1, https://example.com/article2"`
**page:** `Optional` - -The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - -For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets).
@@ -4043,7 +3544,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -4051,7 +3552,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. +**robotsCompliant:** `Optional`
@@ -4063,7 +3564,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-
client.searchLink.searchUrlPost(request) -> SearchResponseDto +
client.searchByLink.post(request) -> SearchResponseDto
@@ -4090,14 +3591,11 @@ Searches for articles using their ID(s) or link(s).
```java -client.searchLink().searchUrlPost( - SearchUrlPostRequest +client.searchByLink().post( + PostSearchByLinkRequest .builder() - .ids( - Ids.of() - ) .links( - Links.of() + Links.of("https://www.reuters.com/business/energy/oil-prices-up-after-israeli-attacks-oversupply-caps-gains-2025-09-10/") ) .build() ); @@ -4193,8 +3691,8 @@ Formats with examples:
-## SearchSimilar -
client.searchsimilar.get() -> SearchSimilarGetResponse +## Sources +
client.sources.get() -> SourcesResponseDto
@@ -4206,7 +3704,7 @@ Formats with examples:
-Searches for articles similar to a specified query. +Retrieves a list of sources based on specified criteria such as language, country, rank, and more.
@@ -4221,24 +3719,19 @@ Searches for articles similar to a specified query.
```java -client.searchsimilar().get( - SearchSimilarGetRequest +client.sources().get( + GetSourcesRequest .builder() - .q("technology AND (Apple OR Microsoft) NOT Google") - .searchIn("title_content, title_content_translated") - .includeTranslationFields(true) - .similarDocumentsFields("title,summary") - .predefinedSources("top 100 US, top 5 GB") - .from(OffsetDateTime.parse("2024-07-01T00:00:00Z")) - .to(OffsetDateTime.parse("2024-07-01T00:00:00Z")) - .includeNlpData(true) - .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") - .nerName("Tesla") - .iptcTags("20000199,20000209") - .notIptcTags("20000205,20000209") - .customTags("Tag1,Tag2,Tag3") + .lang("en,es") + .countries("US,CA") + .predefinedSources("top 50 US, top 20 GB") + .sourceName("sport,tech") + .sourceUrl("bbc.com") + .includeAdditionalInfo(true) + .isNewsDomain(true) + .newsType("General News Outlets,Tech News and Updates") + .fromRank(100) + .toRank(100) .build() ); ``` @@ -4255,18 +3748,11 @@ client.searchsimilar().get(
-**q:** `String` - -The keyword(s) to search for in articles. Query syntax supports logical operators (`AND`, `OR`, `NOT`) and wildcards: +**lang:** `Optional` -- For an exact match, use double quotes. For example, `"technology news"`. -- Use `*` to search for any keyword. -- Use `+` to include and `-` to exclude specific words or phrases. - For example, `+Apple`, `-Google`. -- Use `AND`, `OR`, and `NOT` to refine search results. - For example, `technology AND (Apple OR Microsoft) NOT Google`. +The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. -For more details, see [Advanced querying](/docs/v3/documentation/guides-and-concepts/advanced-querying). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang).
@@ -4274,7 +3760,11 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**searchIn:** `Optional` +**countries:** `Optional` + +The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. + +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country).
@@ -4282,7 +3772,13 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**includeTranslationFields:** `Optional` +**predefinedSources:** `Optional` + +Predefined top news sources per country. + +Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). + +Multiple countries with the number of top sources can be specified as a comma-separated string.
@@ -4290,7 +3786,11 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**includeSimilarDocuments:** `Optional` — If true, includes similar documents in the response. +**sourceName:** `Optional` + +Word or phrase to search within the source names. To specify multiple values, use a comma-separated string. + +**Note**: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like `"sport"` or `"new york times"`. For example, `"sport"` returns sources such as `"Motorsport"`, `"Dot Esport"`, and `"Tuttosport"`.
@@ -4298,7 +3798,12 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**similarDocumentsNumber:** `Optional` — The number of similar documents to return. +**sourceUrl:** `Optional` + +The domain(s) of the news publication to search for. + +**Caution**: When specifying the `source_url` parameter, +you can only use `include_additional_info` as an extra parameter.
@@ -4306,7 +3811,7 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**similarDocumentsFields:** `Optional` — The fields to consider for finding similar documents. +**includeAdditionalInfo:** `Optional`
@@ -4314,17 +3819,7 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc
-**predefinedSources:** `Optional` - -Predefined top news sources per country. - -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. - -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` +**isNewsDomain:** `Optional`
@@ -4332,13 +3827,7 @@ Examples:
-**sources:** `Optional` - -One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string. - -Examples: -- `"nytimes.com"` -- `"theguardian.com, finance.yahoo.com"` +**newsDomainType:** `Optional`
@@ -4346,11 +3835,11 @@ Examples:
-**notSources:** `Optional` +**newsType:** `Optional` -The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. +Filters results based on the news type. Multiple types can be specified using a comma-separated string. -Example: `"cnn.com, wsj.com"` +For a complete list of available news types, see [Enumerated parameters > News type](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#news-type-news-type).
@@ -4358,13 +3847,7 @@ Example: `"cnn.com, wsj.com"`
-**lang:** `Optional` - -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. - -Example: `"en, es"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +**fromRank:** `Optional`
@@ -4372,1043 +3855,19 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove
-**notLang:** `Optional` - -The language(s) to exclude from the search. The accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To exclude multiple languages, use a comma-separated string. - -Example: `"fr, de"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +**toRank:** `Optional`
+
+
-
-
- -**countries:** `Optional` - -The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. - -Example: `"US, CA"` -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). -
+
-
-
- -**notCountries:** `Optional` - -The publisher location countries to exclude from the search. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To exclude multiple countries, use a comma-separated string. - -Example:`"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). - -
-
- -
-
- -**from:** `Optional` - -The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `7 day ago`, `today` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. - -
-
- -
-
- -**to:** `Optional` - -The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `1 day ago`, `now` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. - -
-
- -
-
- -**byParseDate:** `Optional` — If true, the `from_` and `to_` parameters use article parse dates instead of published dates. Additionally, the `parse_date` variable is added to the output for each article object. - -
-
- -
-
- -**publishedDatePrecision:** `Optional` - -The precision of the published date. There are three types: -- `full`: The day and time of an article is correctly identified with the appropriate timezone. -- `timezone unknown`: The day and time of an article is correctly identified without timezone. -- `date`: Only the day is identified without an exact time. - -
-
- -
-
- -**sortBy:** `Optional` - -The sorting order of the results. Possible values are: -- `relevancy`: The most relevant results first. -- `date`: The most recently published results first. -- `rank`: The results from the highest-ranked sources first. - -
-
- -
-
- -**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - -
-
- -
-
- -**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - -
-
- -
-
- -**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - -
-
- -
-
- -**isHeadline:** `Optional` — If true, only returns articles that were posted on the home page of a given news domain. - -
-
- -
-
- -**isOpinion:** `Optional` — If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - -
-
- -
-
- -**isPaidContent:** `Optional` — If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - -
-
- -
-
- -**parentUrl:** `Optional` - -The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - -Example: `"wsj.com/politics, wsj.com/tech"` - -
-
- -
-
- -**allLinks:** `Optional` - -The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - -Example: `"https://aiindex.stanford.edu/report, https://www.stateof.ai"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). - -
-
- -
-
- -**allDomainLinks:** `Optional` - -The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - -Example: `"who.int, nih.gov"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). - -
-
- -
-
- -**wordCountMin:** `Optional` — The minimum number of words an article must contain. To be used for avoiding articles with small content. - -
-
- -
-
- -**wordCountMax:** `Optional` — The maximum number of words an article can contain. To be used for avoiding articles with large content. - -
-
- -
-
- -**page:** `Optional` - -The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - -For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets). - -
-
- -
-
- -**pageSize:** `Optional` — The number of articles to return per page. - -
-
- -
-
- -**includeNlpData:** `Optional` - -
-
- -
-
- -**hasNlp:** `Optional` - -
-
- -
-
- -**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`. - -
-
- -
-
- -**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
-
- -
-
- -**nerName:** `Optional` - -The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string. - -Example: `"Tesla, Amazon"` - -
-
- -
-
- -**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
-
- -
-
- -**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
-
- -
-
- -**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
-
- -
-
- -**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -
-
- -
-
- -**iptcTags:** `Optional` - -Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - -Example: `"20000199, 20000209"` - -**Note**: The `iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. - -To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). - -
-
- -
-
- -**notIptcTags:** `Optional` - -Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - -Example: `"20000205, 20000209"` - -**Note**: The `not_iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. - -To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). - -
-
- -
-
- -**customTags:** `Optional` - -Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: - -- `custom_tags.taxonomy=Tag1,Tag2,Tag3`, where `taxonomy` is the taxonomy name and `Tag1,Tag2,Tag3` is a comma-separated list of tags. - -Example: `custom_tags.industry="Manufacturing, Supply Chain, Logistics"` - -To learn more, see the [Custom tags](/docs/v3/documentation/guides-and-concepts/custom-tags). - -
-
- -
-
- -**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - -
-
- - - - - - -
- -
client.searchsimilar.post(request) -> SearchSimilarPostResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Searches for articles similar to the specified query. You can filter results by language, country, source, and more. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```java -client.searchsimilar().post( - SearchSimilarPostRequest - .builder() - .q("artificial intelligence") - .includeSimilarDocuments(true) - .similarDocumentsNumber(5) - .build() -); -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**q:** `String` - -
-
- -
-
- -**searchIn:** `Optional` - -
-
- -
-
- -**includeTranslationFields:** `Optional` - -
-
- -
-
- -**includeSimilarDocuments:** `Optional` - -
-
- -
-
- -**similarDocumentsNumber:** `Optional` - -
-
- -
-
- -**similarDocumentsFields:** `Optional` - -
-
- -
-
- -**predefinedSources:** `Optional` - -
-
- -
-
- -**sources:** `Optional` - -
-
- -
-
- -**notSources:** `Optional` - -
-
- -
-
- -**lang:** `Optional` - -
-
- -
-
- -**notLang:** `Optional` - -
-
- -
-
- -**countries:** `Optional` - -
-
- -
-
- -**notCountries:** `Optional` - -
-
- -
-
- -**from:** `Optional` - -
-
- -
-
- -**to:** `Optional` - -
-
- -
-
- -**byParseDate:** `Optional` - -
-
- -
-
- -**publishedDatePrecision:** `Optional` - -
-
- -
-
- -**sortBy:** `Optional` - -
-
- -
-
- -**rankedOnly:** `Optional` - -
-
- -
-
- -**fromRank:** `Optional` - -
-
- -
-
- -**toRank:** `Optional` - -
-
- -
-
- -**isHeadline:** `Optional` - -
-
- -
-
- -**isOpinion:** `Optional` - -
-
- -
-
- -**isPaidContent:** `Optional` - -
-
- -
-
- -**parentUrl:** `Optional` - -
-
- -
-
- -**allLinks:** `Optional` - -
-
- -
-
- -**allDomainLinks:** `Optional` - -
-
- -
-
- -**wordCountMin:** `Optional` - -
-
- -
-
- -**wordCountMax:** `Optional` - -
-
- -
-
- -**page:** `Optional` - -
-
- -
-
- -**pageSize:** `Optional` - -
-
- -
-
- -**includeNlpData:** `Optional` - -
-
- -
-
- -**hasNlp:** `Optional` - -
-
- -
-
- -**theme:** `Optional` - -
-
- -
-
- -**notTheme:** `Optional` - -
-
- -
-
- -**nerName:** `Optional` - -
-
- -
-
- -**titleSentimentMin:** `Optional` - -
-
- -
-
- -**titleSentimentMax:** `Optional` - -
-
- -
-
- -**contentSentimentMin:** `Optional` - -
-
- -
-
- -**contentSentimentMax:** `Optional` - -
-
- -
-
- -**iptcTags:** `Optional` - -
-
- -
-
- -**notIptcTags:** `Optional` - -
-
- -
-
- -**customTags:** `Optional` - -
-
- -
-
- -**robotsCompliant:** `Optional` - -
-
-
-
- - -
-
-
- -## Sources -
client.sources.get() -> SourcesResponseDto -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieves a list of sources based on specified criteria such as language, country, rank, and more. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```java -client.sources().get( - SourcesGetRequest - .builder() - .predefinedSources("top 100 US, top 5 GB") - .sourceUrl("bbc.com") - .build() -); -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**lang:** `Optional` - -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. - -Example: `"en, es"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). - -
-
- -
-
- -**countries:** `Optional` - -The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. - -Example: `"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). - -
-
- -
-
- -**predefinedSources:** `Optional` - -Predefined top news sources per country. - -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. - -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` - -
-
- -
-
- -**sourceName:** `Optional` - -Word or phrase to search within the source names. To specify multiple values, use a comma-separated string. - -Example: `"sport, tech"` - -**Note**: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like `"sport"` or `"new york times"`. For example, `"sport"` returns sources such as `"Motorsport"`, `"Dot Esport"`, and `"Tuttosport"`. - -
-
- -
-
- -**sourceUrl:** `Optional` - -The domain(s) of the news publication to search for. - -**Caution**: When specifying the `source_url` parameter, -you can only use `include_additional_info` as an extra parameter. - -
-
- -
-
- -**includeAdditionalInfo:** `Optional` - -If true, returns the following additional datapoints about each news source: -- `nb_articles_for_7d`: The number of articles published by the source in the last week. -- `country`: Source country of origin. -- `rank`: SEO rank. -- `is_news_domain`: Boolean indicating if the source is a news domain. -- `news_domain_type`: Type of news domain (e.g., "Original Content"). -- `news_type`: Category of news (e.g., "General News Outlets"). - -
-
- -
-
- -**isNewsDomain:** `Optional` — If true, filters results to include only news domains. - -
-
- -
-
- -**newsDomainType:** `Optional` - -Filters results based on the news domain type. Possible values are: -- `Original Content`: Sources that produce their own content. -- `Aggregator`: Sources that collect content from various other sources. -- `Press Releases`: Sources primarily publishing press releases. -- `Republisher`: Sources that republish content from other sources. -- `Other`: Sources that don't fit into main categories. - -
-
- -
-
- -**newsType:** `Optional` - -Filters results based on the news type. Multiple types can be specified using a comma-separated string. - -Example: `"General News Outlets,Tech News and Updates"` - -For a complete list of available news types, see [Enumerated parameters > News type](/docs/v3/api-reference/overview/enumerated-parameters#news-type-news-type). - -
-
- -
-
- -**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - -
-
- -
-
- -**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - -
-
-
-
- - -
-
-
- -
client.sources.post(request) -> SourcesResponseDto +
client.sources.post(request) -> SourcesResponseDto
@@ -5436,16 +3895,10 @@ Retrieves the list of sources available in the database. You can filter the sour ```java client.sources().post( - SourcesPostRequest + PostSourcesRequest .builder() .predefinedSources( - PredefinedSources.of() - ) - .includeAdditionalInfo(true) - .isNewsDomain(true) - .newsDomainType(NewsDomainType.ORIGINAL_CONTENT) - .newsType( - NewsType.of("General News Outlets") + PredefinedSources.of("top 10 US") ) .build() ); @@ -5555,8 +4008,8 @@ client.sources().post(
-## Aggregation -
client.aggregation.get() -> AggregationGetResponse +## AggregationCount +
client.aggregationCount.get() -> GetAggregationCountResponse
@@ -5583,20 +4036,56 @@ Retrieves the count of articles aggregated by day or hour based on various searc
```java -client.aggregation().get( - AggregationGetRequest +client.aggregationCount().get( + GetAggregationCountRequest .builder() - .q("technology AND (Apple OR Microsoft) NOT Google") + .q("\"supply chain\" AND Amazon NOT China") .searchIn("title_content, title_content_translated") - .predefinedSources("top 100 US, top 5 GB") - .from(OffsetDateTime.parse("2024-07-01T00:00:00Z")) - .to(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + .predefinedSources("top 50 US, top 20 GB") + .sources("nytimes.com,finance.yahoo.com") + .notSources("cnn.com,wsj.com") + .lang("en,es") + .notLang("fr,de") + .countries("US,CA") + .notCountries("UK,FR") + .notAuthorName("John Doe, Jane Doe") + .from( + From.of(OffsetDateTime.parse("2024-07-01T00:00:00Z")) + ) + .to( + To.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + ) + .publishedDatePrecision("full") + .byParseDate(true) + .rankedOnly(true) + .fromRank(100) + .toRank(100) + .isHeadline(true) + .isOpinion(true) + .isPaidContent(false) + .parentUrl("wsj.com/politics,wsj.com/tech") + .allLinks("https://aiindex.stanford.edu/report,https://www.stateof.ai") + .allDomainLinks("who.int,nih.gov") + .allLinksText("Nvidia,Tesla") + .wordCountMin(300) + .wordCountMax(1000) + .page(2) + .pageSize(50) .includeNlpData(true) .hasNlp(true) - .theme("Business,Finance") - .notTheme("Crime") + .theme("Finance,Tech") + .notTheme("Crime,Sports") + .orgEntityName("\"Apple Inc\" OR Microsoft") + .perEntityName("\"Elon Musk\" OR \"Jeff Bezos\"") + .locEntityName("\"San Francisco\" OR \"New York City\"") + .miscEntityName("AWS OR \"Microsoft Azure\"") + .titleSentimentMin(-0.5f) + .titleSentimentMax(0.5f) + .contentSentimentMin(-0.5f) + .contentSentimentMax(0.5f) .iptcTags("20000199,20000209") .notIptcTags("20000205,20000209") + .robotsCompliant(true) .build() ); ``` @@ -5614,17 +4103,6 @@ client.aggregation().get(
**q:** `String` - -The keyword(s) to search for in articles. Query syntax supports logical operators (`AND`, `OR`, `NOT`) and wildcards: - -- For an exact match, use double quotes. For example, `"technology news"`. -- Use `*` to search for any keyword. -- Use `+` to include and `-` to exclude specific words or phrases. - For example, `+Apple`, `-Google`. -- Use `AND`, `OR`, and `NOT` to refine search results. - For example, `technology AND (Apple OR Microsoft) NOT Google`. - -For more details, see [Advanced querying](/docs/v3/documentation/guides-and-concepts/advanced-querying).
@@ -5652,13 +4130,9 @@ For more details, see [Advanced querying](/docs/v3/documentation/guides-and-conc Predefined top news sources per country. -Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Multiple countries with the number of top sources can be specified as a comma-separated string. +Format: start with the word `top`, followed by the number of desired sources, and then the two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). -Examples: -- `"top 100 US"` -- `"top 33 AT"` -- `"top 50 US, top 20 GB"` -- `"top 33 AT, top 50 IT"` +Multiple countries with the number of top sources can be specified as a comma-separated string. @@ -5666,13 +4140,7 @@ Examples:
-**sources:** `Optional` - -One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string. - -Examples: -- `"nytimes.com"` -- `"theguardian.com, finance.yahoo.com"` +**sources:** `Optional` — One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as `finance.yahoo.com`, are also acceptable.To specify multiple sources, use a comma-separated string.
@@ -5680,11 +4148,7 @@ Examples:
-**notSources:** `Optional` - -The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - -Example: `"cnn.com, wsj.com"` +**notSources:** `Optional` — The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.
@@ -5694,11 +4158,9 @@ Example: `"cnn.com, wsj.com"` **lang:** `Optional` -The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. +The language(s) of the search. The only accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To select multiple languages, use a comma-separated string. -Example: `"en, es"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -5710,9 +4172,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The language(s) to exclude from the search. The accepted format is the two-letter [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) code. To exclude multiple languages, use a comma-separated string. -Example: `"fr, de"` - -To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/overview/enumerated-parameters#language-lang-and-not-lang). +To learn more, see [Enumerated parameters > Language](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#language-lang-and-not-lang). @@ -5724,9 +4184,7 @@ To learn more, see [Enumerated parameters > Language](/docs/v3/api-reference/ove The countries where the news publisher is located. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To select multiple countries, use a comma-separated string. -Example: `"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -5738,9 +4196,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over The publisher location countries to exclude from the search. The accepted format is the two-letter [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. To exclude multiple countries, use a comma-separated string. -Example:`"US, CA"` - -To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/overview/enumerated-parameters#country-country-and-not-country). +To learn more, see [Enumerated parameters > Country](https://www.newscatcherapi.com/docs/news-api/api-reference/enumerated-parameters#country-country-and-not-country). @@ -5748,11 +4204,7 @@ To learn more, see [Enumerated parameters > Country](/docs/v3/api-reference/over
-**notAuthorName:** `Optional` - -The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - -Example: `"John Doe, Jane Doe"` +**notAuthorName:** `Optional` — The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.
@@ -5760,18 +4212,7 @@ Example: `"John Doe, Jane Doe"`
-**from:** `Optional` - -The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `7 day ago`, `today` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**from:** `Optional`
@@ -5779,18 +4220,7 @@ Formats with examples:
-**to:** `Optional` - -The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - -Formats with examples: -- YYYY-mm-ddTHH:MM:SS: `2024-07-01T00:00:00` -- YYYY-MM-dd: `2024-07-01` -- YYYY/mm/dd HH:MM:SS: `2024/07/01 00:00:00` -- YYYY/mm/dd: `2024/07/01` -- English phrases: `1 day ago`, `now` - -**Note**: By default, applied to the publication date of the article. To use the article's parse date instead, set the `by_parse_date` parameter to `true`. +**to:** `Optional`
@@ -5798,12 +4228,7 @@ Formats with examples:
-**publishedDatePrecision:** `Optional` - -The precision of the published date. There are three types: -- `full`: The day and time of an article is correctly identified with the appropriate timezone. -- `timezone unknown`: The day and time of an article is correctly identified without timezone. -- `date`: Only the day is identified without an exact time. +**publishedDatePrecision:** `Optional`
@@ -5811,7 +4236,7 @@ The precision of the published date. There are three types:
-**byParseDate:** `Optional` — If true, the `from_` and `to_` parameters use article parse dates instead of published dates. Additionally, the `parse_date` variable is added to the output for each article object. +**byParseDate:** `Optional`
@@ -5819,12 +4244,7 @@ The precision of the published date. There are three types:
-**sortBy:** `Optional` - -The sorting order of the results. Possible values are: -- `relevancy`: The most relevant results first. -- `date`: The most recently published results first. -- `rank`: The results from the highest-ranked sources first. +**sortBy:** `Optional`
@@ -5832,7 +4252,7 @@ The sorting order of the results. Possible values are:
-**rankedOnly:** `Optional` — If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. +**rankedOnly:** `Optional`
@@ -5840,7 +4260,7 @@ The sorting order of the results. Possible values are:
-**fromRank:** `Optional` — The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**fromRank:** `Optional`
@@ -5848,7 +4268,7 @@ The sorting order of the results. Possible values are:
-**toRank:** `Optional` — The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. +**toRank:** `Optional`
@@ -5856,7 +4276,7 @@ The sorting order of the results. Possible values are:
-**isHeadline:** `Optional` — If true, only returns articles that were posted on the home page of a given news domain. +**isHeadline:** `Optional`
@@ -5864,7 +4284,7 @@ The sorting order of the results. Possible values are:
-**isOpinion:** `Optional` — If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. +**isOpinion:** `Optional`
@@ -5872,7 +4292,7 @@ The sorting order of the results. Possible values are:
-**isPaidContent:** `Optional` — If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. +**isPaidContent:** `Optional`
@@ -5880,11 +4300,7 @@ The sorting order of the results. Possible values are:
-**parentUrl:** `Optional` - -The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - -Example: `"wsj.com/politics, wsj.com/tech"` +**parentUrl:** `Optional` — The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.
@@ -5896,9 +4312,7 @@ Example: `"wsj.com/politics, wsj.com/tech"` The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. -Example: `"https://aiindex.stanford.edu/report, https://www.stateof.ai"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -5910,9 +4324,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. -Example: `"who.int, nih.gov"` - -For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-url). +For more details, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url). @@ -5920,7 +4332,13 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMin:** `Optional` — The minimum number of words an article must contain. To be used for avoiding articles with small content. +**allLinksText:** `Optional` + +The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + +**Note**: When this parameter is used, the response includes the `all_links_data` field with detailed link information. + +To learn more, see [Search by URL](https://www.newscatcherapi.com/docs/news-api/how-to/search-by-url).
@@ -5928,7 +4346,7 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**wordCountMax:** `Optional` — The maximum number of words an article can contain. To be used for avoiding articles with large content. +**wordCountMin:** `Optional`
@@ -5936,11 +4354,15 @@ For more details, see [Search by URL](/docs/v3/documentation/how-to/search-by-ur
-**page:** `Optional` +**wordCountMax:** `Optional` + +
+
-The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. +
+
-For details, see [How to paginate large datasets](https://www.newscatcherapi.com/docs/v3/documentation/how-to/paginate-large-datasets). +**page:** `Optional`
@@ -5948,7 +4370,7 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
-**pageSize:** `Optional` — The number of articles to return per page. +**pageSize:** `Optional`
@@ -5973,16 +4395,6 @@ For details, see [How to paginate large datasets](https://www.newscatcherapi.com
**theme:** `Optional` - -Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - -Example: `"Finance, Tech"` - -**Note**: The `theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features). - -Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`, `Politics`, `Science`, `Sports`, `Tech`, `Crime`, `Financial Crime`, `Lifestyle`, `Automotive`, `Travel`, `Weather`, `General`.
@@ -5991,14 +4403,6 @@ Available options: `Business`, `Economics`, `Entertainment`, `Finance`, `Health`
**notTheme:** `Optional` - -Inverse of the `theme` parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - -Example: `"Crime, Tech"` - -**Note**: The `not_theme` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -6007,14 +4411,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**orgEntityName:** `Optional` - -Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Apple, Microsoft"` - -**Note**: The `ORG_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -6023,14 +4419,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**perEntityName:** `Optional` - -Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Elon Musk, Jeff Bezos"` - -**Note**: The `PER_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -6039,14 +4427,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**locEntityName:** `Optional` - -Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"California, New York"` - -**Note**: The `LOC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -6055,14 +4435,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**miscEntityName:** `Optional` - -Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the `search_in` parameter (e.g., `title_content_translated`). - -Example: `"Bitcoin, Blockchain"` - -**Note**: The `MISC_entity_name` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-entity).
@@ -6071,17 +4443,6 @@ To learn more, see [Search by entity](/docs/v3/documentation/how-to/search-by-en
**titleSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -6090,17 +4451,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**titleSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their titles. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `title_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -6109,17 +4459,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMin:** `Optional` - -Filters articles based on the minimum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_min` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -6128,17 +4467,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp
**contentSentimentMax:** `Optional` - -Filters articles based on the maximum sentiment score of their content. - -Range is `-1.0` to `1.0`, where: -- Negative values indicate negative sentiment. -- Positive values indicate positive sentiment. -- Values close to 0 indicate neutral sentiment. - -**Note**: The `content_sentiment_max` parameter is only available if NLP is included in your subscription plan. - -To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp-features).
@@ -6150,8 +4478,6 @@ To learn more, see [NLP features](/docs/v3/documentation/guides-and-concepts/nlp Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. -Example: `"20000199, 20000209"` - **Note**: The `iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCodes/treeview/mediatopic/mediatopic-en-GB.html). @@ -6164,9 +4490,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod **notIptcTags:** `Optional` -Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - -Example: `"20000205, 20000209"` +Inverse of the `iptc_tags` parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. **Note**: The `not_iptc_tags` parameter is only available in the `v3_nlp_iptc_tags` subscription plan. @@ -6178,7 +4502,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod
-**robotsCompliant:** `Optional` — If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. +**robotsCompliant:** `Optional`
@@ -6190,7 +4514,7 @@ To learn more, see [IPTC Media Topic NewsCodes](https://www.iptc.org/std/NewsCod
-
client.aggregation.post(request) -> AggregationPostResponse +
client.aggregationCount.post(request) -> PostAggregationCountResponse
@@ -6217,20 +4541,11 @@ Retrieves the count of articles aggregated by day or hour based on various searc
```java -client.aggregation().post( - AggregationPostRequest +client.aggregationCount().post( + PostAggregationCountRequest .builder() - .q("renewable energy") + .q("\"supply chain\" AND Amazon NOT China") .aggregationBy(AggregationBy.DAY) - .predefinedSources( - PredefinedSources.of("top 50 US") - ) - .from( - From.of(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - ) - .to( - To.of(OffsetDateTime.parse("2024-06-30T00:00:00Z")) - ) .build() ); ``` @@ -6351,7 +4666,7 @@ client.aggregation().post(
-**publishedDatePrecision:** `Optional` +**publishedDatePrecision:** `Optional`
@@ -6447,6 +4762,14 @@ client.aggregation().post(
+**allLinksText:** `Optional` + +
+
+ +
+
+ **wordCountMin:** `Optional`
@@ -6495,7 +4818,7 @@ client.aggregation().post(
-**theme:** `Optional` +**theme:** `Optional`
@@ -6503,7 +4826,7 @@ client.aggregation().post(
-**notTheme:** `Optional` +**notTheme:** `Optional`
@@ -6681,3 +5004,4 @@ client.subscription().post();
+ diff --git a/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClient.java b/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClient.java index 28530cc..6026e6c 100644 --- a/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClient.java +++ b/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClient.java @@ -5,13 +5,12 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.Suppliers; -import com.newscatcher.api.resources.aggregation.AsyncAggregationClient; +import com.newscatcher.api.resources.aggregationcount.AsyncAggregationCountClient; import com.newscatcher.api.resources.authors.AsyncAuthorsClient; import com.newscatcher.api.resources.breakingnews.AsyncBreakingNewsClient; -import com.newscatcher.api.resources.latestheadlines.AsyncLatestheadlinesClient; +import com.newscatcher.api.resources.latestheadlines.AsyncLatestHeadlinesClient; import com.newscatcher.api.resources.search.AsyncSearchClient; -import com.newscatcher.api.resources.searchlink.AsyncSearchLinkClient; -import com.newscatcher.api.resources.searchsimilar.AsyncSearchsimilarClient; +import com.newscatcher.api.resources.searchbylink.AsyncSearchByLinkClient; import com.newscatcher.api.resources.sources.AsyncSourcesClient; import com.newscatcher.api.resources.subscription.AsyncSubscriptionClient; import java.util.function.Supplier; @@ -21,32 +20,29 @@ public class AsyncNewscatcherApiClient { protected final Supplier searchClient; - protected final Supplier latestheadlinesClient; + protected final Supplier latestHeadlinesClient; protected final Supplier breakingNewsClient; protected final Supplier authorsClient; - protected final Supplier searchLinkClient; - - protected final Supplier searchsimilarClient; + protected final Supplier searchByLinkClient; protected final Supplier sourcesClient; - protected final Supplier aggregationClient; + protected final Supplier aggregationCountClient; protected final Supplier subscriptionClient; public AsyncNewscatcherApiClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.searchClient = Suppliers.memoize(() -> new AsyncSearchClient(clientOptions)); - this.latestheadlinesClient = Suppliers.memoize(() -> new AsyncLatestheadlinesClient(clientOptions)); + this.latestHeadlinesClient = Suppliers.memoize(() -> new AsyncLatestHeadlinesClient(clientOptions)); this.breakingNewsClient = Suppliers.memoize(() -> new AsyncBreakingNewsClient(clientOptions)); this.authorsClient = Suppliers.memoize(() -> new AsyncAuthorsClient(clientOptions)); - this.searchLinkClient = Suppliers.memoize(() -> new AsyncSearchLinkClient(clientOptions)); - this.searchsimilarClient = Suppliers.memoize(() -> new AsyncSearchsimilarClient(clientOptions)); + this.searchByLinkClient = Suppliers.memoize(() -> new AsyncSearchByLinkClient(clientOptions)); this.sourcesClient = Suppliers.memoize(() -> new AsyncSourcesClient(clientOptions)); - this.aggregationClient = Suppliers.memoize(() -> new AsyncAggregationClient(clientOptions)); + this.aggregationCountClient = Suppliers.memoize(() -> new AsyncAggregationCountClient(clientOptions)); this.subscriptionClient = Suppliers.memoize(() -> new AsyncSubscriptionClient(clientOptions)); } @@ -54,8 +50,8 @@ public AsyncSearchClient search() { return this.searchClient.get(); } - public AsyncLatestheadlinesClient latestheadlines() { - return this.latestheadlinesClient.get(); + public AsyncLatestHeadlinesClient latestHeadlines() { + return this.latestHeadlinesClient.get(); } public AsyncBreakingNewsClient breakingNews() { @@ -66,20 +62,16 @@ public AsyncAuthorsClient authors() { return this.authorsClient.get(); } - public AsyncSearchLinkClient searchLink() { - return this.searchLinkClient.get(); - } - - public AsyncSearchsimilarClient searchsimilar() { - return this.searchsimilarClient.get(); + public AsyncSearchByLinkClient searchByLink() { + return this.searchByLinkClient.get(); } public AsyncSourcesClient sources() { return this.sourcesClient.get(); } - public AsyncAggregationClient aggregation() { - return this.aggregationClient.get(); + public AsyncAggregationCountClient aggregationCount() { + return this.aggregationCountClient.get(); } public AsyncSubscriptionClient subscription() { diff --git a/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClientBuilder.java b/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClientBuilder.java index b436328..fd69583 100644 --- a/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClientBuilder.java +++ b/src/main/java/com/newscatcher/api/AsyncNewscatcherApiClientBuilder.java @@ -5,6 +5,7 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.Environment; +import com.newscatcher.api.core.LogConfig; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -23,6 +24,8 @@ public class AsyncNewscatcherApiClientBuilder { private OkHttpClient httpClient; + private Optional logging = Optional.empty(); + /** * Sets apiKey */ @@ -65,6 +68,14 @@ public AsyncNewscatcherApiClientBuilder httpClient(OkHttpClient httpClient) { return this; } + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public AsyncNewscatcherApiClientBuilder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + /** * Add a custom header to be sent with all requests. * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. @@ -85,6 +96,7 @@ protected ClientOptions buildClientOptions() { setHttpClient(builder); setTimeouts(builder); setRetries(builder); + setLogging(builder); for (Map.Entry header : this.customHeaders.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -157,6 +169,18 @@ protected void setHttpClient(ClientOptions.Builder builder) { } } + /** + * Sets the logging configuration for the SDK. + * Override this method to customize logging behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setLogging(ClientOptions.Builder builder) { + if (this.logging.isPresent()) { + builder.logging(this.logging.get()); + } + } + /** * Override this method to add any additional configuration to the client. * This method is called at the end of the configuration chain, allowing you to add diff --git a/src/main/java/com/newscatcher/api/NewscatcherApiClient.java b/src/main/java/com/newscatcher/api/NewscatcherApiClient.java index 3930efa..81801da 100644 --- a/src/main/java/com/newscatcher/api/NewscatcherApiClient.java +++ b/src/main/java/com/newscatcher/api/NewscatcherApiClient.java @@ -5,13 +5,12 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.Suppliers; -import com.newscatcher.api.resources.aggregation.AggregationClient; +import com.newscatcher.api.resources.aggregationcount.AggregationCountClient; import com.newscatcher.api.resources.authors.AuthorsClient; import com.newscatcher.api.resources.breakingnews.BreakingNewsClient; -import com.newscatcher.api.resources.latestheadlines.LatestheadlinesClient; +import com.newscatcher.api.resources.latestheadlines.LatestHeadlinesClient; import com.newscatcher.api.resources.search.SearchClient; -import com.newscatcher.api.resources.searchlink.SearchLinkClient; -import com.newscatcher.api.resources.searchsimilar.SearchsimilarClient; +import com.newscatcher.api.resources.searchbylink.SearchByLinkClient; import com.newscatcher.api.resources.sources.SourcesClient; import com.newscatcher.api.resources.subscription.SubscriptionClient; import java.util.function.Supplier; @@ -21,32 +20,29 @@ public class NewscatcherApiClient { protected final Supplier searchClient; - protected final Supplier latestheadlinesClient; + protected final Supplier latestHeadlinesClient; protected final Supplier breakingNewsClient; protected final Supplier authorsClient; - protected final Supplier searchLinkClient; - - protected final Supplier searchsimilarClient; + protected final Supplier searchByLinkClient; protected final Supplier sourcesClient; - protected final Supplier aggregationClient; + protected final Supplier aggregationCountClient; protected final Supplier subscriptionClient; public NewscatcherApiClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; this.searchClient = Suppliers.memoize(() -> new SearchClient(clientOptions)); - this.latestheadlinesClient = Suppliers.memoize(() -> new LatestheadlinesClient(clientOptions)); + this.latestHeadlinesClient = Suppliers.memoize(() -> new LatestHeadlinesClient(clientOptions)); this.breakingNewsClient = Suppliers.memoize(() -> new BreakingNewsClient(clientOptions)); this.authorsClient = Suppliers.memoize(() -> new AuthorsClient(clientOptions)); - this.searchLinkClient = Suppliers.memoize(() -> new SearchLinkClient(clientOptions)); - this.searchsimilarClient = Suppliers.memoize(() -> new SearchsimilarClient(clientOptions)); + this.searchByLinkClient = Suppliers.memoize(() -> new SearchByLinkClient(clientOptions)); this.sourcesClient = Suppliers.memoize(() -> new SourcesClient(clientOptions)); - this.aggregationClient = Suppliers.memoize(() -> new AggregationClient(clientOptions)); + this.aggregationCountClient = Suppliers.memoize(() -> new AggregationCountClient(clientOptions)); this.subscriptionClient = Suppliers.memoize(() -> new SubscriptionClient(clientOptions)); } @@ -54,8 +50,8 @@ public SearchClient search() { return this.searchClient.get(); } - public LatestheadlinesClient latestheadlines() { - return this.latestheadlinesClient.get(); + public LatestHeadlinesClient latestHeadlines() { + return this.latestHeadlinesClient.get(); } public BreakingNewsClient breakingNews() { @@ -66,20 +62,16 @@ public AuthorsClient authors() { return this.authorsClient.get(); } - public SearchLinkClient searchLink() { - return this.searchLinkClient.get(); - } - - public SearchsimilarClient searchsimilar() { - return this.searchsimilarClient.get(); + public SearchByLinkClient searchByLink() { + return this.searchByLinkClient.get(); } public SourcesClient sources() { return this.sourcesClient.get(); } - public AggregationClient aggregation() { - return this.aggregationClient.get(); + public AggregationCountClient aggregationCount() { + return this.aggregationCountClient.get(); } public SubscriptionClient subscription() { diff --git a/src/main/java/com/newscatcher/api/NewscatcherApiClientBuilder.java b/src/main/java/com/newscatcher/api/NewscatcherApiClientBuilder.java index ccf6584..b78089d 100644 --- a/src/main/java/com/newscatcher/api/NewscatcherApiClientBuilder.java +++ b/src/main/java/com/newscatcher/api/NewscatcherApiClientBuilder.java @@ -5,6 +5,7 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.Environment; +import com.newscatcher.api.core.LogConfig; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -23,6 +24,8 @@ public class NewscatcherApiClientBuilder { private OkHttpClient httpClient; + private Optional logging = Optional.empty(); + /** * Sets apiKey */ @@ -65,6 +68,14 @@ public NewscatcherApiClientBuilder httpClient(OkHttpClient httpClient) { return this; } + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public NewscatcherApiClientBuilder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + /** * Add a custom header to be sent with all requests. * For headers that need to be computed dynamically or conditionally, use the setAdditional() method override instead. @@ -85,6 +96,7 @@ protected ClientOptions buildClientOptions() { setHttpClient(builder); setTimeouts(builder); setRetries(builder); + setLogging(builder); for (Map.Entry header : this.customHeaders.entrySet()) { builder.addHeader(header.getKey(), header.getValue()); } @@ -157,6 +169,18 @@ protected void setHttpClient(ClientOptions.Builder builder) { } } + /** + * Sets the logging configuration for the SDK. + * Override this method to customize logging behavior. + * + * @param builder The ClientOptions.Builder to configure + */ + protected void setLogging(ClientOptions.Builder builder) { + if (this.logging.isPresent()) { + builder.logging(this.logging.get()); + } + } + /** * Override this method to add any additional configuration to the client. * This method is called at the end of the configuration chain, allowing you to add diff --git a/src/main/java/com/newscatcher/api/core/ClientOptions.java b/src/main/java/com/newscatcher/api/core/ClientOptions.java index 4bf7fa9..8b1bf29 100644 --- a/src/main/java/com/newscatcher/api/core/ClientOptions.java +++ b/src/main/java/com/newscatcher/api/core/ClientOptions.java @@ -21,26 +21,34 @@ public final class ClientOptions { private final int timeout; + private final int maxRetries; + + private final Optional logging; + private ClientOptions( Environment environment, Map headers, Map> headerSuppliers, OkHttpClient httpClient, - int timeout) { + int timeout, + int maxRetries, + Optional logging) { this.environment = environment; this.headers = new HashMap<>(); this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "com.newscatcherapi:newscatcher-sdk/1.2.0"); + put("User-Agent", "com.newscatcherapi:newscatcher-sdk/2.0.0"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.newscatcher.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.2.0"); + put("X-Fern-SDK-Version", "2.0.0"); } }); this.headerSuppliers = headerSuppliers; this.httpClient = httpClient; this.timeout = timeout; + this.maxRetries = maxRetries; + this.logging = logging; } public Environment environment() { @@ -82,6 +90,14 @@ public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { .build(); } + public int maxRetries() { + return this.maxRetries; + } + + public Optional logging() { + return this.logging; + } + public static Builder builder() { return new Builder(); } @@ -99,6 +115,8 @@ public static class Builder { private OkHttpClient httpClient = null; + private Optional logging = Optional.empty(); + public Builder environment(Environment environment) { this.environment = environment; return this; @@ -143,6 +161,14 @@ public Builder httpClient(OkHttpClient httpClient) { return this; } + /** + * Configure logging for the SDK. Silent by default — no log output unless explicitly configured. + */ + public Builder logging(LogConfig logging) { + this.logging = Optional.of(logging); + return this; + } + public ClientOptions build() { OkHttpClient.Builder httpClientBuilder = this.httpClient != null ? this.httpClient.newBuilder() : new OkHttpClient.Builder(); @@ -162,10 +188,20 @@ public ClientOptions build() { .addInterceptor(new RetryInterceptor(this.maxRetries)); } + Logger logger = Logger.from(this.logging); + httpClientBuilder.addInterceptor(new LoggingInterceptor(logger)); + this.httpClient = httpClientBuilder.build(); this.timeout = Optional.of(httpClient.callTimeoutMillis() / 1000); - return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout.get()); + return new ClientOptions( + environment, + headers, + headerSuppliers, + httpClient, + this.timeout.get(), + this.maxRetries, + this.logging); } /** @@ -176,6 +212,10 @@ public static Builder from(ClientOptions clientOptions) { builder.environment = clientOptions.environment(); builder.timeout = Optional.of(clientOptions.timeout(null)); builder.httpClient = clientOptions.httpClient(); + builder.headers.putAll(clientOptions.headers); + builder.headerSuppliers.putAll(clientOptions.headerSuppliers); + builder.maxRetries = clientOptions.maxRetries(); + builder.logging = clientOptions.logging(); return builder; } } diff --git a/src/main/java/com/newscatcher/api/core/ConsoleLogger.java b/src/main/java/com/newscatcher/api/core/ConsoleLogger.java new file mode 100644 index 0000000..b0c1252 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/ConsoleLogger.java @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +import java.util.logging.Level; + +/** + * Default logger implementation that writes to the console using {@link java.util.logging.Logger}. + * + *

Uses the "fern" logger name with a simple format of "LEVEL - message". + */ +public final class ConsoleLogger implements ILogger { + + private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger("fern"); + + static { + if (logger.getHandlers().length == 0) { + java.util.logging.ConsoleHandler handler = new java.util.logging.ConsoleHandler(); + handler.setFormatter(new java.util.logging.SimpleFormatter() { + @Override + public String format(java.util.logging.LogRecord record) { + return record.getLevel() + " - " + record.getMessage() + System.lineSeparator(); + } + }); + logger.addHandler(handler); + logger.setUseParentHandlers(false); + logger.setLevel(Level.ALL); + } + } + + @Override + public void debug(String message) { + logger.log(Level.FINE, message); + } + + @Override + public void info(String message) { + logger.log(Level.INFO, message); + } + + @Override + public void warn(String message) { + logger.log(Level.WARNING, message); + } + + @Override + public void error(String message) { + logger.log(Level.SEVERE, message); + } +} diff --git a/src/main/java/com/newscatcher/api/core/ILogger.java b/src/main/java/com/newscatcher/api/core/ILogger.java new file mode 100644 index 0000000..7518cc7 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/ILogger.java @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +/** + * Interface for custom logger implementations. + * + *

Implement this interface to provide a custom logging backend for the SDK. + * The SDK will call the appropriate method based on the log level. + * + *

Example: + *

{@code
+ * public class MyCustomLogger implements ILogger {
+ *     public void debug(String message) {
+ *         System.out.println("[DBG] " + message);
+ *     }
+ *     public void info(String message) {
+ *         System.out.println("[INF] " + message);
+ *     }
+ *     public void warn(String message) {
+ *         System.out.println("[WRN] " + message);
+ *     }
+ *     public void error(String message) {
+ *         System.out.println("[ERR] " + message);
+ *     }
+ * }
+ * }
+ */ +public interface ILogger { + void debug(String message); + + void info(String message); + + void warn(String message); + + void error(String message); +} diff --git a/src/main/java/com/newscatcher/api/core/LogConfig.java b/src/main/java/com/newscatcher/api/core/LogConfig.java new file mode 100644 index 0000000..ec48c04 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/LogConfig.java @@ -0,0 +1,98 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +/** + * Configuration for SDK logging. + * + *

Use the builder to configure logging behavior: + *

{@code
+ * LogConfig config = LogConfig.builder()
+ *     .level(LogLevel.DEBUG)
+ *     .silent(false)
+ *     .build();
+ * }
+ * + *

Or with a custom logger: + *

{@code
+ * LogConfig config = LogConfig.builder()
+ *     .level(LogLevel.DEBUG)
+ *     .logger(new MyCustomLogger())
+ *     .silent(false)
+ *     .build();
+ * }
+ * + *

Defaults: + *

    + *
  • {@code level} — {@link LogLevel#INFO}
  • + *
  • {@code logger} — {@link ConsoleLogger} (writes to stderr via java.util.logging)
  • + *
  • {@code silent} — {@code true} (no output unless explicitly enabled)
  • + *
+ */ +public final class LogConfig { + + private final LogLevel level; + private final ILogger logger; + private final boolean silent; + + private LogConfig(LogLevel level, ILogger logger, boolean silent) { + this.level = level; + this.logger = logger; + this.silent = silent; + } + + public LogLevel level() { + return level; + } + + public ILogger logger() { + return logger; + } + + public boolean silent() { + return silent; + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + private LogLevel level = LogLevel.INFO; + private ILogger logger = new ConsoleLogger(); + private boolean silent = true; + + private Builder() {} + + /** + * Set the minimum log level. Only messages at this level or above will be logged. + * Defaults to {@link LogLevel#INFO}. + */ + public Builder level(LogLevel level) { + this.level = level; + return this; + } + + /** + * Set a custom logger implementation. Defaults to {@link ConsoleLogger}. + */ + public Builder logger(ILogger logger) { + this.logger = logger; + return this; + } + + /** + * Set whether logging is silent (disabled). Defaults to {@code true}. + * Set to {@code false} to enable log output. + */ + public Builder silent(boolean silent) { + this.silent = silent; + return this; + } + + public LogConfig build() { + return new LogConfig(level, logger, silent); + } + } +} diff --git a/src/main/java/com/newscatcher/api/core/LogLevel.java b/src/main/java/com/newscatcher/api/core/LogLevel.java new file mode 100644 index 0000000..e0bb965 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/LogLevel.java @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +/** + * Log levels for SDK logging configuration. + * Silent by default — no log output unless explicitly configured. + */ +public enum LogLevel { + DEBUG(1), + INFO(2), + WARN(3), + ERROR(4); + + private final int value; + + LogLevel(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + /** + * Parse a log level from a string (case-insensitive). + * + * @param level the level string (debug, info, warn, error) + * @return the corresponding LogLevel + * @throws IllegalArgumentException if the string does not match any level + */ + public static LogLevel fromString(String level) { + return LogLevel.valueOf(level.toUpperCase()); + } +} diff --git a/src/main/java/com/newscatcher/api/core/Logger.java b/src/main/java/com/newscatcher/api/core/Logger.java new file mode 100644 index 0000000..e3e8f0f --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/Logger.java @@ -0,0 +1,97 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +/** + * SDK logger that filters messages based on level and silent mode. + * + *

Silent by default — no log output unless explicitly configured. + * Create via {@link LogConfig} or directly: + *

{@code
+ * Logger logger = new Logger(LogLevel.DEBUG, new ConsoleLogger(), false);
+ * logger.debug("request sent");
+ * }
+ */ +public final class Logger { + + private static final Logger DEFAULT = new Logger(LogLevel.INFO, new ConsoleLogger(), true); + + private final LogLevel level; + private final ILogger logger; + private final boolean silent; + + public Logger(LogLevel level, ILogger logger, boolean silent) { + this.level = level; + this.logger = logger; + this.silent = silent; + } + + /** + * Returns a default silent logger (no output). + */ + public static Logger getDefault() { + return DEFAULT; + } + + /** + * Creates a Logger from a {@link LogConfig}. If config is {@code null}, returns the default silent logger. + */ + public static Logger from(LogConfig config) { + if (config == null) { + return DEFAULT; + } + return new Logger(config.level(), config.logger(), config.silent()); + } + + /** + * Creates a Logger from an {@code Optional}. If empty, returns the default silent logger. + */ + public static Logger from(java.util.Optional config) { + return config.map(Logger::from).orElse(DEFAULT); + } + + private boolean shouldLog(LogLevel messageLevel) { + return !silent && level.getValue() <= messageLevel.getValue(); + } + + public boolean isDebug() { + return shouldLog(LogLevel.DEBUG); + } + + public boolean isInfo() { + return shouldLog(LogLevel.INFO); + } + + public boolean isWarn() { + return shouldLog(LogLevel.WARN); + } + + public boolean isError() { + return shouldLog(LogLevel.ERROR); + } + + public void debug(String message) { + if (isDebug()) { + logger.debug(message); + } + } + + public void info(String message) { + if (isInfo()) { + logger.info(message); + } + } + + public void warn(String message) { + if (isWarn()) { + logger.warn(message); + } + } + + public void error(String message) { + if (isError()) { + logger.error(message); + } + } +} diff --git a/src/main/java/com/newscatcher/api/core/LoggingInterceptor.java b/src/main/java/com/newscatcher/api/core/LoggingInterceptor.java new file mode 100644 index 0000000..7568199 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/LoggingInterceptor.java @@ -0,0 +1,104 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +/** + * OkHttp interceptor that logs HTTP requests and responses. + * + *

Logs request method, URL, and headers (with sensitive values redacted) at debug level. + * Logs response status at debug level, and 4xx/5xx responses at error level. + * Does nothing if the logger is silent. + */ +public final class LoggingInterceptor implements Interceptor { + + private static final Set SENSITIVE_HEADERS = new HashSet<>(Arrays.asList( + "authorization", + "www-authenticate", + "x-api-key", + "api-key", + "apikey", + "x-api-token", + "x-auth-token", + "auth-token", + "proxy-authenticate", + "proxy-authorization", + "cookie", + "set-cookie", + "x-csrf-token", + "x-xsrf-token", + "x-session-token", + "x-access-token")); + + private final Logger logger; + + public LoggingInterceptor(Logger logger) { + this.logger = logger; + } + + @Override + public Response intercept(Chain chain) throws IOException { + Request request = chain.request(); + + if (logger.isDebug()) { + StringBuilder sb = new StringBuilder(); + sb.append("HTTP Request: ").append(request.method()).append(" ").append(request.url()); + sb.append(" headers={"); + boolean first = true; + for (String name : request.headers().names()) { + if (!first) { + sb.append(", "); + } + sb.append(name).append("="); + if (SENSITIVE_HEADERS.contains(name.toLowerCase())) { + sb.append("[REDACTED]"); + } else { + sb.append(request.header(name)); + } + first = false; + } + sb.append("}"); + sb.append(" has_body=").append(request.body() != null); + logger.debug(sb.toString()); + } + + Response response = chain.proceed(request); + + if (logger.isDebug()) { + StringBuilder sb = new StringBuilder(); + sb.append("HTTP Response: status=").append(response.code()); + sb.append(" url=").append(response.request().url()); + sb.append(" headers={"); + boolean first = true; + for (String name : response.headers().names()) { + if (!first) { + sb.append(", "); + } + sb.append(name).append("="); + if (SENSITIVE_HEADERS.contains(name.toLowerCase())) { + sb.append("[REDACTED]"); + } else { + sb.append(response.header(name)); + } + first = false; + } + sb.append("}"); + logger.debug(sb.toString()); + } + + if (response.code() >= 400 && logger.isError()) { + logger.error("HTTP Error: status=" + response.code() + " url=" + + response.request().url()); + } + + return response; + } +} diff --git a/src/main/java/com/newscatcher/api/core/NewscatcherApiApiException.java b/src/main/java/com/newscatcher/api/core/NewscatcherApiApiException.java index 5aea8cc..58ad4a3 100644 --- a/src/main/java/com/newscatcher/api/core/NewscatcherApiApiException.java +++ b/src/main/java/com/newscatcher/api/core/NewscatcherApiApiException.java @@ -65,9 +65,9 @@ public Map> headers() { return this.headers; } - @java.lang.Override + @Override public String toString() { return "NewscatcherApiApiException{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " - + body + "}"; + + ObjectMappers.stringify(body) + "}"; } } diff --git a/src/main/java/com/newscatcher/api/core/NullableNonemptyFilter.java b/src/main/java/com/newscatcher/api/core/NullableNonemptyFilter.java index fe77d6f..8f70f6e 100644 --- a/src/main/java/com/newscatcher/api/core/NullableNonemptyFilter.java +++ b/src/main/java/com/newscatcher/api/core/NullableNonemptyFilter.java @@ -14,6 +14,9 @@ public boolean equals(Object o) { } private boolean isOptionalEmpty(Object o) { - return o instanceof Optional && !((Optional) o).isPresent(); + if (o instanceof Optional) { + return !((Optional) o).isPresent(); + } + return false; } } diff --git a/src/main/java/com/newscatcher/api/core/ObjectMappers.java b/src/main/java/com/newscatcher/api/core/ObjectMappers.java index cb2c72f..8e78be8 100644 --- a/src/main/java/com/newscatcher/api/core/ObjectMappers.java +++ b/src/main/java/com/newscatcher/api/core/ObjectMappers.java @@ -4,6 +4,7 @@ package com.newscatcher.api.core; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -33,4 +34,12 @@ public static String stringify(Object o) { return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); } } + + public static Object parseErrorBody(String responseBodyString) { + try { + return JSON_MAPPER.readValue(responseBodyString, Object.class); + } catch (JsonProcessingException ignored) { + return responseBodyString; + } + } } diff --git a/src/main/java/com/newscatcher/api/core/RequestOptions.java b/src/main/java/com/newscatcher/api/core/RequestOptions.java index dd39cdf..a6cb9f7 100644 --- a/src/main/java/com/newscatcher/api/core/RequestOptions.java +++ b/src/main/java/com/newscatcher/api/core/RequestOptions.java @@ -20,17 +20,25 @@ public final class RequestOptions { private final Map> headerSuppliers; + private final Map queryParameters; + + private final Map> queryParameterSuppliers; + private RequestOptions( String apiKey, Optional timeout, TimeUnit timeoutTimeUnit, Map headers, - Map> headerSuppliers) { + Map> headerSuppliers, + Map queryParameters, + Map> queryParameterSuppliers) { this.apiKey = apiKey; this.timeout = timeout; this.timeoutTimeUnit = timeoutTimeUnit; this.headers = headers; this.headerSuppliers = headerSuppliers; + this.queryParameters = queryParameters; + this.queryParameterSuppliers = queryParameterSuppliers; } public Optional getTimeout() { @@ -53,6 +61,14 @@ public Map getHeaders() { return headers; } + public Map getQueryParameters() { + Map queryParameters = new HashMap<>(this.queryParameters); + this.queryParameterSuppliers.forEach((key, supplier) -> { + queryParameters.put(key, supplier.get()); + }); + return queryParameters; + } + public static Builder builder() { return new Builder(); } @@ -68,6 +84,10 @@ public static class Builder { private final Map> headerSuppliers = new HashMap<>(); + private final Map queryParameters = new HashMap<>(); + + private final Map> queryParameterSuppliers = new HashMap<>(); + public Builder apiKey(String apiKey) { this.apiKey = apiKey; return this; @@ -94,8 +114,25 @@ public Builder addHeader(String key, Supplier value) { return this; } + public Builder addQueryParameter(String key, String value) { + this.queryParameters.put(key, value); + return this; + } + + public Builder addQueryParameter(String key, Supplier value) { + this.queryParameterSuppliers.put(key, value); + return this; + } + public RequestOptions build() { - return new RequestOptions(apiKey, timeout, timeoutTimeUnit, headers, headerSuppliers); + return new RequestOptions( + apiKey, + timeout, + timeoutTimeUnit, + headers, + headerSuppliers, + queryParameters, + queryParameterSuppliers); } } } diff --git a/src/main/java/com/newscatcher/api/core/RetryInterceptor.java b/src/main/java/com/newscatcher/api/core/RetryInterceptor.java index d084037..265fe1f 100644 --- a/src/main/java/com/newscatcher/api/core/RetryInterceptor.java +++ b/src/main/java/com/newscatcher/api/core/RetryInterceptor.java @@ -5,6 +5,9 @@ import java.io.IOException; import java.time.Duration; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Optional; import java.util.Random; import okhttp3.Interceptor; @@ -12,7 +15,10 @@ public class RetryInterceptor implements Interceptor { - private static final Duration ONE_SECOND = Duration.ofSeconds(1); + private static final Duration INITIAL_RETRY_DELAY = Duration.ofMillis(1000); + private static final Duration MAX_RETRY_DELAY = Duration.ofMillis(60000); + private static final double JITTER_FACTOR = 0.2; + private final ExponentialBackoff backoff; private final Random random = new Random(); @@ -32,7 +38,7 @@ public Response intercept(Chain chain) throws IOException { } private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); + Optional nextBackoff = this.backoff.nextBackoff(response); while (nextBackoff.isPresent()) { try { Thread.sleep(nextBackoff.get().toMillis()); @@ -42,7 +48,7 @@ private Response retryChain(Response response, Chain chain) throws IOException { response.close(); response = chain.proceed(chain.request()); if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); + nextBackoff = this.backoff.nextBackoff(response); } else { return response; } @@ -51,6 +57,102 @@ private Response retryChain(Response response, Chain chain) throws IOException { return response; } + /** + * Calculates the retry delay from response headers, with fallback to exponential backoff. + * Priority: Retry-After > X-RateLimit-Reset > Exponential Backoff + */ + private Duration getRetryDelayFromHeaders(Response response, int retryAttempt) { + // Check for Retry-After header first (RFC 7231), with no jitter + String retryAfter = response.header("Retry-After"); + if (retryAfter != null) { + // Parse as number of seconds... + Optional secondsDelay = tryParseLong(retryAfter) + .map(seconds -> seconds * 1000) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (secondsDelay.isPresent()) { + return secondsDelay.get(); + } + + // ...or as an HTTP date; both are valid + Optional dateDelay = tryParseHttpDate(retryAfter) + .map(resetTime -> resetTime.toInstant().toEpochMilli() - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(Duration::ofMillis); + if (dateDelay.isPresent()) { + return dateDelay.get(); + } + } + + // Then check for industry-standard X-RateLimit-Reset header, with positive jitter + String rateLimitReset = response.header("X-RateLimit-Reset"); + if (rateLimitReset != null) { + // Assume Unix timestamp in epoch seconds + Optional rateLimitDelay = tryParseLong(rateLimitReset) + .map(resetTimeSeconds -> (resetTimeSeconds * 1000) - System.currentTimeMillis()) + .filter(delayMs -> delayMs > 0) + .map(delayMs -> Math.min(delayMs, MAX_RETRY_DELAY.toMillis())) + .map(this::addPositiveJitter) + .map(Duration::ofMillis); + if (rateLimitDelay.isPresent()) { + return rateLimitDelay.get(); + } + } + + // Fall back to exponential backoff, with symmetric jitter + long baseDelay = INITIAL_RETRY_DELAY.toMillis() * (1L << retryAttempt); // 2^retryAttempt + long cappedDelay = Math.min(baseDelay, MAX_RETRY_DELAY.toMillis()); + return Duration.ofMillis(addSymmetricJitter(cappedDelay)); + } + + /** + * Attempts to parse a string as a long, returning empty Optional on failure. + */ + private Optional tryParseLong(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(Long.parseLong(value)); + } catch (NumberFormatException e) { + return Optional.empty(); + } + } + + /** + * Attempts to parse a string as an HTTP date (RFC 1123), returning empty Optional on failure. + */ + private Optional tryParseHttpDate(String value) { + if (value == null) { + return Optional.empty(); + } + try { + return Optional.of(ZonedDateTime.parse(value, DateTimeFormatter.RFC_1123_DATE_TIME)); + } catch (DateTimeParseException e) { + return Optional.empty(); + } + } + + /** + * Adds positive jitter (100-120% of original value) to prevent thundering herd. + * Used for X-RateLimit-Reset header delays. + */ + private long addPositiveJitter(long delayMs) { + double jitterMultiplier = 1.0 + (random.nextDouble() * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + + /** + * Adds symmetric jitter (90-110% of original value) to prevent thundering herd. + * Used for exponential backoff delays. + */ + private long addSymmetricJitter(long delayMs) { + double jitterMultiplier = 1.0 + ((random.nextDouble() - 0.5) * JITTER_FACTOR); + return (long) (delayMs * jitterMultiplier); + } + private static boolean shouldRetry(int statusCode) { return statusCode == 408 || statusCode == 429 || statusCode >= 500; } @@ -65,14 +167,14 @@ private final class ExponentialBackoff { this.maxNumRetries = maxNumRetries; } - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { + public Optional nextBackoff(Response response) { + if (retryNumber >= maxNumRetries) { return Optional.empty(); } - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); + Duration delay = getRetryDelayFromHeaders(response, retryNumber); + retryNumber += 1; + return Optional.of(delay); } } } diff --git a/src/main/java/com/newscatcher/api/core/Rfc2822DateTimeDeserializer.java b/src/main/java/com/newscatcher/api/core/Rfc2822DateTimeDeserializer.java new file mode 100644 index 0000000..345f71c --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/Rfc2822DateTimeDeserializer.java @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Custom deserializer that handles converting RFC 2822 (RFC 1123) dates into {@link OffsetDateTime} objects. + * This is used for fields with format "date-time-rfc-2822", such as Twilio's dateCreated, dateSent, dateUpdated. + */ +public class Rfc2822DateTimeDeserializer extends JsonDeserializer { + + @Override + public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { + String raw = parser.getValueAsString(); + return ZonedDateTime.parse(raw, DateTimeFormatter.RFC_1123_DATE_TIME).toOffsetDateTime(); + } +} diff --git a/src/main/java/com/newscatcher/api/core/SseEvent.java b/src/main/java/com/newscatcher/api/core/SseEvent.java new file mode 100644 index 0000000..28cbcc2 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/SseEvent.java @@ -0,0 +1,114 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.Optional; + +/** + * Represents a Server-Sent Event with all standard fields. + * Used for event-level discrimination where the discriminator is at the SSE envelope level. + * + * @param The type of the data field + */ +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonIgnoreProperties(ignoreUnknown = true) +public final class SseEvent { + private final String event; + private final T data; + private final String id; + private final Long retry; + + private SseEvent(String event, T data, String id, Long retry) { + this.event = event; + this.data = data; + this.id = id; + this.retry = retry; + } + + @JsonProperty("event") + public Optional getEvent() { + return Optional.ofNullable(event); + } + + @JsonProperty("data") + public T getData() { + return data; + } + + @JsonProperty("id") + public Optional getId() { + return Optional.ofNullable(id); + } + + @JsonProperty("retry") + public Optional getRetry() { + return Optional.ofNullable(retry); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SseEvent sseEvent = (SseEvent) o; + return Objects.equals(event, sseEvent.event) + && Objects.equals(data, sseEvent.data) + && Objects.equals(id, sseEvent.id) + && Objects.equals(retry, sseEvent.retry); + } + + @Override + public int hashCode() { + return Objects.hash(event, data, id, retry); + } + + @Override + public String toString() { + return "SseEvent{" + "event='" + + event + '\'' + ", data=" + + data + ", id='" + + id + '\'' + ", retry=" + + retry + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static final class Builder { + private String event; + private T data; + private String id; + private Long retry; + + private Builder() {} + + public Builder event(String event) { + this.event = event; + return this; + } + + public Builder data(T data) { + this.data = data; + return this; + } + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder retry(Long retry) { + this.retry = retry; + return this; + } + + public SseEvent build() { + return new SseEvent<>(event, data, id, retry); + } + } +} diff --git a/src/main/java/com/newscatcher/api/core/SseEventParser.java b/src/main/java/com/newscatcher/api/core/SseEventParser.java new file mode 100644 index 0000000..da2e974 --- /dev/null +++ b/src/main/java/com/newscatcher/api/core/SseEventParser.java @@ -0,0 +1,228 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.core; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.core.type.TypeReference; +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +/** + * Utility class for parsing Server-Sent Events with support for discriminated unions. + *

+ * Handles two discrimination patterns: + *

    + *
  1. Data-level discrimination: The discriminator (e.g., 'type') is inside the JSON data payload. + * Jackson's polymorphic deserialization handles this automatically.
  2. + *
  3. Event-level discrimination: The discriminator (e.g., 'event') is at the SSE envelope level. + * This requires constructing the full SSE envelope for Jackson to process.
  4. + *
+ */ +public final class SseEventParser { + + private static final Set SSE_ENVELOPE_FIELDS = new HashSet<>(Arrays.asList("event", "data", "id", "retry")); + + private SseEventParser() { + // Utility class + } + + /** + * Parse an SSE event using event-level discrimination. + *

+ * Constructs the full SSE envelope object with event, data, id, and retry fields, + * then deserializes it to the target union type. + * + * @param eventType The SSE event type (from event: field) + * @param data The SSE data content (from data: field) + * @param id The SSE event ID (from id: field), may be null + * @param retry The SSE retry value (from retry: field), may be null + * @param unionClass The target union class + * @param discriminatorProperty The property name used for discrimination (e.g., "event") + * @param The target type + * @return The deserialized object + */ + public static T parseEventLevelUnion( + String eventType, String data, String id, Long retry, Class unionClass, String discriminatorProperty) { + try { + // Determine if data should be parsed as JSON based on the variant's expected type + Object parsedData = parseDataForVariant(eventType, data, unionClass, discriminatorProperty); + + // Construct the SSE envelope object + Map envelope = new HashMap<>(); + envelope.put(discriminatorProperty, eventType); + envelope.put("data", parsedData); + if (id != null) { + envelope.put("id", id); + } + if (retry != null) { + envelope.put("retry", retry); + } + + // Serialize to JSON and deserialize to target type + String envelopeJson = ObjectMappers.JSON_MAPPER.writeValueAsString(envelope); + return ObjectMappers.JSON_MAPPER.readValue(envelopeJson, unionClass); + } catch (Exception e) { + throw new RuntimeException("Failed to parse SSE event with event-level discrimination", e); + } + } + + /** + * Parse an SSE event using data-level discrimination. + *

+ * Simply parses the data field as JSON and deserializes it to the target type. + * Jackson's polymorphic deserialization handles the discrimination automatically. + * + * @param data The SSE data content (from data: field) + * @param valueType The target type + * @param The target type + * @return The deserialized object + */ + public static T parseDataLevelUnion(String data, Class valueType) { + try { + return ObjectMappers.JSON_MAPPER.readValue(data, valueType); + } catch (Exception e) { + throw new RuntimeException("Failed to parse SSE data with data-level discrimination", e); + } + } + + /** + * Determines if the given discriminator property indicates event-level discrimination. + * Event-level discrimination occurs when the discriminator is an SSE envelope field. + * + * @param discriminatorProperty The discriminator property name + * @return true if event-level discrimination, false otherwise + */ + public static boolean isEventLevelDiscrimination(String discriminatorProperty) { + return SSE_ENVELOPE_FIELDS.contains(discriminatorProperty); + } + + /** + * Attempts to find the discriminator property from the union class's Jackson annotations. + * + * @param unionClass The union class to inspect + * @return The discriminator property name, or empty if not found + */ + public static Optional findDiscriminatorProperty(Class unionClass) { + try { + // Look for JsonTypeInfo on the class itself + JsonTypeInfo typeInfo = unionClass.getAnnotation(JsonTypeInfo.class); + if (typeInfo != null && !typeInfo.property().isEmpty()) { + return Optional.of(typeInfo.property()); + } + + // Look for inner Value interface with JsonTypeInfo + for (Class innerClass : unionClass.getDeclaredClasses()) { + typeInfo = innerClass.getAnnotation(JsonTypeInfo.class); + if (typeInfo != null && !typeInfo.property().isEmpty()) { + return Optional.of(typeInfo.property()); + } + } + } catch (Exception e) { + // Ignore reflection errors + } + return Optional.empty(); + } + + /** + * Parse the data field based on what the matching variant expects. + * If the variant expects a String for its data field, returns the raw string. + * Otherwise, parses the data as JSON. + */ + private static Object parseDataForVariant( + String eventType, String data, Class unionClass, String discriminatorProperty) { + if (data == null || data.isEmpty()) { + return data; + } + + try { + // Try to find the variant class that matches this event type + Class variantClass = findVariantClass(unionClass, eventType, discriminatorProperty); + if (variantClass != null) { + // Check if the variant expects a String for the data field + Field dataField = findField(variantClass, "data"); + if (dataField != null && String.class.equals(dataField.getType())) { + // Variant expects String - return raw data + return data; + } + } + + // Try to parse as JSON + return ObjectMappers.JSON_MAPPER.readValue(data, new TypeReference>() {}); + } catch (Exception e) { + // If JSON parsing fails, return as string + return data; + } + } + + /** + * Find the variant class that matches the given discriminator value. + */ + private static Class findVariantClass( + Class unionClass, String discriminatorValue, String discriminatorProperty) { + try { + // Look for JsonSubTypes annotation + JsonSubTypes subTypes = findJsonSubTypes(unionClass); + if (subTypes == null) { + return null; + } + + for (JsonSubTypes.Type subType : subTypes.value()) { + JsonTypeName typeName = subType.value().getAnnotation(JsonTypeName.class); + if (typeName != null && typeName.value().equals(discriminatorValue)) { + return subType.value(); + } + // Also check the name attribute of @JsonSubTypes.Type + if (subType.name().equals(discriminatorValue)) { + return subType.value(); + } + } + } catch (Exception e) { + // Ignore reflection errors + } + return null; + } + + /** + * Find JsonSubTypes annotation on the class or its inner classes. + */ + private static JsonSubTypes findJsonSubTypes(Class unionClass) { + // Check the class itself + JsonSubTypes subTypes = unionClass.getAnnotation(JsonSubTypes.class); + if (subTypes != null) { + return subTypes; + } + + // Check inner classes (for Fern-style unions with inner Value interface) + for (Class innerClass : unionClass.getDeclaredClasses()) { + subTypes = innerClass.getAnnotation(JsonSubTypes.class); + if (subTypes != null) { + return subTypes; + } + } + return null; + } + + /** + * Find a field by name in a class, including private fields. + */ + private static Field findField(Class clazz, String fieldName) { + try { + return clazz.getDeclaredField(fieldName); + } catch (NoSuchFieldException e) { + // Check superclass + Class superClass = clazz.getSuperclass(); + if (superClass != null && superClass != Object.class) { + return findField(superClass, fieldName); + } + return null; + } + } +} diff --git a/src/main/java/com/newscatcher/api/core/Stream.java b/src/main/java/com/newscatcher/api/core/Stream.java index ce28044..b3b525c 100644 --- a/src/main/java/com/newscatcher/api/core/Stream.java +++ b/src/main/java/com/newscatcher/api/core/Stream.java @@ -28,7 +28,8 @@ public final class Stream implements Iterable, Closeable { public enum StreamType { JSON, - SSE + SSE, + SSE_EVENT_DISCRIMINATED } private final Class valueType; @@ -37,6 +38,7 @@ public enum StreamType { private final String messageTerminator; private final String streamTerminator; private final Reader sseReader; + private final String discriminatorProperty; private boolean isClosed = false; /** @@ -53,11 +55,18 @@ public Stream(Class valueType, Reader reader, String delimiter) { this.messageTerminator = delimiter; this.streamTerminator = null; this.sseReader = null; + this.discriminatorProperty = null; } private Stream(Class valueType, StreamType type, Reader reader, String terminator) { + this(valueType, type, reader, terminator, null); + } + + private Stream( + Class valueType, StreamType type, Reader reader, String terminator, String discriminatorProperty) { this.valueType = valueType; this.streamType = type; + this.discriminatorProperty = discriminatorProperty; if (type == StreamType.JSON) { this.scanner = new Scanner(reader).useDelimiter(terminator); this.messageTerminator = terminator; @@ -87,6 +96,38 @@ public static Stream fromSse(Class valueType, Reader sseReader, String return new Stream<>(valueType, StreamType.SSE, sseReader, streamTerminator); } + /** + * Creates a stream from SSE data with event-level discrimination support. + * Use this when the SSE payload is a discriminated union where the discriminator + * is an SSE envelope field (e.g., 'event'). + * + * @param valueType The class of the objects in the stream. + * @param sseReader The reader that provides the SSE data. + * @param discriminatorProperty The property name used for discrimination (e.g., "event"). + * @param The type of objects in the stream. + * @return A new Stream instance configured for SSE with event-level discrimination. + */ + public static Stream fromSseWithEventDiscrimination( + Class valueType, Reader sseReader, String discriminatorProperty) { + return new Stream<>(valueType, StreamType.SSE_EVENT_DISCRIMINATED, sseReader, null, discriminatorProperty); + } + + /** + * Creates a stream from SSE data with event-level discrimination support and a stream terminator. + * + * @param valueType The class of the objects in the stream. + * @param sseReader The reader that provides the SSE data. + * @param discriminatorProperty The property name used for discrimination (e.g., "event"). + * @param streamTerminator The terminator string that signals end of stream (e.g., "[DONE]"). + * @param The type of objects in the stream. + * @return A new Stream instance configured for SSE with event-level discrimination. + */ + public static Stream fromSseWithEventDiscrimination( + Class valueType, Reader sseReader, String discriminatorProperty, String streamTerminator) { + return new Stream<>( + valueType, StreamType.SSE_EVENT_DISCRIMINATED, sseReader, streamTerminator, discriminatorProperty); + } + @Override public void close() throws IOException { if (!isClosed) { @@ -112,10 +153,14 @@ private boolean isStreamClosed() { */ @Override public Iterator iterator() { - if (streamType == StreamType.SSE) { - return new SSEIterator(); - } else { - return new JsonIterator(); + switch (streamType) { + case SSE: + return new SSEIterator(); + case SSE_EVENT_DISCRIMINATED: + return new SSEEventDiscriminatedIterator(); + case JSON: + default: + return new JsonIterator(); } } @@ -174,8 +219,8 @@ private final class SSEIterator implements Iterator { private T nextItem; private boolean hasNextItem = false; private boolean endOfStream = false; - private StringBuilder buffer = new StringBuilder(); - private boolean prefixSeen = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; private SSEIterator() { if (sseReader != null && !isStreamClosed()) { @@ -223,39 +268,228 @@ private boolean readNextMessage() { try { while (sseScanner.hasNextLine()) { - String chunk = sseScanner.nextLine(); - buffer.append(chunk).append(NEWLINE); + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + continue; + } + } + continue; + } - int terminatorIndex; - while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) { - String line = buffer.substring(0, terminatorIndex + messageTerminator.length()); - buffer.delete(0, terminatorIndex + messageTerminator.length()); + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } - line = line.trim(); - if (line.isEmpty()) { - continue; + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { + endOfStream = true; + return false; } - if (!prefixSeen && line.startsWith(DATA_PREFIX)) { - prefixSeen = true; - line = line.substring(DATA_PREFIX.length()).trim(); - } else if (!prefixSeen) { - continue; + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + // Event ID field (ignored) + } else if (line.startsWith("retry:")) { + // Retry field (ignored) + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + if (eventDataBuffer.length() > 0) { + try { + nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType); + hasNextItem = true; + eventDataBuffer.setLength(0); + currentEventType = null; + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + eventDataBuffer.setLength(0); + currentEventType = null; + } + } - if (streamTerminator != null && line.contains(streamTerminator)) { + endOfStream = true; + return false; + + } catch (Exception e) { + System.err.println("Failed to parse SSE stream: " + e.getMessage()); + endOfStream = true; + return false; + } + } + } + + /** + * Iterator for SSE streams with event-level discrimination. + * Uses SseEventParser to construct the full SSE envelope for Jackson deserialization. + */ + private final class SSEEventDiscriminatedIterator implements Iterator { + private Scanner sseScanner; + private T nextItem; + private boolean hasNextItem = false; + private boolean endOfStream = false; + private StringBuilder eventDataBuffer = new StringBuilder(); + private String currentEventType = null; + private String currentEventId = null; + private Long currentRetry = null; + + private SSEEventDiscriminatedIterator() { + if (sseReader != null && !isStreamClosed()) { + this.sseScanner = new Scanner(sseReader); + } else { + this.endOfStream = true; + } + } + + @Override + public boolean hasNext() { + if (isStreamClosed() || endOfStream) { + return false; + } + + if (hasNextItem) { + return true; + } + + return readNextMessage(); + } + + @Override + public T next() { + if (!hasNext()) { + throw new NoSuchElementException("No more elements in stream"); + } + + T result = nextItem; + nextItem = null; + hasNextItem = false; + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + private boolean readNextMessage() { + if (sseScanner == null || isStreamClosed()) { + endOfStream = true; + return false; + } + + try { + while (sseScanner.hasNextLine()) { + String line = sseScanner.nextLine(); + + if (line.trim().isEmpty()) { + if (eventDataBuffer.length() > 0 || currentEventType != null) { + try { + // Use SseEventParser for event-level discrimination + nextItem = SseEventParser.parseEventLevelUnion( + currentEventType, + eventDataBuffer.toString(), + currentEventId, + currentRetry, + valueType, + discriminatorProperty); + hasNextItem = true; + resetEventState(); + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse SSE event: " + parseEx.getMessage()); + resetEventState(); + continue; + } + } + continue; + } + + if (line.startsWith(DATA_PREFIX)) { + String dataContent = line.substring(DATA_PREFIX.length()); + if (dataContent.startsWith(" ")) { + dataContent = dataContent.substring(1); + } + + if (eventDataBuffer.length() == 0 + && streamTerminator != null + && dataContent.trim().equals(streamTerminator)) { endOfStream = true; return false; } + if (eventDataBuffer.length() > 0) { + eventDataBuffer.append('\n'); + } + eventDataBuffer.append(dataContent); + } else if (line.startsWith("event:")) { + String eventValue = line.length() > 6 ? line.substring(6) : ""; + if (eventValue.startsWith(" ")) { + eventValue = eventValue.substring(1); + } + currentEventType = eventValue; + } else if (line.startsWith("id:")) { + String idValue = line.length() > 3 ? line.substring(3) : ""; + if (idValue.startsWith(" ")) { + idValue = idValue.substring(1); + } + currentEventId = idValue; + } else if (line.startsWith("retry:")) { + String retryValue = line.length() > 6 ? line.substring(6) : ""; + if (retryValue.startsWith(" ")) { + retryValue = retryValue.substring(1); + } try { - nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType); - hasNextItem = true; - prefixSeen = false; - return true; - } catch (Exception parseEx) { - continue; + currentRetry = Long.parseLong(retryValue.trim()); + } catch (NumberFormatException e) { + // Ignore invalid retry values } + } else if (line.startsWith(":")) { + // Comment line (ignored) + } + } + + // Handle any remaining buffered data at end of stream + if (eventDataBuffer.length() > 0 || currentEventType != null) { + try { + nextItem = SseEventParser.parseEventLevelUnion( + currentEventType, + eventDataBuffer.toString(), + currentEventId, + currentRetry, + valueType, + discriminatorProperty); + hasNextItem = true; + resetEventState(); + return true; + } catch (Exception parseEx) { + System.err.println("Failed to parse final SSE event: " + parseEx.getMessage()); + resetEventState(); } } @@ -268,5 +502,12 @@ private boolean readNextMessage() { return false; } } + + private void resetEventState() { + eventDataBuffer.setLength(0); + currentEventType = null; + currentEventId = null; + currentRetry = null; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationGetRequest.java b/src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationGetRequest.java deleted file mode 100644 index 9a28606..0000000 --- a/src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationGetRequest.java +++ /dev/null @@ -1,2501 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.aggregation.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.aggregation.types.AggregationGetRequestPublishedDatePrecision; -import com.newscatcher.api.resources.aggregation.types.AggregationGetRequestSortBy; -import com.newscatcher.api.types.AggregationBy; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AggregationGetRequest.Builder.class) -public final class AggregationGetRequest { - private final String q; - - private final Optional aggregationBy; - - private final Optional searchIn; - - private final Optional predefinedSources; - - private final Optional sources; - - private final Optional notSources; - - private final Optional lang; - - private final Optional notLang; - - private final Optional countries; - - private final Optional notCountries; - - private final Optional notAuthorName; - - private final Optional from; - - private final Optional to; - - private final Optional publishedDatePrecision; - - private final Optional byParseDate; - - private final Optional sortBy; - - private final Optional rankedOnly; - - private final Optional fromRank; - - private final Optional toRank; - - private final Optional isHeadline; - - private final Optional isOpinion; - - private final Optional isPaidContent; - - private final Optional parentUrl; - - private final Optional allLinks; - - private final Optional allDomainLinks; - - private final Optional wordCountMin; - - private final Optional wordCountMax; - - private final Optional page; - - private final Optional pageSize; - - private final Optional includeNlpData; - - private final Optional hasNlp; - - private final Optional theme; - - private final Optional notTheme; - - private final Optional orgEntityName; - - private final Optional perEntityName; - - private final Optional locEntityName; - - private final Optional miscEntityName; - - private final Optional titleSentimentMin; - - private final Optional titleSentimentMax; - - private final Optional contentSentimentMin; - - private final Optional contentSentimentMax; - - private final Optional iptcTags; - - private final Optional notIptcTags; - - private final Optional robotsCompliant; - - private final Map additionalProperties; - - private AggregationGetRequest( - String q, - Optional aggregationBy, - Optional searchIn, - Optional predefinedSources, - Optional sources, - Optional notSources, - Optional lang, - Optional notLang, - Optional countries, - Optional notCountries, - Optional notAuthorName, - Optional from, - Optional to, - Optional publishedDatePrecision, - Optional byParseDate, - Optional sortBy, - Optional rankedOnly, - Optional fromRank, - Optional toRank, - Optional isHeadline, - Optional isOpinion, - Optional isPaidContent, - Optional parentUrl, - Optional allLinks, - Optional allDomainLinks, - Optional wordCountMin, - Optional wordCountMax, - Optional page, - Optional pageSize, - Optional includeNlpData, - Optional hasNlp, - Optional theme, - Optional notTheme, - Optional orgEntityName, - Optional perEntityName, - Optional locEntityName, - Optional miscEntityName, - Optional titleSentimentMin, - Optional titleSentimentMax, - Optional contentSentimentMin, - Optional contentSentimentMax, - Optional iptcTags, - Optional notIptcTags, - Optional robotsCompliant, - Map additionalProperties) { - this.q = q; - this.aggregationBy = aggregationBy; - this.searchIn = searchIn; - this.predefinedSources = predefinedSources; - this.sources = sources; - this.notSources = notSources; - this.lang = lang; - this.notLang = notLang; - this.countries = countries; - this.notCountries = notCountries; - this.notAuthorName = notAuthorName; - this.from = from; - this.to = to; - this.publishedDatePrecision = publishedDatePrecision; - this.byParseDate = byParseDate; - this.sortBy = sortBy; - this.rankedOnly = rankedOnly; - this.fromRank = fromRank; - this.toRank = toRank; - this.isHeadline = isHeadline; - this.isOpinion = isOpinion; - this.isPaidContent = isPaidContent; - this.parentUrl = parentUrl; - this.allLinks = allLinks; - this.allDomainLinks = allDomainLinks; - this.wordCountMin = wordCountMin; - this.wordCountMax = wordCountMax; - this.page = page; - this.pageSize = pageSize; - this.includeNlpData = includeNlpData; - this.hasNlp = hasNlp; - this.theme = theme; - this.notTheme = notTheme; - this.orgEntityName = orgEntityName; - this.perEntityName = perEntityName; - this.locEntityName = locEntityName; - this.miscEntityName = miscEntityName; - this.titleSentimentMin = titleSentimentMin; - this.titleSentimentMax = titleSentimentMax; - this.contentSentimentMin = contentSentimentMin; - this.contentSentimentMax = contentSentimentMax; - this.iptcTags = iptcTags; - this.notIptcTags = notIptcTags; - this.robotsCompliant = robotsCompliant; - this.additionalProperties = additionalProperties; - } - - /** - * @return The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards: - *

    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ - @JsonProperty("q") - public String getQ() { - return q; - } - - @JsonProperty("aggregation_by") - public Optional getAggregationBy() { - return aggregationBy; - } - - @JsonProperty("search_in") - public Optional getSearchIn() { - return searchIn; - } - - /** - * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - @JsonProperty("predefined_sources") - public Optional getPredefinedSources() { - return predefinedSources; - } - - /** - * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. - *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - @JsonProperty("sources") - public Optional getSources() { - return sources; - } - - /** - * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - *

Example: "cnn.com, wsj.com"

- */ - @JsonProperty("not_sources") - public Optional getNotSources() { - return notSources; - } - - /** - * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - @JsonProperty("lang") - public Optional getLang() { - return lang; - } - - /** - * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. - *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - @JsonProperty("not_lang") - public Optional getNotLang() { - return notLang; - } - - /** - * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @JsonProperty("countries") - public Optional getCountries() { - return countries; - } - - /** - * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. - *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @JsonProperty("not_countries") - public Optional getNotCountries() { - return notCountries; - } - - /** - * @return The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - *

Example: "John Doe, Jane Doe"

- */ - @JsonProperty("not_author_name") - public Optional getNotAuthorName() { - return notAuthorName; - } - - /** - * @return The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @JsonProperty("from_") - public Optional getFrom() { - return from; - } - - /** - * @return The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @JsonProperty("to_") - public Optional getTo() { - return to; - } - - /** - * @return The precision of the published date. There are three types: - *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { - return publishedDatePrecision; - } - - /** - * @return If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object. - */ - @JsonProperty("by_parse_date") - public Optional getByParseDate() { - return byParseDate; - } - - /** - * @return The sorting order of the results. Possible values are: - *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - @JsonProperty("sort_by") - public Optional getSortBy() { - return sortBy; - } - - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ - @JsonProperty("ranked_only") - public Optional getRankedOnly() { - return rankedOnly; - } - - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ - @JsonProperty("from_rank") - public Optional getFromRank() { - return fromRank; - } - - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ - @JsonProperty("to_rank") - public Optional getToRank() { - return toRank; - } - - /** - * @return If true, only returns articles that were posted on the home page of a given news domain. - */ - @JsonProperty("is_headline") - public Optional getIsHeadline() { - return isHeadline; - } - - /** - * @return If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - */ - @JsonProperty("is_opinion") - public Optional getIsOpinion() { - return isOpinion; - } - - /** - * @return If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - */ - @JsonProperty("is_paid_content") - public Optional getIsPaidContent() { - return isPaidContent; - } - - /** - * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - *

Example: "wsj.com/politics, wsj.com/tech"

- */ - @JsonProperty("parent_url") - public Optional getParentUrl() { - return parentUrl; - } - - /** - * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - @JsonProperty("all_links") - public Optional getAllLinks() { - return allLinks; - } - - /** - * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - @JsonProperty("all_domain_links") - public Optional getAllDomainLinks() { - return allDomainLinks; - } - - /** - * @return The minimum number of words an article must contain. To be used for avoiding articles with small content. - */ - @JsonProperty("word_count_min") - public Optional getWordCountMin() { - return wordCountMin; - } - - /** - * @return The maximum number of words an article can contain. To be used for avoiding articles with large content. - */ - @JsonProperty("word_count_max") - public Optional getWordCountMax() { - return wordCountMax; - } - - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ - @JsonProperty("page") - public Optional getPage() { - return page; - } - - /** - * @return The number of articles to return per page. - */ - @JsonProperty("page_size") - public Optional getPageSize() { - return pageSize; - } - - @JsonProperty("include_nlp_data") - public Optional getIncludeNlpData() { - return includeNlpData; - } - - @JsonProperty("has_nlp") - public Optional getHasNlp() { - return hasNlp; - } - - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - @JsonProperty("theme") - public Optional getTheme() { - return theme; - } - - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("not_theme") - public Optional getNotTheme() { - return notTheme; - } - - /** - * @return Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @JsonProperty("ORG_entity_name") - public Optional getOrgEntityName() { - return orgEntityName; - } - - /** - * @return Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @JsonProperty("PER_entity_name") - public Optional getPerEntityName() { - return perEntityName; - } - - /** - * @return Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @JsonProperty("LOC_entity_name") - public Optional getLocEntityName() { - return locEntityName; - } - - /** - * @return Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @JsonProperty("MISC_entity_name") - public Optional getMiscEntityName() { - return miscEntityName; - } - - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("title_sentiment_min") - public Optional getTitleSentimentMin() { - return titleSentimentMin; - } - - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("title_sentiment_max") - public Optional getTitleSentimentMax() { - return titleSentimentMax; - } - - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("content_sentiment_min") - public Optional getContentSentimentMin() { - return contentSentimentMin; - } - - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("content_sentiment_max") - public Optional getContentSentimentMax() { - return contentSentimentMax; - } - - /** - * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @JsonProperty("iptc_tags") - public Optional getIptcTags() { - return iptcTags; - } - - /** - * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @JsonProperty("not_iptc_tags") - public Optional getNotIptcTags() { - return notIptcTags; - } - - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AggregationGetRequest && equalTo((AggregationGetRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AggregationGetRequest other) { - return q.equals(other.q) - && aggregationBy.equals(other.aggregationBy) - && searchIn.equals(other.searchIn) - && predefinedSources.equals(other.predefinedSources) - && sources.equals(other.sources) - && notSources.equals(other.notSources) - && lang.equals(other.lang) - && notLang.equals(other.notLang) - && countries.equals(other.countries) - && notCountries.equals(other.notCountries) - && notAuthorName.equals(other.notAuthorName) - && from.equals(other.from) - && to.equals(other.to) - && publishedDatePrecision.equals(other.publishedDatePrecision) - && byParseDate.equals(other.byParseDate) - && sortBy.equals(other.sortBy) - && rankedOnly.equals(other.rankedOnly) - && fromRank.equals(other.fromRank) - && toRank.equals(other.toRank) - && isHeadline.equals(other.isHeadline) - && isOpinion.equals(other.isOpinion) - && isPaidContent.equals(other.isPaidContent) - && parentUrl.equals(other.parentUrl) - && allLinks.equals(other.allLinks) - && allDomainLinks.equals(other.allDomainLinks) - && wordCountMin.equals(other.wordCountMin) - && wordCountMax.equals(other.wordCountMax) - && page.equals(other.page) - && pageSize.equals(other.pageSize) - && includeNlpData.equals(other.includeNlpData) - && hasNlp.equals(other.hasNlp) - && theme.equals(other.theme) - && notTheme.equals(other.notTheme) - && orgEntityName.equals(other.orgEntityName) - && perEntityName.equals(other.perEntityName) - && locEntityName.equals(other.locEntityName) - && miscEntityName.equals(other.miscEntityName) - && titleSentimentMin.equals(other.titleSentimentMin) - && titleSentimentMax.equals(other.titleSentimentMax) - && contentSentimentMin.equals(other.contentSentimentMin) - && contentSentimentMax.equals(other.contentSentimentMax) - && iptcTags.equals(other.iptcTags) - && notIptcTags.equals(other.notIptcTags) - && robotsCompliant.equals(other.robotsCompliant); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.q, - this.aggregationBy, - this.searchIn, - this.predefinedSources, - this.sources, - this.notSources, - this.lang, - this.notLang, - this.countries, - this.notCountries, - this.notAuthorName, - this.from, - this.to, - this.publishedDatePrecision, - this.byParseDate, - this.sortBy, - this.rankedOnly, - this.fromRank, - this.toRank, - this.isHeadline, - this.isOpinion, - this.isPaidContent, - this.parentUrl, - this.allLinks, - this.allDomainLinks, - this.wordCountMin, - this.wordCountMax, - this.page, - this.pageSize, - this.includeNlpData, - this.hasNlp, - this.theme, - this.notTheme, - this.orgEntityName, - this.perEntityName, - this.locEntityName, - this.miscEntityName, - this.titleSentimentMin, - this.titleSentimentMax, - this.contentSentimentMin, - this.contentSentimentMax, - this.iptcTags, - this.notIptcTags, - this.robotsCompliant); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static QStage builder() { - return new Builder(); - } - - public interface QStage { - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ - _FinalStage q(@NotNull String q); - - Builder from(AggregationGetRequest other); - } - - public interface _FinalStage { - AggregationGetRequest build(); - - _FinalStage aggregationBy(Optional aggregationBy); - - _FinalStage aggregationBy(AggregationBy aggregationBy); - - _FinalStage searchIn(Optional searchIn); - - _FinalStage searchIn(String searchIn); - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - _FinalStage predefinedSources(Optional predefinedSources); - - _FinalStage predefinedSources(String predefinedSources); - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - _FinalStage sources(Optional sources); - - _FinalStage sources(String sources); - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- */ - _FinalStage notSources(Optional notSources); - - _FinalStage notSources(String notSources); - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - _FinalStage lang(Optional lang); - - _FinalStage lang(String lang); - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - _FinalStage notLang(Optional notLang); - - _FinalStage notLang(String notLang); - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - _FinalStage countries(Optional countries); - - _FinalStage countries(String countries); - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - _FinalStage notCountries(Optional notCountries); - - _FinalStage notCountries(String notCountries); - - /** - *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

- */ - _FinalStage notAuthorName(Optional notAuthorName); - - _FinalStage notAuthorName(String notAuthorName); - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage from(Optional from); - - _FinalStage from(OffsetDateTime from); - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage to(Optional to); - - _FinalStage to(OffsetDateTime to); - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - _FinalStage publishedDatePrecision( - Optional publishedDatePrecision); - - _FinalStage publishedDatePrecision(AggregationGetRequestPublishedDatePrecision publishedDatePrecision); - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ - _FinalStage byParseDate(Optional byParseDate); - - _FinalStage byParseDate(Boolean byParseDate); - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - _FinalStage sortBy(Optional sortBy); - - _FinalStage sortBy(AggregationGetRequestSortBy sortBy); - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ - _FinalStage rankedOnly(Optional rankedOnly); - - _FinalStage rankedOnly(Boolean rankedOnly); - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - _FinalStage fromRank(Optional fromRank); - - _FinalStage fromRank(Integer fromRank); - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - _FinalStage toRank(Optional toRank); - - _FinalStage toRank(Integer toRank); - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ - _FinalStage isHeadline(Optional isHeadline); - - _FinalStage isHeadline(Boolean isHeadline); - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ - _FinalStage isOpinion(Optional isOpinion); - - _FinalStage isOpinion(Boolean isOpinion); - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ - _FinalStage isPaidContent(Optional isPaidContent); - - _FinalStage isPaidContent(Boolean isPaidContent); - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- */ - _FinalStage parentUrl(Optional parentUrl); - - _FinalStage parentUrl(String parentUrl); - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - _FinalStage allLinks(Optional allLinks); - - _FinalStage allLinks(String allLinks); - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - _FinalStage allDomainLinks(Optional allDomainLinks); - - _FinalStage allDomainLinks(String allDomainLinks); - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ - _FinalStage wordCountMin(Optional wordCountMin); - - _FinalStage wordCountMin(Integer wordCountMin); - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ - _FinalStage wordCountMax(Optional wordCountMax); - - _FinalStage wordCountMax(Integer wordCountMax); - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ - _FinalStage page(Optional page); - - _FinalStage page(Integer page); - - /** - *

The number of articles to return per page.

- */ - _FinalStage pageSize(Optional pageSize); - - _FinalStage pageSize(Integer pageSize); - - _FinalStage includeNlpData(Optional includeNlpData); - - _FinalStage includeNlpData(Boolean includeNlpData); - - _FinalStage hasNlp(Optional hasNlp); - - _FinalStage hasNlp(Boolean hasNlp); - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - _FinalStage theme(Optional theme); - - _FinalStage theme(String theme); - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage notTheme(Optional notTheme); - - _FinalStage notTheme(String notTheme); - - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - _FinalStage orgEntityName(Optional orgEntityName); - - _FinalStage orgEntityName(String orgEntityName); - - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - _FinalStage perEntityName(Optional perEntityName); - - _FinalStage perEntityName(String perEntityName); - - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - _FinalStage locEntityName(Optional locEntityName); - - _FinalStage locEntityName(String locEntityName); - - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - _FinalStage miscEntityName(Optional miscEntityName); - - _FinalStage miscEntityName(String miscEntityName); - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage titleSentimentMin(Optional titleSentimentMin); - - _FinalStage titleSentimentMin(Float titleSentimentMin); - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage titleSentimentMax(Optional titleSentimentMax); - - _FinalStage titleSentimentMax(Float titleSentimentMax); - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage contentSentimentMin(Optional contentSentimentMin); - - _FinalStage contentSentimentMin(Float contentSentimentMin); - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage contentSentimentMax(Optional contentSentimentMax); - - _FinalStage contentSentimentMax(Float contentSentimentMax); - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - _FinalStage iptcTags(Optional iptcTags); - - _FinalStage iptcTags(String iptcTags); - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - _FinalStage notIptcTags(Optional notIptcTags); - - _FinalStage notIptcTags(String notIptcTags); - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ - _FinalStage robotsCompliant(Optional robotsCompliant); - - _FinalStage robotsCompliant(Boolean robotsCompliant); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements QStage, _FinalStage { - private String q; - - private Optional robotsCompliant = Optional.empty(); - - private Optional notIptcTags = Optional.empty(); - - private Optional iptcTags = Optional.empty(); - - private Optional contentSentimentMax = Optional.empty(); - - private Optional contentSentimentMin = Optional.empty(); - - private Optional titleSentimentMax = Optional.empty(); - - private Optional titleSentimentMin = Optional.empty(); - - private Optional miscEntityName = Optional.empty(); - - private Optional locEntityName = Optional.empty(); - - private Optional perEntityName = Optional.empty(); - - private Optional orgEntityName = Optional.empty(); - - private Optional notTheme = Optional.empty(); - - private Optional theme = Optional.empty(); - - private Optional hasNlp = Optional.empty(); - - private Optional includeNlpData = Optional.empty(); - - private Optional pageSize = Optional.empty(); - - private Optional page = Optional.empty(); - - private Optional wordCountMax = Optional.empty(); - - private Optional wordCountMin = Optional.empty(); - - private Optional allDomainLinks = Optional.empty(); - - private Optional allLinks = Optional.empty(); - - private Optional parentUrl = Optional.empty(); - - private Optional isPaidContent = Optional.empty(); - - private Optional isOpinion = Optional.empty(); - - private Optional isHeadline = Optional.empty(); - - private Optional toRank = Optional.empty(); - - private Optional fromRank = Optional.empty(); - - private Optional rankedOnly = Optional.empty(); - - private Optional sortBy = Optional.empty(); - - private Optional byParseDate = Optional.empty(); - - private Optional publishedDatePrecision = Optional.empty(); - - private Optional to = Optional.empty(); - - private Optional from = Optional.empty(); - - private Optional notAuthorName = Optional.empty(); - - private Optional notCountries = Optional.empty(); - - private Optional countries = Optional.empty(); - - private Optional notLang = Optional.empty(); - - private Optional lang = Optional.empty(); - - private Optional notSources = Optional.empty(); - - private Optional sources = Optional.empty(); - - private Optional predefinedSources = Optional.empty(); - - private Optional searchIn = Optional.empty(); - - private Optional aggregationBy = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AggregationGetRequest other) { - q(other.getQ()); - aggregationBy(other.getAggregationBy()); - searchIn(other.getSearchIn()); - predefinedSources(other.getPredefinedSources()); - sources(other.getSources()); - notSources(other.getNotSources()); - lang(other.getLang()); - notLang(other.getNotLang()); - countries(other.getCountries()); - notCountries(other.getNotCountries()); - notAuthorName(other.getNotAuthorName()); - from(other.getFrom()); - to(other.getTo()); - publishedDatePrecision(other.getPublishedDatePrecision()); - byParseDate(other.getByParseDate()); - sortBy(other.getSortBy()); - rankedOnly(other.getRankedOnly()); - fromRank(other.getFromRank()); - toRank(other.getToRank()); - isHeadline(other.getIsHeadline()); - isOpinion(other.getIsOpinion()); - isPaidContent(other.getIsPaidContent()); - parentUrl(other.getParentUrl()); - allLinks(other.getAllLinks()); - allDomainLinks(other.getAllDomainLinks()); - wordCountMin(other.getWordCountMin()); - wordCountMax(other.getWordCountMax()); - page(other.getPage()); - pageSize(other.getPageSize()); - includeNlpData(other.getIncludeNlpData()); - hasNlp(other.getHasNlp()); - theme(other.getTheme()); - notTheme(other.getNotTheme()); - orgEntityName(other.getOrgEntityName()); - perEntityName(other.getPerEntityName()); - locEntityName(other.getLocEntityName()); - miscEntityName(other.getMiscEntityName()); - titleSentimentMin(other.getTitleSentimentMin()); - titleSentimentMax(other.getTitleSentimentMax()); - contentSentimentMin(other.getContentSentimentMin()); - contentSentimentMax(other.getContentSentimentMax()); - iptcTags(other.getIptcTags()); - notIptcTags(other.getNotIptcTags()); - robotsCompliant(other.getRobotsCompliant()); - return this; - } - - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("q") - public _FinalStage q(@NotNull String q) { - this.q = Objects.requireNonNull(q, "q must not be null"); - return this; - } - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ - @java.lang.Override - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public _FinalStage robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notIptcTags(String notIptcTags) { - this.notIptcTags = Optional.ofNullable(notIptcTags); - return this; - } - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @java.lang.Override - @JsonSetter(value = "not_iptc_tags", nulls = Nulls.SKIP) - public _FinalStage notIptcTags(Optional notIptcTags) { - this.notIptcTags = notIptcTags; - return this; - } - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iptcTags(String iptcTags) { - this.iptcTags = Optional.ofNullable(iptcTags); - return this; - } - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @java.lang.Override - @JsonSetter(value = "iptc_tags", nulls = Nulls.SKIP) - public _FinalStage iptcTags(Optional iptcTags) { - this.iptcTags = iptcTags; - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage contentSentimentMax(Float contentSentimentMax) { - this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMax(Optional contentSentimentMax) { - this.contentSentimentMax = contentSentimentMax; - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage contentSentimentMin(Float contentSentimentMin) { - this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMin(Optional contentSentimentMin) { - this.contentSentimentMin = contentSentimentMin; - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage titleSentimentMax(Float titleSentimentMax) { - this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMax(Optional titleSentimentMax) { - this.titleSentimentMax = titleSentimentMax; - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage titleSentimentMin(Float titleSentimentMin) { - this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMin(Optional titleSentimentMin) { - this.titleSentimentMin = titleSentimentMin; - return this; - } - - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage miscEntityName(String miscEntityName) { - this.miscEntityName = Optional.ofNullable(miscEntityName); - return this; - } - - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @java.lang.Override - @JsonSetter(value = "MISC_entity_name", nulls = Nulls.SKIP) - public _FinalStage miscEntityName(Optional miscEntityName) { - this.miscEntityName = miscEntityName; - return this; - } - - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage locEntityName(String locEntityName) { - this.locEntityName = Optional.ofNullable(locEntityName); - return this; - } - - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @java.lang.Override - @JsonSetter(value = "LOC_entity_name", nulls = Nulls.SKIP) - public _FinalStage locEntityName(Optional locEntityName) { - this.locEntityName = locEntityName; - return this; - } - - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage perEntityName(String perEntityName) { - this.perEntityName = Optional.ofNullable(perEntityName); - return this; - } - - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @java.lang.Override - @JsonSetter(value = "PER_entity_name", nulls = Nulls.SKIP) - public _FinalStage perEntityName(Optional perEntityName) { - this.perEntityName = perEntityName; - return this; - } - - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage orgEntityName(String orgEntityName) { - this.orgEntityName = Optional.ofNullable(orgEntityName); - return this; - } - - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ - @java.lang.Override - @JsonSetter(value = "ORG_entity_name", nulls = Nulls.SKIP) - public _FinalStage orgEntityName(Optional orgEntityName) { - this.orgEntityName = orgEntityName; - return this; - } - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notTheme(String notTheme) { - this.notTheme = Optional.ofNullable(notTheme); - return this; - } - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { - this.notTheme = notTheme; - return this; - } - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage theme(String theme) { - this.theme = Optional.ofNullable(theme); - return this; - } - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - @java.lang.Override - @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { - this.theme = theme; - return this; - } - - @java.lang.Override - public _FinalStage hasNlp(Boolean hasNlp) { - this.hasNlp = Optional.ofNullable(hasNlp); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_nlp", nulls = Nulls.SKIP) - public _FinalStage hasNlp(Optional hasNlp) { - this.hasNlp = hasNlp; - return this; - } - - @java.lang.Override - public _FinalStage includeNlpData(Boolean includeNlpData) { - this.includeNlpData = Optional.ofNullable(includeNlpData); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_nlp_data", nulls = Nulls.SKIP) - public _FinalStage includeNlpData(Optional includeNlpData) { - this.includeNlpData = includeNlpData; - return this; - } - - /** - *

The number of articles to return per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage pageSize(Integer pageSize) { - this.pageSize = Optional.ofNullable(pageSize); - return this; - } - - /** - *

The number of articles to return per page.

- */ - @java.lang.Override - @JsonSetter(value = "page_size", nulls = Nulls.SKIP) - public _FinalStage pageSize(Optional pageSize) { - this.pageSize = pageSize; - return this; - } - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ - @java.lang.Override - @JsonSetter(value = "page", nulls = Nulls.SKIP) - public _FinalStage page(Optional page) { - this.page = page; - return this; - } - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage wordCountMax(Integer wordCountMax) { - this.wordCountMax = Optional.ofNullable(wordCountMax); - return this; - } - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ - @java.lang.Override - @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) - public _FinalStage wordCountMax(Optional wordCountMax) { - this.wordCountMax = wordCountMax; - return this; - } - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage wordCountMin(Integer wordCountMin) { - this.wordCountMin = Optional.ofNullable(wordCountMin); - return this; - } - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ - @java.lang.Override - @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) - public _FinalStage wordCountMin(Optional wordCountMin) { - this.wordCountMin = wordCountMin; - return this; - } - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allDomainLinks(String allDomainLinks) { - this.allDomainLinks = Optional.ofNullable(allDomainLinks); - return this; - } - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - @java.lang.Override - @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) - public _FinalStage allDomainLinks(Optional allDomainLinks) { - this.allDomainLinks = allDomainLinks; - return this; - } - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allLinks(String allLinks) { - this.allLinks = Optional.ofNullable(allLinks); - return this; - } - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - @java.lang.Override - @JsonSetter(value = "all_links", nulls = Nulls.SKIP) - public _FinalStage allLinks(Optional allLinks) { - this.allLinks = allLinks; - return this; - } - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage parentUrl(String parentUrl) { - this.parentUrl = Optional.ofNullable(parentUrl); - return this; - } - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- */ - @java.lang.Override - @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) - public _FinalStage parentUrl(Optional parentUrl) { - this.parentUrl = parentUrl; - return this; - } - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isPaidContent(Boolean isPaidContent) { - this.isPaidContent = Optional.ofNullable(isPaidContent); - return this; - } - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ - @java.lang.Override - @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) - public _FinalStage isPaidContent(Optional isPaidContent) { - this.isPaidContent = isPaidContent; - return this; - } - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isOpinion(Boolean isOpinion) { - this.isOpinion = Optional.ofNullable(isOpinion); - return this; - } - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ - @java.lang.Override - @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) - public _FinalStage isOpinion(Optional isOpinion) { - this.isOpinion = isOpinion; - return this; - } - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isHeadline(Boolean isHeadline) { - this.isHeadline = Optional.ofNullable(isHeadline); - return this; - } - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ - @java.lang.Override - @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) - public _FinalStage isHeadline(Optional isHeadline) { - this.isHeadline = isHeadline; - return this; - } - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage toRank(Integer toRank) { - this.toRank = Optional.ofNullable(toRank); - return this; - } - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - @java.lang.Override - @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) - public _FinalStage toRank(Optional toRank) { - this.toRank = toRank; - return this; - } - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fromRank(Integer fromRank) { - this.fromRank = Optional.ofNullable(fromRank); - return this; - } - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - @java.lang.Override - @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) - public _FinalStage fromRank(Optional fromRank) { - this.fromRank = fromRank; - return this; - } - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rankedOnly(Boolean rankedOnly) { - this.rankedOnly = Optional.ofNullable(rankedOnly); - return this; - } - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ - @java.lang.Override - @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) - public _FinalStage rankedOnly(Optional rankedOnly) { - this.rankedOnly = rankedOnly; - return this; - } - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sortBy(AggregationGetRequestSortBy sortBy) { - this.sortBy = Optional.ofNullable(sortBy); - return this; - } - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public _FinalStage sortBy(Optional sortBy) { - this.sortBy = sortBy; - return this; - } - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage byParseDate(Boolean byParseDate) { - this.byParseDate = Optional.ofNullable(byParseDate); - return this; - } - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ - @java.lang.Override - @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) - public _FinalStage byParseDate(Optional byParseDate) { - this.byParseDate = byParseDate; - return this; - } - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage publishedDatePrecision(AggregationGetRequestPublishedDatePrecision publishedDatePrecision) { - this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); - return this; - } - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision( - Optional publishedDatePrecision) { - this.publishedDatePrecision = publishedDatePrecision; - return this; - } - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage to(OffsetDateTime to) { - this.to = Optional.ofNullable(to); - return this; - } - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "to_", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage from(OffsetDateTime from) { - this.from = Optional.ofNullable(from); - return this; - } - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "from_", nulls = Nulls.SKIP) - public _FinalStage from(Optional from) { - this.from = from; - return this; - } - - /** - *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notAuthorName(String notAuthorName) { - this.notAuthorName = Optional.ofNullable(notAuthorName); - return this; - } - - /** - *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

- */ - @java.lang.Override - @JsonSetter(value = "not_author_name", nulls = Nulls.SKIP) - public _FinalStage notAuthorName(Optional notAuthorName) { - this.notAuthorName = notAuthorName; - return this; - } - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notCountries(String notCountries) { - this.notCountries = Optional.ofNullable(notCountries); - return this; - } - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @java.lang.Override - @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) - public _FinalStage notCountries(Optional notCountries) { - this.notCountries = notCountries; - return this; - } - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage countries(String countries) { - this.countries = Optional.ofNullable(countries); - return this; - } - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @java.lang.Override - @JsonSetter(value = "countries", nulls = Nulls.SKIP) - public _FinalStage countries(Optional countries) { - this.countries = countries; - return this; - } - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notLang(String notLang) { - this.notLang = Optional.ofNullable(notLang); - return this; - } - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - @java.lang.Override - @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) - public _FinalStage notLang(Optional notLang) { - this.notLang = notLang; - return this; - } - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lang(String lang) { - this.lang = Optional.ofNullable(lang); - return this; - } - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - @java.lang.Override - @JsonSetter(value = "lang", nulls = Nulls.SKIP) - public _FinalStage lang(Optional lang) { - this.lang = lang; - return this; - } - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notSources(String notSources) { - this.notSources = Optional.ofNullable(notSources); - return this; - } - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- */ - @java.lang.Override - @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) - public _FinalStage notSources(Optional notSources) { - this.notSources = notSources; - return this; - } - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sources(String sources) { - this.sources = Optional.ofNullable(sources); - return this; - } - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "sources", nulls = Nulls.SKIP) - public _FinalStage sources(Optional sources) { - this.sources = sources; - return this; - } - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage predefinedSources(String predefinedSources) { - this.predefinedSources = Optional.ofNullable(predefinedSources); - return this; - } - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) - public _FinalStage predefinedSources(Optional predefinedSources) { - this.predefinedSources = predefinedSources; - return this; - } - - @java.lang.Override - public _FinalStage searchIn(String searchIn) { - this.searchIn = Optional.ofNullable(searchIn); - return this; - } - - @java.lang.Override - @JsonSetter(value = "search_in", nulls = Nulls.SKIP) - public _FinalStage searchIn(Optional searchIn) { - this.searchIn = searchIn; - return this; - } - - @java.lang.Override - public _FinalStage aggregationBy(AggregationBy aggregationBy) { - this.aggregationBy = Optional.ofNullable(aggregationBy); - return this; - } - - @java.lang.Override - @JsonSetter(value = "aggregation_by", nulls = Nulls.SKIP) - public _FinalStage aggregationBy(Optional aggregationBy) { - this.aggregationBy = aggregationBy; - return this; - } - - @java.lang.Override - public AggregationGetRequest build() { - return new AggregationGetRequest( - q, - aggregationBy, - searchIn, - predefinedSources, - sources, - notSources, - lang, - notLang, - countries, - notCountries, - notAuthorName, - from, - to, - publishedDatePrecision, - byParseDate, - sortBy, - rankedOnly, - fromRank, - toRank, - isHeadline, - isOpinion, - isPaidContent, - parentUrl, - allLinks, - allDomainLinks, - wordCountMin, - wordCountMax, - page, - pageSize, - includeNlpData, - hasNlp, - theme, - notTheme, - orgEntityName, - perEntityName, - locEntityName, - miscEntityName, - titleSentimentMin, - titleSentimentMax, - contentSentimentMin, - contentSentimentMax, - iptcTags, - notIptcTags, - robotsCompliant, - additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestPublishedDatePrecision.java b/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestPublishedDatePrecision.java deleted file mode 100644 index 003a611..0000000 --- a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestPublishedDatePrecision.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.aggregation.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AggregationGetRequestPublishedDatePrecision { - FULL("full"), - - TIMEZONE_UNKNOWN("timezone unknown"), - - DATE("date"); - - private final String value; - - AggregationGetRequestPublishedDatePrecision(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestSortBy.java b/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestSortBy.java deleted file mode 100644 index 8cd5f5a..0000000 --- a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetRequestSortBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.aggregation.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AggregationGetRequestSortBy { - RELEVANCY("relevancy"), - - DATE("date"), - - RANK("rank"); - - private final String value; - - AggregationGetRequestSortBy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/AggregationClient.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/AggregationCountClient.java similarity index 54% rename from src/main/java/com/newscatcher/api/resources/aggregation/AggregationClient.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/AggregationCountClient.java index a6fcba7..185e1a9 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/AggregationClient.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/AggregationCountClient.java @@ -1,57 +1,57 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation; +package com.newscatcher.api.resources.aggregationcount; import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.aggregation.requests.AggregationGetRequest; -import com.newscatcher.api.resources.aggregation.requests.AggregationPostRequest; -import com.newscatcher.api.resources.aggregation.types.AggregationGetResponse; -import com.newscatcher.api.resources.aggregation.types.AggregationPostResponse; +import com.newscatcher.api.resources.aggregationcount.requests.GetAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.requests.PostAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.types.GetAggregationCountResponse; +import com.newscatcher.api.resources.aggregationcount.types.PostAggregationCountResponse; -public class AggregationClient { +public class AggregationCountClient { protected final ClientOptions clientOptions; - private final RawAggregationClient rawClient; + private final RawAggregationCountClient rawClient; - public AggregationClient(ClientOptions clientOptions) { + public AggregationCountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new RawAggregationClient(clientOptions); + this.rawClient = new RawAggregationCountClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public RawAggregationClient withRawResponse() { + public RawAggregationCountClient withRawResponse() { return this.rawClient; } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public AggregationGetResponse get(AggregationGetRequest request) { + public GetAggregationCountResponse get(GetAggregationCountRequest request) { return this.rawClient.get(request).body(); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public AggregationGetResponse get(AggregationGetRequest request, RequestOptions requestOptions) { + public GetAggregationCountResponse get(GetAggregationCountRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public AggregationPostResponse post(AggregationPostRequest request) { + public PostAggregationCountResponse post(PostAggregationCountRequest request) { return this.rawClient.post(request).body(); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public AggregationPostResponse post(AggregationPostRequest request, RequestOptions requestOptions) { + public PostAggregationCountResponse post(PostAggregationCountRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/AsyncAggregationClient.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncAggregationCountClient.java similarity index 54% rename from src/main/java/com/newscatcher/api/resources/aggregation/AsyncAggregationClient.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncAggregationCountClient.java index cb18d50..bd5dcd2 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/AsyncAggregationClient.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncAggregationCountClient.java @@ -1,59 +1,60 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation; +package com.newscatcher.api.resources.aggregationcount; import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.aggregation.requests.AggregationGetRequest; -import com.newscatcher.api.resources.aggregation.requests.AggregationPostRequest; -import com.newscatcher.api.resources.aggregation.types.AggregationGetResponse; -import com.newscatcher.api.resources.aggregation.types.AggregationPostResponse; +import com.newscatcher.api.resources.aggregationcount.requests.GetAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.requests.PostAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.types.GetAggregationCountResponse; +import com.newscatcher.api.resources.aggregationcount.types.PostAggregationCountResponse; import java.util.concurrent.CompletableFuture; -public class AsyncAggregationClient { +public class AsyncAggregationCountClient { protected final ClientOptions clientOptions; - private final AsyncRawAggregationClient rawClient; + private final AsyncRawAggregationCountClient rawClient; - public AsyncAggregationClient(ClientOptions clientOptions) { + public AsyncAggregationCountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new AsyncRawAggregationClient(clientOptions); + this.rawClient = new AsyncRawAggregationCountClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public AsyncRawAggregationClient withRawResponse() { + public AsyncRawAggregationCountClient withRawResponse() { return this.rawClient; } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture get(AggregationGetRequest request) { + public CompletableFuture get(GetAggregationCountRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture get(AggregationGetRequest request, RequestOptions requestOptions) { + public CompletableFuture get( + GetAggregationCountRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture post(AggregationPostRequest request) { + public CompletableFuture post(PostAggregationCountRequest request) { return this.rawClient.post(request).thenApply(response -> response.body()); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture post( - AggregationPostRequest request, RequestOptions requestOptions) { + public CompletableFuture post( + PostAggregationCountRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/AsyncRawAggregationClient.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncRawAggregationCountClient.java similarity index 88% rename from src/main/java/com/newscatcher/api/resources/aggregation/AsyncRawAggregationClient.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncRawAggregationCountClient.java index 138871d..ea9757f 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/AsyncRawAggregationClient.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/AsyncRawAggregationCountClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation; +package com.newscatcher.api.resources.aggregationcount; import com.fasterxml.jackson.core.JsonProcessingException; import com.newscatcher.api.core.ClientOptions; @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.aggregation.requests.AggregationGetRequest; -import com.newscatcher.api.resources.aggregation.requests.AggregationPostRequest; -import com.newscatcher.api.resources.aggregation.types.AggregationGetResponse; -import com.newscatcher.api.resources.aggregation.types.AggregationPostResponse; +import com.newscatcher.api.resources.aggregationcount.requests.GetAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.requests.PostAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.types.GetAggregationCountResponse; +import com.newscatcher.api.resources.aggregationcount.types.PostAggregationCountResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -37,25 +37,26 @@ import okhttp3.ResponseBody; import org.jetbrains.annotations.NotNull; -public class AsyncRawAggregationClient { +public class AsyncRawAggregationCountClient { protected final ClientOptions clientOptions; - public AsyncRawAggregationClient(ClientOptions clientOptions) { + public AsyncRawAggregationCountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture> get(AggregationGetRequest request) { + public CompletableFuture> get( + GetAggregationCountRequest request) { return get(request, null); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture> get( - AggregationGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get( + GetAggregationCountRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/aggregation_count"); @@ -161,6 +162,10 @@ public CompletableFuture> get QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -249,6 +254,11 @@ public CompletableFuture> get QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -259,19 +269,19 @@ public CompletableFuture> get if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AggregationGetResponse.class), + responseBodyString, GetAggregationCountResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -313,11 +323,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -336,19 +344,24 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture> post(AggregationPostRequest request) { + public CompletableFuture> post( + PostAggregationCountRequest request) { return post(request, null); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public CompletableFuture> post( - AggregationPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostAggregationCountRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/aggregation_count") - .build(); + .addPathSegments("api/aggregation_count"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -357,7 +370,7 @@ public CompletableFuture> po throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -367,19 +380,19 @@ public CompletableFuture> po if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), AggregationPostResponse.class), + responseBodyString, PostAggregationCountResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -421,11 +434,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/RawAggregationClient.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/RawAggregationCountClient.java similarity index 88% rename from src/main/java/com/newscatcher/api/resources/aggregation/RawAggregationClient.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/RawAggregationCountClient.java index f101eeb..90a62e0 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/RawAggregationClient.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/RawAggregationCountClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation; +package com.newscatcher.api.resources.aggregationcount; import com.fasterxml.jackson.core.JsonProcessingException; import com.newscatcher.api.core.ClientOptions; @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.aggregation.requests.AggregationGetRequest; -import com.newscatcher.api.resources.aggregation.requests.AggregationPostRequest; -import com.newscatcher.api.resources.aggregation.types.AggregationGetResponse; -import com.newscatcher.api.resources.aggregation.types.AggregationPostResponse; +import com.newscatcher.api.resources.aggregationcount.requests.GetAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.requests.PostAggregationCountRequest; +import com.newscatcher.api.resources.aggregationcount.types.GetAggregationCountResponse; +import com.newscatcher.api.resources.aggregationcount.types.PostAggregationCountResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import okhttp3.Headers; @@ -33,25 +33,25 @@ import okhttp3.Response; import okhttp3.ResponseBody; -public class RawAggregationClient { +public class RawAggregationCountClient { protected final ClientOptions clientOptions; - public RawAggregationClient(ClientOptions clientOptions) { + public RawAggregationCountClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public NewscatcherApiHttpResponse get(AggregationGetRequest request) { + public NewscatcherApiHttpResponse get(GetAggregationCountRequest request) { return get(request, null); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public NewscatcherApiHttpResponse get( - AggregationGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get( + GetAggregationCountRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/aggregation_count"); @@ -157,6 +157,10 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -245,6 +249,11 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -257,12 +266,12 @@ public NewscatcherApiHttpResponse get( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AggregationGetResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAggregationCountResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -290,11 +299,9 @@ public NewscatcherApiHttpResponse get( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -303,19 +310,23 @@ public NewscatcherApiHttpResponse get( /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public NewscatcherApiHttpResponse post(AggregationPostRequest request) { + public NewscatcherApiHttpResponse post(PostAggregationCountRequest request) { return post(request, null); } /** * Retrieves the count of articles aggregated by day or hour based on various search criteria, such as keyword, language, country, and source. */ - public NewscatcherApiHttpResponse post( - AggregationPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostAggregationCountRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/aggregation_count") - .build(); + .addPathSegments("api/aggregation_count"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -324,7 +335,7 @@ public NewscatcherApiHttpResponse post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -336,12 +347,12 @@ public NewscatcherApiHttpResponse post( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AggregationPostResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostAggregationCountResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -369,11 +380,9 @@ public NewscatcherApiHttpResponse post( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/aggregationcount/requests/GetAggregationCountRequest.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/requests/GetAggregationCountRequest.java new file mode 100644 index 0000000..8b003f3 --- /dev/null +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/requests/GetAggregationCountRequest.java @@ -0,0 +1,1775 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.resources.aggregationcount.requests; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.api.core.ObjectMappers; +import com.newscatcher.api.types.AggregationBy; +import com.newscatcher.api.types.From; +import com.newscatcher.api.types.SortBy; +import com.newscatcher.api.types.To; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetAggregationCountRequest.Builder.class) +public final class GetAggregationCountRequest { + private final String q; + + private final Optional aggregationBy; + + private final Optional searchIn; + + private final Optional predefinedSources; + + private final Optional sources; + + private final Optional notSources; + + private final Optional lang; + + private final Optional notLang; + + private final Optional countries; + + private final Optional notCountries; + + private final Optional notAuthorName; + + private final Optional from; + + private final Optional to; + + private final Optional publishedDatePrecision; + + private final Optional byParseDate; + + private final Optional sortBy; + + private final Optional rankedOnly; + + private final Optional fromRank; + + private final Optional toRank; + + private final Optional isHeadline; + + private final Optional isOpinion; + + private final Optional isPaidContent; + + private final Optional parentUrl; + + private final Optional allLinks; + + private final Optional allDomainLinks; + + private final Optional allLinksText; + + private final Optional wordCountMin; + + private final Optional wordCountMax; + + private final Optional page; + + private final Optional pageSize; + + private final Optional includeNlpData; + + private final Optional hasNlp; + + private final Optional theme; + + private final Optional notTheme; + + private final Optional orgEntityName; + + private final Optional perEntityName; + + private final Optional locEntityName; + + private final Optional miscEntityName; + + private final Optional titleSentimentMin; + + private final Optional titleSentimentMax; + + private final Optional contentSentimentMin; + + private final Optional contentSentimentMax; + + private final Optional iptcTags; + + private final Optional notIptcTags; + + private final Optional robotsCompliant; + + private final Map additionalProperties; + + private GetAggregationCountRequest( + String q, + Optional aggregationBy, + Optional searchIn, + Optional predefinedSources, + Optional sources, + Optional notSources, + Optional lang, + Optional notLang, + Optional countries, + Optional notCountries, + Optional notAuthorName, + Optional from, + Optional to, + Optional publishedDatePrecision, + Optional byParseDate, + Optional sortBy, + Optional rankedOnly, + Optional fromRank, + Optional toRank, + Optional isHeadline, + Optional isOpinion, + Optional isPaidContent, + Optional parentUrl, + Optional allLinks, + Optional allDomainLinks, + Optional allLinksText, + Optional wordCountMin, + Optional wordCountMax, + Optional page, + Optional pageSize, + Optional includeNlpData, + Optional hasNlp, + Optional theme, + Optional notTheme, + Optional orgEntityName, + Optional perEntityName, + Optional locEntityName, + Optional miscEntityName, + Optional titleSentimentMin, + Optional titleSentimentMax, + Optional contentSentimentMin, + Optional contentSentimentMax, + Optional iptcTags, + Optional notIptcTags, + Optional robotsCompliant, + Map additionalProperties) { + this.q = q; + this.aggregationBy = aggregationBy; + this.searchIn = searchIn; + this.predefinedSources = predefinedSources; + this.sources = sources; + this.notSources = notSources; + this.lang = lang; + this.notLang = notLang; + this.countries = countries; + this.notCountries = notCountries; + this.notAuthorName = notAuthorName; + this.from = from; + this.to = to; + this.publishedDatePrecision = publishedDatePrecision; + this.byParseDate = byParseDate; + this.sortBy = sortBy; + this.rankedOnly = rankedOnly; + this.fromRank = fromRank; + this.toRank = toRank; + this.isHeadline = isHeadline; + this.isOpinion = isOpinion; + this.isPaidContent = isPaidContent; + this.parentUrl = parentUrl; + this.allLinks = allLinks; + this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; + this.wordCountMin = wordCountMin; + this.wordCountMax = wordCountMax; + this.page = page; + this.pageSize = pageSize; + this.includeNlpData = includeNlpData; + this.hasNlp = hasNlp; + this.theme = theme; + this.notTheme = notTheme; + this.orgEntityName = orgEntityName; + this.perEntityName = perEntityName; + this.locEntityName = locEntityName; + this.miscEntityName = miscEntityName; + this.titleSentimentMin = titleSentimentMin; + this.titleSentimentMax = titleSentimentMax; + this.contentSentimentMin = contentSentimentMin; + this.contentSentimentMax = contentSentimentMax; + this.iptcTags = iptcTags; + this.notIptcTags = notIptcTags; + this.robotsCompliant = robotsCompliant; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("q") + public String getQ() { + return q; + } + + @JsonProperty("aggregation_by") + public Optional getAggregationBy() { + return aggregationBy; + } + + @JsonProperty("search_in") + public Optional getSearchIn() { + return searchIn; + } + + /** + * @return Predefined top news sources per country. + *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

+ */ + @JsonProperty("predefined_sources") + public Optional getPredefinedSources() { + return predefinedSources; + } + + /** + * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. + */ + @JsonProperty("sources") + public Optional getSources() { + return sources; + } + + /** + * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. + */ + @JsonProperty("not_sources") + public Optional getNotSources() { + return notSources; + } + + /** + * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. + *

To learn more, see Enumerated parameters > Language.

+ */ + @JsonProperty("lang") + public Optional getLang() { + return lang; + } + + /** + * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. + *

To learn more, see Enumerated parameters > Language.

+ */ + @JsonProperty("not_lang") + public Optional getNotLang() { + return notLang; + } + + /** + * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. + *

To learn more, see Enumerated parameters > Country.

+ */ + @JsonProperty("countries") + public Optional getCountries() { + return countries; + } + + /** + * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. + *

To learn more, see Enumerated parameters > Country.

+ */ + @JsonProperty("not_countries") + public Optional getNotCountries() { + return notCountries; + } + + /** + * @return The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. + */ + @JsonProperty("not_author_name") + public Optional getNotAuthorName() { + return notAuthorName; + } + + @JsonProperty("from_") + public Optional getFrom() { + return from; + } + + @JsonProperty("to_") + public Optional getTo() { + return to; + } + + @JsonProperty("published_date_precision") + public Optional getPublishedDatePrecision() { + return publishedDatePrecision; + } + + @JsonProperty("by_parse_date") + public Optional getByParseDate() { + return byParseDate; + } + + @JsonProperty("sort_by") + public Optional getSortBy() { + return sortBy; + } + + @JsonProperty("ranked_only") + public Optional getRankedOnly() { + return rankedOnly; + } + + @JsonProperty("from_rank") + public Optional getFromRank() { + return fromRank; + } + + @JsonProperty("to_rank") + public Optional getToRank() { + return toRank; + } + + @JsonProperty("is_headline") + public Optional getIsHeadline() { + return isHeadline; + } + + @JsonProperty("is_opinion") + public Optional getIsOpinion() { + return isOpinion; + } + + @JsonProperty("is_paid_content") + public Optional getIsPaidContent() { + return isPaidContent; + } + + /** + * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. + */ + @JsonProperty("parent_url") + public Optional getParentUrl() { + return parentUrl; + } + + /** + * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. + *

For more details, see Search by URL.

+ */ + @JsonProperty("all_links") + public Optional getAllLinks() { + return allLinks; + } + + /** + * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. + *

For more details, see Search by URL.

+ */ + @JsonProperty("all_domain_links") + public Optional getAllDomainLinks() { + return allDomainLinks; + } + + /** + * @return The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ */ + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + + @JsonProperty("word_count_min") + public Optional getWordCountMin() { + return wordCountMin; + } + + @JsonProperty("word_count_max") + public Optional getWordCountMax() { + return wordCountMax; + } + + @JsonProperty("page") + public Optional getPage() { + return page; + } + + @JsonProperty("page_size") + public Optional getPageSize() { + return pageSize; + } + + @JsonProperty("include_nlp_data") + public Optional getIncludeNlpData() { + return includeNlpData; + } + + @JsonProperty("has_nlp") + public Optional getHasNlp() { + return hasNlp; + } + + @JsonProperty("theme") + public Optional getTheme() { + return theme; + } + + @JsonProperty("not_theme") + public Optional getNotTheme() { + return notTheme; + } + + @JsonProperty("ORG_entity_name") + public Optional getOrgEntityName() { + return orgEntityName; + } + + @JsonProperty("PER_entity_name") + public Optional getPerEntityName() { + return perEntityName; + } + + @JsonProperty("LOC_entity_name") + public Optional getLocEntityName() { + return locEntityName; + } + + @JsonProperty("MISC_entity_name") + public Optional getMiscEntityName() { + return miscEntityName; + } + + @JsonProperty("title_sentiment_min") + public Optional getTitleSentimentMin() { + return titleSentimentMin; + } + + @JsonProperty("title_sentiment_max") + public Optional getTitleSentimentMax() { + return titleSentimentMax; + } + + @JsonProperty("content_sentiment_min") + public Optional getContentSentimentMin() { + return contentSentimentMin; + } + + @JsonProperty("content_sentiment_max") + public Optional getContentSentimentMax() { + return contentSentimentMax; + } + + /** + * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. + *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + @JsonProperty("iptc_tags") + public Optional getIptcTags() { + return iptcTags; + } + + /** + * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. + *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + @JsonProperty("not_iptc_tags") + public Optional getNotIptcTags() { + return notIptcTags; + } + + @JsonProperty("robots_compliant") + public Optional getRobotsCompliant() { + return robotsCompliant; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetAggregationCountRequest && equalTo((GetAggregationCountRequest) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetAggregationCountRequest other) { + return q.equals(other.q) + && aggregationBy.equals(other.aggregationBy) + && searchIn.equals(other.searchIn) + && predefinedSources.equals(other.predefinedSources) + && sources.equals(other.sources) + && notSources.equals(other.notSources) + && lang.equals(other.lang) + && notLang.equals(other.notLang) + && countries.equals(other.countries) + && notCountries.equals(other.notCountries) + && notAuthorName.equals(other.notAuthorName) + && from.equals(other.from) + && to.equals(other.to) + && publishedDatePrecision.equals(other.publishedDatePrecision) + && byParseDate.equals(other.byParseDate) + && sortBy.equals(other.sortBy) + && rankedOnly.equals(other.rankedOnly) + && fromRank.equals(other.fromRank) + && toRank.equals(other.toRank) + && isHeadline.equals(other.isHeadline) + && isOpinion.equals(other.isOpinion) + && isPaidContent.equals(other.isPaidContent) + && parentUrl.equals(other.parentUrl) + && allLinks.equals(other.allLinks) + && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) + && wordCountMin.equals(other.wordCountMin) + && wordCountMax.equals(other.wordCountMax) + && page.equals(other.page) + && pageSize.equals(other.pageSize) + && includeNlpData.equals(other.includeNlpData) + && hasNlp.equals(other.hasNlp) + && theme.equals(other.theme) + && notTheme.equals(other.notTheme) + && orgEntityName.equals(other.orgEntityName) + && perEntityName.equals(other.perEntityName) + && locEntityName.equals(other.locEntityName) + && miscEntityName.equals(other.miscEntityName) + && titleSentimentMin.equals(other.titleSentimentMin) + && titleSentimentMax.equals(other.titleSentimentMax) + && contentSentimentMin.equals(other.contentSentimentMin) + && contentSentimentMax.equals(other.contentSentimentMax) + && iptcTags.equals(other.iptcTags) + && notIptcTags.equals(other.notIptcTags) + && robotsCompliant.equals(other.robotsCompliant); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.q, + this.aggregationBy, + this.searchIn, + this.predefinedSources, + this.sources, + this.notSources, + this.lang, + this.notLang, + this.countries, + this.notCountries, + this.notAuthorName, + this.from, + this.to, + this.publishedDatePrecision, + this.byParseDate, + this.sortBy, + this.rankedOnly, + this.fromRank, + this.toRank, + this.isHeadline, + this.isOpinion, + this.isPaidContent, + this.parentUrl, + this.allLinks, + this.allDomainLinks, + this.allLinksText, + this.wordCountMin, + this.wordCountMax, + this.page, + this.pageSize, + this.includeNlpData, + this.hasNlp, + this.theme, + this.notTheme, + this.orgEntityName, + this.perEntityName, + this.locEntityName, + this.miscEntityName, + this.titleSentimentMin, + this.titleSentimentMax, + this.contentSentimentMin, + this.contentSentimentMax, + this.iptcTags, + this.notIptcTags, + this.robotsCompliant); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static QStage builder() { + return new Builder(); + } + + public interface QStage { + _FinalStage q(@NotNull String q); + + Builder from(GetAggregationCountRequest other); + } + + public interface _FinalStage { + GetAggregationCountRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + + _FinalStage aggregationBy(Optional aggregationBy); + + _FinalStage aggregationBy(AggregationBy aggregationBy); + + _FinalStage searchIn(Optional searchIn); + + _FinalStage searchIn(String searchIn); + + /** + *

Predefined top news sources per country.

+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

+ */ + _FinalStage predefinedSources(Optional predefinedSources); + + _FinalStage predefinedSources(String predefinedSources); + + /** + *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

+ */ + _FinalStage sources(Optional sources); + + _FinalStage sources(String sources); + + /** + *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

+ */ + _FinalStage notSources(Optional notSources); + + _FinalStage notSources(String notSources); + + /** + *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ */ + _FinalStage lang(Optional lang); + + _FinalStage lang(String lang); + + /** + *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ */ + _FinalStage notLang(Optional notLang); + + _FinalStage notLang(String notLang); + + /** + *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ */ + _FinalStage countries(Optional countries); + + _FinalStage countries(String countries); + + /** + *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ */ + _FinalStage notCountries(Optional notCountries); + + _FinalStage notCountries(String notCountries); + + /** + *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

+ */ + _FinalStage notAuthorName(Optional notAuthorName); + + _FinalStage notAuthorName(String notAuthorName); + + _FinalStage from(Optional from); + + _FinalStage from(From from); + + _FinalStage to(Optional to); + + _FinalStage to(To to); + + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + + _FinalStage publishedDatePrecision(String publishedDatePrecision); + + _FinalStage byParseDate(Optional byParseDate); + + _FinalStage byParseDate(Boolean byParseDate); + + _FinalStage sortBy(Optional sortBy); + + _FinalStage sortBy(SortBy sortBy); + + _FinalStage rankedOnly(Optional rankedOnly); + + _FinalStage rankedOnly(Boolean rankedOnly); + + _FinalStage fromRank(Optional fromRank); + + _FinalStage fromRank(Integer fromRank); + + _FinalStage toRank(Optional toRank); + + _FinalStage toRank(Integer toRank); + + _FinalStage isHeadline(Optional isHeadline); + + _FinalStage isHeadline(Boolean isHeadline); + + _FinalStage isOpinion(Optional isOpinion); + + _FinalStage isOpinion(Boolean isOpinion); + + _FinalStage isPaidContent(Optional isPaidContent); + + _FinalStage isPaidContent(Boolean isPaidContent); + + /** + *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

+ */ + _FinalStage parentUrl(Optional parentUrl); + + _FinalStage parentUrl(String parentUrl); + + /** + *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

+ *

For more details, see Search by URL.

+ */ + _FinalStage allLinks(Optional allLinks); + + _FinalStage allLinks(String allLinks); + + /** + *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

+ *

For more details, see Search by URL.

+ */ + _FinalStage allDomainLinks(Optional allDomainLinks); + + _FinalStage allDomainLinks(String allDomainLinks); + + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ */ + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(String allLinksText); + + _FinalStage wordCountMin(Optional wordCountMin); + + _FinalStage wordCountMin(Integer wordCountMin); + + _FinalStage wordCountMax(Optional wordCountMax); + + _FinalStage wordCountMax(Integer wordCountMax); + + _FinalStage page(Optional page); + + _FinalStage page(Integer page); + + _FinalStage pageSize(Optional pageSize); + + _FinalStage pageSize(Integer pageSize); + + _FinalStage includeNlpData(Optional includeNlpData); + + _FinalStage includeNlpData(Boolean includeNlpData); + + _FinalStage hasNlp(Optional hasNlp); + + _FinalStage hasNlp(Boolean hasNlp); + + _FinalStage theme(Optional theme); + + _FinalStage theme(String theme); + + _FinalStage notTheme(Optional notTheme); + + _FinalStage notTheme(String notTheme); + + _FinalStage orgEntityName(Optional orgEntityName); + + _FinalStage orgEntityName(String orgEntityName); + + _FinalStage perEntityName(Optional perEntityName); + + _FinalStage perEntityName(String perEntityName); + + _FinalStage locEntityName(Optional locEntityName); + + _FinalStage locEntityName(String locEntityName); + + _FinalStage miscEntityName(Optional miscEntityName); + + _FinalStage miscEntityName(String miscEntityName); + + _FinalStage titleSentimentMin(Optional titleSentimentMin); + + _FinalStage titleSentimentMin(Float titleSentimentMin); + + _FinalStage titleSentimentMax(Optional titleSentimentMax); + + _FinalStage titleSentimentMax(Float titleSentimentMax); + + _FinalStage contentSentimentMin(Optional contentSentimentMin); + + _FinalStage contentSentimentMin(Float contentSentimentMin); + + _FinalStage contentSentimentMax(Optional contentSentimentMax); + + _FinalStage contentSentimentMax(Float contentSentimentMax); + + /** + *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

+ *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + _FinalStage iptcTags(Optional iptcTags); + + _FinalStage iptcTags(String iptcTags); + + /** + *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

+ *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + _FinalStage notIptcTags(Optional notIptcTags); + + _FinalStage notIptcTags(String notIptcTags); + + _FinalStage robotsCompliant(Optional robotsCompliant); + + _FinalStage robotsCompliant(Boolean robotsCompliant); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements QStage, _FinalStage { + private String q; + + private Optional robotsCompliant = Optional.empty(); + + private Optional notIptcTags = Optional.empty(); + + private Optional iptcTags = Optional.empty(); + + private Optional contentSentimentMax = Optional.empty(); + + private Optional contentSentimentMin = Optional.empty(); + + private Optional titleSentimentMax = Optional.empty(); + + private Optional titleSentimentMin = Optional.empty(); + + private Optional miscEntityName = Optional.empty(); + + private Optional locEntityName = Optional.empty(); + + private Optional perEntityName = Optional.empty(); + + private Optional orgEntityName = Optional.empty(); + + private Optional notTheme = Optional.empty(); + + private Optional theme = Optional.empty(); + + private Optional hasNlp = Optional.empty(); + + private Optional includeNlpData = Optional.empty(); + + private Optional pageSize = Optional.empty(); + + private Optional page = Optional.empty(); + + private Optional wordCountMax = Optional.empty(); + + private Optional wordCountMin = Optional.empty(); + + private Optional allLinksText = Optional.empty(); + + private Optional allDomainLinks = Optional.empty(); + + private Optional allLinks = Optional.empty(); + + private Optional parentUrl = Optional.empty(); + + private Optional isPaidContent = Optional.empty(); + + private Optional isOpinion = Optional.empty(); + + private Optional isHeadline = Optional.empty(); + + private Optional toRank = Optional.empty(); + + private Optional fromRank = Optional.empty(); + + private Optional rankedOnly = Optional.empty(); + + private Optional sortBy = Optional.empty(); + + private Optional byParseDate = Optional.empty(); + + private Optional publishedDatePrecision = Optional.empty(); + + private Optional to = Optional.empty(); + + private Optional from = Optional.empty(); + + private Optional notAuthorName = Optional.empty(); + + private Optional notCountries = Optional.empty(); + + private Optional countries = Optional.empty(); + + private Optional notLang = Optional.empty(); + + private Optional lang = Optional.empty(); + + private Optional notSources = Optional.empty(); + + private Optional sources = Optional.empty(); + + private Optional predefinedSources = Optional.empty(); + + private Optional searchIn = Optional.empty(); + + private Optional aggregationBy = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetAggregationCountRequest other) { + q(other.getQ()); + aggregationBy(other.getAggregationBy()); + searchIn(other.getSearchIn()); + predefinedSources(other.getPredefinedSources()); + sources(other.getSources()); + notSources(other.getNotSources()); + lang(other.getLang()); + notLang(other.getNotLang()); + countries(other.getCountries()); + notCountries(other.getNotCountries()); + notAuthorName(other.getNotAuthorName()); + from(other.getFrom()); + to(other.getTo()); + publishedDatePrecision(other.getPublishedDatePrecision()); + byParseDate(other.getByParseDate()); + sortBy(other.getSortBy()); + rankedOnly(other.getRankedOnly()); + fromRank(other.getFromRank()); + toRank(other.getToRank()); + isHeadline(other.getIsHeadline()); + isOpinion(other.getIsOpinion()); + isPaidContent(other.getIsPaidContent()); + parentUrl(other.getParentUrl()); + allLinks(other.getAllLinks()); + allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); + wordCountMin(other.getWordCountMin()); + wordCountMax(other.getWordCountMax()); + page(other.getPage()); + pageSize(other.getPageSize()); + includeNlpData(other.getIncludeNlpData()); + hasNlp(other.getHasNlp()); + theme(other.getTheme()); + notTheme(other.getNotTheme()); + orgEntityName(other.getOrgEntityName()); + perEntityName(other.getPerEntityName()); + locEntityName(other.getLocEntityName()); + miscEntityName(other.getMiscEntityName()); + titleSentimentMin(other.getTitleSentimentMin()); + titleSentimentMax(other.getTitleSentimentMax()); + contentSentimentMin(other.getContentSentimentMin()); + contentSentimentMax(other.getContentSentimentMax()); + iptcTags(other.getIptcTags()); + notIptcTags(other.getNotIptcTags()); + robotsCompliant(other.getRobotsCompliant()); + return this; + } + + @java.lang.Override + @JsonSetter("q") + public _FinalStage q(@NotNull String q) { + this.q = Objects.requireNonNull(q, "q must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage robotsCompliant(Boolean robotsCompliant) { + this.robotsCompliant = Optional.ofNullable(robotsCompliant); + return this; + } + + @java.lang.Override + @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) + public _FinalStage robotsCompliant(Optional robotsCompliant) { + this.robotsCompliant = robotsCompliant; + return this; + } + + /** + *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

+ *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notIptcTags(String notIptcTags) { + this.notIptcTags = Optional.ofNullable(notIptcTags); + return this; + } + + /** + *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

+ *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + @java.lang.Override + @JsonSetter(value = "not_iptc_tags", nulls = Nulls.SKIP) + public _FinalStage notIptcTags(Optional notIptcTags) { + this.notIptcTags = notIptcTags; + return this; + } + + /** + *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

+ *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage iptcTags(String iptcTags) { + this.iptcTags = Optional.ofNullable(iptcTags); + return this; + } + + /** + *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

+ *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

+ *

To learn more, see IPTC Media Topic NewsCodes.

+ */ + @java.lang.Override + @JsonSetter(value = "iptc_tags", nulls = Nulls.SKIP) + public _FinalStage iptcTags(Optional iptcTags) { + this.iptcTags = iptcTags; + return this; + } + + @java.lang.Override + public _FinalStage contentSentimentMax(Float contentSentimentMax) { + this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); + return this; + } + + @java.lang.Override + @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) + public _FinalStage contentSentimentMax(Optional contentSentimentMax) { + this.contentSentimentMax = contentSentimentMax; + return this; + } + + @java.lang.Override + public _FinalStage contentSentimentMin(Float contentSentimentMin) { + this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); + return this; + } + + @java.lang.Override + @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) + public _FinalStage contentSentimentMin(Optional contentSentimentMin) { + this.contentSentimentMin = contentSentimentMin; + return this; + } + + @java.lang.Override + public _FinalStage titleSentimentMax(Float titleSentimentMax) { + this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) + public _FinalStage titleSentimentMax(Optional titleSentimentMax) { + this.titleSentimentMax = titleSentimentMax; + return this; + } + + @java.lang.Override + public _FinalStage titleSentimentMin(Float titleSentimentMin) { + this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); + return this; + } + + @java.lang.Override + @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) + public _FinalStage titleSentimentMin(Optional titleSentimentMin) { + this.titleSentimentMin = titleSentimentMin; + return this; + } + + @java.lang.Override + public _FinalStage miscEntityName(String miscEntityName) { + this.miscEntityName = Optional.ofNullable(miscEntityName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "MISC_entity_name", nulls = Nulls.SKIP) + public _FinalStage miscEntityName(Optional miscEntityName) { + this.miscEntityName = miscEntityName; + return this; + } + + @java.lang.Override + public _FinalStage locEntityName(String locEntityName) { + this.locEntityName = Optional.ofNullable(locEntityName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "LOC_entity_name", nulls = Nulls.SKIP) + public _FinalStage locEntityName(Optional locEntityName) { + this.locEntityName = locEntityName; + return this; + } + + @java.lang.Override + public _FinalStage perEntityName(String perEntityName) { + this.perEntityName = Optional.ofNullable(perEntityName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "PER_entity_name", nulls = Nulls.SKIP) + public _FinalStage perEntityName(Optional perEntityName) { + this.perEntityName = perEntityName; + return this; + } + + @java.lang.Override + public _FinalStage orgEntityName(String orgEntityName) { + this.orgEntityName = Optional.ofNullable(orgEntityName); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ORG_entity_name", nulls = Nulls.SKIP) + public _FinalStage orgEntityName(Optional orgEntityName) { + this.orgEntityName = orgEntityName; + return this; + } + + @java.lang.Override + public _FinalStage notTheme(String notTheme) { + this.notTheme = Optional.ofNullable(notTheme); + return this; + } + + @java.lang.Override + @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) + public _FinalStage notTheme(Optional notTheme) { + this.notTheme = notTheme; + return this; + } + + @java.lang.Override + public _FinalStage theme(String theme) { + this.theme = Optional.ofNullable(theme); + return this; + } + + @java.lang.Override + @JsonSetter(value = "theme", nulls = Nulls.SKIP) + public _FinalStage theme(Optional theme) { + this.theme = theme; + return this; + } + + @java.lang.Override + public _FinalStage hasNlp(Boolean hasNlp) { + this.hasNlp = Optional.ofNullable(hasNlp); + return this; + } + + @java.lang.Override + @JsonSetter(value = "has_nlp", nulls = Nulls.SKIP) + public _FinalStage hasNlp(Optional hasNlp) { + this.hasNlp = hasNlp; + return this; + } + + @java.lang.Override + public _FinalStage includeNlpData(Boolean includeNlpData) { + this.includeNlpData = Optional.ofNullable(includeNlpData); + return this; + } + + @java.lang.Override + @JsonSetter(value = "include_nlp_data", nulls = Nulls.SKIP) + public _FinalStage includeNlpData(Optional includeNlpData) { + this.includeNlpData = includeNlpData; + return this; + } + + @java.lang.Override + public _FinalStage pageSize(Integer pageSize) { + this.pageSize = Optional.ofNullable(pageSize); + return this; + } + + @java.lang.Override + @JsonSetter(value = "page_size", nulls = Nulls.SKIP) + public _FinalStage pageSize(Optional pageSize) { + this.pageSize = pageSize; + return this; + } + + @java.lang.Override + public _FinalStage page(Integer page) { + this.page = Optional.ofNullable(page); + return this; + } + + @java.lang.Override + @JsonSetter(value = "page", nulls = Nulls.SKIP) + public _FinalStage page(Optional page) { + this.page = page; + return this; + } + + @java.lang.Override + public _FinalStage wordCountMax(Integer wordCountMax) { + this.wordCountMax = Optional.ofNullable(wordCountMax); + return this; + } + + @java.lang.Override + @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) + public _FinalStage wordCountMax(Optional wordCountMax) { + this.wordCountMax = wordCountMax; + return this; + } + + @java.lang.Override + public _FinalStage wordCountMin(Integer wordCountMin) { + this.wordCountMin = Optional.ofNullable(wordCountMin); + return this; + } + + @java.lang.Override + @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) + public _FinalStage wordCountMin(Optional wordCountMin) { + this.wordCountMin = wordCountMin; + return this; + } + + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allLinksText(String allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ */ + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + + /** + *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

+ *

For more details, see Search by URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allDomainLinks(String allDomainLinks) { + this.allDomainLinks = Optional.ofNullable(allDomainLinks); + return this; + } + + /** + *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

+ *

For more details, see Search by URL.

+ */ + @java.lang.Override + @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) + public _FinalStage allDomainLinks(Optional allDomainLinks) { + this.allDomainLinks = allDomainLinks; + return this; + } + + /** + *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

+ *

For more details, see Search by URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allLinks(String allLinks) { + this.allLinks = Optional.ofNullable(allLinks); + return this; + } + + /** + *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

+ *

For more details, see Search by URL.

+ */ + @java.lang.Override + @JsonSetter(value = "all_links", nulls = Nulls.SKIP) + public _FinalStage allLinks(Optional allLinks) { + this.allLinks = allLinks; + return this; + } + + /** + *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parentUrl(String parentUrl) { + this.parentUrl = Optional.ofNullable(parentUrl); + return this; + } + + /** + *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

+ */ + @java.lang.Override + @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) + public _FinalStage parentUrl(Optional parentUrl) { + this.parentUrl = parentUrl; + return this; + } + + @java.lang.Override + public _FinalStage isPaidContent(Boolean isPaidContent) { + this.isPaidContent = Optional.ofNullable(isPaidContent); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) + public _FinalStage isPaidContent(Optional isPaidContent) { + this.isPaidContent = isPaidContent; + return this; + } + + @java.lang.Override + public _FinalStage isOpinion(Boolean isOpinion) { + this.isOpinion = Optional.ofNullable(isOpinion); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) + public _FinalStage isOpinion(Optional isOpinion) { + this.isOpinion = isOpinion; + return this; + } + + @java.lang.Override + public _FinalStage isHeadline(Boolean isHeadline) { + this.isHeadline = Optional.ofNullable(isHeadline); + return this; + } + + @java.lang.Override + @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) + public _FinalStage isHeadline(Optional isHeadline) { + this.isHeadline = isHeadline; + return this; + } + + @java.lang.Override + public _FinalStage toRank(Integer toRank) { + this.toRank = Optional.ofNullable(toRank); + return this; + } + + @java.lang.Override + @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) + public _FinalStage toRank(Optional toRank) { + this.toRank = toRank; + return this; + } + + @java.lang.Override + public _FinalStage fromRank(Integer fromRank) { + this.fromRank = Optional.ofNullable(fromRank); + return this; + } + + @java.lang.Override + @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) + public _FinalStage fromRank(Optional fromRank) { + this.fromRank = fromRank; + return this; + } + + @java.lang.Override + public _FinalStage rankedOnly(Boolean rankedOnly) { + this.rankedOnly = Optional.ofNullable(rankedOnly); + return this; + } + + @java.lang.Override + @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) + public _FinalStage rankedOnly(Optional rankedOnly) { + this.rankedOnly = rankedOnly; + return this; + } + + @java.lang.Override + public _FinalStage sortBy(SortBy sortBy) { + this.sortBy = Optional.ofNullable(sortBy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) + public _FinalStage sortBy(Optional sortBy) { + this.sortBy = sortBy; + return this; + } + + @java.lang.Override + public _FinalStage byParseDate(Boolean byParseDate) { + this.byParseDate = Optional.ofNullable(byParseDate); + return this; + } + + @java.lang.Override + @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) + public _FinalStage byParseDate(Optional byParseDate) { + this.byParseDate = byParseDate; + return this; + } + + @java.lang.Override + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { + this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); + return this; + } + + @java.lang.Override + @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { + this.publishedDatePrecision = publishedDatePrecision; + return this; + } + + @java.lang.Override + public _FinalStage to(To to) { + this.to = Optional.ofNullable(to); + return this; + } + + @java.lang.Override + @JsonSetter(value = "to_", nulls = Nulls.SKIP) + public _FinalStage to(Optional to) { + this.to = to; + return this; + } + + @java.lang.Override + public _FinalStage from(From from) { + this.from = Optional.ofNullable(from); + return this; + } + + @java.lang.Override + @JsonSetter(value = "from_", nulls = Nulls.SKIP) + public _FinalStage from(Optional from) { + this.from = from; + return this; + } + + /** + *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notAuthorName(String notAuthorName) { + this.notAuthorName = Optional.ofNullable(notAuthorName); + return this; + } + + /** + *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

+ */ + @java.lang.Override + @JsonSetter(value = "not_author_name", nulls = Nulls.SKIP) + public _FinalStage notAuthorName(Optional notAuthorName) { + this.notAuthorName = notAuthorName; + return this; + } + + /** + *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notCountries(String notCountries) { + this.notCountries = Optional.ofNullable(notCountries); + return this; + } + + /** + *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ */ + @java.lang.Override + @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) + public _FinalStage notCountries(Optional notCountries) { + this.notCountries = notCountries; + return this; + } + + /** + *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage countries(String countries) { + this.countries = Optional.ofNullable(countries); + return this; + } + + /** + *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Country.

+ */ + @java.lang.Override + @JsonSetter(value = "countries", nulls = Nulls.SKIP) + public _FinalStage countries(Optional countries) { + this.countries = countries; + return this; + } + + /** + *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notLang(String notLang) { + this.notLang = Optional.ofNullable(notLang); + return this; + } + + /** + *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ */ + @java.lang.Override + @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) + public _FinalStage notLang(Optional notLang) { + this.notLang = notLang; + return this; + } + + /** + *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage lang(String lang) { + this.lang = Optional.ofNullable(lang); + return this; + } + + /** + *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

+ *

To learn more, see Enumerated parameters > Language.

+ */ + @java.lang.Override + @JsonSetter(value = "lang", nulls = Nulls.SKIP) + public _FinalStage lang(Optional lang) { + this.lang = lang; + return this; + } + + /** + *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage notSources(String notSources) { + this.notSources = Optional.ofNullable(notSources); + return this; + } + + /** + *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

+ */ + @java.lang.Override + @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) + public _FinalStage notSources(Optional notSources) { + this.notSources = notSources; + return this; + } + + /** + *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage sources(String sources) { + this.sources = Optional.ofNullable(sources); + return this; + } + + /** + *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

+ */ + @java.lang.Override + @JsonSetter(value = "sources", nulls = Nulls.SKIP) + public _FinalStage sources(Optional sources) { + this.sources = sources; + return this; + } + + /** + *

Predefined top news sources per country.

+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage predefinedSources(String predefinedSources) { + this.predefinedSources = Optional.ofNullable(predefinedSources); + return this; + } + + /** + *

Predefined top news sources per country.

+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

+ */ + @java.lang.Override + @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) + public _FinalStage predefinedSources(Optional predefinedSources) { + this.predefinedSources = predefinedSources; + return this; + } + + @java.lang.Override + public _FinalStage searchIn(String searchIn) { + this.searchIn = Optional.ofNullable(searchIn); + return this; + } + + @java.lang.Override + @JsonSetter(value = "search_in", nulls = Nulls.SKIP) + public _FinalStage searchIn(Optional searchIn) { + this.searchIn = searchIn; + return this; + } + + @java.lang.Override + public _FinalStage aggregationBy(AggregationBy aggregationBy) { + this.aggregationBy = Optional.ofNullable(aggregationBy); + return this; + } + + @java.lang.Override + @JsonSetter(value = "aggregation_by", nulls = Nulls.SKIP) + public _FinalStage aggregationBy(Optional aggregationBy) { + this.aggregationBy = aggregationBy; + return this; + } + + @java.lang.Override + public GetAggregationCountRequest build() { + return new GetAggregationCountRequest( + q, + aggregationBy, + searchIn, + predefinedSources, + sources, + notSources, + lang, + notLang, + countries, + notCountries, + notAuthorName, + from, + to, + publishedDatePrecision, + byParseDate, + sortBy, + rankedOnly, + fromRank, + toRank, + isHeadline, + isOpinion, + isPaidContent, + parentUrl, + allLinks, + allDomainLinks, + allLinksText, + wordCountMin, + wordCountMax, + page, + pageSize, + includeNlpData, + hasNlp, + theme, + notTheme, + orgEntityName, + perEntityName, + locEntityName, + miscEntityName, + titleSentimentMin, + titleSentimentMax, + contentSentimentMin, + contentSentimentMax, + iptcTags, + notIptcTags, + robotsCompliant, + additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationPostRequest.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/requests/PostAggregationCountRequest.java similarity index 92% rename from src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationPostRequest.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/requests/PostAggregationCountRequest.java index 6166d06..616ea5b 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/requests/AggregationPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/requests/PostAggregationCountRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation.requests; +package com.newscatcher.api.resources.aggregationcount.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -15,6 +15,7 @@ import com.newscatcher.api.types.AggregationBy; import com.newscatcher.api.types.AllDomainLinks; import com.newscatcher.api.types.AllLinks; +import com.newscatcher.api.types.AllLinksText; import com.newscatcher.api.types.Countries; import com.newscatcher.api.types.From; import com.newscatcher.api.types.IptcTags; @@ -24,13 +25,10 @@ import com.newscatcher.api.types.NotIptcTags; import com.newscatcher.api.types.NotLang; import com.newscatcher.api.types.NotSources; -import com.newscatcher.api.types.NotTheme; import com.newscatcher.api.types.ParentUrl; import com.newscatcher.api.types.PredefinedSources; -import com.newscatcher.api.types.PublishedDatePrecision; import com.newscatcher.api.types.SortBy; import com.newscatcher.api.types.Sources; -import com.newscatcher.api.types.Theme; import com.newscatcher.api.types.To; import java.util.HashMap; import java.util.Map; @@ -39,8 +37,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AggregationPostRequest.Builder.class) -public final class AggregationPostRequest { +@JsonDeserialize(builder = PostAggregationCountRequest.Builder.class) +public final class PostAggregationCountRequest { private final String q; private final Optional aggregationBy; @@ -67,7 +65,7 @@ public final class AggregationPostRequest { private final Optional to; - private final Optional publishedDatePrecision; + private final Optional publishedDatePrecision; private final Optional byParseDate; @@ -91,6 +89,8 @@ public final class AggregationPostRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional wordCountMin; private final Optional wordCountMax; @@ -103,9 +103,9 @@ public final class AggregationPostRequest { private final Optional hasNlp; - private final Optional theme; + private final Optional theme; - private final Optional notTheme; + private final Optional notTheme; private final Optional orgEntityName; @@ -131,7 +131,7 @@ public final class AggregationPostRequest { private final Map additionalProperties; - private AggregationPostRequest( + private PostAggregationCountRequest( String q, Optional aggregationBy, Optional searchIn, @@ -145,7 +145,7 @@ private AggregationPostRequest( Optional notAuthorName, Optional from, Optional to, - Optional publishedDatePrecision, + Optional publishedDatePrecision, Optional byParseDate, Optional sortBy, Optional rankedOnly, @@ -157,14 +157,15 @@ private AggregationPostRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional wordCountMin, Optional wordCountMax, Optional page, Optional pageSize, Optional includeNlpData, Optional hasNlp, - Optional theme, - Optional notTheme, + Optional theme, + Optional notTheme, Optional orgEntityName, Optional perEntityName, Optional locEntityName, @@ -202,6 +203,7 @@ private AggregationPostRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.wordCountMin = wordCountMin; this.wordCountMax = wordCountMax; this.page = page; @@ -290,7 +292,7 @@ public Optional getTo() { } @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { + public Optional getPublishedDatePrecision() { return publishedDatePrecision; } @@ -349,6 +351,11 @@ public Optional getAllDomainLinks() { return allDomainLinks; } + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; @@ -380,12 +387,12 @@ public Optional getHasNlp() { } @JsonProperty("theme") - public Optional getTheme() { + public Optional getTheme() { return theme; } @JsonProperty("not_theme") - public Optional getNotTheme() { + public Optional getNotTheme() { return notTheme; } @@ -447,7 +454,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AggregationPostRequest && equalTo((AggregationPostRequest) other); + return other instanceof PostAggregationCountRequest && equalTo((PostAggregationCountRequest) other); } @JsonAnyGetter @@ -455,7 +462,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(AggregationPostRequest other) { + private boolean equalTo(PostAggregationCountRequest other) { return q.equals(other.q) && aggregationBy.equals(other.aggregationBy) && searchIn.equals(other.searchIn) @@ -481,6 +488,7 @@ private boolean equalTo(AggregationPostRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && wordCountMin.equals(other.wordCountMin) && wordCountMax.equals(other.wordCountMax) && page.equals(other.page) @@ -530,6 +538,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.wordCountMin, this.wordCountMax, this.page, @@ -563,11 +572,15 @@ public static QStage builder() { public interface QStage { _FinalStage q(@NotNull String q); - Builder from(AggregationPostRequest other); + Builder from(PostAggregationCountRequest other); } public interface _FinalStage { - AggregationPostRequest build(); + PostAggregationCountRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); _FinalStage aggregationBy(Optional aggregationBy); @@ -617,9 +630,9 @@ public interface _FinalStage { _FinalStage to(To to); - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision); + _FinalStage publishedDatePrecision(String publishedDatePrecision); _FinalStage byParseDate(Optional byParseDate); @@ -665,6 +678,10 @@ public interface _FinalStage { _FinalStage allDomainLinks(AllDomainLinks allDomainLinks); + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(AllLinksText allLinksText); + _FinalStage wordCountMin(Optional wordCountMin); _FinalStage wordCountMin(Integer wordCountMin); @@ -689,13 +706,13 @@ public interface _FinalStage { _FinalStage hasNlp(Boolean hasNlp); - _FinalStage theme(Optional theme); + _FinalStage theme(Optional theme); - _FinalStage theme(Theme theme); + _FinalStage theme(String theme); - _FinalStage notTheme(Optional notTheme); + _FinalStage notTheme(Optional notTheme); - _FinalStage notTheme(NotTheme notTheme); + _FinalStage notTheme(String notTheme); _FinalStage orgEntityName(Optional orgEntityName); @@ -768,9 +785,9 @@ public static final class Builder implements QStage, _FinalStage { private Optional orgEntityName = Optional.empty(); - private Optional notTheme = Optional.empty(); + private Optional notTheme = Optional.empty(); - private Optional theme = Optional.empty(); + private Optional theme = Optional.empty(); private Optional hasNlp = Optional.empty(); @@ -784,6 +801,8 @@ public static final class Builder implements QStage, _FinalStage { private Optional wordCountMin = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -806,7 +825,7 @@ public static final class Builder implements QStage, _FinalStage { private Optional byParseDate = Optional.empty(); - private Optional publishedDatePrecision = Optional.empty(); + private Optional publishedDatePrecision = Optional.empty(); private Optional to = Optional.empty(); @@ -838,7 +857,7 @@ public static final class Builder implements QStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(AggregationPostRequest other) { + public Builder from(PostAggregationCountRequest other) { q(other.getQ()); aggregationBy(other.getAggregationBy()); searchIn(other.getSearchIn()); @@ -864,6 +883,7 @@ public Builder from(AggregationPostRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); wordCountMin(other.getWordCountMin()); wordCountMax(other.getWordCountMax()); page(other.getPage()); @@ -1037,27 +1057,27 @@ public _FinalStage orgEntityName(Optional orgEntityName) { } @java.lang.Override - public _FinalStage notTheme(NotTheme notTheme) { + public _FinalStage notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } @java.lang.Override @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { + public _FinalStage notTheme(Optional notTheme) { this.notTheme = notTheme; return this; } @java.lang.Override - public _FinalStage theme(Theme theme) { + public _FinalStage theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } @java.lang.Override @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { + public _FinalStage theme(Optional theme) { this.theme = theme; return this; } @@ -1140,6 +1160,19 @@ public _FinalStage wordCountMin(Optional wordCountMin) { return this; } + @java.lang.Override + public _FinalStage allLinksText(AllLinksText allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + @java.lang.Override public _FinalStage allDomainLinks(AllDomainLinks allDomainLinks) { this.allDomainLinks = Optional.ofNullable(allDomainLinks); @@ -1284,14 +1317,14 @@ public _FinalStage byParseDate(Optional byParseDate) { } @java.lang.Override - public _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision) { + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); return this; } @java.lang.Override @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { this.publishedDatePrecision = publishedDatePrecision; return this; } @@ -1453,8 +1486,8 @@ public _FinalStage aggregationBy(Optional aggregationBy) { } @java.lang.Override - public AggregationPostRequest build() { - return new AggregationPostRequest( + public PostAggregationCountRequest build() { + return new PostAggregationCountRequest( q, aggregationBy, searchIn, @@ -1480,6 +1513,7 @@ public AggregationPostRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, wordCountMin, wordCountMax, page, @@ -1501,5 +1535,17 @@ public AggregationPostRequest build() { robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationPostResponse.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/types/GetAggregationCountResponse.java similarity index 70% rename from src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationPostResponse.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/types/GetAggregationCountResponse.java index e9e7f78..69633a3 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationPostResponse.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/types/GetAggregationCountResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation.types; +package com.newscatcher.api.resources.aggregationcount.types; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonParseException; @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = AggregationPostResponse.Deserializer.class) -public final class AggregationPostResponse { +@JsonDeserialize(using = GetAggregationCountResponse.Deserializer.class) +public final class GetAggregationCountResponse { private final Object value; private final int type; - private AggregationPostResponse(Object value, int type) { + private GetAggregationCountResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AggregationPostResponse && equalTo((AggregationPostResponse) other); + return other instanceof GetAggregationCountResponse && equalTo((GetAggregationCountResponse) other); } - private boolean equalTo(AggregationPostResponse other) { + private boolean equalTo(GetAggregationCountResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static AggregationPostResponse of(AggregationCountResponseDto value) { - return new AggregationPostResponse(value, 0); + public static GetAggregationCountResponse of(AggregationCountResponseDto value) { + return new GetAggregationCountResponse(value, 0); } - public static AggregationPostResponse of(FailedAggregationCountResponseDto value) { - return new AggregationPostResponse(value, 1); + public static GetAggregationCountResponse of(FailedAggregationCountResponseDto value) { + return new GetAggregationCountResponse(value, 1); } public interface Visitor { @@ -75,13 +75,14 @@ public interface Visitor { T visit(FailedAggregationCountResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(AggregationPostResponse.class); + super(GetAggregationCountResponse.class); } @java.lang.Override - public AggregationPostResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public GetAggregationCountResponse deserialize(JsonParser p, DeserializationContext context) + throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, AggregationCountResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetResponse.java b/src/main/java/com/newscatcher/api/resources/aggregationcount/types/PostAggregationCountResponse.java similarity index 70% rename from src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetResponse.java rename to src/main/java/com/newscatcher/api/resources/aggregationcount/types/PostAggregationCountResponse.java index e021447..6b9e621 100644 --- a/src/main/java/com/newscatcher/api/resources/aggregation/types/AggregationGetResponse.java +++ b/src/main/java/com/newscatcher/api/resources/aggregationcount/types/PostAggregationCountResponse.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.aggregation.types; +package com.newscatcher.api.resources.aggregationcount.types; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonParseException; @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = AggregationGetResponse.Deserializer.class) -public final class AggregationGetResponse { +@JsonDeserialize(using = PostAggregationCountResponse.Deserializer.class) +public final class PostAggregationCountResponse { private final Object value; private final int type; - private AggregationGetResponse(Object value, int type) { + private PostAggregationCountResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AggregationGetResponse && equalTo((AggregationGetResponse) other); + return other instanceof PostAggregationCountResponse && equalTo((PostAggregationCountResponse) other); } - private boolean equalTo(AggregationGetResponse other) { + private boolean equalTo(PostAggregationCountResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static AggregationGetResponse of(AggregationCountResponseDto value) { - return new AggregationGetResponse(value, 0); + public static PostAggregationCountResponse of(AggregationCountResponseDto value) { + return new PostAggregationCountResponse(value, 0); } - public static AggregationGetResponse of(FailedAggregationCountResponseDto value) { - return new AggregationGetResponse(value, 1); + public static PostAggregationCountResponse of(FailedAggregationCountResponseDto value) { + return new PostAggregationCountResponse(value, 1); } public interface Visitor { @@ -75,13 +75,14 @@ public interface Visitor { T visit(FailedAggregationCountResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(AggregationGetResponse.class); + super(PostAggregationCountResponse.class); } @java.lang.Override - public AggregationGetResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public PostAggregationCountResponse deserialize(JsonParser p, DeserializationContext context) + throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, AggregationCountResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/authors/AsyncAuthorsClient.java b/src/main/java/com/newscatcher/api/resources/authors/AsyncAuthorsClient.java index 7532a62..9aadd6d 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/AsyncAuthorsClient.java +++ b/src/main/java/com/newscatcher/api/resources/authors/AsyncAuthorsClient.java @@ -5,10 +5,10 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.authors.requests.AuthorsGetRequest; -import com.newscatcher.api.resources.authors.requests.AuthorsPostRequest; -import com.newscatcher.api.resources.authors.types.AuthorsGetResponse; -import com.newscatcher.api.resources.authors.types.AuthorsPostResponse; +import com.newscatcher.api.resources.authors.requests.GetAuthorsRequest; +import com.newscatcher.api.resources.authors.requests.PostAuthorsRequest; +import com.newscatcher.api.resources.authors.types.GetAuthorsResponse; +import com.newscatcher.api.resources.authors.types.PostAuthorsResponse; import java.util.concurrent.CompletableFuture; public class AsyncAuthorsClient { @@ -31,28 +31,28 @@ public AsyncRawAuthorsClient withRawResponse() { /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public CompletableFuture get(AuthorsGetRequest request) { + public CompletableFuture get(GetAuthorsRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public CompletableFuture get(AuthorsGetRequest request, RequestOptions requestOptions) { + public CompletableFuture get(GetAuthorsRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public CompletableFuture post(AuthorsPostRequest request) { + public CompletableFuture post(PostAuthorsRequest request) { return this.rawClient.post(request).thenApply(response -> response.body()); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public CompletableFuture post(AuthorsPostRequest request, RequestOptions requestOptions) { + public CompletableFuture post(PostAuthorsRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/authors/AsyncRawAuthorsClient.java b/src/main/java/com/newscatcher/api/resources/authors/AsyncRawAuthorsClient.java index 1b5313d..45ac4e0 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/AsyncRawAuthorsClient.java +++ b/src/main/java/com/newscatcher/api/resources/authors/AsyncRawAuthorsClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.authors.requests.AuthorsGetRequest; -import com.newscatcher.api.resources.authors.requests.AuthorsPostRequest; -import com.newscatcher.api.resources.authors.types.AuthorsGetResponse; -import com.newscatcher.api.resources.authors.types.AuthorsPostResponse; +import com.newscatcher.api.resources.authors.requests.GetAuthorsRequest; +import com.newscatcher.api.resources.authors.requests.PostAuthorsRequest; +import com.newscatcher.api.resources.authors.types.GetAuthorsResponse; +import com.newscatcher.api.resources.authors.types.PostAuthorsResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -47,15 +47,15 @@ public AsyncRawAuthorsClient(ClientOptions clientOptions) { /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public CompletableFuture> get(AuthorsGetRequest request) { + public CompletableFuture> get(GetAuthorsRequest request) { return get(request, null); } /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public CompletableFuture> get( - AuthorsGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get( + GetAuthorsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/authors"); @@ -153,6 +153,10 @@ public CompletableFuture> get( QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -248,6 +252,11 @@ public CompletableFuture> get( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -258,18 +267,18 @@ public CompletableFuture> get( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AuthorsGetResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAuthorsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -311,11 +320,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -334,19 +341,23 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public CompletableFuture> post(AuthorsPostRequest request) { + public CompletableFuture> post(PostAuthorsRequest request) { return post(request, null); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public CompletableFuture> post( - AuthorsPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostAuthorsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/authors") - .build(); + .addPathSegments("api/authors"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -355,7 +366,7 @@ public CompletableFuture> post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -365,18 +376,18 @@ public CompletableFuture> post( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AuthorsPostResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostAuthorsResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -418,11 +429,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/authors/AuthorsClient.java b/src/main/java/com/newscatcher/api/resources/authors/AuthorsClient.java index 74b7dac..a2d01ad 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/AuthorsClient.java +++ b/src/main/java/com/newscatcher/api/resources/authors/AuthorsClient.java @@ -5,10 +5,10 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.authors.requests.AuthorsGetRequest; -import com.newscatcher.api.resources.authors.requests.AuthorsPostRequest; -import com.newscatcher.api.resources.authors.types.AuthorsGetResponse; -import com.newscatcher.api.resources.authors.types.AuthorsPostResponse; +import com.newscatcher.api.resources.authors.requests.GetAuthorsRequest; +import com.newscatcher.api.resources.authors.requests.PostAuthorsRequest; +import com.newscatcher.api.resources.authors.types.GetAuthorsResponse; +import com.newscatcher.api.resources.authors.types.PostAuthorsResponse; public class AuthorsClient { protected final ClientOptions clientOptions; @@ -30,28 +30,28 @@ public RawAuthorsClient withRawResponse() { /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public AuthorsGetResponse get(AuthorsGetRequest request) { + public GetAuthorsResponse get(GetAuthorsRequest request) { return this.rawClient.get(request).body(); } /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public AuthorsGetResponse get(AuthorsGetRequest request, RequestOptions requestOptions) { + public GetAuthorsResponse get(GetAuthorsRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public AuthorsPostResponse post(AuthorsPostRequest request) { + public PostAuthorsResponse post(PostAuthorsRequest request) { return this.rawClient.post(request).body(); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public AuthorsPostResponse post(AuthorsPostRequest request, RequestOptions requestOptions) { + public PostAuthorsResponse post(PostAuthorsRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/authors/RawAuthorsClient.java b/src/main/java/com/newscatcher/api/resources/authors/RawAuthorsClient.java index fd85c39..44c3ee6 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/RawAuthorsClient.java +++ b/src/main/java/com/newscatcher/api/resources/authors/RawAuthorsClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.authors.requests.AuthorsGetRequest; -import com.newscatcher.api.resources.authors.requests.AuthorsPostRequest; -import com.newscatcher.api.resources.authors.types.AuthorsGetResponse; -import com.newscatcher.api.resources.authors.types.AuthorsPostResponse; +import com.newscatcher.api.resources.authors.requests.GetAuthorsRequest; +import com.newscatcher.api.resources.authors.requests.PostAuthorsRequest; +import com.newscatcher.api.resources.authors.types.GetAuthorsResponse; +import com.newscatcher.api.resources.authors.types.PostAuthorsResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import okhttp3.Headers; @@ -43,15 +43,15 @@ public RawAuthorsClient(ClientOptions clientOptions) { /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse get(AuthorsGetRequest request) { + public NewscatcherApiHttpResponse get(GetAuthorsRequest request) { return get(request, null); } /** * Searches for articles written by a specified author. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse get( - AuthorsGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get( + GetAuthorsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/authors"); @@ -149,6 +149,10 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -244,6 +248,11 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -256,11 +265,11 @@ public NewscatcherApiHttpResponse get( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AuthorsGetResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetAuthorsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -288,11 +297,9 @@ public NewscatcherApiHttpResponse get( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -301,19 +308,23 @@ public NewscatcherApiHttpResponse get( /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse post(AuthorsPostRequest request) { + public NewscatcherApiHttpResponse post(PostAuthorsRequest request) { return post(request, null); } /** * Searches for articles by author. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse post( - AuthorsPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostAuthorsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/authors") - .build(); + .addPathSegments("api/authors"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -322,7 +333,7 @@ public NewscatcherApiHttpResponse post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -334,12 +345,11 @@ public NewscatcherApiHttpResponse post( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AuthorsPostResponse.class), - response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostAuthorsResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -367,11 +377,9 @@ public NewscatcherApiHttpResponse post( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsGetRequest.java b/src/main/java/com/newscatcher/api/resources/authors/requests/GetAuthorsRequest.java similarity index 55% rename from src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsGetRequest.java rename to src/main/java/com/newscatcher/api/resources/authors/requests/GetAuthorsRequest.java index 4f336c8..f89605f 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/authors/requests/GetAuthorsRequest.java @@ -12,9 +12,9 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.authors.types.AuthorsGetRequestPublishedDatePrecision; -import com.newscatcher.api.resources.authors.types.AuthorsGetRequestSortBy; -import java.time.OffsetDateTime; +import com.newscatcher.api.types.From; +import com.newscatcher.api.types.SortBy; +import com.newscatcher.api.types.To; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -22,8 +22,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AuthorsGetRequest.Builder.class) -public final class AuthorsGetRequest { +@JsonDeserialize(builder = GetAuthorsRequest.Builder.class) +public final class GetAuthorsRequest { private final String authorName; private final Optional notAuthorName; @@ -42,15 +42,15 @@ public final class AuthorsGetRequest { private final Optional notCountries; - private final Optional from; + private final Optional from; - private final Optional to; + private final Optional to; - private final Optional publishedDatePrecision; + private final Optional publishedDatePrecision; private final Optional byParseDate; - private final Optional sortBy; + private final Optional sortBy; private final Optional rankedOnly; @@ -70,6 +70,8 @@ public final class AuthorsGetRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional wordCountMin; private final Optional wordCountMax; @@ -112,7 +114,7 @@ public final class AuthorsGetRequest { private final Map additionalProperties; - private AuthorsGetRequest( + private GetAuthorsRequest( String authorName, Optional notAuthorName, Optional predefinedSources, @@ -122,11 +124,11 @@ private AuthorsGetRequest( Optional notLang, Optional countries, Optional notCountries, - Optional from, - Optional to, - Optional publishedDatePrecision, + Optional from, + Optional to, + Optional publishedDatePrecision, Optional byParseDate, - Optional sortBy, + Optional sortBy, Optional rankedOnly, Optional fromRank, Optional toRank, @@ -136,6 +138,7 @@ private AuthorsGetRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional wordCountMin, Optional wordCountMax, Optional page, @@ -180,6 +183,7 @@ private AuthorsGetRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.wordCountMin = wordCountMin; this.wordCountMax = wordCountMax; this.page = page; @@ -203,9 +207,6 @@ private AuthorsGetRequest( this.additionalProperties = additionalProperties; } - /** - * @return The name of the author to search for. This parameter returns exact matches only. - */ @JsonProperty("author_name") public String getAuthorName() { return authorName; @@ -213,7 +214,6 @@ public String getAuthorName() { /** * @return The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - *

Example: "John Doe, Jane Doe"

*/ @JsonProperty("not_author_name") public Optional getNotAuthorName() { @@ -222,14 +222,8 @@ public Optional getNotAuthorName() { /** * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonProperty("predefined_sources") public Optional getPredefinedSources() { @@ -238,11 +232,6 @@ public Optional getPredefinedSources() { /** * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. - *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @JsonProperty("sources") public Optional getSources() { @@ -251,7 +240,6 @@ public Optional getSources() { /** * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - *

Example: "cnn.com, wsj.com"

*/ @JsonProperty("not_sources") public Optional getNotSources() { @@ -260,8 +248,7 @@ public Optional getNotSources() { /** * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("lang") public Optional getLang() { @@ -270,8 +257,7 @@ public Optional getLang() { /** * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. - *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("not_lang") public Optional getNotLang() { @@ -280,8 +266,7 @@ public Optional getNotLang() { /** * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("countries") public Optional getCountries() { @@ -290,125 +275,63 @@ public Optional getCountries() { /** * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. - *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("not_countries") public Optional getNotCountries() { return notCountries; } - /** - * @return The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @JsonProperty("from_") - public Optional getFrom() { + public Optional getFrom() { return from; } - /** - * @return The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @JsonProperty("to_") - public Optional getTo() { + public Optional getTo() { return to; } - /** - * @return The precision of the published date. There are three types: - *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { + public Optional getPublishedDatePrecision() { return publishedDatePrecision; } - /** - * @return If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object. - */ @JsonProperty("by_parse_date") public Optional getByParseDate() { return byParseDate; } - /** - * @return The sorting order of the results. Possible values are: - *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @JsonProperty("sort_by") - public Optional getSortBy() { + public Optional getSortBy() { return sortBy; } - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ @JsonProperty("ranked_only") public Optional getRankedOnly() { return rankedOnly; } - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("from_rank") public Optional getFromRank() { return fromRank; } - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("to_rank") public Optional getToRank() { return toRank; } - /** - * @return If true, only returns articles that were posted on the home page of a given news domain. - */ @JsonProperty("is_headline") public Optional getIsHeadline() { return isHeadline; } - /** - * @return If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - */ @JsonProperty("is_opinion") public Optional getIsOpinion() { return isOpinion; } - /** - * @return If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - */ @JsonProperty("is_paid_content") public Optional getIsPaidContent() { return isPaidContent; @@ -416,7 +339,6 @@ public Optional getIsPaidContent() { /** * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - *

Example: "wsj.com/politics, wsj.com/tech"

*/ @JsonProperty("parent_url") public Optional getParentUrl() { @@ -425,8 +347,7 @@ public Optional getParentUrl() { /** * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_links") public Optional getAllLinks() { @@ -435,8 +356,7 @@ public Optional getAllLinks() { /** * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_domain_links") public Optional getAllDomainLinks() { @@ -444,33 +364,30 @@ public Optional getAllDomainLinks() { } /** - * @return The minimum number of words an article must contain. To be used for avoiding articles with small content. + * @return The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; } - /** - * @return The maximum number of words an article can contain. To be used for avoiding articles with large content. - */ @JsonProperty("word_count_max") public Optional getWordCountMax() { return wordCountMax; } - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ @JsonProperty("page") public Optional getPage() { return page; } - /** - * @return The number of articles to return per page. - */ @JsonProperty("page_size") public Optional getPageSize() { return pageSize; @@ -491,97 +408,36 @@ public Optional getHasNlp() { return hasNlp; } - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonProperty("theme") public Optional getTheme() { return theme; } - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("not_theme") public Optional getNotTheme() { return notTheme; } - /** - * @return The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string. - *

Example: "Tesla, Amazon"

- */ @JsonProperty("ner_name") public Optional getNerName() { return nerName; } - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_min") public Optional getTitleSentimentMin() { return titleSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_max") public Optional getTitleSentimentMax() { return titleSentimentMax; } - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_min") public Optional getContentSentimentMin() { return contentSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_max") public Optional getContentSentimentMax() { return contentSentimentMax; @@ -589,7 +445,6 @@ public Optional getContentSentimentMax() { /** * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -600,7 +455,6 @@ public Optional getIptcTags() { /** * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -611,7 +465,6 @@ public Optional getNotIptcTags() { /** * @return Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -622,7 +475,6 @@ public Optional getIabTags() { /** * @return Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -634,19 +486,16 @@ public Optional getNotIabTags() { /** * @return Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @JsonProperty("custom_tags") public Optional getCustomTags() { return customTags; } - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ @JsonProperty("robots_compliant") public Optional getRobotsCompliant() { return robotsCompliant; @@ -655,7 +504,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AuthorsGetRequest && equalTo((AuthorsGetRequest) other); + return other instanceof GetAuthorsRequest && equalTo((GetAuthorsRequest) other); } @JsonAnyGetter @@ -663,7 +512,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(AuthorsGetRequest other) { + private boolean equalTo(GetAuthorsRequest other) { return authorName.equals(other.authorName) && notAuthorName.equals(other.notAuthorName) && predefinedSources.equals(other.predefinedSources) @@ -687,6 +536,7 @@ private boolean equalTo(AuthorsGetRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && wordCountMin.equals(other.wordCountMin) && wordCountMax.equals(other.wordCountMax) && page.equals(other.page) @@ -735,6 +585,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.wordCountMin, this.wordCountMax, this.page, @@ -767,20 +618,20 @@ public static AuthorNameStage builder() { } public interface AuthorNameStage { - /** - *

The name of the author to search for. This parameter returns exact matches only.

- */ _FinalStage authorName(@NotNull String authorName); - Builder from(AuthorsGetRequest other); + Builder from(GetAuthorsRequest other); } public interface _FinalStage { - AuthorsGetRequest build(); + GetAuthorsRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

*/ _FinalStage notAuthorName(Optional notAuthorName); @@ -788,14 +639,8 @@ public interface _FinalStage { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ _FinalStage predefinedSources(Optional predefinedSources); @@ -803,11 +648,6 @@ public interface _FinalStage { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ _FinalStage sources(Optional sources); @@ -815,7 +655,6 @@ public interface _FinalStage { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

*/ _FinalStage notSources(Optional notSources); @@ -823,8 +662,7 @@ public interface _FinalStage { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ _FinalStage lang(Optional lang); @@ -832,8 +670,7 @@ public interface _FinalStage { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ _FinalStage notLang(Optional notLang); @@ -841,8 +678,7 @@ public interface _FinalStage { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ _FinalStage countries(Optional countries); @@ -850,121 +686,58 @@ public interface _FinalStage { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ _FinalStage notCountries(Optional notCountries); _FinalStage notCountries(String notCountries); - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage from(Optional from); + _FinalStage from(Optional from); - _FinalStage from(OffsetDateTime from); + _FinalStage from(From from); - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage to(Optional to); + _FinalStage to(Optional to); - _FinalStage to(OffsetDateTime to); + _FinalStage to(To to); - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - _FinalStage publishedDatePrecision(AuthorsGetRequestPublishedDatePrecision publishedDatePrecision); + _FinalStage publishedDatePrecision(String publishedDatePrecision); - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ _FinalStage byParseDate(Optional byParseDate); _FinalStage byParseDate(Boolean byParseDate); - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - _FinalStage sortBy(Optional sortBy); + _FinalStage sortBy(Optional sortBy); - _FinalStage sortBy(AuthorsGetRequestSortBy sortBy); + _FinalStage sortBy(SortBy sortBy); - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ _FinalStage rankedOnly(Optional rankedOnly); _FinalStage rankedOnly(Boolean rankedOnly); - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ _FinalStage fromRank(Optional fromRank); _FinalStage fromRank(Integer fromRank); - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ _FinalStage toRank(Optional toRank); _FinalStage toRank(Integer toRank); - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ _FinalStage isHeadline(Optional isHeadline); _FinalStage isHeadline(Boolean isHeadline); - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ _FinalStage isOpinion(Optional isOpinion); _FinalStage isOpinion(Boolean isOpinion); - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ _FinalStage isPaidContent(Optional isPaidContent); _FinalStage isPaidContent(Boolean isPaidContent); /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

*/ _FinalStage parentUrl(Optional parentUrl); @@ -972,8 +745,7 @@ public interface _FinalStage { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ _FinalStage allLinks(Optional allLinks); @@ -981,38 +753,33 @@ public interface _FinalStage { /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ _FinalStage allDomainLinks(Optional allDomainLinks); _FinalStage allDomainLinks(String allDomainLinks); /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

+ *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(String allLinksText); + _FinalStage wordCountMin(Optional wordCountMin); _FinalStage wordCountMin(Integer wordCountMin); - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ _FinalStage wordCountMax(Optional wordCountMax); _FinalStage wordCountMax(Integer wordCountMax); - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ _FinalStage page(Optional page); _FinalStage page(Integer page); - /** - *

The number of articles to return per page.

- */ _FinalStage pageSize(Optional pageSize); _FinalStage pageSize(Integer pageSize); @@ -1029,98 +796,36 @@ public interface _FinalStage { _FinalStage hasNlp(Boolean hasNlp); - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ _FinalStage theme(Optional theme); _FinalStage theme(String theme); - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage notTheme(Optional notTheme); _FinalStage notTheme(String notTheme); - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- */ _FinalStage nerName(Optional nerName); _FinalStage nerName(String nerName); - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage titleSentimentMin(Optional titleSentimentMin); _FinalStage titleSentimentMin(Float titleSentimentMin); - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage titleSentimentMax(Optional titleSentimentMax); _FinalStage titleSentimentMax(Float titleSentimentMax); - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage contentSentimentMin(Optional contentSentimentMin); _FinalStage contentSentimentMin(Float contentSentimentMin); - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage contentSentimentMax(Optional contentSentimentMax); _FinalStage contentSentimentMax(Float contentSentimentMax); /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1130,7 +835,6 @@ public interface _FinalStage { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1140,7 +844,6 @@ public interface _FinalStage { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1150,7 +853,6 @@ public interface _FinalStage { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1161,18 +863,15 @@ public interface _FinalStage { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ _FinalStage customTags(Optional customTags); _FinalStage customTags(String customTags); - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ _FinalStage robotsCompliant(Optional robotsCompliant); _FinalStage robotsCompliant(Boolean robotsCompliant); @@ -1222,6 +921,8 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Optional wordCountMin = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -1240,15 +941,15 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Optional rankedOnly = Optional.empty(); - private Optional sortBy = Optional.empty(); + private Optional sortBy = Optional.empty(); private Optional byParseDate = Optional.empty(); - private Optional publishedDatePrecision = Optional.empty(); + private Optional publishedDatePrecision = Optional.empty(); - private Optional to = Optional.empty(); + private Optional to = Optional.empty(); - private Optional from = Optional.empty(); + private Optional from = Optional.empty(); private Optional notCountries = Optional.empty(); @@ -1272,7 +973,7 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(AuthorsGetRequest other) { + public Builder from(GetAuthorsRequest other) { authorName(other.getAuthorName()); notAuthorName(other.getNotAuthorName()); predefinedSources(other.getPredefinedSources()); @@ -1296,6 +997,7 @@ public Builder from(AuthorsGetRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); wordCountMin(other.getWordCountMin()); wordCountMax(other.getWordCountMax()); page(other.getPage()); @@ -1319,11 +1021,6 @@ public Builder from(AuthorsGetRequest other) { return this; } - /** - *

The name of the author to search for. This parameter returns exact matches only.

- *

The name of the author to search for. This parameter returns exact matches only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override @JsonSetter("author_name") public _FinalStage authorName(@NotNull String authorName) { @@ -1331,19 +1028,12 @@ public _FinalStage authorName(@NotNull String authorName) { return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage robotsCompliant(Boolean robotsCompliant) { this.robotsCompliant = Optional.ofNullable(robotsCompliant); return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ @java.lang.Override @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) public _FinalStage robotsCompliant(Optional robotsCompliant) { @@ -1354,10 +1044,10 @@ public _FinalStage robotsCompliant(Optional robotsCompliant) { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1369,10 +1059,10 @@ public _FinalStage customTags(String customTags) { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @java.lang.Override @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) @@ -1383,7 +1073,6 @@ public _FinalStage customTags(Optional customTags) { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1396,7 +1085,6 @@ public _FinalStage notIabTags(String notIabTags) { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1409,7 +1097,6 @@ public _FinalStage notIabTags(Optional notIabTags) { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1422,7 +1109,6 @@ public _FinalStage iabTags(String iabTags) { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1435,7 +1121,6 @@ public _FinalStage iabTags(Optional iabTags) { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1448,7 +1133,6 @@ public _FinalStage notIptcTags(String notIptcTags) { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1461,7 +1145,6 @@ public _FinalStage notIptcTags(Optional notIptcTags) { /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1474,7 +1157,6 @@ public _FinalStage iptcTags(String iptcTags) { /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1485,35 +1167,12 @@ public _FinalStage iptcTags(Optional iptcTags) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage contentSentimentMax(Float contentSentimentMax) { this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) public _FinalStage contentSentimentMax(Optional contentSentimentMax) { @@ -1521,35 +1180,12 @@ public _FinalStage contentSentimentMax(Optional contentSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage contentSentimentMin(Float contentSentimentMin) { this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) public _FinalStage contentSentimentMin(Optional contentSentimentMin) { @@ -1557,35 +1193,12 @@ public _FinalStage contentSentimentMin(Optional contentSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage titleSentimentMax(Float titleSentimentMax) { this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) public _FinalStage titleSentimentMax(Optional titleSentimentMax) { @@ -1593,35 +1206,12 @@ public _FinalStage titleSentimentMax(Optional titleSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage titleSentimentMin(Float titleSentimentMin) { this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) public _FinalStage titleSentimentMin(Optional titleSentimentMin) { @@ -1629,21 +1219,12 @@ public _FinalStage titleSentimentMin(Optional titleSentimentMin) { return this; } - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage nerName(String nerName) { this.nerName = Optional.ofNullable(nerName); return this; } - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- */ @java.lang.Override @JsonSetter(value = "ner_name", nulls = Nulls.SKIP) public _FinalStage nerName(Optional nerName) { @@ -1651,25 +1232,12 @@ public _FinalStage nerName(Optional nerName) { return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) public _FinalStage notTheme(Optional notTheme) { @@ -1677,27 +1245,12 @@ public _FinalStage notTheme(Optional notTheme) { return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @java.lang.Override @JsonSetter(value = "theme", nulls = Nulls.SKIP) public _FinalStage theme(Optional theme) { @@ -1744,19 +1297,12 @@ public _FinalStage includeTranslationFields(Optional includeTranslation return this; } - /** - *

The number of articles to return per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage pageSize(Integer pageSize) { this.pageSize = Optional.ofNullable(pageSize); return this; } - /** - *

The number of articles to return per page.

- */ @java.lang.Override @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public _FinalStage pageSize(Optional pageSize) { @@ -1764,21 +1310,12 @@ public _FinalStage pageSize(Optional pageSize) { return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage page(Integer page) { this.page = Optional.ofNullable(page); return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ @java.lang.Override @JsonSetter(value = "page", nulls = Nulls.SKIP) public _FinalStage page(Optional page) { @@ -1786,19 +1323,12 @@ public _FinalStage page(Optional page) { return this; } - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage wordCountMax(Integer wordCountMax) { this.wordCountMax = Optional.ofNullable(wordCountMax); return this; } - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ @java.lang.Override @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) public _FinalStage wordCountMax(Optional wordCountMax) { @@ -1806,19 +1336,12 @@ public _FinalStage wordCountMax(Optional wordCountMax) { return this; } - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage wordCountMin(Integer wordCountMin) { this.wordCountMin = Optional.ofNullable(wordCountMin); return this; } - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ @java.lang.Override @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) public _FinalStage wordCountMin(Optional wordCountMin) { @@ -1826,10 +1349,33 @@ public _FinalStage wordCountMin(Optional wordCountMin) { return this; } + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allLinksText(String allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ */ + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1840,8 +1386,7 @@ public _FinalStage allDomainLinks(String allDomainLinks) { /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @java.lang.Override @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) @@ -1852,8 +1397,7 @@ public _FinalStage allDomainLinks(Optional allDomainLinks) { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1864,8 +1408,7 @@ public _FinalStage allLinks(String allLinks) { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @java.lang.Override @JsonSetter(value = "all_links", nulls = Nulls.SKIP) @@ -1876,7 +1419,6 @@ public _FinalStage allLinks(Optional allLinks) { /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1887,7 +1429,6 @@ public _FinalStage parentUrl(String parentUrl) { /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

*/ @java.lang.Override @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) @@ -1896,19 +1437,12 @@ public _FinalStage parentUrl(Optional parentUrl) { return this; } - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isPaidContent(Boolean isPaidContent) { this.isPaidContent = Optional.ofNullable(isPaidContent); return this; } - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ @java.lang.Override @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) public _FinalStage isPaidContent(Optional isPaidContent) { @@ -1916,19 +1450,12 @@ public _FinalStage isPaidContent(Optional isPaidContent) { return this; } - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isOpinion(Boolean isOpinion) { this.isOpinion = Optional.ofNullable(isOpinion); return this; } - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ @java.lang.Override @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) public _FinalStage isOpinion(Optional isOpinion) { @@ -1936,19 +1463,12 @@ public _FinalStage isOpinion(Optional isOpinion) { return this; } - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isHeadline(Boolean isHeadline) { this.isHeadline = Optional.ofNullable(isHeadline); return this; } - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ @java.lang.Override @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) public _FinalStage isHeadline(Optional isHeadline) { @@ -1956,19 +1476,12 @@ public _FinalStage isHeadline(Optional isHeadline) { return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage toRank(Integer toRank) { this.toRank = Optional.ofNullable(toRank); return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @java.lang.Override @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) public _FinalStage toRank(Optional toRank) { @@ -1976,19 +1489,12 @@ public _FinalStage toRank(Optional toRank) { return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage fromRank(Integer fromRank) { this.fromRank = Optional.ofNullable(fromRank); return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @java.lang.Override @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) public _FinalStage fromRank(Optional fromRank) { @@ -1996,19 +1502,12 @@ public _FinalStage fromRank(Optional fromRank) { return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage rankedOnly(Boolean rankedOnly) { this.rankedOnly = Optional.ofNullable(rankedOnly); return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ @java.lang.Override @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) public _FinalStage rankedOnly(Optional rankedOnly) { @@ -2016,49 +1515,25 @@ public _FinalStage rankedOnly(Optional rankedOnly) { return this; } - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage sortBy(AuthorsGetRequestSortBy sortBy) { + public _FinalStage sortBy(SortBy sortBy) { this.sortBy = Optional.ofNullable(sortBy); return this; } - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @java.lang.Override @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public _FinalStage sortBy(Optional sortBy) { + public _FinalStage sortBy(Optional sortBy) { this.sortBy = sortBy; return this; } - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage byParseDate(Boolean byParseDate) { this.byParseDate = Optional.ofNullable(byParseDate); return this; } - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ @java.lang.Override @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) public _FinalStage byParseDate(Optional byParseDate) { @@ -2066,117 +1541,48 @@ public _FinalStage byParseDate(Optional byParseDate) { return this; } - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage publishedDatePrecision(AuthorsGetRequestPublishedDatePrecision publishedDatePrecision) { + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); return this; } - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ @java.lang.Override @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision( - Optional publishedDatePrecision) { + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { this.publishedDatePrecision = publishedDatePrecision; return this; } - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage to(OffsetDateTime to) { + public _FinalStage to(To to) { this.to = Optional.ofNullable(to); return this; } - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @java.lang.Override @JsonSetter(value = "to_", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { + public _FinalStage to(Optional to) { this.to = to; return this; } - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage from(OffsetDateTime from) { + public _FinalStage from(From from) { this.from = Optional.ofNullable(from); return this; } - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @java.lang.Override @JsonSetter(value = "from_", nulls = Nulls.SKIP) - public _FinalStage from(Optional from) { + public _FinalStage from(Optional from) { this.from = from; return this; } /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2187,8 +1593,7 @@ public _FinalStage notCountries(String notCountries) { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @java.lang.Override @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) @@ -2199,8 +1604,7 @@ public _FinalStage notCountries(Optional notCountries) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2211,8 +1615,7 @@ public _FinalStage countries(String countries) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @java.lang.Override @JsonSetter(value = "countries", nulls = Nulls.SKIP) @@ -2223,8 +1626,7 @@ public _FinalStage countries(Optional countries) { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2235,8 +1637,7 @@ public _FinalStage notLang(String notLang) { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @java.lang.Override @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) @@ -2247,8 +1648,7 @@ public _FinalStage notLang(Optional notLang) { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2259,8 +1659,7 @@ public _FinalStage lang(String lang) { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @java.lang.Override @JsonSetter(value = "lang", nulls = Nulls.SKIP) @@ -2271,7 +1670,6 @@ public _FinalStage lang(Optional lang) { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2282,7 +1680,6 @@ public _FinalStage notSources(String notSources) { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

*/ @java.lang.Override @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) @@ -2293,11 +1690,6 @@ public _FinalStage notSources(Optional notSources) { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2308,11 +1700,6 @@ public _FinalStage sources(String sources) { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @java.lang.Override @JsonSetter(value = "sources", nulls = Nulls.SKIP) @@ -2323,14 +1710,8 @@ public _FinalStage sources(Optional sources) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2341,14 +1722,8 @@ public _FinalStage predefinedSources(String predefinedSources) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @java.lang.Override @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) @@ -2359,7 +1734,6 @@ public _FinalStage predefinedSources(Optional predefinedSources) { /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2370,7 +1744,6 @@ public _FinalStage notAuthorName(String notAuthorName) { /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

*/ @java.lang.Override @JsonSetter(value = "not_author_name", nulls = Nulls.SKIP) @@ -2380,8 +1753,8 @@ public _FinalStage notAuthorName(Optional notAuthorName) { } @java.lang.Override - public AuthorsGetRequest build() { - return new AuthorsGetRequest( + public GetAuthorsRequest build() { + return new GetAuthorsRequest( authorName, notAuthorName, predefinedSources, @@ -2405,6 +1778,7 @@ public AuthorsGetRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, wordCountMin, wordCountMax, page, @@ -2427,5 +1801,17 @@ public AuthorsGetRequest build() { robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsPostRequest.java b/src/main/java/com/newscatcher/api/resources/authors/requests/PostAuthorsRequest.java similarity index 92% rename from src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsPostRequest.java rename to src/main/java/com/newscatcher/api/resources/authors/requests/PostAuthorsRequest.java index 2775807..05bb897 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/requests/AuthorsPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/authors/requests/PostAuthorsRequest.java @@ -14,6 +14,7 @@ import com.newscatcher.api.core.ObjectMappers; import com.newscatcher.api.types.AllDomainLinks; import com.newscatcher.api.types.AllLinks; +import com.newscatcher.api.types.AllLinksText; import com.newscatcher.api.types.Countries; import com.newscatcher.api.types.CustomTags; import com.newscatcher.api.types.From; @@ -26,13 +27,10 @@ import com.newscatcher.api.types.NotIptcTags; import com.newscatcher.api.types.NotLang; import com.newscatcher.api.types.NotSources; -import com.newscatcher.api.types.NotTheme; import com.newscatcher.api.types.ParentUrl; import com.newscatcher.api.types.PredefinedSources; -import com.newscatcher.api.types.PublishedDatePrecision; import com.newscatcher.api.types.SortBy; import com.newscatcher.api.types.Sources; -import com.newscatcher.api.types.Theme; import com.newscatcher.api.types.To; import java.util.HashMap; import java.util.Map; @@ -41,8 +39,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = AuthorsPostRequest.Builder.class) -public final class AuthorsPostRequest { +@JsonDeserialize(builder = PostAuthorsRequest.Builder.class) +public final class PostAuthorsRequest { private final String authorName; private final Optional notAuthorName; @@ -65,7 +63,7 @@ public final class AuthorsPostRequest { private final Optional to; - private final Optional publishedDatePrecision; + private final Optional publishedDatePrecision; private final Optional byParseDate; @@ -89,6 +87,8 @@ public final class AuthorsPostRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional wordCountMin; private final Optional wordCountMax; @@ -103,9 +103,9 @@ public final class AuthorsPostRequest { private final Optional hasNlp; - private final Optional theme; + private final Optional theme; - private final Optional notTheme; + private final Optional notTheme; private final Optional nerName; @@ -131,7 +131,7 @@ public final class AuthorsPostRequest { private final Map additionalProperties; - private AuthorsPostRequest( + private PostAuthorsRequest( String authorName, Optional notAuthorName, Optional predefinedSources, @@ -143,7 +143,7 @@ private AuthorsPostRequest( Optional notCountries, Optional from, Optional to, - Optional publishedDatePrecision, + Optional publishedDatePrecision, Optional byParseDate, Optional sortBy, Optional rankedOnly, @@ -155,6 +155,7 @@ private AuthorsPostRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional wordCountMin, Optional wordCountMax, Optional page, @@ -162,8 +163,8 @@ private AuthorsPostRequest( Optional includeTranslationFields, Optional includeNlpData, Optional hasNlp, - Optional theme, - Optional notTheme, + Optional theme, + Optional notTheme, Optional nerName, Optional titleSentimentMin, Optional titleSentimentMax, @@ -199,6 +200,7 @@ private AuthorsPostRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.wordCountMin = wordCountMin; this.wordCountMax = wordCountMax; this.page = page; @@ -278,7 +280,7 @@ public Optional getTo() { } @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { + public Optional getPublishedDatePrecision() { return publishedDatePrecision; } @@ -337,6 +339,11 @@ public Optional getAllDomainLinks() { return allDomainLinks; } + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; @@ -373,12 +380,12 @@ public Optional getHasNlp() { } @JsonProperty("theme") - public Optional getTheme() { + public Optional getTheme() { return theme; } @JsonProperty("not_theme") - public Optional getNotTheme() { + public Optional getNotTheme() { return notTheme; } @@ -440,7 +447,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AuthorsPostRequest && equalTo((AuthorsPostRequest) other); + return other instanceof PostAuthorsRequest && equalTo((PostAuthorsRequest) other); } @JsonAnyGetter @@ -448,7 +455,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(AuthorsPostRequest other) { + private boolean equalTo(PostAuthorsRequest other) { return authorName.equals(other.authorName) && notAuthorName.equals(other.notAuthorName) && predefinedSources.equals(other.predefinedSources) @@ -472,6 +479,7 @@ private boolean equalTo(AuthorsPostRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && wordCountMin.equals(other.wordCountMin) && wordCountMax.equals(other.wordCountMax) && page.equals(other.page) @@ -520,6 +528,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.wordCountMin, this.wordCountMax, this.page, @@ -554,11 +563,15 @@ public static AuthorNameStage builder() { public interface AuthorNameStage { _FinalStage authorName(@NotNull String authorName); - Builder from(AuthorsPostRequest other); + Builder from(PostAuthorsRequest other); } public interface _FinalStage { - AuthorsPostRequest build(); + PostAuthorsRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); _FinalStage notAuthorName(Optional notAuthorName); @@ -600,9 +613,9 @@ public interface _FinalStage { _FinalStage to(To to); - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision); + _FinalStage publishedDatePrecision(String publishedDatePrecision); _FinalStage byParseDate(Optional byParseDate); @@ -648,6 +661,10 @@ public interface _FinalStage { _FinalStage allDomainLinks(AllDomainLinks allDomainLinks); + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(AllLinksText allLinksText); + _FinalStage wordCountMin(Optional wordCountMin); _FinalStage wordCountMin(Integer wordCountMin); @@ -676,13 +693,13 @@ public interface _FinalStage { _FinalStage hasNlp(Boolean hasNlp); - _FinalStage theme(Optional theme); + _FinalStage theme(Optional theme); - _FinalStage theme(Theme theme); + _FinalStage theme(String theme); - _FinalStage notTheme(Optional notTheme); + _FinalStage notTheme(Optional notTheme); - _FinalStage notTheme(NotTheme notTheme); + _FinalStage notTheme(String notTheme); _FinalStage nerName(Optional nerName); @@ -755,9 +772,9 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Optional nerName = Optional.empty(); - private Optional notTheme = Optional.empty(); + private Optional notTheme = Optional.empty(); - private Optional theme = Optional.empty(); + private Optional theme = Optional.empty(); private Optional hasNlp = Optional.empty(); @@ -773,6 +790,8 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Optional wordCountMin = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -795,7 +814,7 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Optional byParseDate = Optional.empty(); - private Optional publishedDatePrecision = Optional.empty(); + private Optional publishedDatePrecision = Optional.empty(); private Optional to = Optional.empty(); @@ -823,7 +842,7 @@ public static final class Builder implements AuthorNameStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(AuthorsPostRequest other) { + public Builder from(PostAuthorsRequest other) { authorName(other.getAuthorName()); notAuthorName(other.getNotAuthorName()); predefinedSources(other.getPredefinedSources()); @@ -847,6 +866,7 @@ public Builder from(AuthorsPostRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); wordCountMin(other.getWordCountMin()); wordCountMax(other.getWordCountMax()); page(other.getPage()); @@ -1021,27 +1041,27 @@ public _FinalStage nerName(Optional nerName) { } @java.lang.Override - public _FinalStage notTheme(NotTheme notTheme) { + public _FinalStage notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } @java.lang.Override @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { + public _FinalStage notTheme(Optional notTheme) { this.notTheme = notTheme; return this; } @java.lang.Override - public _FinalStage theme(Theme theme) { + public _FinalStage theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } @java.lang.Override @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { + public _FinalStage theme(Optional theme) { this.theme = theme; return this; } @@ -1137,6 +1157,19 @@ public _FinalStage wordCountMin(Optional wordCountMin) { return this; } + @java.lang.Override + public _FinalStage allLinksText(AllLinksText allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + @java.lang.Override public _FinalStage allDomainLinks(AllDomainLinks allDomainLinks) { this.allDomainLinks = Optional.ofNullable(allDomainLinks); @@ -1281,14 +1314,14 @@ public _FinalStage byParseDate(Optional byParseDate) { } @java.lang.Override - public _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision) { + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); return this; } @java.lang.Override @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { this.publishedDatePrecision = publishedDatePrecision; return this; } @@ -1424,8 +1457,8 @@ public _FinalStage notAuthorName(Optional notAuthorName) { } @java.lang.Override - public AuthorsPostRequest build() { - return new AuthorsPostRequest( + public PostAuthorsRequest build() { + return new PostAuthorsRequest( authorName, notAuthorName, predefinedSources, @@ -1449,6 +1482,7 @@ public AuthorsPostRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, wordCountMin, wordCountMax, page, @@ -1471,5 +1505,17 @@ public AuthorsPostRequest build() { robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestPublishedDatePrecision.java b/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestPublishedDatePrecision.java deleted file mode 100644 index 2647d95..0000000 --- a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestPublishedDatePrecision.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.authors.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuthorsGetRequestPublishedDatePrecision { - FULL("full"), - - TIMEZONE_UNKNOWN("timezone unknown"), - - DATE("date"); - - private final String value; - - AuthorsGetRequestPublishedDatePrecision(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestSortBy.java b/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestSortBy.java deleted file mode 100644 index ad018c8..0000000 --- a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetRequestSortBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.authors.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AuthorsGetRequestSortBy { - RELEVANCY("relevancy"), - - DATE("date"), - - RANK("rank"); - - private final String value; - - AuthorsGetRequestSortBy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetResponse.java b/src/main/java/com/newscatcher/api/resources/authors/types/GetAuthorsResponse.java similarity index 76% rename from src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetResponse.java rename to src/main/java/com/newscatcher/api/resources/authors/types/GetAuthorsResponse.java index 3fea8cd..8589c8c 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsGetResponse.java +++ b/src/main/java/com/newscatcher/api/resources/authors/types/GetAuthorsResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = AuthorsGetResponse.Deserializer.class) -public final class AuthorsGetResponse { +@JsonDeserialize(using = GetAuthorsResponse.Deserializer.class) +public final class GetAuthorsResponse { private final Object value; private final int type; - private AuthorsGetResponse(Object value, int type) { + private GetAuthorsResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AuthorsGetResponse && equalTo((AuthorsGetResponse) other); + return other instanceof GetAuthorsResponse && equalTo((GetAuthorsResponse) other); } - private boolean equalTo(AuthorsGetResponse other) { + private boolean equalTo(GetAuthorsResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static AuthorsGetResponse of(SearchResponseDto value) { - return new AuthorsGetResponse(value, 0); + public static GetAuthorsResponse of(SearchResponseDto value) { + return new GetAuthorsResponse(value, 0); } - public static AuthorsGetResponse of(FailedAuthorsResponseDto value) { - return new AuthorsGetResponse(value, 1); + public static GetAuthorsResponse of(FailedAuthorsResponseDto value) { + return new GetAuthorsResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(FailedAuthorsResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(AuthorsGetResponse.class); + super(GetAuthorsResponse.class); } @java.lang.Override - public AuthorsGetResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public GetAuthorsResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsPostResponse.java b/src/main/java/com/newscatcher/api/resources/authors/types/PostAuthorsResponse.java similarity index 76% rename from src/main/java/com/newscatcher/api/resources/authors/types/AuthorsPostResponse.java rename to src/main/java/com/newscatcher/api/resources/authors/types/PostAuthorsResponse.java index 7c1b866..700a078 100644 --- a/src/main/java/com/newscatcher/api/resources/authors/types/AuthorsPostResponse.java +++ b/src/main/java/com/newscatcher/api/resources/authors/types/PostAuthorsResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = AuthorsPostResponse.Deserializer.class) -public final class AuthorsPostResponse { +@JsonDeserialize(using = PostAuthorsResponse.Deserializer.class) +public final class PostAuthorsResponse { private final Object value; private final int type; - private AuthorsPostResponse(Object value, int type) { + private PostAuthorsResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof AuthorsPostResponse && equalTo((AuthorsPostResponse) other); + return other instanceof PostAuthorsResponse && equalTo((PostAuthorsResponse) other); } - private boolean equalTo(AuthorsPostResponse other) { + private boolean equalTo(PostAuthorsResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static AuthorsPostResponse of(SearchResponseDto value) { - return new AuthorsPostResponse(value, 0); + public static PostAuthorsResponse of(SearchResponseDto value) { + return new PostAuthorsResponse(value, 0); } - public static AuthorsPostResponse of(FailedAuthorsResponseDto value) { - return new AuthorsPostResponse(value, 1); + public static PostAuthorsResponse of(FailedAuthorsResponseDto value) { + return new PostAuthorsResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(FailedAuthorsResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(AuthorsPostResponse.class); + super(PostAuthorsResponse.class); } @java.lang.Override - public AuthorsPostResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public PostAuthorsResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncBreakingNewsClient.java b/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncBreakingNewsClient.java index 2f05a13..13a73b9 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncBreakingNewsClient.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncBreakingNewsClient.java @@ -5,8 +5,8 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsGetRequest; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsPostRequest; +import com.newscatcher.api.resources.breakingnews.requests.GetBreakingNewsRequest; +import com.newscatcher.api.resources.breakingnews.requests.PostBreakingNewsRequest; import com.newscatcher.api.types.BreakingNewsResponseDto; import java.util.concurrent.CompletableFuture; @@ -30,44 +30,58 @@ public AsyncRawBreakingNewsClient withRawResponse() { /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsGet() { - return this.rawClient.breakingNewsGet().thenApply(response -> response.body()); + public CompletableFuture get() { + return this.rawClient.get().thenApply(response -> response.body()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsGet(BreakingNewsGetRequest request) { - return this.rawClient.breakingNewsGet(request).thenApply(response -> response.body()); + public CompletableFuture get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).thenApply(response -> response.body()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsGet( - BreakingNewsGetRequest request, RequestOptions requestOptions) { - return this.rawClient.breakingNewsGet(request, requestOptions).thenApply(response -> response.body()); + public CompletableFuture get(GetBreakingNewsRequest request) { + return this.rawClient.get(request).thenApply(response -> response.body()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsPost() { - return this.rawClient.breakingNewsPost().thenApply(response -> response.body()); + public CompletableFuture get( + GetBreakingNewsRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsPost(BreakingNewsPostRequest request) { - return this.rawClient.breakingNewsPost(request).thenApply(response -> response.body()); + public CompletableFuture post() { + return this.rawClient.post().thenApply(response -> response.body()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture breakingNewsPost( - BreakingNewsPostRequest request, RequestOptions requestOptions) { - return this.rawClient.breakingNewsPost(request, requestOptions).thenApply(response -> response.body()); + public CompletableFuture post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public CompletableFuture post(PostBreakingNewsRequest request) { + return this.rawClient.post(request).thenApply(response -> response.body()); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public CompletableFuture post( + PostBreakingNewsRequest request, RequestOptions requestOptions) { + return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncRawBreakingNewsClient.java b/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncRawBreakingNewsClient.java index 81df43f..c649336 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncRawBreakingNewsClient.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/AsyncRawBreakingNewsClient.java @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsGetRequest; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsPostRequest; +import com.newscatcher.api.resources.breakingnews.requests.GetBreakingNewsRequest; +import com.newscatcher.api.resources.breakingnews.requests.PostBreakingNewsRequest; import com.newscatcher.api.types.BreakingNewsResponseDto; import com.newscatcher.api.types.Error; import java.io.IOException; @@ -46,23 +46,29 @@ public AsyncRawBreakingNewsClient(ClientOptions clientOptions) { /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsGet() { - return breakingNewsGet(BreakingNewsGetRequest.builder().build()); + public CompletableFuture> get() { + return get(GetBreakingNewsRequest.builder().build()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsGet( - BreakingNewsGetRequest request) { - return breakingNewsGet(request, null); + public CompletableFuture> get(RequestOptions requestOptions) { + return get(GetBreakingNewsRequest.builder().build(), requestOptions); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsGet( - BreakingNewsGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get(GetBreakingNewsRequest request) { + return get(request, null); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public CompletableFuture> get( + GetBreakingNewsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/breaking_news"); @@ -161,9 +167,10 @@ public CompletableFuture> br request.getContentSentimentMax().get(), false); } - if (request.getRobotsCompliant().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) @@ -180,14 +187,13 @@ public CompletableFuture> br @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BreakingNewsResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BreakingNewsResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -229,11 +235,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -252,27 +256,38 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsPost() { - return breakingNewsPost(BreakingNewsPostRequest.builder().build()); + public CompletableFuture> post() { + return post(PostBreakingNewsRequest.builder().build()); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public CompletableFuture> post(RequestOptions requestOptions) { + return post(PostBreakingNewsRequest.builder().build(), requestOptions); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsPost( - BreakingNewsPostRequest request) { - return breakingNewsPost(request, null); + public CompletableFuture> post( + PostBreakingNewsRequest request) { + return post(request, null); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public CompletableFuture> breakingNewsPost( - BreakingNewsPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostBreakingNewsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/breaking_news") - .build(); + .addPathSegments("api/breaking_news"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -281,7 +296,7 @@ public CompletableFuture> br throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -296,14 +311,13 @@ public CompletableFuture> br @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), BreakingNewsResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BreakingNewsResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -345,11 +359,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/BreakingNewsClient.java b/src/main/java/com/newscatcher/api/resources/breakingnews/BreakingNewsClient.java index 318f7ef..4a6dfd7 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/BreakingNewsClient.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/BreakingNewsClient.java @@ -5,8 +5,8 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsGetRequest; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsPostRequest; +import com.newscatcher.api.resources.breakingnews.requests.GetBreakingNewsRequest; +import com.newscatcher.api.resources.breakingnews.requests.PostBreakingNewsRequest; import com.newscatcher.api.types.BreakingNewsResponseDto; public class BreakingNewsClient { @@ -29,42 +29,56 @@ public RawBreakingNewsClient withRawResponse() { /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsGet() { - return this.rawClient.breakingNewsGet().body(); + public BreakingNewsResponseDto get() { + return this.rawClient.get().body(); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsGet(BreakingNewsGetRequest request) { - return this.rawClient.breakingNewsGet(request).body(); + public BreakingNewsResponseDto get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).body(); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsGet(BreakingNewsGetRequest request, RequestOptions requestOptions) { - return this.rawClient.breakingNewsGet(request, requestOptions).body(); + public BreakingNewsResponseDto get(GetBreakingNewsRequest request) { + return this.rawClient.get(request).body(); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsPost() { - return this.rawClient.breakingNewsPost().body(); + public BreakingNewsResponseDto get(GetBreakingNewsRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).body(); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsPost(BreakingNewsPostRequest request) { - return this.rawClient.breakingNewsPost(request).body(); + public BreakingNewsResponseDto post() { + return this.rawClient.post().body(); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public BreakingNewsResponseDto breakingNewsPost(BreakingNewsPostRequest request, RequestOptions requestOptions) { - return this.rawClient.breakingNewsPost(request, requestOptions).body(); + public BreakingNewsResponseDto post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).body(); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public BreakingNewsResponseDto post(PostBreakingNewsRequest request) { + return this.rawClient.post(request).body(); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public BreakingNewsResponseDto post(PostBreakingNewsRequest request, RequestOptions requestOptions) { + return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/RawBreakingNewsClient.java b/src/main/java/com/newscatcher/api/resources/breakingnews/RawBreakingNewsClient.java index d8b14dd..5f03a20 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/RawBreakingNewsClient.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/RawBreakingNewsClient.java @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsGetRequest; -import com.newscatcher.api.resources.breakingnews.requests.BreakingNewsPostRequest; +import com.newscatcher.api.resources.breakingnews.requests.GetBreakingNewsRequest; +import com.newscatcher.api.resources.breakingnews.requests.PostBreakingNewsRequest; import com.newscatcher.api.types.BreakingNewsResponseDto; import com.newscatcher.api.types.Error; import java.io.IOException; @@ -42,22 +42,29 @@ public RawBreakingNewsClient(ClientOptions clientOptions) { /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsGet() { - return breakingNewsGet(BreakingNewsGetRequest.builder().build()); + public NewscatcherApiHttpResponse get() { + return get(GetBreakingNewsRequest.builder().build()); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsGet(BreakingNewsGetRequest request) { - return breakingNewsGet(request, null); + public NewscatcherApiHttpResponse get(RequestOptions requestOptions) { + return get(GetBreakingNewsRequest.builder().build(), requestOptions); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsGet( - BreakingNewsGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get(GetBreakingNewsRequest request) { + return get(request, null); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public NewscatcherApiHttpResponse get( + GetBreakingNewsRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/breaking_news"); @@ -156,9 +163,10 @@ public NewscatcherApiHttpResponse breakingNewsGet( request.getContentSentimentMax().get(), false); } - if (request.getRobotsCompliant().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) @@ -172,12 +180,12 @@ public NewscatcherApiHttpResponse breakingNewsGet( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BreakingNewsResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BreakingNewsResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -205,11 +213,9 @@ public NewscatcherApiHttpResponse breakingNewsGet( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -218,26 +224,37 @@ public NewscatcherApiHttpResponse breakingNewsGet( /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsPost() { - return breakingNewsPost(BreakingNewsPostRequest.builder().build()); + public NewscatcherApiHttpResponse post() { + return post(PostBreakingNewsRequest.builder().build()); + } + + /** + * Retrieves breaking news articles and sorts them based on specified criteria. + */ + public NewscatcherApiHttpResponse post(RequestOptions requestOptions) { + return post(PostBreakingNewsRequest.builder().build(), requestOptions); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsPost(BreakingNewsPostRequest request) { - return breakingNewsPost(request, null); + public NewscatcherApiHttpResponse post(PostBreakingNewsRequest request) { + return post(request, null); } /** * Retrieves breaking news articles and sorts them based on specified criteria. */ - public NewscatcherApiHttpResponse breakingNewsPost( - BreakingNewsPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostBreakingNewsRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/breaking_news") - .build(); + .addPathSegments("api/breaking_news"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -246,7 +263,7 @@ public NewscatcherApiHttpResponse breakingNewsPost( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -258,12 +275,12 @@ public NewscatcherApiHttpResponse breakingNewsPost( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BreakingNewsResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BreakingNewsResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -291,11 +308,9 @@ public NewscatcherApiHttpResponse breakingNewsPost( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsGetRequest.java b/src/main/java/com/newscatcher/api/resources/breakingnews/requests/GetBreakingNewsRequest.java similarity index 50% rename from src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsGetRequest.java rename to src/main/java/com/newscatcher/api/resources/breakingnews/requests/GetBreakingNewsRequest.java index e1acbae..e8101ad 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/requests/GetBreakingNewsRequest.java @@ -12,16 +12,16 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.breakingnews.types.BreakingNewsGetRequestSortBy; +import com.newscatcher.api.types.SortBy; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = BreakingNewsGetRequest.Builder.class) -public final class BreakingNewsGetRequest { - private final Optional sortBy; +@JsonDeserialize(builder = GetBreakingNewsRequest.Builder.class) +public final class GetBreakingNewsRequest { + private final Optional sortBy; private final Optional rankedOnly; @@ -61,12 +61,10 @@ public final class BreakingNewsGetRequest { private final Optional contentSentimentMax; - private final Optional robotsCompliant; - private final Map additionalProperties; - private BreakingNewsGetRequest( - Optional sortBy, + private GetBreakingNewsRequest( + Optional sortBy, Optional rankedOnly, Optional fromRank, Optional toRank, @@ -86,7 +84,6 @@ private BreakingNewsGetRequest( Optional titleSentimentMax, Optional contentSentimentMin, Optional contentSentimentMax, - Optional robotsCompliant, Map additionalProperties) { this.sortBy = sortBy; this.rankedOnly = rankedOnly; @@ -108,59 +105,34 @@ private BreakingNewsGetRequest( this.titleSentimentMax = titleSentimentMax; this.contentSentimentMin = contentSentimentMin; this.contentSentimentMax = contentSentimentMax; - this.robotsCompliant = robotsCompliant; this.additionalProperties = additionalProperties; } - /** - * @return The sorting order of the results. Possible values are: - *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @JsonProperty("sort_by") - public Optional getSortBy() { + public Optional getSortBy() { return sortBy; } - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ @JsonProperty("ranked_only") public Optional getRankedOnly() { return rankedOnly; } - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("from_rank") public Optional getFromRank() { return fromRank; } - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("to_rank") public Optional getToRank() { return toRank; } - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ @JsonProperty("page") public Optional getPage() { return page; } - /** - * @return The number of articles to return per page. - */ @JsonProperty("page_size") public Optional getPageSize() { return pageSize; @@ -186,149 +158,60 @@ public Optional getHasNlp() { return hasNlp; } - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonProperty("theme") public Optional getTheme() { return theme; } - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("not_theme") public Optional getNotTheme() { return notTheme; } - /** - * @return Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("ORG_entity_name") public Optional getOrgEntityName() { return orgEntityName; } - /** - * @return Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("PER_entity_name") public Optional getPerEntityName() { return perEntityName; } - /** - * @return Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("LOC_entity_name") public Optional getLocEntityName() { return locEntityName; } - /** - * @return Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("MISC_entity_name") public Optional getMiscEntityName() { return miscEntityName; } - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_min") public Optional getTitleSentimentMin() { return titleSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_max") public Optional getTitleSentimentMax() { return titleSentimentMax; } - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_min") public Optional getContentSentimentMin() { return contentSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_max") public Optional getContentSentimentMax() { return contentSentimentMax; } - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; - } - @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof BreakingNewsGetRequest && equalTo((BreakingNewsGetRequest) other); + return other instanceof GetBreakingNewsRequest && equalTo((GetBreakingNewsRequest) other); } @JsonAnyGetter @@ -336,7 +219,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(BreakingNewsGetRequest other) { + private boolean equalTo(GetBreakingNewsRequest other) { return sortBy.equals(other.sortBy) && rankedOnly.equals(other.rankedOnly) && fromRank.equals(other.fromRank) @@ -356,8 +239,7 @@ private boolean equalTo(BreakingNewsGetRequest other) { && titleSentimentMin.equals(other.titleSentimentMin) && titleSentimentMax.equals(other.titleSentimentMax) && contentSentimentMin.equals(other.contentSentimentMin) - && contentSentimentMax.equals(other.contentSentimentMax) - && robotsCompliant.equals(other.robotsCompliant); + && contentSentimentMax.equals(other.contentSentimentMax); } @java.lang.Override @@ -382,8 +264,7 @@ public int hashCode() { this.titleSentimentMin, this.titleSentimentMax, this.contentSentimentMin, - this.contentSentimentMax, - this.robotsCompliant); + this.contentSentimentMax); } @java.lang.Override @@ -397,7 +278,7 @@ public static Builder builder() { @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder { - private Optional sortBy = Optional.empty(); + private Optional sortBy = Optional.empty(); private Optional rankedOnly = Optional.empty(); @@ -437,14 +318,12 @@ public static final class Builder { private Optional contentSentimentMax = Optional.empty(); - private Optional robotsCompliant = Optional.empty(); - @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(BreakingNewsGetRequest other) { + public Builder from(GetBreakingNewsRequest other) { sortBy(other.getSortBy()); rankedOnly(other.getRankedOnly()); fromRank(other.getFromRank()); @@ -465,32 +344,20 @@ public Builder from(BreakingNewsGetRequest other) { titleSentimentMax(other.getTitleSentimentMax()); contentSentimentMin(other.getContentSentimentMin()); contentSentimentMax(other.getContentSentimentMax()); - robotsCompliant(other.getRobotsCompliant()); return this; } - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public Builder sortBy(Optional sortBy) { + public Builder sortBy(Optional sortBy) { this.sortBy = sortBy; return this; } - public Builder sortBy(BreakingNewsGetRequestSortBy sortBy) { + public Builder sortBy(SortBy sortBy) { this.sortBy = Optional.ofNullable(sortBy); return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) public Builder rankedOnly(Optional rankedOnly) { this.rankedOnly = rankedOnly; @@ -502,9 +369,6 @@ public Builder rankedOnly(Boolean rankedOnly) { return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) public Builder fromRank(Optional fromRank) { this.fromRank = fromRank; @@ -516,9 +380,6 @@ public Builder fromRank(Integer fromRank) { return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) public Builder toRank(Optional toRank) { this.toRank = toRank; @@ -530,10 +391,6 @@ public Builder toRank(Integer toRank) { return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -545,9 +402,6 @@ public Builder page(Integer page) { return this; } - /** - *

The number of articles to return per page.

- */ @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -603,13 +457,6 @@ public Builder hasNlp(Boolean hasNlp) { return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonSetter(value = "theme", nulls = Nulls.SKIP) public Builder theme(Optional theme) { this.theme = theme; @@ -621,12 +468,6 @@ public Builder theme(String theme) { return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) public Builder notTheme(Optional notTheme) { this.notTheme = notTheme; @@ -638,12 +479,6 @@ public Builder notTheme(String notTheme) { return this; } - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "ORG_entity_name", nulls = Nulls.SKIP) public Builder orgEntityName(Optional orgEntityName) { this.orgEntityName = orgEntityName; @@ -655,12 +490,6 @@ public Builder orgEntityName(String orgEntityName) { return this; } - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "PER_entity_name", nulls = Nulls.SKIP) public Builder perEntityName(Optional perEntityName) { this.perEntityName = perEntityName; @@ -672,12 +501,6 @@ public Builder perEntityName(String perEntityName) { return this; } - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "LOC_entity_name", nulls = Nulls.SKIP) public Builder locEntityName(Optional locEntityName) { this.locEntityName = locEntityName; @@ -689,12 +512,6 @@ public Builder locEntityName(String locEntityName) { return this; } - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "MISC_entity_name", nulls = Nulls.SKIP) public Builder miscEntityName(Optional miscEntityName) { this.miscEntityName = miscEntityName; @@ -706,17 +523,6 @@ public Builder miscEntityName(String miscEntityName) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) public Builder titleSentimentMin(Optional titleSentimentMin) { this.titleSentimentMin = titleSentimentMin; @@ -728,17 +534,6 @@ public Builder titleSentimentMin(Float titleSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) public Builder titleSentimentMax(Optional titleSentimentMax) { this.titleSentimentMax = titleSentimentMax; @@ -750,17 +545,6 @@ public Builder titleSentimentMax(Float titleSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) public Builder contentSentimentMin(Optional contentSentimentMin) { this.contentSentimentMin = contentSentimentMin; @@ -772,17 +556,6 @@ public Builder contentSentimentMin(Float contentSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) public Builder contentSentimentMax(Optional contentSentimentMax) { this.contentSentimentMax = contentSentimentMax; @@ -794,22 +567,8 @@ public Builder contentSentimentMax(Float contentSentimentMax) { return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public Builder robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - - public Builder robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - public BreakingNewsGetRequest build() { - return new BreakingNewsGetRequest( + public GetBreakingNewsRequest build() { + return new GetBreakingNewsRequest( sortBy, rankedOnly, fromRank, @@ -830,8 +589,17 @@ public BreakingNewsGetRequest build() { titleSentimentMax, contentSentimentMin, contentSentimentMax, - robotsCompliant, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsPostRequest.java b/src/main/java/com/newscatcher/api/resources/breakingnews/requests/PostBreakingNewsRequest.java similarity index 85% rename from src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsPostRequest.java rename to src/main/java/com/newscatcher/api/resources/breakingnews/requests/PostBreakingNewsRequest.java index c8950f7..91ec832 100644 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/requests/BreakingNewsPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/breakingnews/requests/PostBreakingNewsRequest.java @@ -12,17 +12,15 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.types.NotTheme; import com.newscatcher.api.types.SortBy; -import com.newscatcher.api.types.Theme; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = BreakingNewsPostRequest.Builder.class) -public final class BreakingNewsPostRequest { +@JsonDeserialize(builder = PostBreakingNewsRequest.Builder.class) +public final class PostBreakingNewsRequest { private final Optional sortBy; private final Optional rankedOnly; @@ -43,9 +41,9 @@ public final class BreakingNewsPostRequest { private final Optional hasNlp; - private final Optional theme; + private final Optional theme; - private final Optional notTheme; + private final Optional notTheme; private final Optional orgEntityName; @@ -61,13 +59,11 @@ public final class BreakingNewsPostRequest { private final Optional contentSentimentMin; - private final Optional contentSentientMax; - - private final Optional robotsCompliant; + private final Optional contentSentimentMax; private final Map additionalProperties; - private BreakingNewsPostRequest( + private PostBreakingNewsRequest( Optional sortBy, Optional rankedOnly, Optional fromRank, @@ -78,8 +74,8 @@ private BreakingNewsPostRequest( Optional includeTranslationFields, Optional includeNlpData, Optional hasNlp, - Optional theme, - Optional notTheme, + Optional theme, + Optional notTheme, Optional orgEntityName, Optional perEntityName, Optional locEntityName, @@ -87,8 +83,7 @@ private BreakingNewsPostRequest( Optional titleSentimentMin, Optional titleSentimentMax, Optional contentSentimentMin, - Optional contentSentientMax, - Optional robotsCompliant, + Optional contentSentimentMax, Map additionalProperties) { this.sortBy = sortBy; this.rankedOnly = rankedOnly; @@ -109,8 +104,7 @@ private BreakingNewsPostRequest( this.titleSentimentMin = titleSentimentMin; this.titleSentimentMax = titleSentimentMax; this.contentSentimentMin = contentSentimentMin; - this.contentSentientMax = contentSentientMax; - this.robotsCompliant = robotsCompliant; + this.contentSentimentMax = contentSentimentMax; this.additionalProperties = additionalProperties; } @@ -165,12 +159,12 @@ public Optional getHasNlp() { } @JsonProperty("theme") - public Optional getTheme() { + public Optional getTheme() { return theme; } @JsonProperty("not_theme") - public Optional getNotTheme() { + public Optional getNotTheme() { return notTheme; } @@ -209,20 +203,15 @@ public Optional getContentSentimentMin() { return contentSentimentMin; } - @JsonProperty("content_sentient_max") - public Optional getContentSentientMax() { - return contentSentientMax; - } - - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; + @JsonProperty("content_sentiment_max") + public Optional getContentSentimentMax() { + return contentSentimentMax; } @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof BreakingNewsPostRequest && equalTo((BreakingNewsPostRequest) other); + return other instanceof PostBreakingNewsRequest && equalTo((PostBreakingNewsRequest) other); } @JsonAnyGetter @@ -230,7 +219,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(BreakingNewsPostRequest other) { + private boolean equalTo(PostBreakingNewsRequest other) { return sortBy.equals(other.sortBy) && rankedOnly.equals(other.rankedOnly) && fromRank.equals(other.fromRank) @@ -250,8 +239,7 @@ private boolean equalTo(BreakingNewsPostRequest other) { && titleSentimentMin.equals(other.titleSentimentMin) && titleSentimentMax.equals(other.titleSentimentMax) && contentSentimentMin.equals(other.contentSentimentMin) - && contentSentientMax.equals(other.contentSentientMax) - && robotsCompliant.equals(other.robotsCompliant); + && contentSentimentMax.equals(other.contentSentimentMax); } @java.lang.Override @@ -276,8 +264,7 @@ public int hashCode() { this.titleSentimentMin, this.titleSentimentMax, this.contentSentimentMin, - this.contentSentientMax, - this.robotsCompliant); + this.contentSentimentMax); } @java.lang.Override @@ -311,9 +298,9 @@ public static final class Builder { private Optional hasNlp = Optional.empty(); - private Optional theme = Optional.empty(); + private Optional theme = Optional.empty(); - private Optional notTheme = Optional.empty(); + private Optional notTheme = Optional.empty(); private Optional orgEntityName = Optional.empty(); @@ -329,16 +316,14 @@ public static final class Builder { private Optional contentSentimentMin = Optional.empty(); - private Optional contentSentientMax = Optional.empty(); - - private Optional robotsCompliant = Optional.empty(); + private Optional contentSentimentMax = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); private Builder() {} - public Builder from(BreakingNewsPostRequest other) { + public Builder from(PostBreakingNewsRequest other) { sortBy(other.getSortBy()); rankedOnly(other.getRankedOnly()); fromRank(other.getFromRank()); @@ -358,8 +343,7 @@ public Builder from(BreakingNewsPostRequest other) { titleSentimentMin(other.getTitleSentimentMin()); titleSentimentMax(other.getTitleSentimentMax()); contentSentimentMin(other.getContentSentimentMin()); - contentSentientMax(other.getContentSentientMax()); - robotsCompliant(other.getRobotsCompliant()); + contentSentimentMax(other.getContentSentimentMax()); return this; } @@ -474,23 +458,23 @@ public Builder hasNlp(Boolean hasNlp) { } @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public Builder theme(Optional theme) { + public Builder theme(Optional theme) { this.theme = theme; return this; } - public Builder theme(Theme theme) { + public Builder theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public Builder notTheme(Optional notTheme) { + public Builder notTheme(Optional notTheme) { this.notTheme = notTheme; return this; } - public Builder notTheme(NotTheme notTheme) { + public Builder notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } @@ -572,30 +556,19 @@ public Builder contentSentimentMin(Float contentSentimentMin) { return this; } - @JsonSetter(value = "content_sentient_max", nulls = Nulls.SKIP) - public Builder contentSentientMax(Optional contentSentientMax) { - this.contentSentientMax = contentSentientMax; - return this; - } - - public Builder contentSentientMax(Float contentSentientMax) { - this.contentSentientMax = Optional.ofNullable(contentSentientMax); - return this; - } - - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public Builder robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; + @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) + public Builder contentSentimentMax(Optional contentSentimentMax) { + this.contentSentimentMax = contentSentimentMax; return this; } - public Builder robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); + public Builder contentSentimentMax(Float contentSentimentMax) { + this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); return this; } - public BreakingNewsPostRequest build() { - return new BreakingNewsPostRequest( + public PostBreakingNewsRequest build() { + return new PostBreakingNewsRequest( sortBy, rankedOnly, fromRank, @@ -615,9 +588,18 @@ public BreakingNewsPostRequest build() { titleSentimentMin, titleSentimentMax, contentSentimentMin, - contentSentientMax, - robotsCompliant, + contentSentimentMax, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/breakingnews/types/BreakingNewsGetRequestSortBy.java b/src/main/java/com/newscatcher/api/resources/breakingnews/types/BreakingNewsGetRequestSortBy.java deleted file mode 100644 index 6785f24..0000000 --- a/src/main/java/com/newscatcher/api/resources/breakingnews/types/BreakingNewsGetRequestSortBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.breakingnews.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum BreakingNewsGetRequestSortBy { - RELEVANCY("relevancy"), - - DATE("date"), - - RANK("rank"); - - private final String value; - - BreakingNewsGetRequestSortBy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestheadlinesClient.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestHeadlinesClient.java similarity index 51% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestheadlinesClient.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestHeadlinesClient.java index 94933a6..ca8e8d4 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestheadlinesClient.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncLatestHeadlinesClient.java @@ -5,70 +5,84 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesGetRequest; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesPostRequest; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesGetResponse; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesPostResponse; +import com.newscatcher.api.resources.latestheadlines.requests.GetLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.requests.PostLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.types.GetLatestHeadlinesResponse; +import com.newscatcher.api.resources.latestheadlines.types.PostLatestHeadlinesResponse; import java.util.concurrent.CompletableFuture; -public class AsyncLatestheadlinesClient { +public class AsyncLatestHeadlinesClient { protected final ClientOptions clientOptions; - private final AsyncRawLatestheadlinesClient rawClient; + private final AsyncRawLatestHeadlinesClient rawClient; - public AsyncLatestheadlinesClient(ClientOptions clientOptions) { + public AsyncLatestHeadlinesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new AsyncRawLatestheadlinesClient(clientOptions); + this.rawClient = new AsyncRawLatestHeadlinesClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public AsyncRawLatestheadlinesClient withRawResponse() { + public AsyncRawLatestHeadlinesClient withRawResponse() { return this.rawClient; } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture get() { + public CompletableFuture get() { return this.rawClient.get().thenApply(response -> response.body()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture get(LatestHeadlinesGetRequest request) { + public CompletableFuture get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public CompletableFuture get(GetLatestHeadlinesRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture get( - LatestHeadlinesGetRequest request, RequestOptions requestOptions) { + public CompletableFuture get( + GetLatestHeadlinesRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture post() { + public CompletableFuture post() { return this.rawClient.post().thenApply(response -> response.body()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture post(LatestHeadlinesPostRequest request) { + public CompletableFuture post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public CompletableFuture post(PostLatestHeadlinesRequest request) { return this.rawClient.post(request).thenApply(response -> response.body()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture post( - LatestHeadlinesPostRequest request, RequestOptions requestOptions) { + public CompletableFuture post( + PostLatestHeadlinesRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestheadlinesClient.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestHeadlinesClient.java similarity index 84% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestheadlinesClient.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestHeadlinesClient.java index ddd08ab..4e46f2b 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestheadlinesClient.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/AsyncRawLatestHeadlinesClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesGetRequest; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesPostRequest; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesGetResponse; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesPostResponse; +import com.newscatcher.api.resources.latestheadlines.requests.GetLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.requests.PostLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.types.GetLatestHeadlinesResponse; +import com.newscatcher.api.resources.latestheadlines.types.PostLatestHeadlinesResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -37,33 +37,41 @@ import okhttp3.ResponseBody; import org.jetbrains.annotations.NotNull; -public class AsyncRawLatestheadlinesClient { +public class AsyncRawLatestHeadlinesClient { protected final ClientOptions clientOptions; - public AsyncRawLatestheadlinesClient(ClientOptions clientOptions) { + public AsyncRawLatestHeadlinesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> get() { - return get(LatestHeadlinesGetRequest.builder().build()); + public CompletableFuture> get() { + return get(GetLatestHeadlinesRequest.builder().build()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> get( - LatestHeadlinesGetRequest request) { + public CompletableFuture> get( + RequestOptions requestOptions) { + return get(GetLatestHeadlinesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public CompletableFuture> get( + GetLatestHeadlinesRequest request) { return get(request, null); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> get( - LatestHeadlinesGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get( + GetLatestHeadlinesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/latest_headlines"); @@ -75,6 +83,10 @@ public CompletableFuture> QueryStringMapper.addQueryParameter( httpUrl, "by_parse_date", request.getByParseDate().get(), false); } + if (request.getSortBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_by", request.getSortBy().get(), false); + } if (request.getLang().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "lang", request.getLang().get(), false); @@ -138,6 +150,10 @@ public CompletableFuture> QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -266,6 +282,11 @@ public CompletableFuture> QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -276,19 +297,19 @@ public CompletableFuture> if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), LatestHeadlinesGetResponse.class), + responseBodyString, GetLatestHeadlinesResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -330,11 +351,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -353,27 +372,39 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> post() { - return post(LatestHeadlinesPostRequest.builder().build()); + public CompletableFuture> post() { + return post(PostLatestHeadlinesRequest.builder().build()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> post( - LatestHeadlinesPostRequest request) { + public CompletableFuture> post( + RequestOptions requestOptions) { + return post(PostLatestHeadlinesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public CompletableFuture> post( + PostLatestHeadlinesRequest request) { return post(request, null); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public CompletableFuture> post( - LatestHeadlinesPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostLatestHeadlinesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/latest_headlines") - .build(); + .addPathSegments("api/latest_headlines"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -382,7 +413,7 @@ public CompletableFuture throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -392,19 +423,19 @@ public CompletableFuture if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), LatestHeadlinesPostResponse.class), + responseBodyString, PostLatestHeadlinesResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -446,11 +477,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/LatestheadlinesClient.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/LatestHeadlinesClient.java similarity index 53% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/LatestheadlinesClient.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/LatestHeadlinesClient.java index 70c314c..6ccd73b 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/LatestheadlinesClient.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/LatestHeadlinesClient.java @@ -5,67 +5,81 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesGetRequest; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesPostRequest; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesGetResponse; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesPostResponse; +import com.newscatcher.api.resources.latestheadlines.requests.GetLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.requests.PostLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.types.GetLatestHeadlinesResponse; +import com.newscatcher.api.resources.latestheadlines.types.PostLatestHeadlinesResponse; -public class LatestheadlinesClient { +public class LatestHeadlinesClient { protected final ClientOptions clientOptions; - private final RawLatestheadlinesClient rawClient; + private final RawLatestHeadlinesClient rawClient; - public LatestheadlinesClient(ClientOptions clientOptions) { + public LatestHeadlinesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; - this.rawClient = new RawLatestheadlinesClient(clientOptions); + this.rawClient = new RawLatestHeadlinesClient(clientOptions); } /** * Get responses with HTTP metadata like headers */ - public RawLatestheadlinesClient withRawResponse() { + public RawLatestHeadlinesClient withRawResponse() { return this.rawClient; } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesGetResponse get() { + public GetLatestHeadlinesResponse get() { return this.rawClient.get().body(); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesGetResponse get(LatestHeadlinesGetRequest request) { + public GetLatestHeadlinesResponse get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).body(); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public GetLatestHeadlinesResponse get(GetLatestHeadlinesRequest request) { return this.rawClient.get(request).body(); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesGetResponse get(LatestHeadlinesGetRequest request, RequestOptions requestOptions) { + public GetLatestHeadlinesResponse get(GetLatestHeadlinesRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesPostResponse post() { + public PostLatestHeadlinesResponse post() { return this.rawClient.post().body(); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesPostResponse post(LatestHeadlinesPostRequest request) { + public PostLatestHeadlinesResponse post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).body(); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public PostLatestHeadlinesResponse post(PostLatestHeadlinesRequest request) { return this.rawClient.post(request).body(); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public LatestHeadlinesPostResponse post(LatestHeadlinesPostRequest request, RequestOptions requestOptions) { + public PostLatestHeadlinesResponse post(PostLatestHeadlinesRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestheadlinesClient.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestHeadlinesClient.java similarity index 84% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestheadlinesClient.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestHeadlinesClient.java index 055a1f9..48f3bcd 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestheadlinesClient.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/RawLatestHeadlinesClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesGetRequest; -import com.newscatcher.api.resources.latestheadlines.requests.LatestHeadlinesPostRequest; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesGetResponse; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesPostResponse; +import com.newscatcher.api.resources.latestheadlines.requests.GetLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.requests.PostLatestHeadlinesRequest; +import com.newscatcher.api.resources.latestheadlines.types.GetLatestHeadlinesResponse; +import com.newscatcher.api.resources.latestheadlines.types.PostLatestHeadlinesResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import okhttp3.Headers; @@ -33,32 +33,39 @@ import okhttp3.Response; import okhttp3.ResponseBody; -public class RawLatestheadlinesClient { +public class RawLatestHeadlinesClient { protected final ClientOptions clientOptions; - public RawLatestheadlinesClient(ClientOptions clientOptions) { + public RawLatestHeadlinesClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse get() { - return get(LatestHeadlinesGetRequest.builder().build()); + public NewscatcherApiHttpResponse get() { + return get(GetLatestHeadlinesRequest.builder().build()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse get(LatestHeadlinesGetRequest request) { + public NewscatcherApiHttpResponse get(RequestOptions requestOptions) { + return get(GetLatestHeadlinesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public NewscatcherApiHttpResponse get(GetLatestHeadlinesRequest request) { return get(request, null); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse get( - LatestHeadlinesGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get( + GetLatestHeadlinesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/latest_headlines"); @@ -70,6 +77,10 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "by_parse_date", request.getByParseDate().get(), false); } + if (request.getSortBy().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "sort_by", request.getSortBy().get(), false); + } if (request.getLang().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "lang", request.getLang().get(), false); @@ -133,6 +144,10 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getWordCountMin().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, "word_count_min", request.getWordCountMin().get(), false); @@ -261,6 +276,11 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -273,12 +293,12 @@ public NewscatcherApiHttpResponse get( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LatestHeadlinesGetResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetLatestHeadlinesResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -306,11 +326,9 @@ public NewscatcherApiHttpResponse get( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -319,26 +337,37 @@ public NewscatcherApiHttpResponse get( /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse post() { - return post(LatestHeadlinesPostRequest.builder().build()); + public NewscatcherApiHttpResponse post() { + return post(PostLatestHeadlinesRequest.builder().build()); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse post(LatestHeadlinesPostRequest request) { + public NewscatcherApiHttpResponse post(RequestOptions requestOptions) { + return post(PostLatestHeadlinesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. + */ + public NewscatcherApiHttpResponse post(PostLatestHeadlinesRequest request) { return post(request, null); } /** * Retrieves the latest headlines for the specified time period. You can filter results by language, country, source, and more. */ - public NewscatcherApiHttpResponse post( - LatestHeadlinesPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostLatestHeadlinesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/latest_headlines") - .build(); + .addPathSegments("api/latest_headlines"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -347,7 +376,7 @@ public NewscatcherApiHttpResponse post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -359,12 +388,12 @@ public NewscatcherApiHttpResponse post( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), LatestHeadlinesPostResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostLatestHeadlinesResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -392,11 +421,9 @@ public NewscatcherApiHttpResponse post( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesGetRequest.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/GetLatestHeadlinesRequest.java similarity index 63% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesGetRequest.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/requests/GetLatestHeadlinesRequest.java index 98fb11c..e4b0e78 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/GetLatestHeadlinesRequest.java @@ -12,19 +12,22 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.latestheadlines.types.LatestHeadlinesGetRequestClusteringVariable; +import com.newscatcher.api.types.ClusteringVariable; +import com.newscatcher.api.types.SortBy; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = LatestHeadlinesGetRequest.Builder.class) -public final class LatestHeadlinesGetRequest { +@JsonDeserialize(builder = GetLatestHeadlinesRequest.Builder.class) +public final class GetLatestHeadlinesRequest { private final Optional when; private final Optional byParseDate; + private final Optional sortBy; + private final Optional lang; private final Optional notLang; @@ -55,6 +58,8 @@ public final class LatestHeadlinesGetRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional wordCountMin; private final Optional wordCountMax; @@ -65,7 +70,7 @@ public final class LatestHeadlinesGetRequest { private final Optional clusteringEnabled; - private final Optional clusteringVariable; + private final Optional clusteringVariable; private final Optional clusteringThreshold; @@ -109,9 +114,10 @@ public final class LatestHeadlinesGetRequest { private final Map additionalProperties; - private LatestHeadlinesGetRequest( + private GetLatestHeadlinesRequest( Optional when, Optional byParseDate, + Optional sortBy, Optional lang, Optional notLang, Optional countries, @@ -127,12 +133,13 @@ private LatestHeadlinesGetRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional wordCountMin, Optional wordCountMax, Optional page, Optional pageSize, Optional clusteringEnabled, - Optional clusteringVariable, + Optional clusteringVariable, Optional clusteringThreshold, Optional includeTranslationFields, Optional includeNlpData, @@ -156,6 +163,7 @@ private LatestHeadlinesGetRequest( Map additionalProperties) { this.when = when; this.byParseDate = byParseDate; + this.sortBy = sortBy; this.lang = lang; this.notLang = notLang; this.countries = countries; @@ -171,6 +179,7 @@ private LatestHeadlinesGetRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.wordCountMin = wordCountMin; this.wordCountMax = wordCountMax; this.page = page; @@ -200,33 +209,24 @@ private LatestHeadlinesGetRequest( this.additionalProperties = additionalProperties; } - /** - * @return The time period for which you want to get the latest headlines. - *

Format examples:

- *
    - *
  • 7d: Last seven days
  • - *
  • 30d: Last 30 days
  • - *
  • 1h: Last hour
  • - *
  • 24h: Last 24 hours
  • - *
- */ @JsonProperty("when") public Optional getWhen() { return when; } - /** - * @return If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object. - */ @JsonProperty("by_parse_date") public Optional getByParseDate() { return byParseDate; } + @JsonProperty("sort_by") + public Optional getSortBy() { + return sortBy; + } + /** * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("lang") public Optional getLang() { @@ -235,8 +235,7 @@ public Optional getLang() { /** * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. - *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("not_lang") public Optional getNotLang() { @@ -245,8 +244,7 @@ public Optional getNotLang() { /** * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("countries") public Optional getCountries() { @@ -255,8 +253,7 @@ public Optional getCountries() { /** * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. - *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("not_countries") public Optional getNotCountries() { @@ -265,14 +262,8 @@ public Optional getNotCountries() { /** * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonProperty("predefined_sources") public Optional getPredefinedSources() { @@ -281,11 +272,6 @@ public Optional getPredefinedSources() { /** * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. - *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @JsonProperty("sources") public Optional getSources() { @@ -294,7 +280,6 @@ public Optional getSources() { /** * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - *

Example: "cnn.com, wsj.com"

*/ @JsonProperty("not_sources") public Optional getNotSources() { @@ -303,40 +288,27 @@ public Optional getNotSources() { /** * @return The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - *

Example: "John Doe, Jane Doe"

*/ @JsonProperty("not_author_name") public Optional getNotAuthorName() { return notAuthorName; } - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ @JsonProperty("ranked_only") public Optional getRankedOnly() { return rankedOnly; } - /** - * @return If true, only returns articles that were posted on the home page of a given news domain. - */ @JsonProperty("is_headline") public Optional getIsHeadline() { return isHeadline; } - /** - * @return If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - */ @JsonProperty("is_opinion") public Optional getIsOpinion() { return isOpinion; } - /** - * @return If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - */ @JsonProperty("is_paid_content") public Optional getIsPaidContent() { return isPaidContent; @@ -344,7 +316,6 @@ public Optional getIsPaidContent() { /** * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - *

Example: "wsj.com/politics, wsj.com/tech"

*/ @JsonProperty("parent_url") public Optional getParentUrl() { @@ -353,8 +324,7 @@ public Optional getParentUrl() { /** * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_links") public Optional getAllLinks() { @@ -363,8 +333,7 @@ public Optional getAllLinks() { /** * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_domain_links") public Optional getAllDomainLinks() { @@ -372,72 +341,45 @@ public Optional getAllDomainLinks() { } /** - * @return The minimum number of words an article must contain. To be used for avoiding articles with small content. + * @return The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; } - /** - * @return The maximum number of words an article can contain. To be used for avoiding articles with large content. - */ @JsonProperty("word_count_max") public Optional getWordCountMax() { return wordCountMax; } - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ @JsonProperty("page") public Optional getPage() { return page; } - /** - * @return The number of articles to return per page. - */ @JsonProperty("page_size") public Optional getPageSize() { return pageSize; } - /** - * @return Determines whether to group similar articles into clusters. If true, the API returns clustered results. - *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_enabled") public Optional getClusteringEnabled() { return clusteringEnabled; } - /** - * @return Specifies which part of the article to use for determining similarity when clustering. - *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_variable") - public Optional getClusteringVariable() { + public Optional getClusteringVariable() { return clusteringVariable; } - /** - * @return Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles. - *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_threshold") public Optional getClusteringThreshold() { return clusteringThreshold; @@ -458,132 +400,51 @@ public Optional getHasNlp() { return hasNlp; } - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonProperty("theme") public Optional getTheme() { return theme; } - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("not_theme") public Optional getNotTheme() { return notTheme; } - /** - * @return Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("ORG_entity_name") public Optional getOrgEntityName() { return orgEntityName; } - /** - * @return Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("PER_entity_name") public Optional getPerEntityName() { return perEntityName; } - /** - * @return Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("LOC_entity_name") public Optional getLocEntityName() { return locEntityName; } - /** - * @return Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("MISC_entity_name") public Optional getMiscEntityName() { return miscEntityName; } - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_min") public Optional getTitleSentimentMin() { return titleSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_max") public Optional getTitleSentimentMax() { return titleSentimentMax; } - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_min") public Optional getContentSentimentMin() { return contentSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_max") public Optional getContentSentimentMax() { return contentSentimentMax; @@ -591,7 +452,6 @@ public Optional getContentSentimentMax() { /** * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -602,7 +462,6 @@ public Optional getIptcTags() { /** * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -613,7 +472,6 @@ public Optional getNotIptcTags() { /** * @return Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -624,7 +482,6 @@ public Optional getIabTags() { /** * @return Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -636,19 +493,16 @@ public Optional getNotIabTags() { /** * @return Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @JsonProperty("custom_tags") public Optional getCustomTags() { return customTags; } - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ @JsonProperty("robots_compliant") public Optional getRobotsCompliant() { return robotsCompliant; @@ -657,7 +511,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof LatestHeadlinesGetRequest && equalTo((LatestHeadlinesGetRequest) other); + return other instanceof GetLatestHeadlinesRequest && equalTo((GetLatestHeadlinesRequest) other); } @JsonAnyGetter @@ -665,9 +519,10 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(LatestHeadlinesGetRequest other) { + private boolean equalTo(GetLatestHeadlinesRequest other) { return when.equals(other.when) && byParseDate.equals(other.byParseDate) + && sortBy.equals(other.sortBy) && lang.equals(other.lang) && notLang.equals(other.notLang) && countries.equals(other.countries) @@ -683,6 +538,7 @@ private boolean equalTo(LatestHeadlinesGetRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && wordCountMin.equals(other.wordCountMin) && wordCountMax.equals(other.wordCountMax) && page.equals(other.page) @@ -716,6 +572,7 @@ public int hashCode() { return Objects.hash( this.when, this.byParseDate, + this.sortBy, this.lang, this.notLang, this.countries, @@ -731,6 +588,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.wordCountMin, this.wordCountMax, this.page, @@ -774,6 +632,8 @@ public static final class Builder { private Optional byParseDate = Optional.empty(); + private Optional sortBy = Optional.empty(); + private Optional lang = Optional.empty(); private Optional notLang = Optional.empty(); @@ -804,6 +664,8 @@ public static final class Builder { private Optional allDomainLinks = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional wordCountMin = Optional.empty(); private Optional wordCountMax = Optional.empty(); @@ -814,7 +676,7 @@ public static final class Builder { private Optional clusteringEnabled = Optional.empty(); - private Optional clusteringVariable = Optional.empty(); + private Optional clusteringVariable = Optional.empty(); private Optional clusteringThreshold = Optional.empty(); @@ -861,9 +723,10 @@ public static final class Builder { private Builder() {} - public Builder from(LatestHeadlinesGetRequest other) { + public Builder from(GetLatestHeadlinesRequest other) { when(other.getWhen()); byParseDate(other.getByParseDate()); + sortBy(other.getSortBy()); lang(other.getLang()); notLang(other.getNotLang()); countries(other.getCountries()); @@ -879,6 +742,7 @@ public Builder from(LatestHeadlinesGetRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); wordCountMin(other.getWordCountMin()); wordCountMax(other.getWordCountMax()); page(other.getPage()); @@ -908,16 +772,6 @@ public Builder from(LatestHeadlinesGetRequest other) { return this; } - /** - *

The time period for which you want to get the latest headlines.

- *

Format examples:

- *
    - *
  • 7d: Last seven days
  • - *
  • 30d: Last 30 days
  • - *
  • 1h: Last hour
  • - *
  • 24h: Last 24 hours
  • - *
- */ @JsonSetter(value = "when", nulls = Nulls.SKIP) public Builder when(Optional when) { this.when = when; @@ -929,9 +783,6 @@ public Builder when(String when) { return this; } - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) public Builder byParseDate(Optional byParseDate) { this.byParseDate = byParseDate; @@ -943,10 +794,20 @@ public Builder byParseDate(Boolean byParseDate) { return this; } + @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) + public Builder sortBy(Optional sortBy) { + this.sortBy = sortBy; + return this; + } + + public Builder sortBy(SortBy sortBy) { + this.sortBy = Optional.ofNullable(sortBy); + return this; + } + /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonSetter(value = "lang", nulls = Nulls.SKIP) public Builder lang(Optional lang) { @@ -961,8 +822,7 @@ public Builder lang(String lang) { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) public Builder notLang(Optional notLang) { @@ -977,8 +837,7 @@ public Builder notLang(String notLang) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonSetter(value = "countries", nulls = Nulls.SKIP) public Builder countries(Optional countries) { @@ -993,8 +852,7 @@ public Builder countries(String countries) { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) public Builder notCountries(Optional notCountries) { @@ -1009,14 +867,8 @@ public Builder notCountries(String notCountries) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) public Builder predefinedSources(Optional predefinedSources) { @@ -1031,11 +883,6 @@ public Builder predefinedSources(String predefinedSources) { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @JsonSetter(value = "sources", nulls = Nulls.SKIP) public Builder sources(Optional sources) { @@ -1050,7 +897,6 @@ public Builder sources(String sources) { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

*/ @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) public Builder notSources(Optional notSources) { @@ -1065,7 +911,6 @@ public Builder notSources(String notSources) { /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

*/ @JsonSetter(value = "not_author_name", nulls = Nulls.SKIP) public Builder notAuthorName(Optional notAuthorName) { @@ -1078,9 +923,6 @@ public Builder notAuthorName(String notAuthorName) { return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) public Builder rankedOnly(Optional rankedOnly) { this.rankedOnly = rankedOnly; @@ -1092,9 +934,6 @@ public Builder rankedOnly(Boolean rankedOnly) { return this; } - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) public Builder isHeadline(Optional isHeadline) { this.isHeadline = isHeadline; @@ -1106,9 +945,6 @@ public Builder isHeadline(Boolean isHeadline) { return this; } - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) public Builder isOpinion(Optional isOpinion) { this.isOpinion = isOpinion; @@ -1120,9 +956,6 @@ public Builder isOpinion(Boolean isOpinion) { return this; } - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) public Builder isPaidContent(Optional isPaidContent) { this.isPaidContent = isPaidContent; @@ -1136,7 +969,6 @@ public Builder isPaidContent(Boolean isPaidContent) { /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

*/ @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) public Builder parentUrl(Optional parentUrl) { @@ -1151,8 +983,7 @@ public Builder parentUrl(String parentUrl) { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonSetter(value = "all_links", nulls = Nulls.SKIP) public Builder allLinks(Optional allLinks) { @@ -1167,8 +998,7 @@ public Builder allLinks(String allLinks) { /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) public Builder allDomainLinks(Optional allDomainLinks) { @@ -1182,8 +1012,21 @@ public Builder allDomainLinks(String allDomainLinks) { } /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

+ *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public Builder allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + + public Builder allLinksText(String allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) public Builder wordCountMin(Optional wordCountMin) { this.wordCountMin = wordCountMin; @@ -1195,9 +1038,6 @@ public Builder wordCountMin(Integer wordCountMin) { return this; } - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) public Builder wordCountMax(Optional wordCountMax) { this.wordCountMax = wordCountMax; @@ -1209,10 +1049,6 @@ public Builder wordCountMax(Integer wordCountMax) { return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -1224,9 +1060,6 @@ public Builder page(Integer page) { return this; } - /** - *

The number of articles to return per page.

- */ @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -1238,10 +1071,6 @@ public Builder pageSize(Integer pageSize) { return this; } - /** - *

Determines whether to group similar articles into clusters. If true, the API returns clustered results.

- *

To learn more, see Clustering news articles.

- */ @JsonSetter(value = "clustering_enabled", nulls = Nulls.SKIP) public Builder clusteringEnabled(Optional clusteringEnabled) { this.clusteringEnabled = clusteringEnabled; @@ -1253,37 +1082,17 @@ public Builder clusteringEnabled(Boolean clusteringEnabled) { return this; } - /** - *

Specifies which part of the article to use for determining similarity when clustering.

- *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonSetter(value = "clustering_variable", nulls = Nulls.SKIP) - public Builder clusteringVariable(Optional clusteringVariable) { + public Builder clusteringVariable(Optional clusteringVariable) { this.clusteringVariable = clusteringVariable; return this; } - public Builder clusteringVariable(LatestHeadlinesGetRequestClusteringVariable clusteringVariable) { + public Builder clusteringVariable(ClusteringVariable clusteringVariable) { this.clusteringVariable = Optional.ofNullable(clusteringVariable); return this; } - /** - *

Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles.

- *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonSetter(value = "clustering_threshold", nulls = Nulls.SKIP) public Builder clusteringThreshold(Optional clusteringThreshold) { this.clusteringThreshold = clusteringThreshold; @@ -1328,13 +1137,6 @@ public Builder hasNlp(Boolean hasNlp) { return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonSetter(value = "theme", nulls = Nulls.SKIP) public Builder theme(Optional theme) { this.theme = theme; @@ -1346,12 +1148,6 @@ public Builder theme(String theme) { return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) public Builder notTheme(Optional notTheme) { this.notTheme = notTheme; @@ -1363,12 +1159,6 @@ public Builder notTheme(String notTheme) { return this; } - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "ORG_entity_name", nulls = Nulls.SKIP) public Builder orgEntityName(Optional orgEntityName) { this.orgEntityName = orgEntityName; @@ -1380,12 +1170,6 @@ public Builder orgEntityName(String orgEntityName) { return this; } - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "PER_entity_name", nulls = Nulls.SKIP) public Builder perEntityName(Optional perEntityName) { this.perEntityName = perEntityName; @@ -1397,12 +1181,6 @@ public Builder perEntityName(String perEntityName) { return this; } - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "LOC_entity_name", nulls = Nulls.SKIP) public Builder locEntityName(Optional locEntityName) { this.locEntityName = locEntityName; @@ -1414,12 +1192,6 @@ public Builder locEntityName(String locEntityName) { return this; } - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonSetter(value = "MISC_entity_name", nulls = Nulls.SKIP) public Builder miscEntityName(Optional miscEntityName) { this.miscEntityName = miscEntityName; @@ -1431,17 +1203,6 @@ public Builder miscEntityName(String miscEntityName) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) public Builder titleSentimentMin(Optional titleSentimentMin) { this.titleSentimentMin = titleSentimentMin; @@ -1453,17 +1214,6 @@ public Builder titleSentimentMin(Float titleSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) public Builder titleSentimentMax(Optional titleSentimentMax) { this.titleSentimentMax = titleSentimentMax; @@ -1475,17 +1225,6 @@ public Builder titleSentimentMax(Float titleSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) public Builder contentSentimentMin(Optional contentSentimentMin) { this.contentSentimentMin = contentSentimentMin; @@ -1497,17 +1236,6 @@ public Builder contentSentimentMin(Float contentSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) public Builder contentSentimentMax(Optional contentSentimentMax) { this.contentSentimentMax = contentSentimentMax; @@ -1521,7 +1249,6 @@ public Builder contentSentimentMax(Float contentSentimentMax) { /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1538,7 +1265,6 @@ public Builder iptcTags(String iptcTags) { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1555,7 +1281,6 @@ public Builder notIptcTags(String notIptcTags) { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1572,7 +1297,6 @@ public Builder iabTags(String iabTags) { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1590,10 +1314,10 @@ public Builder notIabTags(String notIabTags) { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) public Builder customTags(Optional customTags) { @@ -1606,9 +1330,6 @@ public Builder customTags(String customTags) { return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) public Builder robotsCompliant(Optional robotsCompliant) { this.robotsCompliant = robotsCompliant; @@ -1620,10 +1341,11 @@ public Builder robotsCompliant(Boolean robotsCompliant) { return this; } - public LatestHeadlinesGetRequest build() { - return new LatestHeadlinesGetRequest( + public GetLatestHeadlinesRequest build() { + return new GetLatestHeadlinesRequest( when, byParseDate, + sortBy, lang, notLang, countries, @@ -1639,6 +1361,7 @@ public LatestHeadlinesGetRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, wordCountMin, wordCountMax, page, @@ -1667,5 +1390,15 @@ public LatestHeadlinesGetRequest build() { robotsCompliant, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesPostRequest.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/PostLatestHeadlinesRequest.java similarity index 94% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesPostRequest.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/requests/PostLatestHeadlinesRequest.java index b9f1723..26c74ab 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/LatestHeadlinesPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/requests/PostLatestHeadlinesRequest.java @@ -14,6 +14,7 @@ import com.newscatcher.api.core.ObjectMappers; import com.newscatcher.api.types.AllDomainLinks; import com.newscatcher.api.types.AllLinks; +import com.newscatcher.api.types.AllLinksText; import com.newscatcher.api.types.ClusteringVariable; import com.newscatcher.api.types.Countries; import com.newscatcher.api.types.CustomTags; @@ -26,19 +27,17 @@ import com.newscatcher.api.types.NotIptcTags; import com.newscatcher.api.types.NotLang; import com.newscatcher.api.types.NotSources; -import com.newscatcher.api.types.NotTheme; import com.newscatcher.api.types.ParentUrl; import com.newscatcher.api.types.PredefinedSources; import com.newscatcher.api.types.Sources; -import com.newscatcher.api.types.Theme; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = LatestHeadlinesPostRequest.Builder.class) -public final class LatestHeadlinesPostRequest { +@JsonDeserialize(builder = PostLatestHeadlinesRequest.Builder.class) +public final class PostLatestHeadlinesRequest { private final Optional when; private final Optional byParseDate; @@ -73,6 +72,8 @@ public final class LatestHeadlinesPostRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional wordCountMin; private final Optional wordCountMax; @@ -93,9 +94,9 @@ public final class LatestHeadlinesPostRequest { private final Optional hasNlp; - private final Optional theme; + private final Optional theme; - private final Optional notTheme; + private final Optional notTheme; private final Optional orgEntityName; @@ -127,7 +128,7 @@ public final class LatestHeadlinesPostRequest { private final Map additionalProperties; - private LatestHeadlinesPostRequest( + private PostLatestHeadlinesRequest( Optional when, Optional byParseDate, Optional lang, @@ -145,6 +146,7 @@ private LatestHeadlinesPostRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional wordCountMin, Optional wordCountMax, Optional page, @@ -155,8 +157,8 @@ private LatestHeadlinesPostRequest( Optional includeTranslationFields, Optional includeNlpData, Optional hasNlp, - Optional theme, - Optional notTheme, + Optional theme, + Optional notTheme, Optional orgEntityName, Optional perEntityName, Optional locEntityName, @@ -189,6 +191,7 @@ private LatestHeadlinesPostRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.wordCountMin = wordCountMin; this.wordCountMax = wordCountMax; this.page = page; @@ -303,6 +306,11 @@ public Optional getAllDomainLinks() { return allDomainLinks; } + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; @@ -354,12 +362,12 @@ public Optional getHasNlp() { } @JsonProperty("theme") - public Optional getTheme() { + public Optional getTheme() { return theme; } @JsonProperty("not_theme") - public Optional getNotTheme() { + public Optional getNotTheme() { return notTheme; } @@ -436,7 +444,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof LatestHeadlinesPostRequest && equalTo((LatestHeadlinesPostRequest) other); + return other instanceof PostLatestHeadlinesRequest && equalTo((PostLatestHeadlinesRequest) other); } @JsonAnyGetter @@ -444,7 +452,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(LatestHeadlinesPostRequest other) { + private boolean equalTo(PostLatestHeadlinesRequest other) { return when.equals(other.when) && byParseDate.equals(other.byParseDate) && lang.equals(other.lang) @@ -462,6 +470,7 @@ private boolean equalTo(LatestHeadlinesPostRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && wordCountMin.equals(other.wordCountMin) && wordCountMax.equals(other.wordCountMax) && page.equals(other.page) @@ -510,6 +519,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.wordCountMin, this.wordCountMax, this.page, @@ -583,6 +593,8 @@ public static final class Builder { private Optional allDomainLinks = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional wordCountMin = Optional.empty(); private Optional wordCountMax = Optional.empty(); @@ -603,9 +615,9 @@ public static final class Builder { private Optional hasNlp = Optional.empty(); - private Optional theme = Optional.empty(); + private Optional theme = Optional.empty(); - private Optional notTheme = Optional.empty(); + private Optional notTheme = Optional.empty(); private Optional orgEntityName = Optional.empty(); @@ -640,7 +652,7 @@ public static final class Builder { private Builder() {} - public Builder from(LatestHeadlinesPostRequest other) { + public Builder from(PostLatestHeadlinesRequest other) { when(other.getWhen()); byParseDate(other.getByParseDate()); lang(other.getLang()); @@ -658,6 +670,7 @@ public Builder from(LatestHeadlinesPostRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); wordCountMin(other.getWordCountMin()); wordCountMax(other.getWordCountMax()); page(other.getPage()); @@ -874,6 +887,17 @@ public Builder allDomainLinks(AllDomainLinks allDomainLinks) { return this; } + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public Builder allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + + public Builder allLinksText(AllLinksText allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) public Builder wordCountMin(Optional wordCountMin) { this.wordCountMin = wordCountMin; @@ -985,23 +1009,23 @@ public Builder hasNlp(Boolean hasNlp) { } @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public Builder theme(Optional theme) { + public Builder theme(Optional theme) { this.theme = theme; return this; } - public Builder theme(Theme theme) { + public Builder theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public Builder notTheme(Optional notTheme) { + public Builder notTheme(Optional notTheme) { this.notTheme = notTheme; return this; } - public Builder notTheme(NotTheme notTheme) { + public Builder notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } @@ -1160,8 +1184,8 @@ public Builder robotsCompliant(Boolean robotsCompliant) { return this; } - public LatestHeadlinesPostRequest build() { - return new LatestHeadlinesPostRequest( + public PostLatestHeadlinesRequest build() { + return new PostLatestHeadlinesRequest( when, byParseDate, lang, @@ -1179,6 +1203,7 @@ public LatestHeadlinesPostRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, wordCountMin, wordCountMax, page, @@ -1207,5 +1232,15 @@ public LatestHeadlinesPostRequest build() { robotsCompliant, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetResponse.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/types/GetLatestHeadlinesResponse.java similarity index 75% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetResponse.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/types/GetLatestHeadlinesResponse.java index b65c9c3..112d7ab 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetResponse.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/types/GetLatestHeadlinesResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = LatestHeadlinesGetResponse.Deserializer.class) -public final class LatestHeadlinesGetResponse { +@JsonDeserialize(using = GetLatestHeadlinesResponse.Deserializer.class) +public final class GetLatestHeadlinesResponse { private final Object value; private final int type; - private LatestHeadlinesGetResponse(Object value, int type) { + private GetLatestHeadlinesResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof LatestHeadlinesGetResponse && equalTo((LatestHeadlinesGetResponse) other); + return other instanceof GetLatestHeadlinesResponse && equalTo((GetLatestHeadlinesResponse) other); } - private boolean equalTo(LatestHeadlinesGetResponse other) { + private boolean equalTo(GetLatestHeadlinesResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static LatestHeadlinesGetResponse of(SearchResponseDto value) { - return new LatestHeadlinesGetResponse(value, 0); + public static GetLatestHeadlinesResponse of(SearchResponseDto value) { + return new GetLatestHeadlinesResponse(value, 0); } - public static LatestHeadlinesGetResponse of(ClusteredSearchResponseDto value) { - return new LatestHeadlinesGetResponse(value, 1); + public static GetLatestHeadlinesResponse of(ClusteredSearchResponseDto value) { + return new GetLatestHeadlinesResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(ClusteredSearchResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(LatestHeadlinesGetResponse.class); + super(GetLatestHeadlinesResponse.class); } @java.lang.Override - public LatestHeadlinesGetResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public GetLatestHeadlinesResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetRequestClusteringVariable.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetRequestClusteringVariable.java deleted file mode 100644 index 171731c..0000000 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesGetRequestClusteringVariable.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.latestheadlines.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum LatestHeadlinesGetRequestClusteringVariable { - CONTENT("content"), - - TITLE("title"), - - SUMMARY("summary"); - - private final String value; - - LatestHeadlinesGetRequestClusteringVariable(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesPostResponse.java b/src/main/java/com/newscatcher/api/resources/latestheadlines/types/PostLatestHeadlinesResponse.java similarity index 75% rename from src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesPostResponse.java rename to src/main/java/com/newscatcher/api/resources/latestheadlines/types/PostLatestHeadlinesResponse.java index 2aa3463..da8f572 100644 --- a/src/main/java/com/newscatcher/api/resources/latestheadlines/types/LatestHeadlinesPostResponse.java +++ b/src/main/java/com/newscatcher/api/resources/latestheadlines/types/PostLatestHeadlinesResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = LatestHeadlinesPostResponse.Deserializer.class) -public final class LatestHeadlinesPostResponse { +@JsonDeserialize(using = PostLatestHeadlinesResponse.Deserializer.class) +public final class PostLatestHeadlinesResponse { private final Object value; private final int type; - private LatestHeadlinesPostResponse(Object value, int type) { + private PostLatestHeadlinesResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof LatestHeadlinesPostResponse && equalTo((LatestHeadlinesPostResponse) other); + return other instanceof PostLatestHeadlinesResponse && equalTo((PostLatestHeadlinesResponse) other); } - private boolean equalTo(LatestHeadlinesPostResponse other) { + private boolean equalTo(PostLatestHeadlinesResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static LatestHeadlinesPostResponse of(SearchResponseDto value) { - return new LatestHeadlinesPostResponse(value, 0); + public static PostLatestHeadlinesResponse of(SearchResponseDto value) { + return new PostLatestHeadlinesResponse(value, 0); } - public static LatestHeadlinesPostResponse of(ClusteredSearchResponseDto value) { - return new LatestHeadlinesPostResponse(value, 1); + public static PostLatestHeadlinesResponse of(ClusteredSearchResponseDto value) { + return new PostLatestHeadlinesResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(ClusteredSearchResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(LatestHeadlinesPostResponse.class); + super(PostLatestHeadlinesResponse.class); } @java.lang.Override - public LatestHeadlinesPostResponse deserialize(JsonParser p, DeserializationContext context) + public PostLatestHeadlinesResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { diff --git a/src/main/java/com/newscatcher/api/resources/search/AsyncRawSearchClient.java b/src/main/java/com/newscatcher/api/resources/search/AsyncRawSearchClient.java index ddfb46b..b1d4b03 100644 --- a/src/main/java/com/newscatcher/api/resources/search/AsyncRawSearchClient.java +++ b/src/main/java/com/newscatcher/api/resources/search/AsyncRawSearchClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.search.requests.SearchGetRequest; -import com.newscatcher.api.resources.search.requests.SearchPostRequest; -import com.newscatcher.api.resources.search.types.SearchGetResponse; -import com.newscatcher.api.resources.search.types.SearchPostResponse; +import com.newscatcher.api.resources.search.requests.GetSearchRequest; +import com.newscatcher.api.resources.search.requests.PostSearchRequest; +import com.newscatcher.api.resources.search.types.GetSearchResponse; +import com.newscatcher.api.resources.search.types.PostSearchResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import java.util.concurrent.CompletableFuture; @@ -45,17 +45,17 @@ public AsyncRawSearchClient(ClientOptions clientOptions) { } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture> get(SearchGetRequest request) { + public CompletableFuture> get(GetSearchRequest request) { return get(request, null); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture> get( - SearchGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get( + GetSearchRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/search"); @@ -168,6 +168,10 @@ public CompletableFuture> get( QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getAdditionalDomainInfo().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, @@ -315,6 +319,11 @@ public CompletableFuture> get( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -325,18 +334,18 @@ public CompletableFuture> get( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchGetResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetSearchResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -378,11 +387,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -399,21 +406,25 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture> post(SearchPostRequest request) { + public CompletableFuture> post(PostSearchRequest request) { return post(request, null); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture> post( - SearchPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostSearchRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/search") - .build(); + .addPathSegments("api/search"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -422,7 +433,7 @@ public CompletableFuture> post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -432,18 +443,18 @@ public CompletableFuture> post( if (requestOptions != null && requestOptions.getTimeout().isPresent()) { client = clientOptions.httpClientWithTimeout(requestOptions); } - CompletableFuture> future = new CompletableFuture<>(); + CompletableFuture> future = new CompletableFuture<>(); client.newCall(okhttpRequest).enqueue(new Callback() { @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchPostResponse.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostSearchResponse.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -485,11 +496,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/search/AsyncSearchClient.java b/src/main/java/com/newscatcher/api/resources/search/AsyncSearchClient.java index 306bb5d..c1f1cf4 100644 --- a/src/main/java/com/newscatcher/api/resources/search/AsyncSearchClient.java +++ b/src/main/java/com/newscatcher/api/resources/search/AsyncSearchClient.java @@ -5,10 +5,10 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.search.requests.SearchGetRequest; -import com.newscatcher.api.resources.search.requests.SearchPostRequest; -import com.newscatcher.api.resources.search.types.SearchGetResponse; -import com.newscatcher.api.resources.search.types.SearchPostResponse; +import com.newscatcher.api.resources.search.requests.GetSearchRequest; +import com.newscatcher.api.resources.search.requests.PostSearchRequest; +import com.newscatcher.api.resources.search.types.GetSearchResponse; +import com.newscatcher.api.resources.search.types.PostSearchResponse; import java.util.concurrent.CompletableFuture; public class AsyncSearchClient { @@ -29,30 +29,30 @@ public AsyncRawSearchClient withRawResponse() { } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture get(SearchGetRequest request) { + public CompletableFuture get(GetSearchRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture get(SearchGetRequest request, RequestOptions requestOptions) { + public CompletableFuture get(GetSearchRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture post(SearchPostRequest request) { + public CompletableFuture post(PostSearchRequest request) { return this.rawClient.post(request).thenApply(response -> response.body()); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public CompletableFuture post(SearchPostRequest request, RequestOptions requestOptions) { + public CompletableFuture post(PostSearchRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/search/RawSearchClient.java b/src/main/java/com/newscatcher/api/resources/search/RawSearchClient.java index 5b2e061..615b8ba 100644 --- a/src/main/java/com/newscatcher/api/resources/search/RawSearchClient.java +++ b/src/main/java/com/newscatcher/api/resources/search/RawSearchClient.java @@ -19,10 +19,10 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.search.requests.SearchGetRequest; -import com.newscatcher.api.resources.search.requests.SearchPostRequest; -import com.newscatcher.api.resources.search.types.SearchGetResponse; -import com.newscatcher.api.resources.search.types.SearchPostResponse; +import com.newscatcher.api.resources.search.requests.GetSearchRequest; +import com.newscatcher.api.resources.search.requests.PostSearchRequest; +import com.newscatcher.api.resources.search.types.GetSearchResponse; +import com.newscatcher.api.resources.search.types.PostSearchResponse; import com.newscatcher.api.types.Error; import java.io.IOException; import okhttp3.Headers; @@ -41,16 +41,16 @@ public RawSearchClient(ClientOptions clientOptions) { } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public NewscatcherApiHttpResponse get(SearchGetRequest request) { + public NewscatcherApiHttpResponse get(GetSearchRequest request) { return get(request, null); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public NewscatcherApiHttpResponse get(SearchGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get(GetSearchRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/search"); @@ -163,6 +163,10 @@ public NewscatcherApiHttpResponse get(SearchGetRequest reques QueryStringMapper.addQueryParameter( httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); } + if (request.getAllLinksText().isPresent()) { + QueryStringMapper.addQueryParameter( + httpUrl, "all_links_text", request.getAllLinksText().get(), false); + } if (request.getAdditionalDomainInfo().isPresent()) { QueryStringMapper.addQueryParameter( httpUrl, @@ -310,6 +314,11 @@ public NewscatcherApiHttpResponse get(SearchGetRequest reques QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -322,11 +331,11 @@ public NewscatcherApiHttpResponse get(SearchGetRequest reques } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchGetResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetSearchResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -354,32 +363,34 @@ public NewscatcherApiHttpResponse get(SearchGetRequest reques } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public NewscatcherApiHttpResponse post(SearchPostRequest request) { + public NewscatcherApiHttpResponse post(PostSearchRequest request) { return post(request, null); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public NewscatcherApiHttpResponse post( - SearchPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostSearchRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/search") - .build(); + .addPathSegments("api/search"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -388,7 +399,7 @@ public NewscatcherApiHttpResponse post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -400,11 +411,11 @@ public NewscatcherApiHttpResponse post( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchPostResponse.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PostSearchResponse.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -432,11 +443,9 @@ public NewscatcherApiHttpResponse post( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/search/SearchClient.java b/src/main/java/com/newscatcher/api/resources/search/SearchClient.java index fd79774..e77ce0f 100644 --- a/src/main/java/com/newscatcher/api/resources/search/SearchClient.java +++ b/src/main/java/com/newscatcher/api/resources/search/SearchClient.java @@ -5,10 +5,10 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.search.requests.SearchGetRequest; -import com.newscatcher.api.resources.search.requests.SearchPostRequest; -import com.newscatcher.api.resources.search.types.SearchGetResponse; -import com.newscatcher.api.resources.search.types.SearchPostResponse; +import com.newscatcher.api.resources.search.requests.GetSearchRequest; +import com.newscatcher.api.resources.search.requests.PostSearchRequest; +import com.newscatcher.api.resources.search.types.GetSearchResponse; +import com.newscatcher.api.resources.search.types.PostSearchResponse; public class SearchClient { protected final ClientOptions clientOptions; @@ -28,30 +28,30 @@ public RawSearchClient withRawResponse() { } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public SearchGetResponse get(SearchGetRequest request) { + public GetSearchResponse get(GetSearchRequest request) { return this.rawClient.get(request).body(); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public SearchGetResponse get(SearchGetRequest request, RequestOptions requestOptions) { + public GetSearchResponse get(GetSearchRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public SearchPostResponse post(SearchPostRequest request) { + public PostSearchResponse post(PostSearchRequest request) { return this.rawClient.post(request).body(); } /** - * Searches for articles based on specified criteria such as keyword, language, country, source, and more. + * Searches for articles based on specified criteria such as keywords, language, country, source, and more. */ - public SearchPostResponse post(SearchPostRequest request, RequestOptions requestOptions) { + public PostSearchResponse post(PostSearchRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/search/requests/SearchGetRequest.java b/src/main/java/com/newscatcher/api/resources/search/requests/GetSearchRequest.java similarity index 50% rename from src/main/java/com/newscatcher/api/resources/search/requests/SearchGetRequest.java rename to src/main/java/com/newscatcher/api/resources/search/requests/GetSearchRequest.java index 28cadf2..35f5f53 100644 --- a/src/main/java/com/newscatcher/api/resources/search/requests/SearchGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/search/requests/GetSearchRequest.java @@ -12,11 +12,11 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.search.types.SearchGetRequestClusteringVariable; -import com.newscatcher.api.resources.search.types.SearchGetRequestNewsDomainType; -import com.newscatcher.api.resources.search.types.SearchGetRequestPublishedDatePrecision; -import com.newscatcher.api.resources.search.types.SearchGetRequestSortBy; -import java.time.OffsetDateTime; +import com.newscatcher.api.types.ClusteringVariable; +import com.newscatcher.api.types.From; +import com.newscatcher.api.types.NewsDomainType; +import com.newscatcher.api.types.SortBy; +import com.newscatcher.api.types.To; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -24,8 +24,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchGetRequest.Builder.class) -public final class SearchGetRequest { +@JsonDeserialize(builder = GetSearchRequest.Builder.class) +public final class GetSearchRequest { private final String q; private final Optional searchIn; @@ -50,15 +50,15 @@ public final class SearchGetRequest { private final Optional notAuthorName; - private final Optional from; + private final Optional from; - private final Optional to; + private final Optional to; - private final Optional publishedDatePrecision; + private final Optional publishedDatePrecision; private final Optional byParseDate; - private final Optional sortBy; + private final Optional sortBy; private final Optional rankedOnly; @@ -78,11 +78,13 @@ public final class SearchGetRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional additionalDomainInfo; private final Optional isNewsDomain; - private final Optional newsDomainType; + private final Optional newsDomainType; private final Optional newsType; @@ -96,7 +98,7 @@ public final class SearchGetRequest { private final Optional clusteringEnabled; - private final Optional clusteringVariable; + private final Optional clusteringVariable; private final Optional clusteringThreshold; @@ -140,7 +142,7 @@ public final class SearchGetRequest { private final Map additionalProperties; - private SearchGetRequest( + private GetSearchRequest( String q, Optional searchIn, Optional includeTranslationFields, @@ -153,11 +155,11 @@ private SearchGetRequest( Optional countries, Optional notCountries, Optional notAuthorName, - Optional from, - Optional to, - Optional publishedDatePrecision, + Optional from, + Optional to, + Optional publishedDatePrecision, Optional byParseDate, - Optional sortBy, + Optional sortBy, Optional rankedOnly, Optional fromRank, Optional toRank, @@ -167,16 +169,17 @@ private SearchGetRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional additionalDomainInfo, Optional isNewsDomain, - Optional newsDomainType, + Optional newsDomainType, Optional newsType, Optional wordCountMin, Optional wordCountMax, Optional page, Optional pageSize, Optional clusteringEnabled, - Optional clusteringVariable, + Optional clusteringVariable, Optional clusteringThreshold, Optional includeNlpData, Optional hasNlp, @@ -224,6 +227,7 @@ private SearchGetRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.additionalDomainInfo = additionalDomainInfo; this.isNewsDomain = isNewsDomain; this.newsDomainType = newsDomainType; @@ -257,18 +261,6 @@ private SearchGetRequest( this.additionalProperties = additionalProperties; } - /** - * @return The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards: - *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ @JsonProperty("q") public String getQ() { return q; @@ -286,14 +278,8 @@ public Optional getIncludeTranslationFields() { /** * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonProperty("predefined_sources") public Optional getPredefinedSources() { @@ -302,7 +288,6 @@ public Optional getPredefinedSources() { /** * @return Word or phrase to search within the source names. To specify multiple values, use a comma-separated string. - *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

*/ @JsonProperty("source_name") @@ -312,11 +297,6 @@ public Optional getSourceName() { /** * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. - *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @JsonProperty("sources") public Optional getSources() { @@ -325,7 +305,6 @@ public Optional getSources() { /** * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - *

Example: "cnn.com, wsj.com"

*/ @JsonProperty("not_sources") public Optional getNotSources() { @@ -334,8 +313,7 @@ public Optional getNotSources() { /** * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("lang") public Optional getLang() { @@ -344,8 +322,7 @@ public Optional getLang() { /** * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. - *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("not_lang") public Optional getNotLang() { @@ -354,8 +331,7 @@ public Optional getNotLang() { /** * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("countries") public Optional getCountries() { @@ -364,8 +340,7 @@ public Optional getCountries() { /** * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. - *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("not_countries") public Optional getNotCountries() { @@ -374,124 +349,62 @@ public Optional getNotCountries() { /** * @return The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string. - *

Example: "John Doe, Jane Doe"

*/ @JsonProperty("not_author_name") public Optional getNotAuthorName() { return notAuthorName; } - /** - * @return The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @JsonProperty("from_") - public Optional getFrom() { + public Optional getFrom() { return from; } - /** - * @return The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @JsonProperty("to_") - public Optional getTo() { + public Optional getTo() { return to; } - /** - * @return The precision of the published date. There are three types: - *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { + public Optional getPublishedDatePrecision() { return publishedDatePrecision; } - /** - * @return If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object. - */ @JsonProperty("by_parse_date") public Optional getByParseDate() { return byParseDate; } - /** - * @return The sorting order of the results. Possible values are: - *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @JsonProperty("sort_by") - public Optional getSortBy() { + public Optional getSortBy() { return sortBy; } - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ @JsonProperty("ranked_only") public Optional getRankedOnly() { return rankedOnly; } - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("from_rank") public Optional getFromRank() { return fromRank; } - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("to_rank") public Optional getToRank() { return toRank; } - /** - * @return If true, only returns articles that were posted on the home page of a given news domain. - */ @JsonProperty("is_headline") public Optional getIsHeadline() { return isHeadline; } - /** - * @return If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - */ @JsonProperty("is_opinion") public Optional getIsOpinion() { return isOpinion; } - /** - * @return If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - */ @JsonProperty("is_paid_content") public Optional getIsPaidContent() { return isPaidContent; @@ -499,7 +412,6 @@ public Optional getIsPaidContent() { /** * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - *

Example: "wsj.com/politics, wsj.com/tech"

*/ @JsonProperty("parent_url") public Optional getParentUrl() { @@ -508,8 +420,7 @@ public Optional getParentUrl() { /** * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_links") public Optional getAllLinks() { @@ -518,8 +429,7 @@ public Optional getAllLinks() { /** * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @JsonProperty("all_domain_links") public Optional getAllDomainLinks() { @@ -527,118 +437,69 @@ public Optional getAllDomainLinks() { } /** - * @return If true, includes additional domain information in the response for each article: - *
    - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "News and Blogs").
  • - *
+ * @return The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string. + *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("additional_domain_info") public Optional getAdditionalDomainInfo() { return additionalDomainInfo; } - /** - * @return If true, filters results to include only news domains. - */ @JsonProperty("is_news_domain") public Optional getIsNewsDomain() { return isNewsDomain; } - /** - * @return Filters results based on the news domain type. Possible values are: - *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- */ @JsonProperty("news_domain_type") - public Optional getNewsDomainType() { + public Optional getNewsDomainType() { return newsDomainType; } /** * @return Filters results based on the news type. Multiple types can be specified using a comma-separated string. - *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

*/ @JsonProperty("news_type") public Optional getNewsType() { return newsType; } - /** - * @return The minimum number of words an article must contain. To be used for avoiding articles with small content. - */ @JsonProperty("word_count_min") public Optional getWordCountMin() { return wordCountMin; } - /** - * @return The maximum number of words an article can contain. To be used for avoiding articles with large content. - */ @JsonProperty("word_count_max") public Optional getWordCountMax() { return wordCountMax; } - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ @JsonProperty("page") public Optional getPage() { return page; } - /** - * @return The number of articles to return per page. - */ @JsonProperty("page_size") public Optional getPageSize() { return pageSize; } - /** - * @return Determines whether to group similar articles into clusters. If true, the API returns clustered results. - *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_enabled") public Optional getClusteringEnabled() { return clusteringEnabled; } - /** - * @return Specifies which part of the article to use for determining similarity when clustering. - *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_variable") - public Optional getClusteringVariable() { + public Optional getClusteringVariable() { return clusteringVariable; } - /** - * @return Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles. - *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- */ @JsonProperty("clustering_threshold") public Optional getClusteringThreshold() { return clusteringThreshold; @@ -654,132 +515,51 @@ public Optional getHasNlp() { return hasNlp; } - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @JsonProperty("theme") public Optional getTheme() { return theme; } - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("not_theme") public Optional getNotTheme() { return notTheme; } - /** - * @return Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("ORG_entity_name") public Optional getOrgEntityName() { return orgEntityName; } - /** - * @return Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("PER_entity_name") public Optional getPerEntityName() { return perEntityName; } - /** - * @return Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("LOC_entity_name") public Optional getLocEntityName() { return locEntityName; } - /** - * @return Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated). - *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @JsonProperty("MISC_entity_name") public Optional getMiscEntityName() { return miscEntityName; } - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_min") public Optional getTitleSentimentMin() { return titleSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("title_sentiment_max") public Optional getTitleSentimentMax() { return titleSentimentMax; } - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_min") public Optional getContentSentimentMin() { return contentSentimentMin; } - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @JsonProperty("content_sentiment_max") public Optional getContentSentimentMax() { return contentSentimentMax; @@ -787,7 +567,6 @@ public Optional getContentSentimentMax() { /** * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -798,7 +577,6 @@ public Optional getIptcTags() { /** * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -809,7 +587,6 @@ public Optional getNotIptcTags() { /** * @return Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string. - *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -820,7 +597,6 @@ public Optional getIabTags() { /** * @return Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string. - *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -832,28 +608,21 @@ public Optional getNotIabTags() { /** * @return Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @JsonProperty("custom_tags") public Optional getCustomTags() { return customTags; } - /** - * @return If true, excludes duplicate and highly similar articles from the search results. If false, returns all relevant articles, including duplicates. - *

To learn more, see Articles deduplication.

- */ @JsonProperty("exclude_duplicates") public Optional getExcludeDuplicates() { return excludeDuplicates; } - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ @JsonProperty("robots_compliant") public Optional getRobotsCompliant() { return robotsCompliant; @@ -862,7 +631,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchGetRequest && equalTo((SearchGetRequest) other); + return other instanceof GetSearchRequest && equalTo((GetSearchRequest) other); } @JsonAnyGetter @@ -870,7 +639,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchGetRequest other) { + private boolean equalTo(GetSearchRequest other) { return q.equals(other.q) && searchIn.equals(other.searchIn) && includeTranslationFields.equals(other.includeTranslationFields) @@ -897,6 +666,7 @@ private boolean equalTo(SearchGetRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && additionalDomainInfo.equals(other.additionalDomainInfo) && isNewsDomain.equals(other.isNewsDomain) && newsDomainType.equals(other.newsDomainType) @@ -958,6 +728,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.additionalDomainInfo, this.isNewsDomain, this.newsDomainType, @@ -1000,25 +771,17 @@ public static QStage builder() { } public interface QStage { - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ _FinalStage q(@NotNull String q); - Builder from(SearchGetRequest other); + Builder from(GetSearchRequest other); } public interface _FinalStage { - SearchGetRequest build(); + GetSearchRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); _FinalStage searchIn(Optional searchIn); @@ -1030,14 +793,8 @@ public interface _FinalStage { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ _FinalStage predefinedSources(Optional predefinedSources); @@ -1045,7 +802,6 @@ public interface _FinalStage { /** *

Word or phrase to search within the source names. To specify multiple values, use a comma-separated string.

- *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

*/ _FinalStage sourceName(Optional sourceName); @@ -1054,11 +810,6 @@ public interface _FinalStage { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ _FinalStage sources(Optional sources); @@ -1066,7 +817,6 @@ public interface _FinalStage { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

*/ _FinalStage notSources(Optional notSources); @@ -1074,8 +824,7 @@ public interface _FinalStage { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ _FinalStage lang(Optional lang); @@ -1083,8 +832,7 @@ public interface _FinalStage { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ _FinalStage notLang(Optional notLang); @@ -1092,8 +840,7 @@ public interface _FinalStage { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ _FinalStage countries(Optional countries); @@ -1101,8 +848,7 @@ public interface _FinalStage { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ _FinalStage notCountries(Optional notCountries); @@ -1110,120 +856,57 @@ public interface _FinalStage { /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

*/ _FinalStage notAuthorName(Optional notAuthorName); _FinalStage notAuthorName(String notAuthorName); - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage from(Optional from); + _FinalStage from(Optional from); - _FinalStage from(OffsetDateTime from); + _FinalStage from(From from); - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage to(Optional to); + _FinalStage to(Optional to); - _FinalStage to(OffsetDateTime to); + _FinalStage to(To to); - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - _FinalStage publishedDatePrecision(SearchGetRequestPublishedDatePrecision publishedDatePrecision); + _FinalStage publishedDatePrecision(String publishedDatePrecision); - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ _FinalStage byParseDate(Optional byParseDate); _FinalStage byParseDate(Boolean byParseDate); - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - _FinalStage sortBy(Optional sortBy); + _FinalStage sortBy(Optional sortBy); - _FinalStage sortBy(SearchGetRequestSortBy sortBy); + _FinalStage sortBy(SortBy sortBy); - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ _FinalStage rankedOnly(Optional rankedOnly); _FinalStage rankedOnly(Boolean rankedOnly); - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ _FinalStage fromRank(Optional fromRank); _FinalStage fromRank(Integer fromRank); - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ _FinalStage toRank(Optional toRank); _FinalStage toRank(Integer toRank); - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ _FinalStage isHeadline(Optional isHeadline); _FinalStage isHeadline(Boolean isHeadline); - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ _FinalStage isOpinion(Optional isOpinion); _FinalStage isOpinion(Boolean isOpinion); - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ _FinalStage isPaidContent(Optional isPaidContent); _FinalStage isPaidContent(Boolean isPaidContent); /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

*/ _FinalStage parentUrl(Optional parentUrl); @@ -1231,8 +914,7 @@ public interface _FinalStage { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ _FinalStage allLinks(Optional allLinks); @@ -1240,116 +922,65 @@ public interface _FinalStage { /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ _FinalStage allDomainLinks(Optional allDomainLinks); _FinalStage allDomainLinks(String allDomainLinks); /** - *

If true, includes additional domain information in the response for each article:

- *
    - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "News and Blogs").
  • - *
+ *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

*/ + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(String allLinksText); + _FinalStage additionalDomainInfo(Optional additionalDomainInfo); _FinalStage additionalDomainInfo(Boolean additionalDomainInfo); - /** - *

If true, filters results to include only news domains.

- */ _FinalStage isNewsDomain(Optional isNewsDomain); _FinalStage isNewsDomain(Boolean isNewsDomain); - /** - *

Filters results based on the news domain type. Possible values are:

- *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- */ - _FinalStage newsDomainType(Optional newsDomainType); + _FinalStage newsDomainType(Optional newsDomainType); - _FinalStage newsDomainType(SearchGetRequestNewsDomainType newsDomainType); + _FinalStage newsDomainType(NewsDomainType newsDomainType); /** *

Filters results based on the news type. Multiple types can be specified using a comma-separated string.

- *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

*/ _FinalStage newsType(Optional newsType); _FinalStage newsType(String newsType); - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ _FinalStage wordCountMin(Optional wordCountMin); _FinalStage wordCountMin(Integer wordCountMin); - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ _FinalStage wordCountMax(Optional wordCountMax); _FinalStage wordCountMax(Integer wordCountMax); - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ _FinalStage page(Optional page); _FinalStage page(Integer page); - /** - *

The number of articles to return per page.

- */ _FinalStage pageSize(Optional pageSize); _FinalStage pageSize(Integer pageSize); - /** - *

Determines whether to group similar articles into clusters. If true, the API returns clustered results.

- *

To learn more, see Clustering news articles.

- */ _FinalStage clusteringEnabled(Optional clusteringEnabled); _FinalStage clusteringEnabled(Boolean clusteringEnabled); - /** - *

Specifies which part of the article to use for determining similarity when clustering.

- *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- */ - _FinalStage clusteringVariable(Optional clusteringVariable); + _FinalStage clusteringVariable(Optional clusteringVariable); - _FinalStage clusteringVariable(SearchGetRequestClusteringVariable clusteringVariable); + _FinalStage clusteringVariable(ClusteringVariable clusteringVariable); - /** - *

Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles.

- *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- */ _FinalStage clusteringThreshold(Optional clusteringThreshold); _FinalStage clusteringThreshold(Float clusteringThreshold); @@ -1362,130 +993,48 @@ public interface _FinalStage { _FinalStage hasNlp(Boolean hasNlp); - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ _FinalStage theme(Optional theme); _FinalStage theme(String theme); - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage notTheme(Optional notTheme); _FinalStage notTheme(String notTheme); - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ _FinalStage orgEntityName(Optional orgEntityName); _FinalStage orgEntityName(String orgEntityName); - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ _FinalStage perEntityName(Optional perEntityName); _FinalStage perEntityName(String perEntityName); - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ _FinalStage locEntityName(Optional locEntityName); _FinalStage locEntityName(String locEntityName); - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ _FinalStage miscEntityName(Optional miscEntityName); _FinalStage miscEntityName(String miscEntityName); - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage titleSentimentMin(Optional titleSentimentMin); _FinalStage titleSentimentMin(Float titleSentimentMin); - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage titleSentimentMax(Optional titleSentimentMax); _FinalStage titleSentimentMax(Float titleSentimentMax); - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage contentSentimentMin(Optional contentSentimentMin); _FinalStage contentSentimentMin(Float contentSentimentMin); - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ _FinalStage contentSentimentMax(Optional contentSentimentMax); _FinalStage contentSentimentMax(Float contentSentimentMax); /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1495,7 +1044,6 @@ public interface _FinalStage { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1505,7 +1053,6 @@ public interface _FinalStage { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1515,7 +1062,6 @@ public interface _FinalStage { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1526,26 +1072,19 @@ public interface _FinalStage { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ _FinalStage customTags(Optional customTags); _FinalStage customTags(String customTags); - /** - *

If true, excludes duplicate and highly similar articles from the search results. If false, returns all relevant articles, including duplicates.

- *

To learn more, see Articles deduplication.

- */ _FinalStage excludeDuplicates(Optional excludeDuplicates); _FinalStage excludeDuplicates(Boolean excludeDuplicates); - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ _FinalStage robotsCompliant(Optional robotsCompliant); _FinalStage robotsCompliant(Boolean robotsCompliant); @@ -1595,7 +1134,7 @@ public static final class Builder implements QStage, _FinalStage { private Optional clusteringThreshold = Optional.empty(); - private Optional clusteringVariable = Optional.empty(); + private Optional clusteringVariable = Optional.empty(); private Optional clusteringEnabled = Optional.empty(); @@ -1609,12 +1148,14 @@ public static final class Builder implements QStage, _FinalStage { private Optional newsType = Optional.empty(); - private Optional newsDomainType = Optional.empty(); + private Optional newsDomainType = Optional.empty(); private Optional isNewsDomain = Optional.empty(); private Optional additionalDomainInfo = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -1633,15 +1174,15 @@ public static final class Builder implements QStage, _FinalStage { private Optional rankedOnly = Optional.empty(); - private Optional sortBy = Optional.empty(); + private Optional sortBy = Optional.empty(); private Optional byParseDate = Optional.empty(); - private Optional publishedDatePrecision = Optional.empty(); + private Optional publishedDatePrecision = Optional.empty(); - private Optional to = Optional.empty(); + private Optional to = Optional.empty(); - private Optional from = Optional.empty(); + private Optional from = Optional.empty(); private Optional notAuthorName = Optional.empty(); @@ -1671,7 +1212,7 @@ public static final class Builder implements QStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(SearchGetRequest other) { + public Builder from(GetSearchRequest other) { q(other.getQ()); searchIn(other.getSearchIn()); includeTranslationFields(other.getIncludeTranslationFields()); @@ -1698,6 +1239,7 @@ public Builder from(SearchGetRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); additionalDomainInfo(other.getAdditionalDomainInfo()); isNewsDomain(other.getIsNewsDomain()); newsDomainType(other.getNewsDomainType()); @@ -1731,29 +1273,6 @@ public Builder from(SearchGetRequest other) { return this; } - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override @JsonSetter("q") public _FinalStage q(@NotNull String q) { @@ -1761,19 +1280,12 @@ public _FinalStage q(@NotNull String q) { return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage robotsCompliant(Boolean robotsCompliant) { this.robotsCompliant = Optional.ofNullable(robotsCompliant); return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ @java.lang.Override @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) public _FinalStage robotsCompliant(Optional robotsCompliant) { @@ -1781,21 +1293,12 @@ public _FinalStage robotsCompliant(Optional robotsCompliant) { return this; } - /** - *

If true, excludes duplicate and highly similar articles from the search results. If false, returns all relevant articles, including duplicates.

- *

To learn more, see Articles deduplication.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage excludeDuplicates(Boolean excludeDuplicates) { this.excludeDuplicates = Optional.ofNullable(excludeDuplicates); return this; } - /** - *

If true, excludes duplicate and highly similar articles from the search results. If false, returns all relevant articles, including duplicates.

- *

To learn more, see Articles deduplication.

- */ @java.lang.Override @JsonSetter(value = "exclude_duplicates", nulls = Nulls.SKIP) public _FinalStage excludeDuplicates(Optional excludeDuplicates) { @@ -1806,10 +1309,10 @@ public _FinalStage excludeDuplicates(Optional excludeDuplicates) { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1821,10 +1324,10 @@ public _FinalStage customTags(String customTags) { /** *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

*
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • + *
  • custom_tags.taxonomy=Tag1,Tag2, where taxonomy is the taxonomy name and Tag1,Tag2 is a comma-separated list of tag names.
  • *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

+ *

Example: custom_tags.industry="Manufacturing,Logistics"

+ *

To learn more, see the Custom tags.

*/ @java.lang.Override @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) @@ -1835,7 +1338,6 @@ public _FinalStage customTags(Optional customTags) { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1848,7 +1350,6 @@ public _FinalStage notIabTags(String notIabTags) { /** *

Inverse of the iab_tags parameter. Excludes articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories to exclude, use a comma-separated string.

- *

Example: "Agriculture, Metals"

*

Note: The not_iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1861,7 +1362,6 @@ public _FinalStage notIabTags(Optional notIabTags) { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1874,7 +1374,6 @@ public _FinalStage iabTags(String iabTags) { /** *

Filters articles based on Interactive Advertising Bureau (IAB) content categories. These tags provide a standardized taxonomy for digital advertising content categorization. To specify multiple IAB categories, use a comma-separated string.

- *

Example: "Business, Events"

*

Note: The iab_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see the IAB Content taxonomy.

*/ @@ -1887,7 +1386,6 @@ public _FinalStage iabTags(Optional iabTags) { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1900,7 +1398,6 @@ public _FinalStage notIptcTags(String notIptcTags) { /** *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

*

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1913,7 +1410,6 @@ public _FinalStage notIptcTags(Optional notIptcTags) { /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1926,7 +1422,6 @@ public _FinalStage iptcTags(String iptcTags) { /** *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

*

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

*

To learn more, see IPTC Media Topic NewsCodes.

*/ @@ -1937,35 +1432,12 @@ public _FinalStage iptcTags(Optional iptcTags) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage contentSentimentMax(Float contentSentimentMax) { this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); return this; } - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) public _FinalStage contentSentimentMax(Optional contentSentimentMax) { @@ -1973,35 +1445,12 @@ public _FinalStage contentSentimentMax(Optional contentSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage contentSentimentMin(Float contentSentimentMin) { this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); return this; } - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) public _FinalStage contentSentimentMin(Optional contentSentimentMin) { @@ -2009,35 +1458,12 @@ public _FinalStage contentSentimentMin(Optional contentSentimentMin) { return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage titleSentimentMax(Float titleSentimentMax) { this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); return this; } - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) public _FinalStage titleSentimentMax(Optional titleSentimentMax) { @@ -2045,35 +1471,12 @@ public _FinalStage titleSentimentMax(Optional titleSentimentMax) { return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage titleSentimentMin(Float titleSentimentMin) { this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); return this; } - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) public _FinalStage titleSentimentMin(Optional titleSentimentMin) { @@ -2081,25 +1484,12 @@ public _FinalStage titleSentimentMin(Optional titleSentimentMin) { return this; } - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage miscEntityName(String miscEntityName) { this.miscEntityName = Optional.ofNullable(miscEntityName); return this; } - /** - *

Filters articles that mention other named entities not falling under person, organization, or location categories. Includes events, nationalities, products, works of art, and more. To specify multiple entities, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Bitcoin, Blockchain"

- *

Note: The MISC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @java.lang.Override @JsonSetter(value = "MISC_entity_name", nulls = Nulls.SKIP) public _FinalStage miscEntityName(Optional miscEntityName) { @@ -2107,25 +1497,12 @@ public _FinalStage miscEntityName(Optional miscEntityName) { return this; } - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage locEntityName(String locEntityName) { this.locEntityName = Optional.ofNullable(locEntityName); return this; } - /** - *

Filters articles that mention specific location names, as identified by NLP analysis. To specify multiple locations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "California, New York"

- *

Note: The LOC_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @java.lang.Override @JsonSetter(value = "LOC_entity_name", nulls = Nulls.SKIP) public _FinalStage locEntityName(Optional locEntityName) { @@ -2133,25 +1510,12 @@ public _FinalStage locEntityName(Optional locEntityName) { return this; } - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage perEntityName(String perEntityName) { this.perEntityName = Optional.ofNullable(perEntityName); return this; } - /** - *

Filters articles that mention specific person names, as identified by NLP analysis. To specify multiple names, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Elon Musk, Jeff Bezos"

- *

Note: The PER_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @java.lang.Override @JsonSetter(value = "PER_entity_name", nulls = Nulls.SKIP) public _FinalStage perEntityName(Optional perEntityName) { @@ -2159,25 +1523,12 @@ public _FinalStage perEntityName(Optional perEntityName) { return this; } - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage orgEntityName(String orgEntityName) { this.orgEntityName = Optional.ofNullable(orgEntityName); return this; } - /** - *

Filters articles that mention specific organization names, as identified by NLP analysis. To specify multiple organizations, use a comma-separated string. To search named entities in translations, combine with the translation options of the search_in parameter (e.g., title_content_translated).

- *

Example: "Apple, Microsoft"

- *

Note: The ORG_entity_name parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see Search by entity.

- */ @java.lang.Override @JsonSetter(value = "ORG_entity_name", nulls = Nulls.SKIP) public _FinalStage orgEntityName(Optional orgEntityName) { @@ -2185,25 +1536,12 @@ public _FinalStage orgEntityName(Optional orgEntityName) { return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ @java.lang.Override @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) public _FinalStage notTheme(Optional notTheme) { @@ -2211,27 +1549,12 @@ public _FinalStage notTheme(Optional notTheme) { return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ @java.lang.Override @JsonSetter(value = "theme", nulls = Nulls.SKIP) public _FinalStage theme(Optional theme) { @@ -2265,33 +1588,12 @@ public _FinalStage includeNlpData(Optional includeNlpData) { return this; } - /** - *

Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles.

- *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage clusteringThreshold(Float clusteringThreshold) { this.clusteringThreshold = Optional.ofNullable(clusteringThreshold); return this; } - /** - *

Sets the similarity threshold for grouping articles into clusters. A lower value creates more inclusive clusters, while a higher value requires greater similarity between articles.

- *

Examples:

- *
    - *
  • 0.3: Results in larger, more diverse clusters.
  • - *
  • 0.6: Balances cluster size and article similarity (default).
  • - *
  • 0.9: Creates smaller, tightly related clusters.
  • - *
- *

To learn more, see Clustering news articles.

- */ @java.lang.Override @JsonSetter(value = "clustering_threshold", nulls = Nulls.SKIP) public _FinalStage clusteringThreshold(Optional clusteringThreshold) { @@ -2299,55 +1601,25 @@ public _FinalStage clusteringThreshold(Optional clusteringThreshold) { return this; } - /** - *

Specifies which part of the article to use for determining similarity when clustering.

- *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage clusteringVariable(SearchGetRequestClusteringVariable clusteringVariable) { + public _FinalStage clusteringVariable(ClusteringVariable clusteringVariable) { this.clusteringVariable = Optional.ofNullable(clusteringVariable); return this; } - /** - *

Specifies which part of the article to use for determining similarity when clustering.

- *

Possible values are:

- *
    - *
  • content: Uses the full article content (default).
  • - *
  • title: Uses only the article title.
  • - *
  • summary: Uses the article summary.
  • - *
- *

To learn more, see Clustering news articles.

- */ @java.lang.Override @JsonSetter(value = "clustering_variable", nulls = Nulls.SKIP) - public _FinalStage clusteringVariable(Optional clusteringVariable) { + public _FinalStage clusteringVariable(Optional clusteringVariable) { this.clusteringVariable = clusteringVariable; return this; } - /** - *

Determines whether to group similar articles into clusters. If true, the API returns clustered results.

- *

To learn more, see Clustering news articles.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage clusteringEnabled(Boolean clusteringEnabled) { this.clusteringEnabled = Optional.ofNullable(clusteringEnabled); return this; } - /** - *

Determines whether to group similar articles into clusters. If true, the API returns clustered results.

- *

To learn more, see Clustering news articles.

- */ @java.lang.Override @JsonSetter(value = "clustering_enabled", nulls = Nulls.SKIP) public _FinalStage clusteringEnabled(Optional clusteringEnabled) { @@ -2355,19 +1627,12 @@ public _FinalStage clusteringEnabled(Optional clusteringEnabled) { return this; } - /** - *

The number of articles to return per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage pageSize(Integer pageSize) { this.pageSize = Optional.ofNullable(pageSize); return this; } - /** - *

The number of articles to return per page.

- */ @java.lang.Override @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public _FinalStage pageSize(Optional pageSize) { @@ -2375,21 +1640,12 @@ public _FinalStage pageSize(Optional pageSize) { return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage page(Integer page) { this.page = Optional.ofNullable(page); return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ @java.lang.Override @JsonSetter(value = "page", nulls = Nulls.SKIP) public _FinalStage page(Optional page) { @@ -2397,19 +1653,12 @@ public _FinalStage page(Optional page) { return this; } - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage wordCountMax(Integer wordCountMax) { this.wordCountMax = Optional.ofNullable(wordCountMax); return this; } - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ @java.lang.Override @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) public _FinalStage wordCountMax(Optional wordCountMax) { @@ -2417,19 +1666,12 @@ public _FinalStage wordCountMax(Optional wordCountMax) { return this; } - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage wordCountMin(Integer wordCountMin) { this.wordCountMin = Optional.ofNullable(wordCountMin); return this; } - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ @java.lang.Override @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) public _FinalStage wordCountMin(Optional wordCountMin) { @@ -2439,8 +1681,7 @@ public _FinalStage wordCountMin(Optional wordCountMin) { /** *

Filters results based on the news type. Multiple types can be specified using a comma-separated string.

- *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2451,8 +1692,7 @@ public _FinalStage newsType(String newsType) { /** *

Filters results based on the news type. Multiple types can be specified using a comma-separated string.

- *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

*/ @java.lang.Override @JsonSetter(value = "news_type", nulls = Nulls.SKIP) @@ -2461,53 +1701,25 @@ public _FinalStage newsType(Optional newsType) { return this; } - /** - *

Filters results based on the news domain type. Possible values are:

- *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage newsDomainType(SearchGetRequestNewsDomainType newsDomainType) { + public _FinalStage newsDomainType(NewsDomainType newsDomainType) { this.newsDomainType = Optional.ofNullable(newsDomainType); return this; } - /** - *

Filters results based on the news domain type. Possible values are:

- *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- */ @java.lang.Override @JsonSetter(value = "news_domain_type", nulls = Nulls.SKIP) - public _FinalStage newsDomainType(Optional newsDomainType) { + public _FinalStage newsDomainType(Optional newsDomainType) { this.newsDomainType = newsDomainType; return this; } - /** - *

If true, filters results to include only news domains.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isNewsDomain(Boolean isNewsDomain) { this.isNewsDomain = Optional.ofNullable(isNewsDomain); return this; } - /** - *

If true, filters results to include only news domains.

- */ @java.lang.Override @JsonSetter(value = "is_news_domain", nulls = Nulls.SKIP) public _FinalStage isNewsDomain(Optional isNewsDomain) { @@ -2515,29 +1727,12 @@ public _FinalStage isNewsDomain(Optional isNewsDomain) { return this; } - /** - *

If true, includes additional domain information in the response for each article:

- *
    - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "News and Blogs").
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage additionalDomainInfo(Boolean additionalDomainInfo) { this.additionalDomainInfo = Optional.ofNullable(additionalDomainInfo); return this; } - /** - *

If true, includes additional domain information in the response for each article:

- *
    - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "News and Blogs").
  • - *
- */ @java.lang.Override @JsonSetter(value = "additional_domain_info", nulls = Nulls.SKIP) public _FinalStage additionalDomainInfo(Optional additionalDomainInfo) { @@ -2545,10 +1740,33 @@ public _FinalStage additionalDomainInfo(Optional additionalDomainInfo) return this; } + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allLinksText(String allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + /** + *

The text content of links mentioned in the article. Searches for links where the anchor text contains the specified terms. For multiple terms, use a comma-separated string.

+ *

Note: When this parameter is used, the response includes the all_links_data field with detailed link information.

+ *

To learn more, see Search by URL.

+ */ + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2559,8 +1777,7 @@ public _FinalStage allDomainLinks(String allDomainLinks) { /** *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @java.lang.Override @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) @@ -2571,8 +1788,7 @@ public _FinalStage allDomainLinks(Optional allDomainLinks) { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2583,8 +1799,7 @@ public _FinalStage allLinks(String allLinks) { /** *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

+ *

For more details, see Search by URL.

*/ @java.lang.Override @JsonSetter(value = "all_links", nulls = Nulls.SKIP) @@ -2595,7 +1810,6 @@ public _FinalStage allLinks(Optional allLinks) { /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2606,7 +1820,6 @@ public _FinalStage parentUrl(String parentUrl) { /** *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

*/ @java.lang.Override @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) @@ -2615,19 +1828,12 @@ public _FinalStage parentUrl(Optional parentUrl) { return this; } - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isPaidContent(Boolean isPaidContent) { this.isPaidContent = Optional.ofNullable(isPaidContent); return this; } - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ @java.lang.Override @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) public _FinalStage isPaidContent(Optional isPaidContent) { @@ -2635,19 +1841,12 @@ public _FinalStage isPaidContent(Optional isPaidContent) { return this; } - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isOpinion(Boolean isOpinion) { this.isOpinion = Optional.ofNullable(isOpinion); return this; } - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ @java.lang.Override @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) public _FinalStage isOpinion(Optional isOpinion) { @@ -2655,19 +1854,12 @@ public _FinalStage isOpinion(Optional isOpinion) { return this; } - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage isHeadline(Boolean isHeadline) { this.isHeadline = Optional.ofNullable(isHeadline); return this; } - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ @java.lang.Override @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) public _FinalStage isHeadline(Optional isHeadline) { @@ -2675,19 +1867,12 @@ public _FinalStage isHeadline(Optional isHeadline) { return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage toRank(Integer toRank) { this.toRank = Optional.ofNullable(toRank); return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @java.lang.Override @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) public _FinalStage toRank(Optional toRank) { @@ -2695,19 +1880,12 @@ public _FinalStage toRank(Optional toRank) { return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage fromRank(Integer fromRank) { this.fromRank = Optional.ofNullable(fromRank); return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @java.lang.Override @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) public _FinalStage fromRank(Optional fromRank) { @@ -2715,19 +1893,12 @@ public _FinalStage fromRank(Optional fromRank) { return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage rankedOnly(Boolean rankedOnly) { this.rankedOnly = Optional.ofNullable(rankedOnly); return this; } - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ @java.lang.Override @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) public _FinalStage rankedOnly(Optional rankedOnly) { @@ -2735,49 +1906,25 @@ public _FinalStage rankedOnly(Optional rankedOnly) { return this; } - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage sortBy(SearchGetRequestSortBy sortBy) { + public _FinalStage sortBy(SortBy sortBy) { this.sortBy = Optional.ofNullable(sortBy); return this; } - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ @java.lang.Override @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public _FinalStage sortBy(Optional sortBy) { + public _FinalStage sortBy(Optional sortBy) { this.sortBy = sortBy; return this; } - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override public _FinalStage byParseDate(Boolean byParseDate) { this.byParseDate = Optional.ofNullable(byParseDate); return this; } - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ @java.lang.Override @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) public _FinalStage byParseDate(Optional byParseDate) { @@ -2785,116 +1932,47 @@ public _FinalStage byParseDate(Optional byParseDate) { return this; } - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage publishedDatePrecision(SearchGetRequestPublishedDatePrecision publishedDatePrecision) { + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); return this; } - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ @java.lang.Override @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision( - Optional publishedDatePrecision) { + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { this.publishedDatePrecision = publishedDatePrecision; return this; } - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage to(OffsetDateTime to) { + public _FinalStage to(To to) { this.to = Optional.ofNullable(to); return this; } - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @java.lang.Override @JsonSetter(value = "to_", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { + public _FinalStage to(Optional to) { this.to = to; return this; } - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ @java.lang.Override - public _FinalStage from(OffsetDateTime from) { + public _FinalStage from(From from) { this.from = Optional.ofNullable(from); return this; } - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ @java.lang.Override @JsonSetter(value = "from_", nulls = Nulls.SKIP) - public _FinalStage from(Optional from) { + public _FinalStage from(Optional from) { this.from = from; return this; } /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2905,7 +1983,6 @@ public _FinalStage notAuthorName(String notAuthorName) { /** *

The list of author names to exclude from your search. To exclude articles by specific authors, use a comma-separated string.

- *

Example: "John Doe, Jane Doe"

*/ @java.lang.Override @JsonSetter(value = "not_author_name", nulls = Nulls.SKIP) @@ -2916,8 +1993,7 @@ public _FinalStage notAuthorName(Optional notAuthorName) { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2928,8 +2004,7 @@ public _FinalStage notCountries(String notCountries) { /** *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @java.lang.Override @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) @@ -2940,8 +2015,7 @@ public _FinalStage notCountries(Optional notCountries) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2952,8 +2026,7 @@ public _FinalStage countries(String countries) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @java.lang.Override @JsonSetter(value = "countries", nulls = Nulls.SKIP) @@ -2964,8 +2037,7 @@ public _FinalStage countries(Optional countries) { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -2976,8 +2048,7 @@ public _FinalStage notLang(String notLang) { /** *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @java.lang.Override @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) @@ -2988,8 +2059,7 @@ public _FinalStage notLang(Optional notLang) { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -3000,8 +2070,7 @@ public _FinalStage lang(String lang) { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @java.lang.Override @JsonSetter(value = "lang", nulls = Nulls.SKIP) @@ -3012,7 +2081,6 @@ public _FinalStage lang(Optional lang) { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -3023,7 +2091,6 @@ public _FinalStage notSources(String notSources) { /** *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

*/ @java.lang.Override @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) @@ -3034,11 +2101,6 @@ public _FinalStage notSources(Optional notSources) { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -3049,11 +2111,6 @@ public _FinalStage sources(String sources) { /** *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
*/ @java.lang.Override @JsonSetter(value = "sources", nulls = Nulls.SKIP) @@ -3064,7 +2121,6 @@ public _FinalStage sources(Optional sources) { /** *

Word or phrase to search within the source names. To specify multiple values, use a comma-separated string.

- *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

* @return Reference to {@code this} so that method calls can be chained together. */ @@ -3076,7 +2132,6 @@ public _FinalStage sourceName(String sourceName) { /** *

Word or phrase to search within the source names. To specify multiple values, use a comma-separated string.

- *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

*/ @java.lang.Override @@ -3088,14 +2143,8 @@ public _FinalStage sourceName(Optional sourceName) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -3106,14 +2155,8 @@ public _FinalStage predefinedSources(String predefinedSources) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @java.lang.Override @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) @@ -3149,8 +2192,8 @@ public _FinalStage searchIn(Optional searchIn) { } @java.lang.Override - public SearchGetRequest build() { - return new SearchGetRequest( + public GetSearchRequest build() { + return new GetSearchRequest( q, searchIn, includeTranslationFields, @@ -3177,6 +2220,7 @@ public SearchGetRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, additionalDomainInfo, isNewsDomain, newsDomainType, @@ -3209,5 +2253,17 @@ public SearchGetRequest build() { robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/search/requests/SearchPostRequest.java b/src/main/java/com/newscatcher/api/resources/search/requests/PostSearchRequest.java similarity index 94% rename from src/main/java/com/newscatcher/api/resources/search/requests/SearchPostRequest.java rename to src/main/java/com/newscatcher/api/resources/search/requests/PostSearchRequest.java index 7282b89..ee523dd 100644 --- a/src/main/java/com/newscatcher/api/resources/search/requests/SearchPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/search/requests/PostSearchRequest.java @@ -14,6 +14,7 @@ import com.newscatcher.api.core.ObjectMappers; import com.newscatcher.api.types.AllDomainLinks; import com.newscatcher.api.types.AllLinks; +import com.newscatcher.api.types.AllLinksText; import com.newscatcher.api.types.ClusteringVariable; import com.newscatcher.api.types.Countries; import com.newscatcher.api.types.CustomTags; @@ -29,14 +30,11 @@ import com.newscatcher.api.types.NotIptcTags; import com.newscatcher.api.types.NotLang; import com.newscatcher.api.types.NotSources; -import com.newscatcher.api.types.NotTheme; import com.newscatcher.api.types.ParentUrl; import com.newscatcher.api.types.PredefinedSources; -import com.newscatcher.api.types.PublishedDatePrecision; import com.newscatcher.api.types.SortBy; import com.newscatcher.api.types.SourceName; import com.newscatcher.api.types.Sources; -import com.newscatcher.api.types.Theme; import com.newscatcher.api.types.To; import java.util.HashMap; import java.util.Map; @@ -45,8 +43,8 @@ import org.jetbrains.annotations.NotNull; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchPostRequest.Builder.class) -public final class SearchPostRequest { +@JsonDeserialize(builder = PostSearchRequest.Builder.class) +public final class PostSearchRequest { private final String q; private final Optional searchIn; @@ -75,7 +73,7 @@ public final class SearchPostRequest { private final Optional to; - private final Optional publishedDatePrecision; + private final Optional publishedDatePrecision; private final Optional byParseDate; @@ -99,6 +97,8 @@ public final class SearchPostRequest { private final Optional allDomainLinks; + private final Optional allLinksText; + private final Optional additionalDomainInfo; private final Optional isNewsDomain; @@ -125,9 +125,9 @@ public final class SearchPostRequest { private final Optional hasNlp; - private final Optional theme; + private final Optional theme; - private final Optional notTheme; + private final Optional notTheme; private final Optional orgEntityName; @@ -161,7 +161,7 @@ public final class SearchPostRequest { private final Map additionalProperties; - private SearchPostRequest( + private PostSearchRequest( String q, Optional searchIn, Optional includeTranslationFields, @@ -176,7 +176,7 @@ private SearchPostRequest( Optional notAuthorName, Optional from, Optional to, - Optional publishedDatePrecision, + Optional publishedDatePrecision, Optional byParseDate, Optional sortBy, Optional rankedOnly, @@ -188,6 +188,7 @@ private SearchPostRequest( Optional parentUrl, Optional allLinks, Optional allDomainLinks, + Optional allLinksText, Optional additionalDomainInfo, Optional isNewsDomain, Optional newsDomainType, @@ -201,8 +202,8 @@ private SearchPostRequest( Optional clusteringThreshold, Optional includeNlpData, Optional hasNlp, - Optional theme, - Optional notTheme, + Optional theme, + Optional notTheme, Optional orgEntityName, Optional perEntityName, Optional locEntityName, @@ -245,6 +246,7 @@ private SearchPostRequest( this.parentUrl = parentUrl; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksText = allLinksText; this.additionalDomainInfo = additionalDomainInfo; this.isNewsDomain = isNewsDomain; this.newsDomainType = newsDomainType; @@ -349,7 +351,7 @@ public Optional getTo() { } @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { + public Optional getPublishedDatePrecision() { return publishedDatePrecision; } @@ -408,6 +410,11 @@ public Optional getAllDomainLinks() { return allDomainLinks; } + @JsonProperty("all_links_text") + public Optional getAllLinksText() { + return allLinksText; + } + @JsonProperty("additional_domain_info") public Optional getAdditionalDomainInfo() { return additionalDomainInfo; @@ -474,12 +481,12 @@ public Optional getHasNlp() { } @JsonProperty("theme") - public Optional getTheme() { + public Optional getTheme() { return theme; } @JsonProperty("not_theme") - public Optional getNotTheme() { + public Optional getNotTheme() { return notTheme; } @@ -561,7 +568,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchPostRequest && equalTo((SearchPostRequest) other); + return other instanceof PostSearchRequest && equalTo((PostSearchRequest) other); } @JsonAnyGetter @@ -569,7 +576,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchPostRequest other) { + private boolean equalTo(PostSearchRequest other) { return q.equals(other.q) && searchIn.equals(other.searchIn) && includeTranslationFields.equals(other.includeTranslationFields) @@ -596,6 +603,7 @@ private boolean equalTo(SearchPostRequest other) { && parentUrl.equals(other.parentUrl) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksText.equals(other.allLinksText) && additionalDomainInfo.equals(other.additionalDomainInfo) && isNewsDomain.equals(other.isNewsDomain) && newsDomainType.equals(other.newsDomainType) @@ -657,6 +665,7 @@ public int hashCode() { this.parentUrl, this.allLinks, this.allDomainLinks, + this.allLinksText, this.additionalDomainInfo, this.isNewsDomain, this.newsDomainType, @@ -701,11 +710,15 @@ public static QStage builder() { public interface QStage { _FinalStage q(@NotNull String q); - Builder from(SearchPostRequest other); + Builder from(PostSearchRequest other); } public interface _FinalStage { - SearchPostRequest build(); + PostSearchRequest build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); _FinalStage searchIn(Optional searchIn); @@ -759,9 +772,9 @@ public interface _FinalStage { _FinalStage to(To to); - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); + _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision); + _FinalStage publishedDatePrecision(String publishedDatePrecision); _FinalStage byParseDate(Optional byParseDate); @@ -807,6 +820,10 @@ public interface _FinalStage { _FinalStage allDomainLinks(AllDomainLinks allDomainLinks); + _FinalStage allLinksText(Optional allLinksText); + + _FinalStage allLinksText(AllLinksText allLinksText); + _FinalStage additionalDomainInfo(Optional additionalDomainInfo); _FinalStage additionalDomainInfo(Boolean additionalDomainInfo); @@ -859,13 +876,13 @@ public interface _FinalStage { _FinalStage hasNlp(Boolean hasNlp); - _FinalStage theme(Optional theme); + _FinalStage theme(Optional theme); - _FinalStage theme(Theme theme); + _FinalStage theme(String theme); - _FinalStage notTheme(Optional notTheme); + _FinalStage notTheme(Optional notTheme); - _FinalStage notTheme(NotTheme notTheme); + _FinalStage notTheme(String notTheme); _FinalStage orgEntityName(Optional orgEntityName); @@ -962,9 +979,9 @@ public static final class Builder implements QStage, _FinalStage { private Optional orgEntityName = Optional.empty(); - private Optional notTheme = Optional.empty(); + private Optional notTheme = Optional.empty(); - private Optional theme = Optional.empty(); + private Optional theme = Optional.empty(); private Optional hasNlp = Optional.empty(); @@ -992,6 +1009,8 @@ public static final class Builder implements QStage, _FinalStage { private Optional additionalDomainInfo = Optional.empty(); + private Optional allLinksText = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -1014,7 +1033,7 @@ public static final class Builder implements QStage, _FinalStage { private Optional byParseDate = Optional.empty(); - private Optional publishedDatePrecision = Optional.empty(); + private Optional publishedDatePrecision = Optional.empty(); private Optional to = Optional.empty(); @@ -1048,7 +1067,7 @@ public static final class Builder implements QStage, _FinalStage { private Builder() {} @java.lang.Override - public Builder from(SearchPostRequest other) { + public Builder from(PostSearchRequest other) { q(other.getQ()); searchIn(other.getSearchIn()); includeTranslationFields(other.getIncludeTranslationFields()); @@ -1075,6 +1094,7 @@ public Builder from(SearchPostRequest other) { parentUrl(other.getParentUrl()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksText(other.getAllLinksText()); additionalDomainInfo(other.getAdditionalDomainInfo()); isNewsDomain(other.getIsNewsDomain()); newsDomainType(other.getNewsDomainType()); @@ -1311,27 +1331,27 @@ public _FinalStage orgEntityName(Optional orgEntityName) { } @java.lang.Override - public _FinalStage notTheme(NotTheme notTheme) { + public _FinalStage notTheme(String notTheme) { this.notTheme = Optional.ofNullable(notTheme); return this; } @java.lang.Override @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { + public _FinalStage notTheme(Optional notTheme) { this.notTheme = notTheme; return this; } @java.lang.Override - public _FinalStage theme(Theme theme) { + public _FinalStage theme(String theme) { this.theme = Optional.ofNullable(theme); return this; } @java.lang.Override @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { + public _FinalStage theme(Optional theme) { this.theme = theme; return this; } @@ -1505,6 +1525,19 @@ public _FinalStage additionalDomainInfo(Optional additionalDomainInfo) return this; } + @java.lang.Override + public _FinalStage allLinksText(AllLinksText allLinksText) { + this.allLinksText = Optional.ofNullable(allLinksText); + return this; + } + + @java.lang.Override + @JsonSetter(value = "all_links_text", nulls = Nulls.SKIP) + public _FinalStage allLinksText(Optional allLinksText) { + this.allLinksText = allLinksText; + return this; + } + @java.lang.Override public _FinalStage allDomainLinks(AllDomainLinks allDomainLinks) { this.allDomainLinks = Optional.ofNullable(allDomainLinks); @@ -1649,14 +1682,14 @@ public _FinalStage byParseDate(Optional byParseDate) { } @java.lang.Override - public _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision) { + public _FinalStage publishedDatePrecision(String publishedDatePrecision) { this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); return this; } @java.lang.Override @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { + public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { this.publishedDatePrecision = publishedDatePrecision; return this; } @@ -1831,8 +1864,8 @@ public _FinalStage searchIn(Optional searchIn) { } @java.lang.Override - public SearchPostRequest build() { - return new SearchPostRequest( + public PostSearchRequest build() { + return new PostSearchRequest( q, searchIn, includeTranslationFields, @@ -1859,6 +1892,7 @@ public SearchPostRequest build() { parentUrl, allLinks, allDomainLinks, + allLinksText, additionalDomainInfo, isNewsDomain, newsDomainType, @@ -1891,5 +1925,17 @@ public SearchPostRequest build() { robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetResponse.java b/src/main/java/com/newscatcher/api/resources/search/types/GetSearchResponse.java similarity index 77% rename from src/main/java/com/newscatcher/api/resources/search/types/SearchGetResponse.java rename to src/main/java/com/newscatcher/api/resources/search/types/GetSearchResponse.java index d715dc0..ffc21e1 100644 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetResponse.java +++ b/src/main/java/com/newscatcher/api/resources/search/types/GetSearchResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = SearchGetResponse.Deserializer.class) -public final class SearchGetResponse { +@JsonDeserialize(using = GetSearchResponse.Deserializer.class) +public final class GetSearchResponse { private final Object value; private final int type; - private SearchGetResponse(Object value, int type) { + private GetSearchResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchGetResponse && equalTo((SearchGetResponse) other); + return other instanceof GetSearchResponse && equalTo((GetSearchResponse) other); } - private boolean equalTo(SearchGetResponse other) { + private boolean equalTo(GetSearchResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static SearchGetResponse of(SearchResponseDto value) { - return new SearchGetResponse(value, 0); + public static GetSearchResponse of(SearchResponseDto value) { + return new GetSearchResponse(value, 0); } - public static SearchGetResponse of(ClusteredSearchResponseDto value) { - return new SearchGetResponse(value, 1); + public static GetSearchResponse of(ClusteredSearchResponseDto value) { + return new GetSearchResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(ClusteredSearchResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(SearchGetResponse.class); + super(GetSearchResponse.class); } @java.lang.Override - public SearchGetResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public GetSearchResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchPostResponse.java b/src/main/java/com/newscatcher/api/resources/search/types/PostSearchResponse.java similarity index 76% rename from src/main/java/com/newscatcher/api/resources/search/types/SearchPostResponse.java rename to src/main/java/com/newscatcher/api/resources/search/types/PostSearchResponse.java index 35ad08d..baab84a 100644 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchPostResponse.java +++ b/src/main/java/com/newscatcher/api/resources/search/types/PostSearchResponse.java @@ -15,13 +15,13 @@ import java.io.IOException; import java.util.Objects; -@JsonDeserialize(using = SearchPostResponse.Deserializer.class) -public final class SearchPostResponse { +@JsonDeserialize(using = PostSearchResponse.Deserializer.class) +public final class PostSearchResponse { private final Object value; private final int type; - private SearchPostResponse(Object value, int type) { + private PostSearchResponse(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchPostResponse && equalTo((SearchPostResponse) other); + return other instanceof PostSearchResponse && equalTo((PostSearchResponse) other); } - private boolean equalTo(SearchPostResponse other) { + private boolean equalTo(PostSearchResponse other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static SearchPostResponse of(SearchResponseDto value) { - return new SearchPostResponse(value, 0); + public static PostSearchResponse of(SearchResponseDto value) { + return new PostSearchResponse(value, 0); } - public static SearchPostResponse of(ClusteredSearchResponseDto value) { - return new SearchPostResponse(value, 1); + public static PostSearchResponse of(ClusteredSearchResponseDto value) { + return new PostSearchResponse(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(ClusteredSearchResponseDto value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(SearchPostResponse.class); + super(PostSearchResponse.class); } @java.lang.Override - public SearchPostResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { + public PostSearchResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchResponseDto.class)); diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestClusteringVariable.java b/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestClusteringVariable.java deleted file mode 100644 index 2ec19e3..0000000 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestClusteringVariable.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.search.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchGetRequestClusteringVariable { - CONTENT("content"), - - TITLE("title"), - - SUMMARY("summary"); - - private final String value; - - SearchGetRequestClusteringVariable(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestNewsDomainType.java b/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestNewsDomainType.java deleted file mode 100644 index 6ffb556..0000000 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestNewsDomainType.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.search.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchGetRequestNewsDomainType { - ORIGINAL_CONTENT("Original Content"), - - AGGREGATOR("Aggregator"), - - PRESS_RELEASES("Press Releases"), - - REPUBLISHER("Republisher"), - - OTHER("Other"); - - private final String value; - - SearchGetRequestNewsDomainType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestPublishedDatePrecision.java b/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestPublishedDatePrecision.java deleted file mode 100644 index 8dab427..0000000 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestPublishedDatePrecision.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.search.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchGetRequestPublishedDatePrecision { - FULL("full"), - - TIMEZONE_UNKNOWN("timezone unknown"), - - DATE("date"); - - private final String value; - - SearchGetRequestPublishedDatePrecision(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestSortBy.java b/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestSortBy.java deleted file mode 100644 index 155e98c..0000000 --- a/src/main/java/com/newscatcher/api/resources/search/types/SearchGetRequestSortBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.search.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchGetRequestSortBy { - RELEVANCY("relevancy"), - - DATE("date"), - - RANK("rank"); - - private final String value; - - SearchGetRequestSortBy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/AsyncRawSearchLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchbylink/AsyncRawSearchByLinkClient.java similarity index 84% rename from src/main/java/com/newscatcher/api/resources/searchlink/AsyncRawSearchLinkClient.java rename to src/main/java/com/newscatcher/api/resources/searchbylink/AsyncRawSearchByLinkClient.java index 3659304..275f1f3 100644 --- a/src/main/java/com/newscatcher/api/resources/searchlink/AsyncRawSearchLinkClient.java +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/AsyncRawSearchByLinkClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.searchlink; +package com.newscatcher.api.resources.searchbylink; import com.fasterxml.jackson.core.JsonProcessingException; import com.newscatcher.api.core.ClientOptions; @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlGetRequest; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlPostRequest; +import com.newscatcher.api.resources.searchbylink.requests.GetSearchByLinkRequest; +import com.newscatcher.api.resources.searchbylink.requests.PostSearchByLinkRequest; import com.newscatcher.api.types.Error; import com.newscatcher.api.types.SearchResponseDto; import java.io.IOException; @@ -36,32 +36,39 @@ import okhttp3.ResponseBody; import org.jetbrains.annotations.NotNull; -public class AsyncRawSearchLinkClient { +public class AsyncRawSearchByLinkClient { protected final ClientOptions clientOptions; - public AsyncRawSearchLinkClient(ClientOptions clientOptions) { + public AsyncRawSearchByLinkClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public CompletableFuture> searchUrlGet() { - return searchUrlGet(SearchUrlGetRequest.builder().build()); + public CompletableFuture> get() { + return get(GetSearchByLinkRequest.builder().build()); } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public CompletableFuture> searchUrlGet(SearchUrlGetRequest request) { - return searchUrlGet(request, null); + public CompletableFuture> get(RequestOptions requestOptions) { + return get(GetSearchByLinkRequest.builder().build(), requestOptions); } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public CompletableFuture> searchUrlGet( - SearchUrlGetRequest request, RequestOptions requestOptions) { + public CompletableFuture> get(GetSearchByLinkRequest request) { + return get(request, null); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public CompletableFuture> get( + GetSearchByLinkRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/search_by_link"); @@ -91,6 +98,11 @@ public CompletableFuture> searchUr QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -106,13 +118,13 @@ public CompletableFuture> searchUr @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SearchResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -154,11 +166,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -177,27 +187,37 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { /** * Searches for articles using their ID(s) or link(s). */ - public CompletableFuture> searchUrlPost() { - return searchUrlPost(SearchUrlPostRequest.builder().build()); + public CompletableFuture> post() { + return post(PostSearchByLinkRequest.builder().build()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public CompletableFuture> post(RequestOptions requestOptions) { + return post(PostSearchByLinkRequest.builder().build(), requestOptions); } /** * Searches for articles using their ID(s) or link(s). */ - public CompletableFuture> searchUrlPost( - SearchUrlPostRequest request) { - return searchUrlPost(request, null); + public CompletableFuture> post(PostSearchByLinkRequest request) { + return post(request, null); } /** * Searches for articles using their ID(s) or link(s). */ - public CompletableFuture> searchUrlPost( - SearchUrlPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public CompletableFuture> post( + PostSearchByLinkRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/search_by_link") - .build(); + .addPathSegments("api/search_by_link"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -206,7 +226,7 @@ public CompletableFuture> searchUr throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -221,13 +241,13 @@ public CompletableFuture> searchUr @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SearchResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -269,11 +289,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/searchbylink/AsyncSearchByLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchbylink/AsyncSearchByLinkClient.java new file mode 100644 index 0000000..e9ed3e1 --- /dev/null +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/AsyncSearchByLinkClient.java @@ -0,0 +1,85 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.resources.searchbylink; + +import com.newscatcher.api.core.ClientOptions; +import com.newscatcher.api.core.RequestOptions; +import com.newscatcher.api.resources.searchbylink.requests.GetSearchByLinkRequest; +import com.newscatcher.api.resources.searchbylink.requests.PostSearchByLinkRequest; +import com.newscatcher.api.types.SearchResponseDto; +import java.util.concurrent.CompletableFuture; + +public class AsyncSearchByLinkClient { + protected final ClientOptions clientOptions; + + private final AsyncRawSearchByLinkClient rawClient; + + public AsyncSearchByLinkClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawSearchByLinkClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawSearchByLinkClient withRawResponse() { + return this.rawClient; + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public CompletableFuture get() { + return this.rawClient.get().thenApply(response -> response.body()); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public CompletableFuture get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).thenApply(response -> response.body()); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public CompletableFuture get(GetSearchByLinkRequest request) { + return this.rawClient.get(request).thenApply(response -> response.body()); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public CompletableFuture get(GetSearchByLinkRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public CompletableFuture post() { + return this.rawClient.post().thenApply(response -> response.body()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public CompletableFuture post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).thenApply(response -> response.body()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public CompletableFuture post(PostSearchByLinkRequest request) { + return this.rawClient.post(request).thenApply(response -> response.body()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public CompletableFuture post(PostSearchByLinkRequest request, RequestOptions requestOptions) { + return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/RawSearchLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchbylink/RawSearchByLinkClient.java similarity index 78% rename from src/main/java/com/newscatcher/api/resources/searchlink/RawSearchLinkClient.java rename to src/main/java/com/newscatcher/api/resources/searchbylink/RawSearchByLinkClient.java index a30038b..f09ef72 100644 --- a/src/main/java/com/newscatcher/api/resources/searchlink/RawSearchLinkClient.java +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/RawSearchByLinkClient.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.searchlink; +package com.newscatcher.api.resources.searchbylink; import com.fasterxml.jackson.core.JsonProcessingException; import com.newscatcher.api.core.ClientOptions; @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlGetRequest; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlPostRequest; +import com.newscatcher.api.resources.searchbylink.requests.GetSearchByLinkRequest; +import com.newscatcher.api.resources.searchbylink.requests.PostSearchByLinkRequest; import com.newscatcher.api.types.Error; import com.newscatcher.api.types.SearchResponseDto; import java.io.IOException; @@ -32,32 +32,39 @@ import okhttp3.Response; import okhttp3.ResponseBody; -public class RawSearchLinkClient { +public class RawSearchByLinkClient { protected final ClientOptions clientOptions; - public RawSearchLinkClient(ClientOptions clientOptions) { + public RawSearchByLinkClient(ClientOptions clientOptions) { this.clientOptions = clientOptions; } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public NewscatcherApiHttpResponse searchUrlGet() { - return searchUrlGet(SearchUrlGetRequest.builder().build()); + public NewscatcherApiHttpResponse get() { + return get(GetSearchByLinkRequest.builder().build()); } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public NewscatcherApiHttpResponse searchUrlGet(SearchUrlGetRequest request) { - return searchUrlGet(request, null); + public NewscatcherApiHttpResponse get(RequestOptions requestOptions) { + return get(GetSearchByLinkRequest.builder().build(), requestOptions); } /** * Searches for articles based on specified links or IDs. You can filter results by date range. */ - public NewscatcherApiHttpResponse searchUrlGet( - SearchUrlGetRequest request, RequestOptions requestOptions) { + public NewscatcherApiHttpResponse get(GetSearchByLinkRequest request) { + return get(request, null); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public NewscatcherApiHttpResponse get( + GetSearchByLinkRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/search_by_link"); @@ -87,6 +94,11 @@ public NewscatcherApiHttpResponse searchUrlGet( QueryStringMapper.addQueryParameter( httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -99,11 +111,11 @@ public NewscatcherApiHttpResponse searchUrlGet( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchResponseDto.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SearchResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -131,11 +143,9 @@ public NewscatcherApiHttpResponse searchUrlGet( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -144,26 +154,37 @@ public NewscatcherApiHttpResponse searchUrlGet( /** * Searches for articles using their ID(s) or link(s). */ - public NewscatcherApiHttpResponse searchUrlPost() { - return searchUrlPost(SearchUrlPostRequest.builder().build()); + public NewscatcherApiHttpResponse post() { + return post(PostSearchByLinkRequest.builder().build()); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public NewscatcherApiHttpResponse post(RequestOptions requestOptions) { + return post(PostSearchByLinkRequest.builder().build(), requestOptions); } /** * Searches for articles using their ID(s) or link(s). */ - public NewscatcherApiHttpResponse searchUrlPost(SearchUrlPostRequest request) { - return searchUrlPost(request, null); + public NewscatcherApiHttpResponse post(PostSearchByLinkRequest request) { + return post(request, null); } /** * Searches for articles using their ID(s) or link(s). */ - public NewscatcherApiHttpResponse searchUrlPost( - SearchUrlPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + public NewscatcherApiHttpResponse post( + PostSearchByLinkRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/search_by_link") - .build(); + .addPathSegments("api/search_by_link"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -172,7 +193,7 @@ public NewscatcherApiHttpResponse searchUrlPost( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -184,11 +205,11 @@ public NewscatcherApiHttpResponse searchUrlPost( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchResponseDto.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SearchResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -216,11 +237,9 @@ public NewscatcherApiHttpResponse searchUrlPost( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/searchbylink/SearchByLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchbylink/SearchByLinkClient.java new file mode 100644 index 0000000..6fed6b4 --- /dev/null +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/SearchByLinkClient.java @@ -0,0 +1,84 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.resources.searchbylink; + +import com.newscatcher.api.core.ClientOptions; +import com.newscatcher.api.core.RequestOptions; +import com.newscatcher.api.resources.searchbylink.requests.GetSearchByLinkRequest; +import com.newscatcher.api.resources.searchbylink.requests.PostSearchByLinkRequest; +import com.newscatcher.api.types.SearchResponseDto; + +public class SearchByLinkClient { + protected final ClientOptions clientOptions; + + private final RawSearchByLinkClient rawClient; + + public SearchByLinkClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawSearchByLinkClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawSearchByLinkClient withRawResponse() { + return this.rawClient; + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public SearchResponseDto get() { + return this.rawClient.get().body(); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public SearchResponseDto get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).body(); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public SearchResponseDto get(GetSearchByLinkRequest request) { + return this.rawClient.get(request).body(); + } + + /** + * Searches for articles based on specified links or IDs. You can filter results by date range. + */ + public SearchResponseDto get(GetSearchByLinkRequest request, RequestOptions requestOptions) { + return this.rawClient.get(request, requestOptions).body(); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public SearchResponseDto post() { + return this.rawClient.post().body(); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public SearchResponseDto post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).body(); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public SearchResponseDto post(PostSearchByLinkRequest request) { + return this.rawClient.post(request).body(); + } + + /** + * Searches for articles using their ID(s) or link(s). + */ + public SearchResponseDto post(PostSearchByLinkRequest request, RequestOptions requestOptions) { + return this.rawClient.post(request, requestOptions).body(); + } +} diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlGetRequest.java b/src/main/java/com/newscatcher/api/resources/searchbylink/requests/GetSearchByLinkRequest.java similarity index 77% rename from src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlGetRequest.java rename to src/main/java/com/newscatcher/api/resources/searchbylink/requests/GetSearchByLinkRequest.java index 0384ad6..5979dae 100644 --- a/src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/requests/GetSearchByLinkRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.searchlink.requests; +package com.newscatcher.api.resources.searchbylink.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -20,8 +20,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchUrlGetRequest.Builder.class) -public final class SearchUrlGetRequest { +@JsonDeserialize(builder = GetSearchByLinkRequest.Builder.class) +public final class GetSearchByLinkRequest { private final Optional ids; private final Optional links; @@ -38,7 +38,7 @@ public final class SearchUrlGetRequest { private final Map additionalProperties; - private SearchUrlGetRequest( + private GetSearchByLinkRequest( Optional ids, Optional links, Optional from, @@ -59,7 +59,6 @@ private SearchUrlGetRequest( /** * @return The Newscatcher article ID (corresponds to the _id field in API response) or a list of article IDs to search for. To specify multiple IDs, use a comma-separated string. - *

Example: "1234567890abcdef, abcdef1234567890"

*

Caution: You can use either the links or the ids parameter, but not both at the same time.

*/ @JsonProperty("ids") @@ -69,7 +68,6 @@ public Optional getIds() { /** * @return The article link or list of article links to search for. To specify multiple links, use a comma-separated string. - *

Example: "https://example.com/article1, https://example.com/article2"

*

Caution: You can use either the links or the ids parameter, but not both at the same time.

*/ @JsonProperty("links") @@ -87,26 +85,16 @@ public Optional getTo() { return to; } - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ @JsonProperty("page") public Optional getPage() { return page; } - /** - * @return The number of articles to return per page. - */ @JsonProperty("page_size") public Optional getPageSize() { return pageSize; } - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ @JsonProperty("robots_compliant") public Optional getRobotsCompliant() { return robotsCompliant; @@ -115,7 +103,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchUrlGetRequest && equalTo((SearchUrlGetRequest) other); + return other instanceof GetSearchByLinkRequest && equalTo((GetSearchByLinkRequest) other); } @JsonAnyGetter @@ -123,7 +111,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchUrlGetRequest other) { + private boolean equalTo(GetSearchByLinkRequest other) { return ids.equals(other.ids) && links.equals(other.links) && from.equals(other.from) @@ -168,7 +156,7 @@ public static final class Builder { private Builder() {} - public Builder from(SearchUrlGetRequest other) { + public Builder from(GetSearchByLinkRequest other) { ids(other.getIds()); links(other.getLinks()); from(other.getFrom()); @@ -181,7 +169,6 @@ public Builder from(SearchUrlGetRequest other) { /** *

The Newscatcher article ID (corresponds to the _id field in API response) or a list of article IDs to search for. To specify multiple IDs, use a comma-separated string.

- *

Example: "1234567890abcdef, abcdef1234567890"

*

Caution: You can use either the links or the ids parameter, but not both at the same time.

*/ @JsonSetter(value = "ids", nulls = Nulls.SKIP) @@ -197,7 +184,6 @@ public Builder ids(String ids) { /** *

The article link or list of article links to search for. To specify multiple links, use a comma-separated string.

- *

Example: "https://example.com/article1, https://example.com/article2"

*

Caution: You can use either the links or the ids parameter, but not both at the same time.

*/ @JsonSetter(value = "links", nulls = Nulls.SKIP) @@ -233,10 +219,6 @@ public Builder to(To to) { return this; } - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ @JsonSetter(value = "page", nulls = Nulls.SKIP) public Builder page(Optional page) { this.page = page; @@ -248,9 +230,6 @@ public Builder page(Integer page) { return this; } - /** - *

The number of articles to return per page.

- */ @JsonSetter(value = "page_size", nulls = Nulls.SKIP) public Builder pageSize(Optional pageSize) { this.pageSize = pageSize; @@ -262,9 +241,6 @@ public Builder pageSize(Integer pageSize) { return this; } - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) public Builder robotsCompliant(Optional robotsCompliant) { this.robotsCompliant = robotsCompliant; @@ -276,8 +252,19 @@ public Builder robotsCompliant(Boolean robotsCompliant) { return this; } - public SearchUrlGetRequest build() { - return new SearchUrlGetRequest(ids, links, from, to, page, pageSize, robotsCompliant, additionalProperties); + public GetSearchByLinkRequest build() { + return new GetSearchByLinkRequest( + ids, links, from, to, page, pageSize, robotsCompliant, additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; } } } diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlPostRequest.java b/src/main/java/com/newscatcher/api/resources/searchbylink/requests/PostSearchByLinkRequest.java similarity index 91% rename from src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlPostRequest.java rename to src/main/java/com/newscatcher/api/resources/searchbylink/requests/PostSearchByLinkRequest.java index 475ffc6..ac85416 100644 --- a/src/main/java/com/newscatcher/api/resources/searchlink/requests/SearchUrlPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/searchbylink/requests/PostSearchByLinkRequest.java @@ -1,7 +1,7 @@ /** * This file was auto-generated by Fern from our API Definition. */ -package com.newscatcher.api.resources.searchlink.requests; +package com.newscatcher.api.resources.searchbylink.requests; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; @@ -22,8 +22,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchUrlPostRequest.Builder.class) -public final class SearchUrlPostRequest { +@JsonDeserialize(builder = PostSearchByLinkRequest.Builder.class) +public final class PostSearchByLinkRequest { private final Optional ids; private final Optional links; @@ -40,7 +40,7 @@ public final class SearchUrlPostRequest { private final Map additionalProperties; - private SearchUrlPostRequest( + private PostSearchByLinkRequest( Optional ids, Optional links, Optional from, @@ -119,7 +119,7 @@ public Optional getRobotsCompliant() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SearchUrlPostRequest && equalTo((SearchUrlPostRequest) other); + return other instanceof PostSearchByLinkRequest && equalTo((PostSearchByLinkRequest) other); } @JsonAnyGetter @@ -127,7 +127,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SearchUrlPostRequest other) { + private boolean equalTo(PostSearchByLinkRequest other) { return ids.equals(other.ids) && links.equals(other.links) && from.equals(other.from) @@ -172,7 +172,7 @@ public static final class Builder { private Builder() {} - public Builder from(SearchUrlPostRequest other) { + public Builder from(PostSearchByLinkRequest other) { ids(other.getIds()); links(other.getLinks()); from(other.getFrom()); @@ -282,9 +282,19 @@ public Builder robotsCompliant(Boolean robotsCompliant) { return this; } - public SearchUrlPostRequest build() { - return new SearchUrlPostRequest( + public PostSearchByLinkRequest build() { + return new PostSearchByLinkRequest( ids, links, from, to, page, pageSize, robotsCompliant, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/AsyncSearchLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchlink/AsyncSearchLinkClient.java deleted file mode 100644 index 694e3f0..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchlink/AsyncSearchLinkClient.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchlink; - -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlGetRequest; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlPostRequest; -import com.newscatcher.api.types.SearchResponseDto; -import java.util.concurrent.CompletableFuture; - -public class AsyncSearchLinkClient { - protected final ClientOptions clientOptions; - - private final AsyncRawSearchLinkClient rawClient; - - public AsyncSearchLinkClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawSearchLinkClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawSearchLinkClient withRawResponse() { - return this.rawClient; - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public CompletableFuture searchUrlGet() { - return this.rawClient.searchUrlGet().thenApply(response -> response.body()); - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public CompletableFuture searchUrlGet(SearchUrlGetRequest request) { - return this.rawClient.searchUrlGet(request).thenApply(response -> response.body()); - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public CompletableFuture searchUrlGet( - SearchUrlGetRequest request, RequestOptions requestOptions) { - return this.rawClient.searchUrlGet(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public CompletableFuture searchUrlPost() { - return this.rawClient.searchUrlPost().thenApply(response -> response.body()); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public CompletableFuture searchUrlPost(SearchUrlPostRequest request) { - return this.rawClient.searchUrlPost(request).thenApply(response -> response.body()); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public CompletableFuture searchUrlPost( - SearchUrlPostRequest request, RequestOptions requestOptions) { - return this.rawClient.searchUrlPost(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchlink/SearchLinkClient.java b/src/main/java/com/newscatcher/api/resources/searchlink/SearchLinkClient.java deleted file mode 100644 index 86f5995..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchlink/SearchLinkClient.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchlink; - -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlGetRequest; -import com.newscatcher.api.resources.searchlink.requests.SearchUrlPostRequest; -import com.newscatcher.api.types.SearchResponseDto; - -public class SearchLinkClient { - protected final ClientOptions clientOptions; - - private final RawSearchLinkClient rawClient; - - public SearchLinkClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawSearchLinkClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawSearchLinkClient withRawResponse() { - return this.rawClient; - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public SearchResponseDto searchUrlGet() { - return this.rawClient.searchUrlGet().body(); - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public SearchResponseDto searchUrlGet(SearchUrlGetRequest request) { - return this.rawClient.searchUrlGet(request).body(); - } - - /** - * Searches for articles based on specified links or IDs. You can filter results by date range. - */ - public SearchResponseDto searchUrlGet(SearchUrlGetRequest request, RequestOptions requestOptions) { - return this.rawClient.searchUrlGet(request, requestOptions).body(); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public SearchResponseDto searchUrlPost() { - return this.rawClient.searchUrlPost().body(); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public SearchResponseDto searchUrlPost(SearchUrlPostRequest request) { - return this.rawClient.searchUrlPost(request).body(); - } - - /** - * Searches for articles using their ID(s) or link(s). - */ - public SearchResponseDto searchUrlPost(SearchUrlPostRequest request, RequestOptions requestOptions) { - return this.rawClient.searchUrlPost(request, requestOptions).body(); - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncRawSearchsimilarClient.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncRawSearchsimilarClient.java deleted file mode 100644 index 32974df..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncRawSearchsimilarClient.java +++ /dev/null @@ -1,457 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.MediaTypes; -import com.newscatcher.api.core.NewscatcherApiApiException; -import com.newscatcher.api.core.NewscatcherApiException; -import com.newscatcher.api.core.NewscatcherApiHttpResponse; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.core.QueryStringMapper; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.errors.BadRequestError; -import com.newscatcher.api.errors.ForbiddenError; -import com.newscatcher.api.errors.InternalServerError; -import com.newscatcher.api.errors.RequestTimeoutError; -import com.newscatcher.api.errors.TooManyRequestsError; -import com.newscatcher.api.errors.UnauthorizedError; -import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarGetRequest; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarPostRequest; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetResponse; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarPostResponse; -import com.newscatcher.api.types.Error; -import java.io.IOException; -import java.util.concurrent.CompletableFuture; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; -import org.jetbrains.annotations.NotNull; - -public class AsyncRawSearchsimilarClient { - protected final ClientOptions clientOptions; - - public AsyncRawSearchsimilarClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Searches for articles similar to a specified query. - */ - public CompletableFuture> get( - SearchSimilarGetRequest request) { - return get(request, null); - } - - /** - * Searches for articles similar to a specified query. - */ - public CompletableFuture> get( - SearchSimilarGetRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("api/search_similar"); - QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ(), false); - if (request.getSearchIn().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "search_in", request.getSearchIn().get(), false); - } - if (request.getIncludeTranslationFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "include_translation_fields", - request.getIncludeTranslationFields().get(), - false); - } - if (request.getIncludeSimilarDocuments().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "include_similar_documents", - request.getIncludeSimilarDocuments().get(), - false); - } - if (request.getSimilarDocumentsNumber().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "similar_documents_number", - request.getSimilarDocumentsNumber().get(), - false); - } - if (request.getSimilarDocumentsFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "similar_documents_fields", - request.getSimilarDocumentsFields().get(), - false); - } - if (request.getPredefinedSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "predefined_sources", - request.getPredefinedSources().get(), - false); - } - if (request.getSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sources", request.getSources().get(), false); - } - if (request.getNotSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_sources", request.getNotSources().get(), false); - } - if (request.getLang().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "lang", request.getLang().get(), false); - } - if (request.getNotLang().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_lang", request.getNotLang().get(), false); - } - if (request.getCountries().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "countries", request.getCountries().get(), false); - } - if (request.getNotCountries().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_countries", request.getNotCountries().get(), false); - } - if (request.getFrom().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "from_", request.getFrom().get(), false); - } - if (request.getTo().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "to_", request.getTo().get(), false); - } - if (request.getByParseDate().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "by_parse_date", request.getByParseDate().get(), false); - } - if (request.getPublishedDatePrecision().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "published_date_precision", - request.getPublishedDatePrecision().get(), - false); - } - if (request.getSortBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sort_by", request.getSortBy().get(), false); - } - if (request.getRankedOnly().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "ranked_only", request.getRankedOnly().get(), false); - } - if (request.getFromRank().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "from_rank", request.getFromRank().get(), false); - } - if (request.getToRank().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "to_rank", request.getToRank().get(), false); - } - if (request.getIsHeadline().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_headline", request.getIsHeadline().get(), false); - } - if (request.getIsOpinion().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_opinion", request.getIsOpinion().get(), false); - } - if (request.getIsPaidContent().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_paid_content", request.getIsPaidContent().get(), false); - } - if (request.getParentUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "parent_url", request.getParentUrl().get(), false); - } - if (request.getAllLinks().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "all_links", request.getAllLinks().get(), false); - } - if (request.getAllDomainLinks().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); - } - if (request.getWordCountMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "word_count_min", request.getWordCountMin().get(), false); - } - if (request.getWordCountMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "word_count_max", request.getWordCountMax().get(), false); - } - if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get(), false); - } - if (request.getPageSize().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page_size", request.getPageSize().get(), false); - } - if (request.getIncludeNlpData().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "include_nlp_data", request.getIncludeNlpData().get(), false); - } - if (request.getHasNlp().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "has_nlp", request.getHasNlp().get(), false); - } - if (request.getTheme().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "theme", request.getTheme().get(), false); - } - if (request.getNotTheme().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_theme", request.getNotTheme().get(), false); - } - if (request.getNerName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "ner_name", request.getNerName().get(), false); - } - if (request.getTitleSentimentMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "title_sentiment_min", - request.getTitleSentimentMin().get(), - false); - } - if (request.getTitleSentimentMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "title_sentiment_max", - request.getTitleSentimentMax().get(), - false); - } - if (request.getContentSentimentMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "content_sentiment_min", - request.getContentSentimentMin().get(), - false); - } - if (request.getContentSentimentMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "content_sentiment_max", - request.getContentSentimentMax().get(), - false); - } - if (request.getIptcTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "iptc_tags", request.getIptcTags().get(), false); - } - if (request.getNotIptcTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_iptc_tags", request.getNotIptcTags().get(), false); - } - if (request.getCustomTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "custom_tags", request.getCustomTags().get(), false); - } - if (request.getRobotsCompliant().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchSimilarGetResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - future.completeExceptionally(new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 401: - future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 403: - future.completeExceptionally(new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 408: - future.completeExceptionally(new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 422: - future.completeExceptionally(new UnprocessableEntityError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 429: - future.completeExceptionally(new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 500: - future.completeExceptionally(new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, String.class), - response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally( - new NewscatcherApiException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new NewscatcherApiException("Network error executing HTTP request", e)); - } - }); - return future; - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public CompletableFuture> post( - SearchSimilarPostRequest request) { - return post(request, null); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public CompletableFuture> post( - SearchSimilarPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("api/search_similar") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new NewscatcherApiException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - CompletableFuture> future = new CompletableFuture<>(); - client.newCall(okhttpRequest).enqueue(new Callback() { - @Override - public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { - try (ResponseBody responseBody = response.body()) { - if (response.isSuccessful()) { - future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SearchSimilarPostResponse.class), - response)); - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - future.completeExceptionally(new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 401: - future.completeExceptionally(new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 403: - future.completeExceptionally(new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 408: - future.completeExceptionally(new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 422: - future.completeExceptionally(new UnprocessableEntityError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 429: - future.completeExceptionally(new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), - response)); - return; - case 500: - future.completeExceptionally(new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, String.class), - response)); - return; - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); - return; - } catch (IOException e) { - future.completeExceptionally( - new NewscatcherApiException("Network error executing HTTP request", e)); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - future.completeExceptionally(new NewscatcherApiException("Network error executing HTTP request", e)); - } - }); - return future; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncSearchsimilarClient.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncSearchsimilarClient.java deleted file mode 100644 index e2260f0..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/AsyncSearchsimilarClient.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar; - -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarGetRequest; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarPostRequest; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetResponse; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarPostResponse; -import java.util.concurrent.CompletableFuture; - -public class AsyncSearchsimilarClient { - protected final ClientOptions clientOptions; - - private final AsyncRawSearchsimilarClient rawClient; - - public AsyncSearchsimilarClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new AsyncRawSearchsimilarClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public AsyncRawSearchsimilarClient withRawResponse() { - return this.rawClient; - } - - /** - * Searches for articles similar to a specified query. - */ - public CompletableFuture get(SearchSimilarGetRequest request) { - return this.rawClient.get(request).thenApply(response -> response.body()); - } - - /** - * Searches for articles similar to a specified query. - */ - public CompletableFuture get( - SearchSimilarGetRequest request, RequestOptions requestOptions) { - return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public CompletableFuture post(SearchSimilarPostRequest request) { - return this.rawClient.post(request).thenApply(response -> response.body()); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public CompletableFuture post( - SearchSimilarPostRequest request, RequestOptions requestOptions) { - return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/RawSearchsimilarClient.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/RawSearchsimilarClient.java deleted file mode 100644 index 25ae811..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/RawSearchsimilarClient.java +++ /dev/null @@ -1,393 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.MediaTypes; -import com.newscatcher.api.core.NewscatcherApiApiException; -import com.newscatcher.api.core.NewscatcherApiException; -import com.newscatcher.api.core.NewscatcherApiHttpResponse; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.core.QueryStringMapper; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.errors.BadRequestError; -import com.newscatcher.api.errors.ForbiddenError; -import com.newscatcher.api.errors.InternalServerError; -import com.newscatcher.api.errors.RequestTimeoutError; -import com.newscatcher.api.errors.TooManyRequestsError; -import com.newscatcher.api.errors.UnauthorizedError; -import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarGetRequest; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarPostRequest; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetResponse; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarPostResponse; -import com.newscatcher.api.types.Error; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class RawSearchsimilarClient { - protected final ClientOptions clientOptions; - - public RawSearchsimilarClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Searches for articles similar to a specified query. - */ - public NewscatcherApiHttpResponse get(SearchSimilarGetRequest request) { - return get(request, null); - } - - /** - * Searches for articles similar to a specified query. - */ - public NewscatcherApiHttpResponse get( - SearchSimilarGetRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("api/search_similar"); - QueryStringMapper.addQueryParameter(httpUrl, "q", request.getQ(), false); - if (request.getSearchIn().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "search_in", request.getSearchIn().get(), false); - } - if (request.getIncludeTranslationFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "include_translation_fields", - request.getIncludeTranslationFields().get(), - false); - } - if (request.getIncludeSimilarDocuments().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "include_similar_documents", - request.getIncludeSimilarDocuments().get(), - false); - } - if (request.getSimilarDocumentsNumber().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "similar_documents_number", - request.getSimilarDocumentsNumber().get(), - false); - } - if (request.getSimilarDocumentsFields().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "similar_documents_fields", - request.getSimilarDocumentsFields().get(), - false); - } - if (request.getPredefinedSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "predefined_sources", - request.getPredefinedSources().get(), - false); - } - if (request.getSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sources", request.getSources().get(), false); - } - if (request.getNotSources().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_sources", request.getNotSources().get(), false); - } - if (request.getLang().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "lang", request.getLang().get(), false); - } - if (request.getNotLang().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_lang", request.getNotLang().get(), false); - } - if (request.getCountries().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "countries", request.getCountries().get(), false); - } - if (request.getNotCountries().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_countries", request.getNotCountries().get(), false); - } - if (request.getFrom().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "from_", request.getFrom().get(), false); - } - if (request.getTo().isPresent()) { - QueryStringMapper.addQueryParameter(httpUrl, "to_", request.getTo().get(), false); - } - if (request.getByParseDate().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "by_parse_date", request.getByParseDate().get(), false); - } - if (request.getPublishedDatePrecision().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "published_date_precision", - request.getPublishedDatePrecision().get(), - false); - } - if (request.getSortBy().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "sort_by", request.getSortBy().get(), false); - } - if (request.getRankedOnly().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "ranked_only", request.getRankedOnly().get(), false); - } - if (request.getFromRank().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "from_rank", request.getFromRank().get(), false); - } - if (request.getToRank().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "to_rank", request.getToRank().get(), false); - } - if (request.getIsHeadline().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_headline", request.getIsHeadline().get(), false); - } - if (request.getIsOpinion().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_opinion", request.getIsOpinion().get(), false); - } - if (request.getIsPaidContent().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "is_paid_content", request.getIsPaidContent().get(), false); - } - if (request.getParentUrl().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "parent_url", request.getParentUrl().get(), false); - } - if (request.getAllLinks().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "all_links", request.getAllLinks().get(), false); - } - if (request.getAllDomainLinks().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "all_domain_links", request.getAllDomainLinks().get(), false); - } - if (request.getWordCountMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "word_count_min", request.getWordCountMin().get(), false); - } - if (request.getWordCountMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "word_count_max", request.getWordCountMax().get(), false); - } - if (request.getPage().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page", request.getPage().get(), false); - } - if (request.getPageSize().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "page_size", request.getPageSize().get(), false); - } - if (request.getIncludeNlpData().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "include_nlp_data", request.getIncludeNlpData().get(), false); - } - if (request.getHasNlp().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "has_nlp", request.getHasNlp().get(), false); - } - if (request.getTheme().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "theme", request.getTheme().get(), false); - } - if (request.getNotTheme().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_theme", request.getNotTheme().get(), false); - } - if (request.getNerName().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "ner_name", request.getNerName().get(), false); - } - if (request.getTitleSentimentMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "title_sentiment_min", - request.getTitleSentimentMin().get(), - false); - } - if (request.getTitleSentimentMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "title_sentiment_max", - request.getTitleSentimentMax().get(), - false); - } - if (request.getContentSentimentMin().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "content_sentiment_min", - request.getContentSentimentMin().get(), - false); - } - if (request.getContentSentimentMax().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, - "content_sentiment_max", - request.getContentSentimentMax().get(), - false); - } - if (request.getIptcTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "iptc_tags", request.getIptcTags().get(), false); - } - if (request.getNotIptcTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "not_iptc_tags", request.getNotIptcTags().get(), false); - } - if (request.getCustomTags().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "custom_tags", request.getCustomTags().get(), false); - } - if (request.getRobotsCompliant().isPresent()) { - QueryStringMapper.addQueryParameter( - httpUrl, "robots_compliant", request.getRobotsCompliant().get(), false); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Accept", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchSimilarGetResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 408: - throw new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 422: - throw new UnprocessableEntityError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 429: - throw new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, String.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new NewscatcherApiException("Network error executing HTTP request", e); - } - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public NewscatcherApiHttpResponse post(SearchSimilarPostRequest request) { - return post(request, null); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public NewscatcherApiHttpResponse post( - SearchSimilarPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("api/search_similar") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new NewscatcherApiException("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .addHeader("Accept", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SearchSimilarPostResponse.class), - response); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new BadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 401: - throw new UnauthorizedError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 403: - throw new ForbiddenError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 408: - throw new RequestTimeoutError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 422: - throw new UnprocessableEntityError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 429: - throw new TooManyRequestsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Error.class), response); - case 500: - throw new InternalServerError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, String.class), response); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); - } catch (IOException e) { - throw new NewscatcherApiException("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/SearchsimilarClient.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/SearchsimilarClient.java deleted file mode 100644 index 2340e69..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/SearchsimilarClient.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar; - -import com.newscatcher.api.core.ClientOptions; -import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarGetRequest; -import com.newscatcher.api.resources.searchsimilar.requests.SearchSimilarPostRequest; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetResponse; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarPostResponse; - -public class SearchsimilarClient { - protected final ClientOptions clientOptions; - - private final RawSearchsimilarClient rawClient; - - public SearchsimilarClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.rawClient = new RawSearchsimilarClient(clientOptions); - } - - /** - * Get responses with HTTP metadata like headers - */ - public RawSearchsimilarClient withRawResponse() { - return this.rawClient; - } - - /** - * Searches for articles similar to a specified query. - */ - public SearchSimilarGetResponse get(SearchSimilarGetRequest request) { - return this.rawClient.get(request).body(); - } - - /** - * Searches for articles similar to a specified query. - */ - public SearchSimilarGetResponse get(SearchSimilarGetRequest request, RequestOptions requestOptions) { - return this.rawClient.get(request, requestOptions).body(); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public SearchSimilarPostResponse post(SearchSimilarPostRequest request) { - return this.rawClient.post(request).body(); - } - - /** - * Searches for articles similar to the specified query. You can filter results by language, country, source, and more. - */ - public SearchSimilarPostResponse post(SearchSimilarPostRequest request, RequestOptions requestOptions) { - return this.rawClient.post(request, requestOptions).body(); - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarGetRequest.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarGetRequest.java deleted file mode 100644 index 3e58a5b..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarGetRequest.java +++ /dev/null @@ -1,2473 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetRequestPublishedDatePrecision; -import com.newscatcher.api.resources.searchsimilar.types.SearchSimilarGetRequestSortBy; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchSimilarGetRequest.Builder.class) -public final class SearchSimilarGetRequest { - private final String q; - - private final Optional searchIn; - - private final Optional includeTranslationFields; - - private final Optional includeSimilarDocuments; - - private final Optional similarDocumentsNumber; - - private final Optional similarDocumentsFields; - - private final Optional predefinedSources; - - private final Optional sources; - - private final Optional notSources; - - private final Optional lang; - - private final Optional notLang; - - private final Optional countries; - - private final Optional notCountries; - - private final Optional from; - - private final Optional to; - - private final Optional byParseDate; - - private final Optional publishedDatePrecision; - - private final Optional sortBy; - - private final Optional rankedOnly; - - private final Optional fromRank; - - private final Optional toRank; - - private final Optional isHeadline; - - private final Optional isOpinion; - - private final Optional isPaidContent; - - private final Optional parentUrl; - - private final Optional allLinks; - - private final Optional allDomainLinks; - - private final Optional wordCountMin; - - private final Optional wordCountMax; - - private final Optional page; - - private final Optional pageSize; - - private final Optional includeNlpData; - - private final Optional hasNlp; - - private final Optional theme; - - private final Optional notTheme; - - private final Optional nerName; - - private final Optional titleSentimentMin; - - private final Optional titleSentimentMax; - - private final Optional contentSentimentMin; - - private final Optional contentSentimentMax; - - private final Optional iptcTags; - - private final Optional notIptcTags; - - private final Optional customTags; - - private final Optional robotsCompliant; - - private final Map additionalProperties; - - private SearchSimilarGetRequest( - String q, - Optional searchIn, - Optional includeTranslationFields, - Optional includeSimilarDocuments, - Optional similarDocumentsNumber, - Optional similarDocumentsFields, - Optional predefinedSources, - Optional sources, - Optional notSources, - Optional lang, - Optional notLang, - Optional countries, - Optional notCountries, - Optional from, - Optional to, - Optional byParseDate, - Optional publishedDatePrecision, - Optional sortBy, - Optional rankedOnly, - Optional fromRank, - Optional toRank, - Optional isHeadline, - Optional isOpinion, - Optional isPaidContent, - Optional parentUrl, - Optional allLinks, - Optional allDomainLinks, - Optional wordCountMin, - Optional wordCountMax, - Optional page, - Optional pageSize, - Optional includeNlpData, - Optional hasNlp, - Optional theme, - Optional notTheme, - Optional nerName, - Optional titleSentimentMin, - Optional titleSentimentMax, - Optional contentSentimentMin, - Optional contentSentimentMax, - Optional iptcTags, - Optional notIptcTags, - Optional customTags, - Optional robotsCompliant, - Map additionalProperties) { - this.q = q; - this.searchIn = searchIn; - this.includeTranslationFields = includeTranslationFields; - this.includeSimilarDocuments = includeSimilarDocuments; - this.similarDocumentsNumber = similarDocumentsNumber; - this.similarDocumentsFields = similarDocumentsFields; - this.predefinedSources = predefinedSources; - this.sources = sources; - this.notSources = notSources; - this.lang = lang; - this.notLang = notLang; - this.countries = countries; - this.notCountries = notCountries; - this.from = from; - this.to = to; - this.byParseDate = byParseDate; - this.publishedDatePrecision = publishedDatePrecision; - this.sortBy = sortBy; - this.rankedOnly = rankedOnly; - this.fromRank = fromRank; - this.toRank = toRank; - this.isHeadline = isHeadline; - this.isOpinion = isOpinion; - this.isPaidContent = isPaidContent; - this.parentUrl = parentUrl; - this.allLinks = allLinks; - this.allDomainLinks = allDomainLinks; - this.wordCountMin = wordCountMin; - this.wordCountMax = wordCountMax; - this.page = page; - this.pageSize = pageSize; - this.includeNlpData = includeNlpData; - this.hasNlp = hasNlp; - this.theme = theme; - this.notTheme = notTheme; - this.nerName = nerName; - this.titleSentimentMin = titleSentimentMin; - this.titleSentimentMax = titleSentimentMax; - this.contentSentimentMin = contentSentimentMin; - this.contentSentimentMax = contentSentimentMax; - this.iptcTags = iptcTags; - this.notIptcTags = notIptcTags; - this.customTags = customTags; - this.robotsCompliant = robotsCompliant; - this.additionalProperties = additionalProperties; - } - - /** - * @return The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards: - *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ - @JsonProperty("q") - public String getQ() { - return q; - } - - @JsonProperty("search_in") - public Optional getSearchIn() { - return searchIn; - } - - @JsonProperty("include_translation_fields") - public Optional getIncludeTranslationFields() { - return includeTranslationFields; - } - - /** - * @return If true, includes similar documents in the response. - */ - @JsonProperty("include_similar_documents") - public Optional getIncludeSimilarDocuments() { - return includeSimilarDocuments; - } - - /** - * @return The number of similar documents to return. - */ - @JsonProperty("similar_documents_number") - public Optional getSimilarDocumentsNumber() { - return similarDocumentsNumber; - } - - /** - * @return The fields to consider for finding similar documents. - */ - @JsonProperty("similar_documents_fields") - public Optional getSimilarDocumentsFields() { - return similarDocumentsFields; - } - - /** - * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - @JsonProperty("predefined_sources") - public Optional getPredefinedSources() { - return predefinedSources; - } - - /** - * @return One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string. - *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - @JsonProperty("sources") - public Optional getSources() { - return sources; - } - - /** - * @return The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string. - *

Example: "cnn.com, wsj.com"

- */ - @JsonProperty("not_sources") - public Optional getNotSources() { - return notSources; - } - - /** - * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - @JsonProperty("lang") - public Optional getLang() { - return lang; - } - - /** - * @return The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string. - *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - @JsonProperty("not_lang") - public Optional getNotLang() { - return notLang; - } - - /** - * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @JsonProperty("countries") - public Optional getCountries() { - return countries; - } - - /** - * @return The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string. - *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @JsonProperty("not_countries") - public Optional getNotCountries() { - return notCountries; - } - - /** - * @return The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @JsonProperty("from_") - public Optional getFrom() { - return from; - } - - /** - * @return The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC. - *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @JsonProperty("to_") - public Optional getTo() { - return to; - } - - /** - * @return If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object. - */ - @JsonProperty("by_parse_date") - public Optional getByParseDate() { - return byParseDate; - } - - /** - * @return The precision of the published date. There are three types: - *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { - return publishedDatePrecision; - } - - /** - * @return The sorting order of the results. Possible values are: - *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - @JsonProperty("sort_by") - public Optional getSortBy() { - return sortBy; - } - - /** - * @return If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999. - */ - @JsonProperty("ranked_only") - public Optional getRankedOnly() { - return rankedOnly; - } - - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ - @JsonProperty("from_rank") - public Optional getFromRank() { - return fromRank; - } - - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ - @JsonProperty("to_rank") - public Optional getToRank() { - return toRank; - } - - /** - * @return If true, only returns articles that were posted on the home page of a given news domain. - */ - @JsonProperty("is_headline") - public Optional getIsHeadline() { - return isHeadline; - } - - /** - * @return If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only. - */ - @JsonProperty("is_opinion") - public Optional getIsOpinion() { - return isOpinion; - } - - /** - * @return If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved. - */ - @JsonProperty("is_paid_content") - public Optional getIsPaidContent() { - return isPaidContent; - } - - /** - * @return The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string. - *

Example: "wsj.com/politics, wsj.com/tech"

- */ - @JsonProperty("parent_url") - public Optional getParentUrl() { - return parentUrl; - } - - /** - * @return The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string. - *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - @JsonProperty("all_links") - public Optional getAllLinks() { - return allLinks; - } - - /** - * @return The domain(s) mentioned in the article. For multiple domains, use a comma-separated string. - *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - @JsonProperty("all_domain_links") - public Optional getAllDomainLinks() { - return allDomainLinks; - } - - /** - * @return The minimum number of words an article must contain. To be used for avoiding articles with small content. - */ - @JsonProperty("word_count_min") - public Optional getWordCountMin() { - return wordCountMin; - } - - /** - * @return The maximum number of words an article can contain. To be used for avoiding articles with large content. - */ - @JsonProperty("word_count_max") - public Optional getWordCountMax() { - return wordCountMax; - } - - /** - * @return The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles. - *

For details, see How to paginate large datasets.

- */ - @JsonProperty("page") - public Optional getPage() { - return page; - } - - /** - * @return The number of articles to return per page. - */ - @JsonProperty("page_size") - public Optional getPageSize() { - return pageSize; - } - - @JsonProperty("include_nlp_data") - public Optional getIncludeNlpData() { - return includeNlpData; - } - - @JsonProperty("has_nlp") - public Optional getHasNlp() { - return hasNlp; - } - - /** - * @return Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string. - *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - @JsonProperty("theme") - public Optional getTheme() { - return theme; - } - - /** - * @return Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string. - *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("not_theme") - public Optional getNotTheme() { - return notTheme; - } - - /** - * @return The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string. - *

Example: "Tesla, Amazon"

- */ - @JsonProperty("ner_name") - public Optional getNerName() { - return nerName; - } - - /** - * @return Filters articles based on the minimum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("title_sentiment_min") - public Optional getTitleSentimentMin() { - return titleSentimentMin; - } - - /** - * @return Filters articles based on the maximum sentiment score of their titles. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("title_sentiment_max") - public Optional getTitleSentimentMax() { - return titleSentimentMax; - } - - /** - * @return Filters articles based on the minimum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("content_sentiment_min") - public Optional getContentSentimentMin() { - return contentSentimentMin; - } - - /** - * @return Filters articles based on the maximum sentiment score of their content. - *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @JsonProperty("content_sentiment_max") - public Optional getContentSentimentMax() { - return contentSentimentMax; - } - - /** - * @return Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs. - *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @JsonProperty("iptc_tags") - public Optional getIptcTags() { - return iptcTags; - } - - /** - * @return Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs. - *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @JsonProperty("not_iptc_tags") - public Optional getNotIptcTags() { - return notIptcTags; - } - - /** - * @return Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern: - *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • - *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

- */ - @JsonProperty("custom_tags") - public Optional getCustomTags() { - return customTags; - } - - /** - * @return If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status. - */ - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchSimilarGetRequest && equalTo((SearchSimilarGetRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SearchSimilarGetRequest other) { - return q.equals(other.q) - && searchIn.equals(other.searchIn) - && includeTranslationFields.equals(other.includeTranslationFields) - && includeSimilarDocuments.equals(other.includeSimilarDocuments) - && similarDocumentsNumber.equals(other.similarDocumentsNumber) - && similarDocumentsFields.equals(other.similarDocumentsFields) - && predefinedSources.equals(other.predefinedSources) - && sources.equals(other.sources) - && notSources.equals(other.notSources) - && lang.equals(other.lang) - && notLang.equals(other.notLang) - && countries.equals(other.countries) - && notCountries.equals(other.notCountries) - && from.equals(other.from) - && to.equals(other.to) - && byParseDate.equals(other.byParseDate) - && publishedDatePrecision.equals(other.publishedDatePrecision) - && sortBy.equals(other.sortBy) - && rankedOnly.equals(other.rankedOnly) - && fromRank.equals(other.fromRank) - && toRank.equals(other.toRank) - && isHeadline.equals(other.isHeadline) - && isOpinion.equals(other.isOpinion) - && isPaidContent.equals(other.isPaidContent) - && parentUrl.equals(other.parentUrl) - && allLinks.equals(other.allLinks) - && allDomainLinks.equals(other.allDomainLinks) - && wordCountMin.equals(other.wordCountMin) - && wordCountMax.equals(other.wordCountMax) - && page.equals(other.page) - && pageSize.equals(other.pageSize) - && includeNlpData.equals(other.includeNlpData) - && hasNlp.equals(other.hasNlp) - && theme.equals(other.theme) - && notTheme.equals(other.notTheme) - && nerName.equals(other.nerName) - && titleSentimentMin.equals(other.titleSentimentMin) - && titleSentimentMax.equals(other.titleSentimentMax) - && contentSentimentMin.equals(other.contentSentimentMin) - && contentSentimentMax.equals(other.contentSentimentMax) - && iptcTags.equals(other.iptcTags) - && notIptcTags.equals(other.notIptcTags) - && customTags.equals(other.customTags) - && robotsCompliant.equals(other.robotsCompliant); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.q, - this.searchIn, - this.includeTranslationFields, - this.includeSimilarDocuments, - this.similarDocumentsNumber, - this.similarDocumentsFields, - this.predefinedSources, - this.sources, - this.notSources, - this.lang, - this.notLang, - this.countries, - this.notCountries, - this.from, - this.to, - this.byParseDate, - this.publishedDatePrecision, - this.sortBy, - this.rankedOnly, - this.fromRank, - this.toRank, - this.isHeadline, - this.isOpinion, - this.isPaidContent, - this.parentUrl, - this.allLinks, - this.allDomainLinks, - this.wordCountMin, - this.wordCountMax, - this.page, - this.pageSize, - this.includeNlpData, - this.hasNlp, - this.theme, - this.notTheme, - this.nerName, - this.titleSentimentMin, - this.titleSentimentMax, - this.contentSentimentMin, - this.contentSentimentMax, - this.iptcTags, - this.notIptcTags, - this.customTags, - this.robotsCompliant); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static QStage builder() { - return new Builder(); - } - - public interface QStage { - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- */ - _FinalStage q(@NotNull String q); - - Builder from(SearchSimilarGetRequest other); - } - - public interface _FinalStage { - SearchSimilarGetRequest build(); - - _FinalStage searchIn(Optional searchIn); - - _FinalStage searchIn(String searchIn); - - _FinalStage includeTranslationFields(Optional includeTranslationFields); - - _FinalStage includeTranslationFields(Boolean includeTranslationFields); - - /** - *

If true, includes similar documents in the response.

- */ - _FinalStage includeSimilarDocuments(Optional includeSimilarDocuments); - - _FinalStage includeSimilarDocuments(Boolean includeSimilarDocuments); - - /** - *

The number of similar documents to return.

- */ - _FinalStage similarDocumentsNumber(Optional similarDocumentsNumber); - - _FinalStage similarDocumentsNumber(Integer similarDocumentsNumber); - - /** - *

The fields to consider for finding similar documents.

- */ - _FinalStage similarDocumentsFields(Optional similarDocumentsFields); - - _FinalStage similarDocumentsFields(String similarDocumentsFields); - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - _FinalStage predefinedSources(Optional predefinedSources); - - _FinalStage predefinedSources(String predefinedSources); - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - _FinalStage sources(Optional sources); - - _FinalStage sources(String sources); - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- */ - _FinalStage notSources(Optional notSources); - - _FinalStage notSources(String notSources); - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - _FinalStage lang(Optional lang); - - _FinalStage lang(String lang); - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - _FinalStage notLang(Optional notLang); - - _FinalStage notLang(String notLang); - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - _FinalStage countries(Optional countries); - - _FinalStage countries(String countries); - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - _FinalStage notCountries(Optional notCountries); - - _FinalStage notCountries(String notCountries); - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage from(Optional from); - - _FinalStage from(OffsetDateTime from); - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - _FinalStage to(Optional to); - - _FinalStage to(OffsetDateTime to); - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ - _FinalStage byParseDate(Optional byParseDate); - - _FinalStage byParseDate(Boolean byParseDate); - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - _FinalStage publishedDatePrecision( - Optional publishedDatePrecision); - - _FinalStage publishedDatePrecision(SearchSimilarGetRequestPublishedDatePrecision publishedDatePrecision); - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - _FinalStage sortBy(Optional sortBy); - - _FinalStage sortBy(SearchSimilarGetRequestSortBy sortBy); - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ - _FinalStage rankedOnly(Optional rankedOnly); - - _FinalStage rankedOnly(Boolean rankedOnly); - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - _FinalStage fromRank(Optional fromRank); - - _FinalStage fromRank(Integer fromRank); - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - _FinalStage toRank(Optional toRank); - - _FinalStage toRank(Integer toRank); - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ - _FinalStage isHeadline(Optional isHeadline); - - _FinalStage isHeadline(Boolean isHeadline); - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ - _FinalStage isOpinion(Optional isOpinion); - - _FinalStage isOpinion(Boolean isOpinion); - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ - _FinalStage isPaidContent(Optional isPaidContent); - - _FinalStage isPaidContent(Boolean isPaidContent); - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- */ - _FinalStage parentUrl(Optional parentUrl); - - _FinalStage parentUrl(String parentUrl); - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - _FinalStage allLinks(Optional allLinks); - - _FinalStage allLinks(String allLinks); - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - _FinalStage allDomainLinks(Optional allDomainLinks); - - _FinalStage allDomainLinks(String allDomainLinks); - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ - _FinalStage wordCountMin(Optional wordCountMin); - - _FinalStage wordCountMin(Integer wordCountMin); - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ - _FinalStage wordCountMax(Optional wordCountMax); - - _FinalStage wordCountMax(Integer wordCountMax); - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ - _FinalStage page(Optional page); - - _FinalStage page(Integer page); - - /** - *

The number of articles to return per page.

- */ - _FinalStage pageSize(Optional pageSize); - - _FinalStage pageSize(Integer pageSize); - - _FinalStage includeNlpData(Optional includeNlpData); - - _FinalStage includeNlpData(Boolean includeNlpData); - - _FinalStage hasNlp(Optional hasNlp); - - _FinalStage hasNlp(Boolean hasNlp); - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - _FinalStage theme(Optional theme); - - _FinalStage theme(String theme); - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage notTheme(Optional notTheme); - - _FinalStage notTheme(String notTheme); - - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- */ - _FinalStage nerName(Optional nerName); - - _FinalStage nerName(String nerName); - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage titleSentimentMin(Optional titleSentimentMin); - - _FinalStage titleSentimentMin(Float titleSentimentMin); - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage titleSentimentMax(Optional titleSentimentMax); - - _FinalStage titleSentimentMax(Float titleSentimentMax); - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage contentSentimentMin(Optional contentSentimentMin); - - _FinalStage contentSentimentMin(Float contentSentimentMin); - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - _FinalStage contentSentimentMax(Optional contentSentimentMax); - - _FinalStage contentSentimentMax(Float contentSentimentMax); - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - _FinalStage iptcTags(Optional iptcTags); - - _FinalStage iptcTags(String iptcTags); - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - _FinalStage notIptcTags(Optional notIptcTags); - - _FinalStage notIptcTags(String notIptcTags); - - /** - *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

- *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • - *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

- */ - _FinalStage customTags(Optional customTags); - - _FinalStage customTags(String customTags); - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ - _FinalStage robotsCompliant(Optional robotsCompliant); - - _FinalStage robotsCompliant(Boolean robotsCompliant); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements QStage, _FinalStage { - private String q; - - private Optional robotsCompliant = Optional.empty(); - - private Optional customTags = Optional.empty(); - - private Optional notIptcTags = Optional.empty(); - - private Optional iptcTags = Optional.empty(); - - private Optional contentSentimentMax = Optional.empty(); - - private Optional contentSentimentMin = Optional.empty(); - - private Optional titleSentimentMax = Optional.empty(); - - private Optional titleSentimentMin = Optional.empty(); - - private Optional nerName = Optional.empty(); - - private Optional notTheme = Optional.empty(); - - private Optional theme = Optional.empty(); - - private Optional hasNlp = Optional.empty(); - - private Optional includeNlpData = Optional.empty(); - - private Optional pageSize = Optional.empty(); - - private Optional page = Optional.empty(); - - private Optional wordCountMax = Optional.empty(); - - private Optional wordCountMin = Optional.empty(); - - private Optional allDomainLinks = Optional.empty(); - - private Optional allLinks = Optional.empty(); - - private Optional parentUrl = Optional.empty(); - - private Optional isPaidContent = Optional.empty(); - - private Optional isOpinion = Optional.empty(); - - private Optional isHeadline = Optional.empty(); - - private Optional toRank = Optional.empty(); - - private Optional fromRank = Optional.empty(); - - private Optional rankedOnly = Optional.empty(); - - private Optional sortBy = Optional.empty(); - - private Optional publishedDatePrecision = Optional.empty(); - - private Optional byParseDate = Optional.empty(); - - private Optional to = Optional.empty(); - - private Optional from = Optional.empty(); - - private Optional notCountries = Optional.empty(); - - private Optional countries = Optional.empty(); - - private Optional notLang = Optional.empty(); - - private Optional lang = Optional.empty(); - - private Optional notSources = Optional.empty(); - - private Optional sources = Optional.empty(); - - private Optional predefinedSources = Optional.empty(); - - private Optional similarDocumentsFields = Optional.empty(); - - private Optional similarDocumentsNumber = Optional.empty(); - - private Optional includeSimilarDocuments = Optional.empty(); - - private Optional includeTranslationFields = Optional.empty(); - - private Optional searchIn = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SearchSimilarGetRequest other) { - q(other.getQ()); - searchIn(other.getSearchIn()); - includeTranslationFields(other.getIncludeTranslationFields()); - includeSimilarDocuments(other.getIncludeSimilarDocuments()); - similarDocumentsNumber(other.getSimilarDocumentsNumber()); - similarDocumentsFields(other.getSimilarDocumentsFields()); - predefinedSources(other.getPredefinedSources()); - sources(other.getSources()); - notSources(other.getNotSources()); - lang(other.getLang()); - notLang(other.getNotLang()); - countries(other.getCountries()); - notCountries(other.getNotCountries()); - from(other.getFrom()); - to(other.getTo()); - byParseDate(other.getByParseDate()); - publishedDatePrecision(other.getPublishedDatePrecision()); - sortBy(other.getSortBy()); - rankedOnly(other.getRankedOnly()); - fromRank(other.getFromRank()); - toRank(other.getToRank()); - isHeadline(other.getIsHeadline()); - isOpinion(other.getIsOpinion()); - isPaidContent(other.getIsPaidContent()); - parentUrl(other.getParentUrl()); - allLinks(other.getAllLinks()); - allDomainLinks(other.getAllDomainLinks()); - wordCountMin(other.getWordCountMin()); - wordCountMax(other.getWordCountMax()); - page(other.getPage()); - pageSize(other.getPageSize()); - includeNlpData(other.getIncludeNlpData()); - hasNlp(other.getHasNlp()); - theme(other.getTheme()); - notTheme(other.getNotTheme()); - nerName(other.getNerName()); - titleSentimentMin(other.getTitleSentimentMin()); - titleSentimentMax(other.getTitleSentimentMax()); - contentSentimentMin(other.getContentSentimentMin()); - contentSentimentMax(other.getContentSentimentMax()); - iptcTags(other.getIptcTags()); - notIptcTags(other.getNotIptcTags()); - customTags(other.getCustomTags()); - robotsCompliant(other.getRobotsCompliant()); - return this; - } - - /** - *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- *

The keyword(s) to search for in articles. Query syntax supports logical operators (AND, OR, NOT) and wildcards:

- *
    - *
  • For an exact match, use double quotes. For example, "technology news".
  • - *
  • Use * to search for any keyword.
  • - *
  • Use + to include and - to exclude specific words or phrases. - * For example, +Apple, -Google.
  • - *
  • Use AND, OR, and NOT to refine search results. - * For example, technology AND (Apple OR Microsoft) NOT Google.
  • - *
- *

For more details, see Advanced querying.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("q") - public _FinalStage q(@NotNull String q) { - this.q = Objects.requireNonNull(q, "q must not be null"); - return this; - } - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - /** - *

If true, returns only articles/sources that comply with the publisher's robots.txt rules. If false, returns only articles/sources that do not comply with robots.txt rules. If omitted, returns all articles/sources regardless of compliance status.

- */ - @java.lang.Override - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public _FinalStage robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - - /** - *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

- *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • - *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTags(String customTags) { - this.customTags = Optional.ofNullable(customTags); - return this; - } - - /** - *

Filters articles based on provided taxonomy that is tailored to your specific needs and is accessible only with your API key. To specify tags, use the following pattern:

- *
    - *
  • custom_tags.taxonomy=Tag1,Tag2,Tag3, where taxonomy is the taxonomy name and Tag1,Tag2,Tag3 is a comma-separated list of tags.
  • - *
- *

Example: custom_tags.industry="Manufacturing, Supply Chain, Logistics"

- *

To learn more, see the Custom tags.

- */ - @java.lang.Override - @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) - public _FinalStage customTags(Optional customTags) { - this.customTags = customTags; - return this; - } - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notIptcTags(String notIptcTags) { - this.notIptcTags = Optional.ofNullable(notIptcTags); - return this; - } - - /** - *

Inverse of the iptc_tags parameter. Excludes articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags to exclude, use a comma-separated string of tag IDs.

- *

Example: "20000205, 20000209"

- *

Note: The not_iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @java.lang.Override - @JsonSetter(value = "not_iptc_tags", nulls = Nulls.SKIP) - public _FinalStage notIptcTags(Optional notIptcTags) { - this.notIptcTags = notIptcTags; - return this; - } - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage iptcTags(String iptcTags) { - this.iptcTags = Optional.ofNullable(iptcTags); - return this; - } - - /** - *

Filters articles based on International Press Telecommunications Council (IPTC) media topic tags. To specify multiple IPTC tags, use a comma-separated string of tag IDs.

- *

Example: "20000199, 20000209"

- *

Note: The iptc_tags parameter is only available in the v3_nlp_iptc_tags subscription plan.

- *

To learn more, see IPTC Media Topic NewsCodes.

- */ - @java.lang.Override - @JsonSetter(value = "iptc_tags", nulls = Nulls.SKIP) - public _FinalStage iptcTags(Optional iptcTags) { - this.iptcTags = iptcTags; - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage contentSentimentMax(Float contentSentimentMax) { - this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMax(Optional contentSentimentMax) { - this.contentSentimentMax = contentSentimentMax; - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage contentSentimentMin(Float contentSentimentMin) { - this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their content.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The content_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMin(Optional contentSentimentMin) { - this.contentSentimentMin = contentSentimentMin; - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage titleSentimentMax(Float titleSentimentMax) { - this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); - return this; - } - - /** - *

Filters articles based on the maximum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_max parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMax(Optional titleSentimentMax) { - this.titleSentimentMax = titleSentimentMax; - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage titleSentimentMin(Float titleSentimentMin) { - this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); - return this; - } - - /** - *

Filters articles based on the minimum sentiment score of their titles.

- *

Range is -1.0 to 1.0, where:

- *
    - *
  • Negative values indicate negative sentiment.
  • - *
  • Positive values indicate positive sentiment.
  • - *
  • Values close to 0 indicate neutral sentiment.
  • - *
- *

Note: The title_sentiment_min parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMin(Optional titleSentimentMin) { - this.titleSentimentMin = titleSentimentMin; - return this; - } - - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nerName(String nerName) { - this.nerName = Optional.ofNullable(nerName); - return this; - } - - /** - *

The name of person, organization, location, product or other named entity to search for. To specify multiple names use a comma-separated string.

- *

Example: "Tesla, Amazon"

- */ - @java.lang.Override - @JsonSetter(value = "ner_name", nulls = Nulls.SKIP) - public _FinalStage nerName(Optional nerName) { - this.nerName = nerName; - return this; - } - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notTheme(String notTheme) { - this.notTheme = Optional.ofNullable(notTheme); - return this; - } - - /** - *

Inverse of the theme parameter. Excludes articles based on their general topic, as determined by NLP analysis. To exclude multiple themes, use a comma-separated string.

- *

Example: "Crime, Tech"

- *

Note: The not_theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- */ - @java.lang.Override - @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { - this.notTheme = notTheme; - return this; - } - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage theme(String theme) { - this.theme = Optional.ofNullable(theme); - return this; - } - - /** - *

Filters articles based on their general topic, as determined by NLP analysis. To select multiple themes, use a comma-separated string.

- *

Example: "Finance, Tech"

- *

Note: The theme parameter is only available if NLP is included in your subscription plan.

- *

To learn more, see NLP features.

- *

Available options: Business, Economics, Entertainment, Finance, Health, Politics, Science, Sports, Tech, Crime, Financial Crime, Lifestyle, Automotive, Travel, Weather, General.

- */ - @java.lang.Override - @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { - this.theme = theme; - return this; - } - - @java.lang.Override - public _FinalStage hasNlp(Boolean hasNlp) { - this.hasNlp = Optional.ofNullable(hasNlp); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_nlp", nulls = Nulls.SKIP) - public _FinalStage hasNlp(Optional hasNlp) { - this.hasNlp = hasNlp; - return this; - } - - @java.lang.Override - public _FinalStage includeNlpData(Boolean includeNlpData) { - this.includeNlpData = Optional.ofNullable(includeNlpData); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_nlp_data", nulls = Nulls.SKIP) - public _FinalStage includeNlpData(Optional includeNlpData) { - this.includeNlpData = includeNlpData; - return this; - } - - /** - *

The number of articles to return per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage pageSize(Integer pageSize) { - this.pageSize = Optional.ofNullable(pageSize); - return this; - } - - /** - *

The number of articles to return per page.

- */ - @java.lang.Override - @JsonSetter(value = "page_size", nulls = Nulls.SKIP) - public _FinalStage pageSize(Optional pageSize) { - this.pageSize = pageSize; - return this; - } - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - /** - *

The page number to scroll through the results. Use for pagination, as a single API response can return up to 1,000 articles.

- *

For details, see How to paginate large datasets.

- */ - @java.lang.Override - @JsonSetter(value = "page", nulls = Nulls.SKIP) - public _FinalStage page(Optional page) { - this.page = page; - return this; - } - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage wordCountMax(Integer wordCountMax) { - this.wordCountMax = Optional.ofNullable(wordCountMax); - return this; - } - - /** - *

The maximum number of words an article can contain. To be used for avoiding articles with large content.

- */ - @java.lang.Override - @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) - public _FinalStage wordCountMax(Optional wordCountMax) { - this.wordCountMax = wordCountMax; - return this; - } - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage wordCountMin(Integer wordCountMin) { - this.wordCountMin = Optional.ofNullable(wordCountMin); - return this; - } - - /** - *

The minimum number of words an article must contain. To be used for avoiding articles with small content.

- */ - @java.lang.Override - @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) - public _FinalStage wordCountMin(Optional wordCountMin) { - this.wordCountMin = wordCountMin; - return this; - } - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allDomainLinks(String allDomainLinks) { - this.allDomainLinks = Optional.ofNullable(allDomainLinks); - return this; - } - - /** - *

The domain(s) mentioned in the article. For multiple domains, use a comma-separated string.

- *

Example: "who.int, nih.gov"

- *

For more details, see Search by URL.

- */ - @java.lang.Override - @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) - public _FinalStage allDomainLinks(Optional allDomainLinks) { - this.allDomainLinks = allDomainLinks; - return this; - } - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allLinks(String allLinks) { - this.allLinks = Optional.ofNullable(allLinks); - return this; - } - - /** - *

The complete URL(s) mentioned in the article. For multiple URLs, use a comma-separated string.

- *

Example: "https://aiindex.stanford.edu/report, https://www.stateof.ai"

- *

For more details, see Search by URL.

- */ - @java.lang.Override - @JsonSetter(value = "all_links", nulls = Nulls.SKIP) - public _FinalStage allLinks(Optional allLinks) { - this.allLinks = allLinks; - return this; - } - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage parentUrl(String parentUrl) { - this.parentUrl = Optional.ofNullable(parentUrl); - return this; - } - - /** - *

The categorical URL(s) to filter your search. To filter your search by multiple categorical URLs, use a comma-separated string.

- *

Example: "wsj.com/politics, wsj.com/tech"

- */ - @java.lang.Override - @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) - public _FinalStage parentUrl(Optional parentUrl) { - this.parentUrl = parentUrl; - return this; - } - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isPaidContent(Boolean isPaidContent) { - this.isPaidContent = Optional.ofNullable(isPaidContent); - return this; - } - - /** - *

If false, returns only articles that have publicly available complete content. Some publishers partially block content, so this setting ensures that only full articles are retrieved.

- */ - @java.lang.Override - @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) - public _FinalStage isPaidContent(Optional isPaidContent) { - this.isPaidContent = isPaidContent; - return this; - } - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isOpinion(Boolean isOpinion) { - this.isOpinion = Optional.ofNullable(isOpinion); - return this; - } - - /** - *

If true, returns only opinion pieces. If false, excludes opinion-based articles and returns news only.

- */ - @java.lang.Override - @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) - public _FinalStage isOpinion(Optional isOpinion) { - this.isOpinion = isOpinion; - return this; - } - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isHeadline(Boolean isHeadline) { - this.isHeadline = Optional.ofNullable(isHeadline); - return this; - } - - /** - *

If true, only returns articles that were posted on the home page of a given news domain.

- */ - @java.lang.Override - @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) - public _FinalStage isHeadline(Optional isHeadline) { - this.isHeadline = isHeadline; - return this; - } - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage toRank(Integer toRank) { - this.toRank = Optional.ofNullable(toRank); - return this; - } - - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - @java.lang.Override - @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) - public _FinalStage toRank(Optional toRank) { - this.toRank = toRank; - return this; - } - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage fromRank(Integer fromRank) { - this.fromRank = Optional.ofNullable(fromRank); - return this; - } - - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ - @java.lang.Override - @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) - public _FinalStage fromRank(Optional fromRank) { - this.fromRank = fromRank; - return this; - } - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rankedOnly(Boolean rankedOnly) { - this.rankedOnly = Optional.ofNullable(rankedOnly); - return this; - } - - /** - *

If true, limits the search to sources ranked in the top 1 million online websites. If false, includes unranked sources which are assigned a rank of 999999.

- */ - @java.lang.Override - @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) - public _FinalStage rankedOnly(Optional rankedOnly) { - this.rankedOnly = rankedOnly; - return this; - } - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sortBy(SearchSimilarGetRequestSortBy sortBy) { - this.sortBy = Optional.ofNullable(sortBy); - return this; - } - - /** - *

The sorting order of the results. Possible values are:

- *
    - *
  • relevancy: The most relevant results first.
  • - *
  • date: The most recently published results first.
  • - *
  • rank: The results from the highest-ranked sources first.
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public _FinalStage sortBy(Optional sortBy) { - this.sortBy = sortBy; - return this; - } - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage publishedDatePrecision( - SearchSimilarGetRequestPublishedDatePrecision publishedDatePrecision) { - this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); - return this; - } - - /** - *

The precision of the published date. There are three types:

- *
    - *
  • full: The day and time of an article is correctly identified with the appropriate timezone.
  • - *
  • timezone unknown: The day and time of an article is correctly identified without timezone.
  • - *
  • date: Only the day is identified without an exact time.
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision( - Optional publishedDatePrecision) { - this.publishedDatePrecision = publishedDatePrecision; - return this; - } - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage byParseDate(Boolean byParseDate) { - this.byParseDate = Optional.ofNullable(byParseDate); - return this; - } - - /** - *

If true, the from_ and to_ parameters use article parse dates instead of published dates. Additionally, the parse_date variable is added to the output for each article object.

- */ - @java.lang.Override - @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) - public _FinalStage byParseDate(Optional byParseDate) { - this.byParseDate = byParseDate; - return this; - } - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage to(OffsetDateTime to) { - this.to = Optional.ofNullable(to); - return this; - } - - /** - *

The ending point in time to search up to. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 1 day ago, now
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "to_", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage from(OffsetDateTime from) { - this.from = Optional.ofNullable(from); - return this; - } - - /** - *

The starting point in time to search from. Accepts date-time strings in ISO 8601 format and plain text. The default time zone is UTC.

- *

Formats with examples:

- *
    - *
  • YYYY-mm-ddTHH:MM:SS: 2024-07-01T00:00:00
  • - *
  • YYYY-MM-dd: 2024-07-01
  • - *
  • YYYY/mm/dd HH:MM:SS: 2024/07/01 00:00:00
  • - *
  • YYYY/mm/dd: 2024/07/01
  • - *
  • English phrases: 7 day ago, today
  • - *
- *

Note: By default, applied to the publication date of the article. To use the article's parse date instead, set the by_parse_date parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "from_", nulls = Nulls.SKIP) - public _FinalStage from(Optional from) { - this.from = from; - return this; - } - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notCountries(String notCountries) { - this.notCountries = Optional.ofNullable(notCountries); - return this; - } - - /** - *

The publisher location countries to exclude from the search. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To exclude multiple countries, use a comma-separated string.

- *

Example:"US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @java.lang.Override - @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) - public _FinalStage notCountries(Optional notCountries) { - this.notCountries = notCountries; - return this; - } - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage countries(String countries) { - this.countries = Optional.ofNullable(countries); - return this; - } - - /** - *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

- */ - @java.lang.Override - @JsonSetter(value = "countries", nulls = Nulls.SKIP) - public _FinalStage countries(Optional countries) { - this.countries = countries; - return this; - } - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notLang(String notLang) { - this.notLang = Optional.ofNullable(notLang); - return this; - } - - /** - *

The language(s) to exclude from the search. The accepted format is the two-letter ISO 639-1 code. To exclude multiple languages, use a comma-separated string.

- *

Example: "fr, de"

- *

To learn more, see Enumerated parameters > Language.

- */ - @java.lang.Override - @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) - public _FinalStage notLang(Optional notLang) { - this.notLang = notLang; - return this; - } - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage lang(String lang) { - this.lang = Optional.ofNullable(lang); - return this; - } - - /** - *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

- */ - @java.lang.Override - @JsonSetter(value = "lang", nulls = Nulls.SKIP) - public _FinalStage lang(Optional lang) { - this.lang = lang; - return this; - } - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage notSources(String notSources) { - this.notSources = Optional.ofNullable(notSources); - return this; - } - - /** - *

The news sources to exclude from the search. To exclude multiple sources, use a comma-separated string.

- *

Example: "cnn.com, wsj.com"

- */ - @java.lang.Override - @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) - public _FinalStage notSources(Optional notSources) { - this.notSources = notSources; - return this; - } - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sources(String sources) { - this.sources = Optional.ofNullable(sources); - return this; - } - - /** - *

One or more news sources to narrow down the search. The format must be a domain URL. Subdomains, such as finance.yahoo.com, are also acceptable.To specify multiple sources, use a comma-separated string.

- *

Examples:

- *
    - *
  • "nytimes.com"
  • - *
  • "theguardian.com, finance.yahoo.com"
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "sources", nulls = Nulls.SKIP) - public _FinalStage sources(Optional sources) { - this.sources = sources; - return this; - } - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage predefinedSources(String predefinedSources) { - this.predefinedSources = Optional.ofNullable(predefinedSources); - return this; - } - - /** - *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
- */ - @java.lang.Override - @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) - public _FinalStage predefinedSources(Optional predefinedSources) { - this.predefinedSources = predefinedSources; - return this; - } - - /** - *

The fields to consider for finding similar documents.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage similarDocumentsFields(String similarDocumentsFields) { - this.similarDocumentsFields = Optional.ofNullable(similarDocumentsFields); - return this; - } - - /** - *

The fields to consider for finding similar documents.

- */ - @java.lang.Override - @JsonSetter(value = "similar_documents_fields", nulls = Nulls.SKIP) - public _FinalStage similarDocumentsFields(Optional similarDocumentsFields) { - this.similarDocumentsFields = similarDocumentsFields; - return this; - } - - /** - *

The number of similar documents to return.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage similarDocumentsNumber(Integer similarDocumentsNumber) { - this.similarDocumentsNumber = Optional.ofNullable(similarDocumentsNumber); - return this; - } - - /** - *

The number of similar documents to return.

- */ - @java.lang.Override - @JsonSetter(value = "similar_documents_number", nulls = Nulls.SKIP) - public _FinalStage similarDocumentsNumber(Optional similarDocumentsNumber) { - this.similarDocumentsNumber = similarDocumentsNumber; - return this; - } - - /** - *

If true, includes similar documents in the response.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage includeSimilarDocuments(Boolean includeSimilarDocuments) { - this.includeSimilarDocuments = Optional.ofNullable(includeSimilarDocuments); - return this; - } - - /** - *

If true, includes similar documents in the response.

- */ - @java.lang.Override - @JsonSetter(value = "include_similar_documents", nulls = Nulls.SKIP) - public _FinalStage includeSimilarDocuments(Optional includeSimilarDocuments) { - this.includeSimilarDocuments = includeSimilarDocuments; - return this; - } - - @java.lang.Override - public _FinalStage includeTranslationFields(Boolean includeTranslationFields) { - this.includeTranslationFields = Optional.ofNullable(includeTranslationFields); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_translation_fields", nulls = Nulls.SKIP) - public _FinalStage includeTranslationFields(Optional includeTranslationFields) { - this.includeTranslationFields = includeTranslationFields; - return this; - } - - @java.lang.Override - public _FinalStage searchIn(String searchIn) { - this.searchIn = Optional.ofNullable(searchIn); - return this; - } - - @java.lang.Override - @JsonSetter(value = "search_in", nulls = Nulls.SKIP) - public _FinalStage searchIn(Optional searchIn) { - this.searchIn = searchIn; - return this; - } - - @java.lang.Override - public SearchSimilarGetRequest build() { - return new SearchSimilarGetRequest( - q, - searchIn, - includeTranslationFields, - includeSimilarDocuments, - similarDocumentsNumber, - similarDocumentsFields, - predefinedSources, - sources, - notSources, - lang, - notLang, - countries, - notCountries, - from, - to, - byParseDate, - publishedDatePrecision, - sortBy, - rankedOnly, - fromRank, - toRank, - isHeadline, - isOpinion, - isPaidContent, - parentUrl, - allLinks, - allDomainLinks, - wordCountMin, - wordCountMax, - page, - pageSize, - includeNlpData, - hasNlp, - theme, - notTheme, - nerName, - titleSentimentMin, - titleSentimentMax, - contentSentimentMin, - contentSentimentMax, - iptcTags, - notIptcTags, - customTags, - robotsCompliant, - additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarPostRequest.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarPostRequest.java deleted file mode 100644 index 26c50b8..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/requests/SearchSimilarPostRequest.java +++ /dev/null @@ -1,1504 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.requests; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.types.AllDomainLinks; -import com.newscatcher.api.types.AllLinks; -import com.newscatcher.api.types.Countries; -import com.newscatcher.api.types.CustomTags; -import com.newscatcher.api.types.From; -import com.newscatcher.api.types.IptcTags; -import com.newscatcher.api.types.Lang; -import com.newscatcher.api.types.NotCountries; -import com.newscatcher.api.types.NotIptcTags; -import com.newscatcher.api.types.NotLang; -import com.newscatcher.api.types.NotSources; -import com.newscatcher.api.types.NotTheme; -import com.newscatcher.api.types.ParentUrl; -import com.newscatcher.api.types.PredefinedSources; -import com.newscatcher.api.types.PublishedDatePrecision; -import com.newscatcher.api.types.SortBy; -import com.newscatcher.api.types.Sources; -import com.newscatcher.api.types.Theme; -import com.newscatcher.api.types.To; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchSimilarPostRequest.Builder.class) -public final class SearchSimilarPostRequest { - private final String q; - - private final Optional searchIn; - - private final Optional includeTranslationFields; - - private final Optional includeSimilarDocuments; - - private final Optional similarDocumentsNumber; - - private final Optional similarDocumentsFields; - - private final Optional predefinedSources; - - private final Optional sources; - - private final Optional notSources; - - private final Optional lang; - - private final Optional notLang; - - private final Optional countries; - - private final Optional notCountries; - - private final Optional from; - - private final Optional to; - - private final Optional byParseDate; - - private final Optional publishedDatePrecision; - - private final Optional sortBy; - - private final Optional rankedOnly; - - private final Optional fromRank; - - private final Optional toRank; - - private final Optional isHeadline; - - private final Optional isOpinion; - - private final Optional isPaidContent; - - private final Optional parentUrl; - - private final Optional allLinks; - - private final Optional allDomainLinks; - - private final Optional wordCountMin; - - private final Optional wordCountMax; - - private final Optional page; - - private final Optional pageSize; - - private final Optional includeNlpData; - - private final Optional hasNlp; - - private final Optional theme; - - private final Optional notTheme; - - private final Optional nerName; - - private final Optional titleSentimentMin; - - private final Optional titleSentimentMax; - - private final Optional contentSentimentMin; - - private final Optional contentSentimentMax; - - private final Optional iptcTags; - - private final Optional notIptcTags; - - private final Optional customTags; - - private final Optional robotsCompliant; - - private final Map additionalProperties; - - private SearchSimilarPostRequest( - String q, - Optional searchIn, - Optional includeTranslationFields, - Optional includeSimilarDocuments, - Optional similarDocumentsNumber, - Optional similarDocumentsFields, - Optional predefinedSources, - Optional sources, - Optional notSources, - Optional lang, - Optional notLang, - Optional countries, - Optional notCountries, - Optional from, - Optional to, - Optional byParseDate, - Optional publishedDatePrecision, - Optional sortBy, - Optional rankedOnly, - Optional fromRank, - Optional toRank, - Optional isHeadline, - Optional isOpinion, - Optional isPaidContent, - Optional parentUrl, - Optional allLinks, - Optional allDomainLinks, - Optional wordCountMin, - Optional wordCountMax, - Optional page, - Optional pageSize, - Optional includeNlpData, - Optional hasNlp, - Optional theme, - Optional notTheme, - Optional nerName, - Optional titleSentimentMin, - Optional titleSentimentMax, - Optional contentSentimentMin, - Optional contentSentimentMax, - Optional iptcTags, - Optional notIptcTags, - Optional customTags, - Optional robotsCompliant, - Map additionalProperties) { - this.q = q; - this.searchIn = searchIn; - this.includeTranslationFields = includeTranslationFields; - this.includeSimilarDocuments = includeSimilarDocuments; - this.similarDocumentsNumber = similarDocumentsNumber; - this.similarDocumentsFields = similarDocumentsFields; - this.predefinedSources = predefinedSources; - this.sources = sources; - this.notSources = notSources; - this.lang = lang; - this.notLang = notLang; - this.countries = countries; - this.notCountries = notCountries; - this.from = from; - this.to = to; - this.byParseDate = byParseDate; - this.publishedDatePrecision = publishedDatePrecision; - this.sortBy = sortBy; - this.rankedOnly = rankedOnly; - this.fromRank = fromRank; - this.toRank = toRank; - this.isHeadline = isHeadline; - this.isOpinion = isOpinion; - this.isPaidContent = isPaidContent; - this.parentUrl = parentUrl; - this.allLinks = allLinks; - this.allDomainLinks = allDomainLinks; - this.wordCountMin = wordCountMin; - this.wordCountMax = wordCountMax; - this.page = page; - this.pageSize = pageSize; - this.includeNlpData = includeNlpData; - this.hasNlp = hasNlp; - this.theme = theme; - this.notTheme = notTheme; - this.nerName = nerName; - this.titleSentimentMin = titleSentimentMin; - this.titleSentimentMax = titleSentimentMax; - this.contentSentimentMin = contentSentimentMin; - this.contentSentimentMax = contentSentimentMax; - this.iptcTags = iptcTags; - this.notIptcTags = notIptcTags; - this.customTags = customTags; - this.robotsCompliant = robotsCompliant; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("q") - public String getQ() { - return q; - } - - @JsonProperty("search_in") - public Optional getSearchIn() { - return searchIn; - } - - @JsonProperty("include_translation_fields") - public Optional getIncludeTranslationFields() { - return includeTranslationFields; - } - - @JsonProperty("include_similar_documents") - public Optional getIncludeSimilarDocuments() { - return includeSimilarDocuments; - } - - @JsonProperty("similar_documents_number") - public Optional getSimilarDocumentsNumber() { - return similarDocumentsNumber; - } - - @JsonProperty("similar_documents_fields") - public Optional getSimilarDocumentsFields() { - return similarDocumentsFields; - } - - @JsonProperty("predefined_sources") - public Optional getPredefinedSources() { - return predefinedSources; - } - - @JsonProperty("sources") - public Optional getSources() { - return sources; - } - - @JsonProperty("not_sources") - public Optional getNotSources() { - return notSources; - } - - @JsonProperty("lang") - public Optional getLang() { - return lang; - } - - @JsonProperty("not_lang") - public Optional getNotLang() { - return notLang; - } - - @JsonProperty("countries") - public Optional getCountries() { - return countries; - } - - @JsonProperty("not_countries") - public Optional getNotCountries() { - return notCountries; - } - - @JsonProperty("from_") - public Optional getFrom() { - return from; - } - - @JsonProperty("to_") - public Optional getTo() { - return to; - } - - @JsonProperty("by_parse_date") - public Optional getByParseDate() { - return byParseDate; - } - - @JsonProperty("published_date_precision") - public Optional getPublishedDatePrecision() { - return publishedDatePrecision; - } - - @JsonProperty("sort_by") - public Optional getSortBy() { - return sortBy; - } - - @JsonProperty("ranked_only") - public Optional getRankedOnly() { - return rankedOnly; - } - - @JsonProperty("from_rank") - public Optional getFromRank() { - return fromRank; - } - - @JsonProperty("to_rank") - public Optional getToRank() { - return toRank; - } - - @JsonProperty("is_headline") - public Optional getIsHeadline() { - return isHeadline; - } - - @JsonProperty("is_opinion") - public Optional getIsOpinion() { - return isOpinion; - } - - @JsonProperty("is_paid_content") - public Optional getIsPaidContent() { - return isPaidContent; - } - - @JsonProperty("parent_url") - public Optional getParentUrl() { - return parentUrl; - } - - @JsonProperty("all_links") - public Optional getAllLinks() { - return allLinks; - } - - @JsonProperty("all_domain_links") - public Optional getAllDomainLinks() { - return allDomainLinks; - } - - @JsonProperty("word_count_min") - public Optional getWordCountMin() { - return wordCountMin; - } - - @JsonProperty("word_count_max") - public Optional getWordCountMax() { - return wordCountMax; - } - - @JsonProperty("page") - public Optional getPage() { - return page; - } - - @JsonProperty("page_size") - public Optional getPageSize() { - return pageSize; - } - - @JsonProperty("include_nlp_data") - public Optional getIncludeNlpData() { - return includeNlpData; - } - - @JsonProperty("has_nlp") - public Optional getHasNlp() { - return hasNlp; - } - - @JsonProperty("theme") - public Optional getTheme() { - return theme; - } - - @JsonProperty("not_theme") - public Optional getNotTheme() { - return notTheme; - } - - @JsonProperty("ner_name") - public Optional getNerName() { - return nerName; - } - - @JsonProperty("title_sentiment_min") - public Optional getTitleSentimentMin() { - return titleSentimentMin; - } - - @JsonProperty("title_sentiment_max") - public Optional getTitleSentimentMax() { - return titleSentimentMax; - } - - @JsonProperty("content_sentiment_min") - public Optional getContentSentimentMin() { - return contentSentimentMin; - } - - @JsonProperty("content_sentiment_max") - public Optional getContentSentimentMax() { - return contentSentimentMax; - } - - @JsonProperty("iptc_tags") - public Optional getIptcTags() { - return iptcTags; - } - - @JsonProperty("not_iptc_tags") - public Optional getNotIptcTags() { - return notIptcTags; - } - - @JsonProperty("custom_tags") - public Optional getCustomTags() { - return customTags; - } - - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchSimilarPostRequest && equalTo((SearchSimilarPostRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SearchSimilarPostRequest other) { - return q.equals(other.q) - && searchIn.equals(other.searchIn) - && includeTranslationFields.equals(other.includeTranslationFields) - && includeSimilarDocuments.equals(other.includeSimilarDocuments) - && similarDocumentsNumber.equals(other.similarDocumentsNumber) - && similarDocumentsFields.equals(other.similarDocumentsFields) - && predefinedSources.equals(other.predefinedSources) - && sources.equals(other.sources) - && notSources.equals(other.notSources) - && lang.equals(other.lang) - && notLang.equals(other.notLang) - && countries.equals(other.countries) - && notCountries.equals(other.notCountries) - && from.equals(other.from) - && to.equals(other.to) - && byParseDate.equals(other.byParseDate) - && publishedDatePrecision.equals(other.publishedDatePrecision) - && sortBy.equals(other.sortBy) - && rankedOnly.equals(other.rankedOnly) - && fromRank.equals(other.fromRank) - && toRank.equals(other.toRank) - && isHeadline.equals(other.isHeadline) - && isOpinion.equals(other.isOpinion) - && isPaidContent.equals(other.isPaidContent) - && parentUrl.equals(other.parentUrl) - && allLinks.equals(other.allLinks) - && allDomainLinks.equals(other.allDomainLinks) - && wordCountMin.equals(other.wordCountMin) - && wordCountMax.equals(other.wordCountMax) - && page.equals(other.page) - && pageSize.equals(other.pageSize) - && includeNlpData.equals(other.includeNlpData) - && hasNlp.equals(other.hasNlp) - && theme.equals(other.theme) - && notTheme.equals(other.notTheme) - && nerName.equals(other.nerName) - && titleSentimentMin.equals(other.titleSentimentMin) - && titleSentimentMax.equals(other.titleSentimentMax) - && contentSentimentMin.equals(other.contentSentimentMin) - && contentSentimentMax.equals(other.contentSentimentMax) - && iptcTags.equals(other.iptcTags) - && notIptcTags.equals(other.notIptcTags) - && customTags.equals(other.customTags) - && robotsCompliant.equals(other.robotsCompliant); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.q, - this.searchIn, - this.includeTranslationFields, - this.includeSimilarDocuments, - this.similarDocumentsNumber, - this.similarDocumentsFields, - this.predefinedSources, - this.sources, - this.notSources, - this.lang, - this.notLang, - this.countries, - this.notCountries, - this.from, - this.to, - this.byParseDate, - this.publishedDatePrecision, - this.sortBy, - this.rankedOnly, - this.fromRank, - this.toRank, - this.isHeadline, - this.isOpinion, - this.isPaidContent, - this.parentUrl, - this.allLinks, - this.allDomainLinks, - this.wordCountMin, - this.wordCountMax, - this.page, - this.pageSize, - this.includeNlpData, - this.hasNlp, - this.theme, - this.notTheme, - this.nerName, - this.titleSentimentMin, - this.titleSentimentMax, - this.contentSentimentMin, - this.contentSentimentMax, - this.iptcTags, - this.notIptcTags, - this.customTags, - this.robotsCompliant); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static QStage builder() { - return new Builder(); - } - - public interface QStage { - _FinalStage q(@NotNull String q); - - Builder from(SearchSimilarPostRequest other); - } - - public interface _FinalStage { - SearchSimilarPostRequest build(); - - _FinalStage searchIn(Optional searchIn); - - _FinalStage searchIn(String searchIn); - - _FinalStage includeTranslationFields(Optional includeTranslationFields); - - _FinalStage includeTranslationFields(Boolean includeTranslationFields); - - _FinalStage includeSimilarDocuments(Optional includeSimilarDocuments); - - _FinalStage includeSimilarDocuments(Boolean includeSimilarDocuments); - - _FinalStage similarDocumentsNumber(Optional similarDocumentsNumber); - - _FinalStage similarDocumentsNumber(Integer similarDocumentsNumber); - - _FinalStage similarDocumentsFields(Optional similarDocumentsFields); - - _FinalStage similarDocumentsFields(String similarDocumentsFields); - - _FinalStage predefinedSources(Optional predefinedSources); - - _FinalStage predefinedSources(PredefinedSources predefinedSources); - - _FinalStage sources(Optional sources); - - _FinalStage sources(Sources sources); - - _FinalStage notSources(Optional notSources); - - _FinalStage notSources(NotSources notSources); - - _FinalStage lang(Optional lang); - - _FinalStage lang(Lang lang); - - _FinalStage notLang(Optional notLang); - - _FinalStage notLang(NotLang notLang); - - _FinalStage countries(Optional countries); - - _FinalStage countries(Countries countries); - - _FinalStage notCountries(Optional notCountries); - - _FinalStage notCountries(NotCountries notCountries); - - _FinalStage from(Optional from); - - _FinalStage from(From from); - - _FinalStage to(Optional to); - - _FinalStage to(To to); - - _FinalStage byParseDate(Optional byParseDate); - - _FinalStage byParseDate(Boolean byParseDate); - - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - - _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision); - - _FinalStage sortBy(Optional sortBy); - - _FinalStage sortBy(SortBy sortBy); - - _FinalStage rankedOnly(Optional rankedOnly); - - _FinalStage rankedOnly(Boolean rankedOnly); - - _FinalStage fromRank(Optional fromRank); - - _FinalStage fromRank(Integer fromRank); - - _FinalStage toRank(Optional toRank); - - _FinalStage toRank(Integer toRank); - - _FinalStage isHeadline(Optional isHeadline); - - _FinalStage isHeadline(Boolean isHeadline); - - _FinalStage isOpinion(Optional isOpinion); - - _FinalStage isOpinion(Boolean isOpinion); - - _FinalStage isPaidContent(Optional isPaidContent); - - _FinalStage isPaidContent(Boolean isPaidContent); - - _FinalStage parentUrl(Optional parentUrl); - - _FinalStage parentUrl(ParentUrl parentUrl); - - _FinalStage allLinks(Optional allLinks); - - _FinalStage allLinks(AllLinks allLinks); - - _FinalStage allDomainLinks(Optional allDomainLinks); - - _FinalStage allDomainLinks(AllDomainLinks allDomainLinks); - - _FinalStage wordCountMin(Optional wordCountMin); - - _FinalStage wordCountMin(Integer wordCountMin); - - _FinalStage wordCountMax(Optional wordCountMax); - - _FinalStage wordCountMax(Integer wordCountMax); - - _FinalStage page(Optional page); - - _FinalStage page(Integer page); - - _FinalStage pageSize(Optional pageSize); - - _FinalStage pageSize(Integer pageSize); - - _FinalStage includeNlpData(Optional includeNlpData); - - _FinalStage includeNlpData(Boolean includeNlpData); - - _FinalStage hasNlp(Optional hasNlp); - - _FinalStage hasNlp(Boolean hasNlp); - - _FinalStage theme(Optional theme); - - _FinalStage theme(Theme theme); - - _FinalStage notTheme(Optional notTheme); - - _FinalStage notTheme(NotTheme notTheme); - - _FinalStage nerName(Optional nerName); - - _FinalStage nerName(String nerName); - - _FinalStage titleSentimentMin(Optional titleSentimentMin); - - _FinalStage titleSentimentMin(Float titleSentimentMin); - - _FinalStage titleSentimentMax(Optional titleSentimentMax); - - _FinalStage titleSentimentMax(Float titleSentimentMax); - - _FinalStage contentSentimentMin(Optional contentSentimentMin); - - _FinalStage contentSentimentMin(Float contentSentimentMin); - - _FinalStage contentSentimentMax(Optional contentSentimentMax); - - _FinalStage contentSentimentMax(Float contentSentimentMax); - - _FinalStage iptcTags(Optional iptcTags); - - _FinalStage iptcTags(IptcTags iptcTags); - - _FinalStage notIptcTags(Optional notIptcTags); - - _FinalStage notIptcTags(NotIptcTags notIptcTags); - - _FinalStage customTags(Optional customTags); - - _FinalStage customTags(CustomTags customTags); - - _FinalStage robotsCompliant(Optional robotsCompliant); - - _FinalStage robotsCompliant(Boolean robotsCompliant); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements QStage, _FinalStage { - private String q; - - private Optional robotsCompliant = Optional.empty(); - - private Optional customTags = Optional.empty(); - - private Optional notIptcTags = Optional.empty(); - - private Optional iptcTags = Optional.empty(); - - private Optional contentSentimentMax = Optional.empty(); - - private Optional contentSentimentMin = Optional.empty(); - - private Optional titleSentimentMax = Optional.empty(); - - private Optional titleSentimentMin = Optional.empty(); - - private Optional nerName = Optional.empty(); - - private Optional notTheme = Optional.empty(); - - private Optional theme = Optional.empty(); - - private Optional hasNlp = Optional.empty(); - - private Optional includeNlpData = Optional.empty(); - - private Optional pageSize = Optional.empty(); - - private Optional page = Optional.empty(); - - private Optional wordCountMax = Optional.empty(); - - private Optional wordCountMin = Optional.empty(); - - private Optional allDomainLinks = Optional.empty(); - - private Optional allLinks = Optional.empty(); - - private Optional parentUrl = Optional.empty(); - - private Optional isPaidContent = Optional.empty(); - - private Optional isOpinion = Optional.empty(); - - private Optional isHeadline = Optional.empty(); - - private Optional toRank = Optional.empty(); - - private Optional fromRank = Optional.empty(); - - private Optional rankedOnly = Optional.empty(); - - private Optional sortBy = Optional.empty(); - - private Optional publishedDatePrecision = Optional.empty(); - - private Optional byParseDate = Optional.empty(); - - private Optional to = Optional.empty(); - - private Optional from = Optional.empty(); - - private Optional notCountries = Optional.empty(); - - private Optional countries = Optional.empty(); - - private Optional notLang = Optional.empty(); - - private Optional lang = Optional.empty(); - - private Optional notSources = Optional.empty(); - - private Optional sources = Optional.empty(); - - private Optional predefinedSources = Optional.empty(); - - private Optional similarDocumentsFields = Optional.empty(); - - private Optional similarDocumentsNumber = Optional.empty(); - - private Optional includeSimilarDocuments = Optional.empty(); - - private Optional includeTranslationFields = Optional.empty(); - - private Optional searchIn = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SearchSimilarPostRequest other) { - q(other.getQ()); - searchIn(other.getSearchIn()); - includeTranslationFields(other.getIncludeTranslationFields()); - includeSimilarDocuments(other.getIncludeSimilarDocuments()); - similarDocumentsNumber(other.getSimilarDocumentsNumber()); - similarDocumentsFields(other.getSimilarDocumentsFields()); - predefinedSources(other.getPredefinedSources()); - sources(other.getSources()); - notSources(other.getNotSources()); - lang(other.getLang()); - notLang(other.getNotLang()); - countries(other.getCountries()); - notCountries(other.getNotCountries()); - from(other.getFrom()); - to(other.getTo()); - byParseDate(other.getByParseDate()); - publishedDatePrecision(other.getPublishedDatePrecision()); - sortBy(other.getSortBy()); - rankedOnly(other.getRankedOnly()); - fromRank(other.getFromRank()); - toRank(other.getToRank()); - isHeadline(other.getIsHeadline()); - isOpinion(other.getIsOpinion()); - isPaidContent(other.getIsPaidContent()); - parentUrl(other.getParentUrl()); - allLinks(other.getAllLinks()); - allDomainLinks(other.getAllDomainLinks()); - wordCountMin(other.getWordCountMin()); - wordCountMax(other.getWordCountMax()); - page(other.getPage()); - pageSize(other.getPageSize()); - includeNlpData(other.getIncludeNlpData()); - hasNlp(other.getHasNlp()); - theme(other.getTheme()); - notTheme(other.getNotTheme()); - nerName(other.getNerName()); - titleSentimentMin(other.getTitleSentimentMin()); - titleSentimentMax(other.getTitleSentimentMax()); - contentSentimentMin(other.getContentSentimentMin()); - contentSentimentMax(other.getContentSentimentMax()); - iptcTags(other.getIptcTags()); - notIptcTags(other.getNotIptcTags()); - customTags(other.getCustomTags()); - robotsCompliant(other.getRobotsCompliant()); - return this; - } - - @java.lang.Override - @JsonSetter("q") - public _FinalStage q(@NotNull String q) { - this.q = Objects.requireNonNull(q, "q must not be null"); - return this; - } - - @java.lang.Override - public _FinalStage robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - @java.lang.Override - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public _FinalStage robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - - @java.lang.Override - public _FinalStage customTags(CustomTags customTags) { - this.customTags = Optional.ofNullable(customTags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) - public _FinalStage customTags(Optional customTags) { - this.customTags = customTags; - return this; - } - - @java.lang.Override - public _FinalStage notIptcTags(NotIptcTags notIptcTags) { - this.notIptcTags = Optional.ofNullable(notIptcTags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "not_iptc_tags", nulls = Nulls.SKIP) - public _FinalStage notIptcTags(Optional notIptcTags) { - this.notIptcTags = notIptcTags; - return this; - } - - @java.lang.Override - public _FinalStage iptcTags(IptcTags iptcTags) { - this.iptcTags = Optional.ofNullable(iptcTags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "iptc_tags", nulls = Nulls.SKIP) - public _FinalStage iptcTags(Optional iptcTags) { - this.iptcTags = iptcTags; - return this; - } - - @java.lang.Override - public _FinalStage contentSentimentMax(Float contentSentimentMax) { - this.contentSentimentMax = Optional.ofNullable(contentSentimentMax); - return this; - } - - @java.lang.Override - @JsonSetter(value = "content_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMax(Optional contentSentimentMax) { - this.contentSentimentMax = contentSentimentMax; - return this; - } - - @java.lang.Override - public _FinalStage contentSentimentMin(Float contentSentimentMin) { - this.contentSentimentMin = Optional.ofNullable(contentSentimentMin); - return this; - } - - @java.lang.Override - @JsonSetter(value = "content_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage contentSentimentMin(Optional contentSentimentMin) { - this.contentSentimentMin = contentSentimentMin; - return this; - } - - @java.lang.Override - public _FinalStage titleSentimentMax(Float titleSentimentMax) { - this.titleSentimentMax = Optional.ofNullable(titleSentimentMax); - return this; - } - - @java.lang.Override - @JsonSetter(value = "title_sentiment_max", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMax(Optional titleSentimentMax) { - this.titleSentimentMax = titleSentimentMax; - return this; - } - - @java.lang.Override - public _FinalStage titleSentimentMin(Float titleSentimentMin) { - this.titleSentimentMin = Optional.ofNullable(titleSentimentMin); - return this; - } - - @java.lang.Override - @JsonSetter(value = "title_sentiment_min", nulls = Nulls.SKIP) - public _FinalStage titleSentimentMin(Optional titleSentimentMin) { - this.titleSentimentMin = titleSentimentMin; - return this; - } - - @java.lang.Override - public _FinalStage nerName(String nerName) { - this.nerName = Optional.ofNullable(nerName); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ner_name", nulls = Nulls.SKIP) - public _FinalStage nerName(Optional nerName) { - this.nerName = nerName; - return this; - } - - @java.lang.Override - public _FinalStage notTheme(NotTheme notTheme) { - this.notTheme = Optional.ofNullable(notTheme); - return this; - } - - @java.lang.Override - @JsonSetter(value = "not_theme", nulls = Nulls.SKIP) - public _FinalStage notTheme(Optional notTheme) { - this.notTheme = notTheme; - return this; - } - - @java.lang.Override - public _FinalStage theme(Theme theme) { - this.theme = Optional.ofNullable(theme); - return this; - } - - @java.lang.Override - @JsonSetter(value = "theme", nulls = Nulls.SKIP) - public _FinalStage theme(Optional theme) { - this.theme = theme; - return this; - } - - @java.lang.Override - public _FinalStage hasNlp(Boolean hasNlp) { - this.hasNlp = Optional.ofNullable(hasNlp); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_nlp", nulls = Nulls.SKIP) - public _FinalStage hasNlp(Optional hasNlp) { - this.hasNlp = hasNlp; - return this; - } - - @java.lang.Override - public _FinalStage includeNlpData(Boolean includeNlpData) { - this.includeNlpData = Optional.ofNullable(includeNlpData); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_nlp_data", nulls = Nulls.SKIP) - public _FinalStage includeNlpData(Optional includeNlpData) { - this.includeNlpData = includeNlpData; - return this; - } - - @java.lang.Override - public _FinalStage pageSize(Integer pageSize) { - this.pageSize = Optional.ofNullable(pageSize); - return this; - } - - @java.lang.Override - @JsonSetter(value = "page_size", nulls = Nulls.SKIP) - public _FinalStage pageSize(Optional pageSize) { - this.pageSize = pageSize; - return this; - } - - @java.lang.Override - public _FinalStage page(Integer page) { - this.page = Optional.ofNullable(page); - return this; - } - - @java.lang.Override - @JsonSetter(value = "page", nulls = Nulls.SKIP) - public _FinalStage page(Optional page) { - this.page = page; - return this; - } - - @java.lang.Override - public _FinalStage wordCountMax(Integer wordCountMax) { - this.wordCountMax = Optional.ofNullable(wordCountMax); - return this; - } - - @java.lang.Override - @JsonSetter(value = "word_count_max", nulls = Nulls.SKIP) - public _FinalStage wordCountMax(Optional wordCountMax) { - this.wordCountMax = wordCountMax; - return this; - } - - @java.lang.Override - public _FinalStage wordCountMin(Integer wordCountMin) { - this.wordCountMin = Optional.ofNullable(wordCountMin); - return this; - } - - @java.lang.Override - @JsonSetter(value = "word_count_min", nulls = Nulls.SKIP) - public _FinalStage wordCountMin(Optional wordCountMin) { - this.wordCountMin = wordCountMin; - return this; - } - - @java.lang.Override - public _FinalStage allDomainLinks(AllDomainLinks allDomainLinks) { - this.allDomainLinks = Optional.ofNullable(allDomainLinks); - return this; - } - - @java.lang.Override - @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) - public _FinalStage allDomainLinks(Optional allDomainLinks) { - this.allDomainLinks = allDomainLinks; - return this; - } - - @java.lang.Override - public _FinalStage allLinks(AllLinks allLinks) { - this.allLinks = Optional.ofNullable(allLinks); - return this; - } - - @java.lang.Override - @JsonSetter(value = "all_links", nulls = Nulls.SKIP) - public _FinalStage allLinks(Optional allLinks) { - this.allLinks = allLinks; - return this; - } - - @java.lang.Override - public _FinalStage parentUrl(ParentUrl parentUrl) { - this.parentUrl = Optional.ofNullable(parentUrl); - return this; - } - - @java.lang.Override - @JsonSetter(value = "parent_url", nulls = Nulls.SKIP) - public _FinalStage parentUrl(Optional parentUrl) { - this.parentUrl = parentUrl; - return this; - } - - @java.lang.Override - public _FinalStage isPaidContent(Boolean isPaidContent) { - this.isPaidContent = Optional.ofNullable(isPaidContent); - return this; - } - - @java.lang.Override - @JsonSetter(value = "is_paid_content", nulls = Nulls.SKIP) - public _FinalStage isPaidContent(Optional isPaidContent) { - this.isPaidContent = isPaidContent; - return this; - } - - @java.lang.Override - public _FinalStage isOpinion(Boolean isOpinion) { - this.isOpinion = Optional.ofNullable(isOpinion); - return this; - } - - @java.lang.Override - @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) - public _FinalStage isOpinion(Optional isOpinion) { - this.isOpinion = isOpinion; - return this; - } - - @java.lang.Override - public _FinalStage isHeadline(Boolean isHeadline) { - this.isHeadline = Optional.ofNullable(isHeadline); - return this; - } - - @java.lang.Override - @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) - public _FinalStage isHeadline(Optional isHeadline) { - this.isHeadline = isHeadline; - return this; - } - - @java.lang.Override - public _FinalStage toRank(Integer toRank) { - this.toRank = Optional.ofNullable(toRank); - return this; - } - - @java.lang.Override - @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) - public _FinalStage toRank(Optional toRank) { - this.toRank = toRank; - return this; - } - - @java.lang.Override - public _FinalStage fromRank(Integer fromRank) { - this.fromRank = Optional.ofNullable(fromRank); - return this; - } - - @java.lang.Override - @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) - public _FinalStage fromRank(Optional fromRank) { - this.fromRank = fromRank; - return this; - } - - @java.lang.Override - public _FinalStage rankedOnly(Boolean rankedOnly) { - this.rankedOnly = Optional.ofNullable(rankedOnly); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ranked_only", nulls = Nulls.SKIP) - public _FinalStage rankedOnly(Optional rankedOnly) { - this.rankedOnly = rankedOnly; - return this; - } - - @java.lang.Override - public _FinalStage sortBy(SortBy sortBy) { - this.sortBy = Optional.ofNullable(sortBy); - return this; - } - - @java.lang.Override - @JsonSetter(value = "sort_by", nulls = Nulls.SKIP) - public _FinalStage sortBy(Optional sortBy) { - this.sortBy = sortBy; - return this; - } - - @java.lang.Override - public _FinalStage publishedDatePrecision(PublishedDatePrecision publishedDatePrecision) { - this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); - return this; - } - - @java.lang.Override - @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { - this.publishedDatePrecision = publishedDatePrecision; - return this; - } - - @java.lang.Override - public _FinalStage byParseDate(Boolean byParseDate) { - this.byParseDate = Optional.ofNullable(byParseDate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "by_parse_date", nulls = Nulls.SKIP) - public _FinalStage byParseDate(Optional byParseDate) { - this.byParseDate = byParseDate; - return this; - } - - @java.lang.Override - public _FinalStage to(To to) { - this.to = Optional.ofNullable(to); - return this; - } - - @java.lang.Override - @JsonSetter(value = "to_", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - @java.lang.Override - public _FinalStage from(From from) { - this.from = Optional.ofNullable(from); - return this; - } - - @java.lang.Override - @JsonSetter(value = "from_", nulls = Nulls.SKIP) - public _FinalStage from(Optional from) { - this.from = from; - return this; - } - - @java.lang.Override - public _FinalStage notCountries(NotCountries notCountries) { - this.notCountries = Optional.ofNullable(notCountries); - return this; - } - - @java.lang.Override - @JsonSetter(value = "not_countries", nulls = Nulls.SKIP) - public _FinalStage notCountries(Optional notCountries) { - this.notCountries = notCountries; - return this; - } - - @java.lang.Override - public _FinalStage countries(Countries countries) { - this.countries = Optional.ofNullable(countries); - return this; - } - - @java.lang.Override - @JsonSetter(value = "countries", nulls = Nulls.SKIP) - public _FinalStage countries(Optional countries) { - this.countries = countries; - return this; - } - - @java.lang.Override - public _FinalStage notLang(NotLang notLang) { - this.notLang = Optional.ofNullable(notLang); - return this; - } - - @java.lang.Override - @JsonSetter(value = "not_lang", nulls = Nulls.SKIP) - public _FinalStage notLang(Optional notLang) { - this.notLang = notLang; - return this; - } - - @java.lang.Override - public _FinalStage lang(Lang lang) { - this.lang = Optional.ofNullable(lang); - return this; - } - - @java.lang.Override - @JsonSetter(value = "lang", nulls = Nulls.SKIP) - public _FinalStage lang(Optional lang) { - this.lang = lang; - return this; - } - - @java.lang.Override - public _FinalStage notSources(NotSources notSources) { - this.notSources = Optional.ofNullable(notSources); - return this; - } - - @java.lang.Override - @JsonSetter(value = "not_sources", nulls = Nulls.SKIP) - public _FinalStage notSources(Optional notSources) { - this.notSources = notSources; - return this; - } - - @java.lang.Override - public _FinalStage sources(Sources sources) { - this.sources = Optional.ofNullable(sources); - return this; - } - - @java.lang.Override - @JsonSetter(value = "sources", nulls = Nulls.SKIP) - public _FinalStage sources(Optional sources) { - this.sources = sources; - return this; - } - - @java.lang.Override - public _FinalStage predefinedSources(PredefinedSources predefinedSources) { - this.predefinedSources = Optional.ofNullable(predefinedSources); - return this; - } - - @java.lang.Override - @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) - public _FinalStage predefinedSources(Optional predefinedSources) { - this.predefinedSources = predefinedSources; - return this; - } - - @java.lang.Override - public _FinalStage similarDocumentsFields(String similarDocumentsFields) { - this.similarDocumentsFields = Optional.ofNullable(similarDocumentsFields); - return this; - } - - @java.lang.Override - @JsonSetter(value = "similar_documents_fields", nulls = Nulls.SKIP) - public _FinalStage similarDocumentsFields(Optional similarDocumentsFields) { - this.similarDocumentsFields = similarDocumentsFields; - return this; - } - - @java.lang.Override - public _FinalStage similarDocumentsNumber(Integer similarDocumentsNumber) { - this.similarDocumentsNumber = Optional.ofNullable(similarDocumentsNumber); - return this; - } - - @java.lang.Override - @JsonSetter(value = "similar_documents_number", nulls = Nulls.SKIP) - public _FinalStage similarDocumentsNumber(Optional similarDocumentsNumber) { - this.similarDocumentsNumber = similarDocumentsNumber; - return this; - } - - @java.lang.Override - public _FinalStage includeSimilarDocuments(Boolean includeSimilarDocuments) { - this.includeSimilarDocuments = Optional.ofNullable(includeSimilarDocuments); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_similar_documents", nulls = Nulls.SKIP) - public _FinalStage includeSimilarDocuments(Optional includeSimilarDocuments) { - this.includeSimilarDocuments = includeSimilarDocuments; - return this; - } - - @java.lang.Override - public _FinalStage includeTranslationFields(Boolean includeTranslationFields) { - this.includeTranslationFields = Optional.ofNullable(includeTranslationFields); - return this; - } - - @java.lang.Override - @JsonSetter(value = "include_translation_fields", nulls = Nulls.SKIP) - public _FinalStage includeTranslationFields(Optional includeTranslationFields) { - this.includeTranslationFields = includeTranslationFields; - return this; - } - - @java.lang.Override - public _FinalStage searchIn(String searchIn) { - this.searchIn = Optional.ofNullable(searchIn); - return this; - } - - @java.lang.Override - @JsonSetter(value = "search_in", nulls = Nulls.SKIP) - public _FinalStage searchIn(Optional searchIn) { - this.searchIn = searchIn; - return this; - } - - @java.lang.Override - public SearchSimilarPostRequest build() { - return new SearchSimilarPostRequest( - q, - searchIn, - includeTranslationFields, - includeSimilarDocuments, - similarDocumentsNumber, - similarDocumentsFields, - predefinedSources, - sources, - notSources, - lang, - notLang, - countries, - notCountries, - from, - to, - byParseDate, - publishedDatePrecision, - sortBy, - rankedOnly, - fromRank, - toRank, - isHeadline, - isOpinion, - isPaidContent, - parentUrl, - allLinks, - allDomainLinks, - wordCountMin, - wordCountMax, - page, - pageSize, - includeNlpData, - hasNlp, - theme, - notTheme, - nerName, - titleSentimentMin, - titleSentimentMax, - contentSentimentMin, - contentSentimentMax, - iptcTags, - notIptcTags, - customTags, - robotsCompliant, - additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestPublishedDatePrecision.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestPublishedDatePrecision.java deleted file mode 100644 index 4c1ba62..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestPublishedDatePrecision.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchSimilarGetRequestPublishedDatePrecision { - FULL("full"), - - TIMEZONE_UNKNOWN("timezone unknown"), - - DATE("date"); - - private final String value; - - SearchSimilarGetRequestPublishedDatePrecision(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestSortBy.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestSortBy.java deleted file mode 100644 index 45ec969..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetRequestSortBy.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SearchSimilarGetRequestSortBy { - RELEVANCY("relevancy"), - - DATE("date"), - - RANK("rank"); - - private final String value; - - SearchSimilarGetRequestSortBy(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetResponse.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetResponse.java deleted file mode 100644 index 623ec81..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarGetResponse.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.types.FailedSearchSimilarResponseDto; -import com.newscatcher.api.types.SearchSimilarResponseDto; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = SearchSimilarGetResponse.Deserializer.class) -public final class SearchSimilarGetResponse { - private final Object value; - - private final int type; - - private SearchSimilarGetResponse(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - @SuppressWarnings("unchecked") - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SearchSimilarResponseDto) this.value); - } else if (this.type == 1) { - return visitor.visit((FailedSearchSimilarResponseDto) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchSimilarGetResponse && equalTo((SearchSimilarGetResponse) other); - } - - private boolean equalTo(SearchSimilarGetResponse other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static SearchSimilarGetResponse of(SearchSimilarResponseDto value) { - return new SearchSimilarGetResponse(value, 0); - } - - public static SearchSimilarGetResponse of(FailedSearchSimilarResponseDto value) { - return new SearchSimilarGetResponse(value, 1); - } - - public interface Visitor { - T visit(SearchSimilarResponseDto value); - - T visit(FailedSearchSimilarResponseDto value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(SearchSimilarGetResponse.class); - } - - @java.lang.Override - public SearchSimilarGetResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchSimilarResponseDto.class)); - } catch (RuntimeException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FailedSearchSimilarResponseDto.class)); - } catch (RuntimeException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarPostResponse.java b/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarPostResponse.java deleted file mode 100644 index 53bc1e5..0000000 --- a/src/main/java/com/newscatcher/api/resources/searchsimilar/types/SearchSimilarPostResponse.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.searchsimilar.types; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.types.FailedSearchSimilarResponseDto; -import com.newscatcher.api.types.SearchSimilarResponseDto; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = SearchSimilarPostResponse.Deserializer.class) -public final class SearchSimilarPostResponse { - private final Object value; - - private final int type; - - private SearchSimilarPostResponse(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - @SuppressWarnings("unchecked") - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SearchSimilarResponseDto) this.value); - } else if (this.type == 1) { - return visitor.visit((FailedSearchSimilarResponseDto) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchSimilarPostResponse && equalTo((SearchSimilarPostResponse) other); - } - - private boolean equalTo(SearchSimilarPostResponse other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static SearchSimilarPostResponse of(SearchSimilarResponseDto value) { - return new SearchSimilarPostResponse(value, 0); - } - - public static SearchSimilarPostResponse of(FailedSearchSimilarResponseDto value) { - return new SearchSimilarPostResponse(value, 1); - } - - public interface Visitor { - T visit(SearchSimilarResponseDto value); - - T visit(FailedSearchSimilarResponseDto value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(SearchSimilarPostResponse.class); - } - - @java.lang.Override - public SearchSimilarPostResponse deserialize(JsonParser p, DeserializationContext context) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SearchSimilarResponseDto.class)); - } catch (RuntimeException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, FailedSearchSimilarResponseDto.class)); - } catch (RuntimeException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/newscatcher/api/resources/sources/AsyncRawSourcesClient.java b/src/main/java/com/newscatcher/api/resources/sources/AsyncRawSourcesClient.java index e2f69b8..0a06241 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/AsyncRawSourcesClient.java +++ b/src/main/java/com/newscatcher/api/resources/sources/AsyncRawSourcesClient.java @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.sources.requests.SourcesGetRequest; -import com.newscatcher.api.resources.sources.requests.SourcesPostRequest; +import com.newscatcher.api.resources.sources.requests.GetSourcesRequest; +import com.newscatcher.api.resources.sources.requests.PostSourcesRequest; import com.newscatcher.api.types.Error; import com.newscatcher.api.types.SourcesResponseDto; import java.io.IOException; @@ -47,13 +47,20 @@ public AsyncRawSourcesClient(ClientOptions clientOptions) { * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ public CompletableFuture> get() { - return get(SourcesGetRequest.builder().build()); + return get(GetSourcesRequest.builder().build()); } /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public CompletableFuture> get(SourcesGetRequest request) { + public CompletableFuture> get(RequestOptions requestOptions) { + return get(GetSourcesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. + */ + public CompletableFuture> get(GetSourcesRequest request) { return get(request, null); } @@ -61,7 +68,7 @@ public CompletableFuture> get(Sou * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ public CompletableFuture> get( - SourcesGetRequest request, RequestOptions requestOptions) { + GetSourcesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/sources"); @@ -115,6 +122,11 @@ public CompletableFuture> get( QueryStringMapper.addQueryParameter( httpUrl, "to_rank", request.getToRank().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -130,13 +142,13 @@ public CompletableFuture> get( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SourcesResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SourcesResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -178,11 +190,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -202,13 +212,20 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ public CompletableFuture> post() { - return post(SourcesPostRequest.builder().build()); + return post(PostSourcesRequest.builder().build()); + } + + /** + * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. + */ + public CompletableFuture> post(RequestOptions requestOptions) { + return post(PostSourcesRequest.builder().build(), requestOptions); } /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public CompletableFuture> post(SourcesPostRequest request) { + public CompletableFuture> post(PostSourcesRequest request) { return post(request, null); } @@ -216,11 +233,15 @@ public CompletableFuture> post(So * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ public CompletableFuture> post( - SourcesPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + PostSourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/sources") - .build(); + .addPathSegments("api/sources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -229,7 +250,7 @@ public CompletableFuture> post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -244,13 +265,13 @@ public CompletableFuture> post( @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SourcesResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SourcesResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -292,11 +313,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/sources/AsyncSourcesClient.java b/src/main/java/com/newscatcher/api/resources/sources/AsyncSourcesClient.java index 90f7734..111745c 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/AsyncSourcesClient.java +++ b/src/main/java/com/newscatcher/api/resources/sources/AsyncSourcesClient.java @@ -5,8 +5,8 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.sources.requests.SourcesGetRequest; -import com.newscatcher.api.resources.sources.requests.SourcesPostRequest; +import com.newscatcher.api.resources.sources.requests.GetSourcesRequest; +import com.newscatcher.api.resources.sources.requests.PostSourcesRequest; import com.newscatcher.api.types.SourcesResponseDto; import java.util.concurrent.CompletableFuture; @@ -37,14 +37,21 @@ public CompletableFuture get() { /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public CompletableFuture get(SourcesGetRequest request) { + public CompletableFuture get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. + */ + public CompletableFuture get(GetSourcesRequest request) { return this.rawClient.get(request).thenApply(response -> response.body()); } /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public CompletableFuture get(SourcesGetRequest request, RequestOptions requestOptions) { + public CompletableFuture get(GetSourcesRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).thenApply(response -> response.body()); } @@ -58,14 +65,21 @@ public CompletableFuture post() { /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public CompletableFuture post(SourcesPostRequest request) { + public CompletableFuture post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).thenApply(response -> response.body()); + } + + /** + * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. + */ + public CompletableFuture post(PostSourcesRequest request) { return this.rawClient.post(request).thenApply(response -> response.body()); } /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public CompletableFuture post(SourcesPostRequest request, RequestOptions requestOptions) { + public CompletableFuture post(PostSourcesRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).thenApply(response -> response.body()); } } diff --git a/src/main/java/com/newscatcher/api/resources/sources/RawSourcesClient.java b/src/main/java/com/newscatcher/api/resources/sources/RawSourcesClient.java index 63add12..a553cc3 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/RawSourcesClient.java +++ b/src/main/java/com/newscatcher/api/resources/sources/RawSourcesClient.java @@ -19,8 +19,8 @@ import com.newscatcher.api.errors.TooManyRequestsError; import com.newscatcher.api.errors.UnauthorizedError; import com.newscatcher.api.errors.UnprocessableEntityError; -import com.newscatcher.api.resources.sources.requests.SourcesGetRequest; -import com.newscatcher.api.resources.sources.requests.SourcesPostRequest; +import com.newscatcher.api.resources.sources.requests.GetSourcesRequest; +import com.newscatcher.api.resources.sources.requests.PostSourcesRequest; import com.newscatcher.api.types.Error; import com.newscatcher.api.types.SourcesResponseDto; import java.io.IOException; @@ -43,13 +43,20 @@ public RawSourcesClient(ClientOptions clientOptions) { * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ public NewscatcherApiHttpResponse get() { - return get(SourcesGetRequest.builder().build()); + return get(GetSourcesRequest.builder().build()); } /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public NewscatcherApiHttpResponse get(SourcesGetRequest request) { + public NewscatcherApiHttpResponse get(RequestOptions requestOptions) { + return get(GetSourcesRequest.builder().build(), requestOptions); + } + + /** + * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. + */ + public NewscatcherApiHttpResponse get(GetSourcesRequest request) { return get(request, null); } @@ -57,7 +64,7 @@ public NewscatcherApiHttpResponse get(SourcesGetRequest requ * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ public NewscatcherApiHttpResponse get( - SourcesGetRequest request, RequestOptions requestOptions) { + GetSourcesRequest request, RequestOptions requestOptions) { HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() .addPathSegments("api/sources"); @@ -111,6 +118,11 @@ public NewscatcherApiHttpResponse get( QueryStringMapper.addQueryParameter( httpUrl, "to_rank", request.getToRank().get(), false); } + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request.Builder _requestBuilder = new Request.Builder() .url(httpUrl.build()) .method("GET", null) @@ -123,11 +135,11 @@ public NewscatcherApiHttpResponse get( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SourcesResponseDto.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SourcesResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -155,11 +167,9 @@ public NewscatcherApiHttpResponse get( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -169,13 +179,20 @@ public NewscatcherApiHttpResponse get( * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ public NewscatcherApiHttpResponse post() { - return post(SourcesPostRequest.builder().build()); + return post(PostSourcesRequest.builder().build()); + } + + /** + * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. + */ + public NewscatcherApiHttpResponse post(RequestOptions requestOptions) { + return post(PostSourcesRequest.builder().build(), requestOptions); } /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public NewscatcherApiHttpResponse post(SourcesPostRequest request) { + public NewscatcherApiHttpResponse post(PostSourcesRequest request) { return post(request, null); } @@ -183,11 +200,15 @@ public NewscatcherApiHttpResponse post(SourcesPostRequest re * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ public NewscatcherApiHttpResponse post( - SourcesPostRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + PostSourcesRequest request, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/sources") - .build(); + .addPathSegments("api/sources"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } RequestBody body; try { body = RequestBody.create( @@ -196,7 +217,7 @@ public NewscatcherApiHttpResponse post( throw new NewscatcherApiException("Failed to serialize request", e); } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", body) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Content-Type", "application/json") @@ -208,11 +229,11 @@ public NewscatcherApiHttpResponse post( } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SourcesResponseDto.class), response); + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SourcesResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -240,11 +261,9 @@ public NewscatcherApiHttpResponse post( } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/resources/sources/SourcesClient.java b/src/main/java/com/newscatcher/api/resources/sources/SourcesClient.java index b4920b8..bc1b53b 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/SourcesClient.java +++ b/src/main/java/com/newscatcher/api/resources/sources/SourcesClient.java @@ -5,8 +5,8 @@ import com.newscatcher.api.core.ClientOptions; import com.newscatcher.api.core.RequestOptions; -import com.newscatcher.api.resources.sources.requests.SourcesGetRequest; -import com.newscatcher.api.resources.sources.requests.SourcesPostRequest; +import com.newscatcher.api.resources.sources.requests.GetSourcesRequest; +import com.newscatcher.api.resources.sources.requests.PostSourcesRequest; import com.newscatcher.api.types.SourcesResponseDto; public class SourcesClient { @@ -36,14 +36,21 @@ public SourcesResponseDto get() { /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public SourcesResponseDto get(SourcesGetRequest request) { + public SourcesResponseDto get(RequestOptions requestOptions) { + return this.rawClient.get(requestOptions).body(); + } + + /** + * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. + */ + public SourcesResponseDto get(GetSourcesRequest request) { return this.rawClient.get(request).body(); } /** * Retrieves a list of sources based on specified criteria such as language, country, rank, and more. */ - public SourcesResponseDto get(SourcesGetRequest request, RequestOptions requestOptions) { + public SourcesResponseDto get(GetSourcesRequest request, RequestOptions requestOptions) { return this.rawClient.get(request, requestOptions).body(); } @@ -57,14 +64,21 @@ public SourcesResponseDto post() { /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public SourcesResponseDto post(SourcesPostRequest request) { + public SourcesResponseDto post(RequestOptions requestOptions) { + return this.rawClient.post(requestOptions).body(); + } + + /** + * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. + */ + public SourcesResponseDto post(PostSourcesRequest request) { return this.rawClient.post(request).body(); } /** * Retrieves the list of sources available in the database. You can filter the sources by language, country, and more. */ - public SourcesResponseDto post(SourcesPostRequest request, RequestOptions requestOptions) { + public SourcesResponseDto post(PostSourcesRequest request, RequestOptions requestOptions) { return this.rawClient.post(request, requestOptions).body(); } } diff --git a/src/main/java/com/newscatcher/api/resources/sources/requests/SourcesGetRequest.java b/src/main/java/com/newscatcher/api/resources/sources/requests/GetSourcesRequest.java similarity index 68% rename from src/main/java/com/newscatcher/api/resources/sources/requests/SourcesGetRequest.java rename to src/main/java/com/newscatcher/api/resources/sources/requests/GetSourcesRequest.java index 8a5d5de..dc46b6d 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/requests/SourcesGetRequest.java +++ b/src/main/java/com/newscatcher/api/resources/sources/requests/GetSourcesRequest.java @@ -12,15 +12,15 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.newscatcher.api.core.ObjectMappers; -import com.newscatcher.api.resources.sources.types.SourcesGetRequestNewsDomainType; +import com.newscatcher.api.types.NewsDomainType; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SourcesGetRequest.Builder.class) -public final class SourcesGetRequest { +@JsonDeserialize(builder = GetSourcesRequest.Builder.class) +public final class GetSourcesRequest { private final Optional lang; private final Optional countries; @@ -35,7 +35,7 @@ public final class SourcesGetRequest { private final Optional isNewsDomain; - private final Optional newsDomainType; + private final Optional newsDomainType; private final Optional newsType; @@ -45,7 +45,7 @@ public final class SourcesGetRequest { private final Map additionalProperties; - private SourcesGetRequest( + private GetSourcesRequest( Optional lang, Optional countries, Optional predefinedSources, @@ -53,7 +53,7 @@ private SourcesGetRequest( Optional sourceUrl, Optional includeAdditionalInfo, Optional isNewsDomain, - Optional newsDomainType, + Optional newsDomainType, Optional newsType, Optional fromRank, Optional toRank, @@ -74,8 +74,7 @@ private SourcesGetRequest( /** * @return The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string. - *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonProperty("lang") public Optional getLang() { @@ -84,8 +83,7 @@ public Optional getLang() { /** * @return The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string. - *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonProperty("countries") public Optional getCountries() { @@ -94,14 +92,8 @@ public Optional getCountries() { /** * @return Predefined top news sources per country. - *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonProperty("predefined_sources") public Optional getPredefinedSources() { @@ -110,7 +102,6 @@ public Optional getPredefinedSources() { /** * @return Word or phrase to search within the source names. To specify multiple values, use a comma-separated string. - *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

*/ @JsonProperty("source_name") @@ -128,66 +119,35 @@ public Optional getSourceUrl() { return sourceUrl; } - /** - * @return If true, returns the following additional datapoints about each news source: - *
    - *
  • nb_articles_for_7d: The number of articles published by the source in the last week.
  • - *
  • country: Source country of origin.
  • - *
  • rank: SEO rank.
  • - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "General News Outlets").
  • - *
- */ @JsonProperty("include_additional_info") public Optional getIncludeAdditionalInfo() { return includeAdditionalInfo; } - /** - * @return If true, filters results to include only news domains. - */ @JsonProperty("is_news_domain") public Optional getIsNewsDomain() { return isNewsDomain; } - /** - * @return Filters results based on the news domain type. Possible values are: - *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- */ @JsonProperty("news_domain_type") - public Optional getNewsDomainType() { + public Optional getNewsDomainType() { return newsDomainType; } /** * @return Filters results based on the news type. Multiple types can be specified using a comma-separated string. - *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

*/ @JsonProperty("news_type") public Optional getNewsType() { return newsType; } - /** - * @return The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("from_rank") public Optional getFromRank() { return fromRank; } - /** - * @return The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source. - */ @JsonProperty("to_rank") public Optional getToRank() { return toRank; @@ -196,7 +156,7 @@ public Optional getToRank() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SourcesGetRequest && equalTo((SourcesGetRequest) other); + return other instanceof GetSourcesRequest && equalTo((GetSourcesRequest) other); } @JsonAnyGetter @@ -204,7 +164,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SourcesGetRequest other) { + private boolean equalTo(GetSourcesRequest other) { return lang.equals(other.lang) && countries.equals(other.countries) && predefinedSources.equals(other.predefinedSources) @@ -259,7 +219,7 @@ public static final class Builder { private Optional isNewsDomain = Optional.empty(); - private Optional newsDomainType = Optional.empty(); + private Optional newsDomainType = Optional.empty(); private Optional newsType = Optional.empty(); @@ -272,7 +232,7 @@ public static final class Builder { private Builder() {} - public Builder from(SourcesGetRequest other) { + public Builder from(GetSourcesRequest other) { lang(other.getLang()); countries(other.getCountries()); predefinedSources(other.getPredefinedSources()); @@ -289,8 +249,7 @@ public Builder from(SourcesGetRequest other) { /** *

The language(s) of the search. The only accepted format is the two-letter ISO 639-1 code. To select multiple languages, use a comma-separated string.

- *

Example: "en, es"

- *

To learn more, see Enumerated parameters > Language.

+ *

To learn more, see Enumerated parameters > Language.

*/ @JsonSetter(value = "lang", nulls = Nulls.SKIP) public Builder lang(Optional lang) { @@ -305,8 +264,7 @@ public Builder lang(String lang) { /** *

The countries where the news publisher is located. The accepted format is the two-letter ISO 3166-1 alpha-2 code. To select multiple countries, use a comma-separated string.

- *

Example: "US, CA"

- *

To learn more, see Enumerated parameters > Country.

+ *

To learn more, see Enumerated parameters > Country.

*/ @JsonSetter(value = "countries", nulls = Nulls.SKIP) public Builder countries(Optional countries) { @@ -321,14 +279,8 @@ public Builder countries(String countries) { /** *

Predefined top news sources per country.

- *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2. Multiple countries with the number of top sources can be specified as a comma-separated string.

- *

Examples:

- *
    - *
  • "top 100 US"
  • - *
  • "top 33 AT"
  • - *
  • "top 50 US, top 20 GB"
  • - *
  • "top 33 AT, top 50 IT"
  • - *
+ *

Format: start with the word top, followed by the number of desired sources, and then the two-letter country code ISO 3166-1 alpha-2.

+ *

Multiple countries with the number of top sources can be specified as a comma-separated string.

*/ @JsonSetter(value = "predefined_sources", nulls = Nulls.SKIP) public Builder predefinedSources(Optional predefinedSources) { @@ -343,7 +295,6 @@ public Builder predefinedSources(String predefinedSources) { /** *

Word or phrase to search within the source names. To specify multiple values, use a comma-separated string.

- *

Example: "sport, tech"

*

Note: The search doesn't require an exact match and returns sources containing the specified terms in their names. You can use any word or phrase, like "sport" or "new york times". For example, "sport" returns sources such as "Motorsport", "Dot Esport", and "Tuttosport".

*/ @JsonSetter(value = "source_name", nulls = Nulls.SKIP) @@ -373,17 +324,6 @@ public Builder sourceUrl(String sourceUrl) { return this; } - /** - *

If true, returns the following additional datapoints about each news source:

- *
    - *
  • nb_articles_for_7d: The number of articles published by the source in the last week.
  • - *
  • country: Source country of origin.
  • - *
  • rank: SEO rank.
  • - *
  • is_news_domain: Boolean indicating if the source is a news domain.
  • - *
  • news_domain_type: Type of news domain (e.g., "Original Content").
  • - *
  • news_type: Category of news (e.g., "General News Outlets").
  • - *
- */ @JsonSetter(value = "include_additional_info", nulls = Nulls.SKIP) public Builder includeAdditionalInfo(Optional includeAdditionalInfo) { this.includeAdditionalInfo = includeAdditionalInfo; @@ -395,9 +335,6 @@ public Builder includeAdditionalInfo(Boolean includeAdditionalInfo) { return this; } - /** - *

If true, filters results to include only news domains.

- */ @JsonSetter(value = "is_news_domain", nulls = Nulls.SKIP) public Builder isNewsDomain(Optional isNewsDomain) { this.isNewsDomain = isNewsDomain; @@ -409,31 +346,20 @@ public Builder isNewsDomain(Boolean isNewsDomain) { return this; } - /** - *

Filters results based on the news domain type. Possible values are:

- *
    - *
  • Original Content: Sources that produce their own content.
  • - *
  • Aggregator: Sources that collect content from various other sources.
  • - *
  • Press Releases: Sources primarily publishing press releases.
  • - *
  • Republisher: Sources that republish content from other sources.
  • - *
  • Other: Sources that don't fit into main categories.
  • - *
- */ @JsonSetter(value = "news_domain_type", nulls = Nulls.SKIP) - public Builder newsDomainType(Optional newsDomainType) { + public Builder newsDomainType(Optional newsDomainType) { this.newsDomainType = newsDomainType; return this; } - public Builder newsDomainType(SourcesGetRequestNewsDomainType newsDomainType) { + public Builder newsDomainType(NewsDomainType newsDomainType) { this.newsDomainType = Optional.ofNullable(newsDomainType); return this; } /** *

Filters results based on the news type. Multiple types can be specified using a comma-separated string.

- *

Example: "General News Outlets,Tech News and Updates"

- *

For a complete list of available news types, see Enumerated parameters > News type.

+ *

For a complete list of available news types, see Enumerated parameters > News type.

*/ @JsonSetter(value = "news_type", nulls = Nulls.SKIP) public Builder newsType(Optional newsType) { @@ -446,9 +372,6 @@ public Builder newsType(String newsType) { return this; } - /** - *

The lowest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @JsonSetter(value = "from_rank", nulls = Nulls.SKIP) public Builder fromRank(Optional fromRank) { this.fromRank = fromRank; @@ -460,9 +383,6 @@ public Builder fromRank(Integer fromRank) { return this; } - /** - *

The highest boundary of the rank of a news website to filter by. A lower rank indicates a more popular source.

- */ @JsonSetter(value = "to_rank", nulls = Nulls.SKIP) public Builder toRank(Optional toRank) { this.toRank = toRank; @@ -474,8 +394,8 @@ public Builder toRank(Integer toRank) { return this; } - public SourcesGetRequest build() { - return new SourcesGetRequest( + public GetSourcesRequest build() { + return new GetSourcesRequest( lang, countries, predefinedSources, @@ -489,5 +409,15 @@ public SourcesGetRequest build() { toRank, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/sources/requests/SourcesPostRequest.java b/src/main/java/com/newscatcher/api/resources/sources/requests/PostSourcesRequest.java similarity index 93% rename from src/main/java/com/newscatcher/api/resources/sources/requests/SourcesPostRequest.java rename to src/main/java/com/newscatcher/api/resources/sources/requests/PostSourcesRequest.java index aedf702..c914d5f 100644 --- a/src/main/java/com/newscatcher/api/resources/sources/requests/SourcesPostRequest.java +++ b/src/main/java/com/newscatcher/api/resources/sources/requests/PostSourcesRequest.java @@ -25,8 +25,8 @@ import java.util.Optional; @JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SourcesPostRequest.Builder.class) -public final class SourcesPostRequest { +@JsonDeserialize(builder = PostSourcesRequest.Builder.class) +public final class PostSourcesRequest { private final Optional lang; private final Optional countries; @@ -51,7 +51,7 @@ public final class SourcesPostRequest { private final Map additionalProperties; - private SourcesPostRequest( + private PostSourcesRequest( Optional lang, Optional countries, Optional predefinedSources, @@ -136,7 +136,7 @@ public Optional getToRank() { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof SourcesPostRequest && equalTo((SourcesPostRequest) other); + return other instanceof PostSourcesRequest && equalTo((PostSourcesRequest) other); } @JsonAnyGetter @@ -144,7 +144,7 @@ public Map getAdditionalProperties() { return this.additionalProperties; } - private boolean equalTo(SourcesPostRequest other) { + private boolean equalTo(PostSourcesRequest other) { return lang.equals(other.lang) && countries.equals(other.countries) && predefinedSources.equals(other.predefinedSources) @@ -212,7 +212,7 @@ public static final class Builder { private Builder() {} - public Builder from(SourcesPostRequest other) { + public Builder from(PostSourcesRequest other) { lang(other.getLang()); countries(other.getCountries()); predefinedSources(other.getPredefinedSources()); @@ -348,8 +348,8 @@ public Builder toRank(Integer toRank) { return this; } - public SourcesPostRequest build() { - return new SourcesPostRequest( + public PostSourcesRequest build() { + return new PostSourcesRequest( lang, countries, predefinedSources, @@ -363,5 +363,15 @@ public SourcesPostRequest build() { toRank, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/resources/sources/types/SourcesGetRequestNewsDomainType.java b/src/main/java/com/newscatcher/api/resources/sources/types/SourcesGetRequestNewsDomainType.java deleted file mode 100644 index 5659de8..0000000 --- a/src/main/java/com/newscatcher/api/resources/sources/types/SourcesGetRequestNewsDomainType.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.resources.sources.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SourcesGetRequestNewsDomainType { - ORIGINAL_CONTENT("Original Content"), - - AGGREGATOR("Aggregator"), - - PRESS_RELEASES("Press Releases"), - - REPUBLISHER("Republisher"), - - OTHER("Other"); - - private final String value; - - SourcesGetRequestNewsDomainType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/resources/subscription/AsyncRawSubscriptionClient.java b/src/main/java/com/newscatcher/api/resources/subscription/AsyncRawSubscriptionClient.java index d47852f..10a59c2 100644 --- a/src/main/java/com/newscatcher/api/resources/subscription/AsyncRawSubscriptionClient.java +++ b/src/main/java/com/newscatcher/api/resources/subscription/AsyncRawSubscriptionClient.java @@ -50,12 +50,16 @@ public CompletableFuture> ge * Retrieves information about your subscription plan. */ public CompletableFuture> get(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/subscription") - .build(); + .addPathSegments("api/subscription"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json") @@ -69,14 +73,13 @@ public CompletableFuture> ge @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SubscriptionResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -118,11 +121,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( @@ -149,12 +150,16 @@ public CompletableFuture> po * Retrieves information about your subscription plan. */ public CompletableFuture> post(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/subscription") - .build(); + .addPathSegments("api/subscription"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", RequestBody.create("", null)) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json") @@ -168,14 +173,13 @@ public CompletableFuture> po @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { future.complete(new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SubscriptionResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionResponseDto.class), response)); return; } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -217,11 +221,9 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); future.completeExceptionally(new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response)); + "Error with status code " + response.code(), response.code(), errorBody, response)); return; } catch (IOException e) { future.completeExceptionally( diff --git a/src/main/java/com/newscatcher/api/resources/subscription/RawSubscriptionClient.java b/src/main/java/com/newscatcher/api/resources/subscription/RawSubscriptionClient.java index 90dc0bb..f705b64 100644 --- a/src/main/java/com/newscatcher/api/resources/subscription/RawSubscriptionClient.java +++ b/src/main/java/com/newscatcher/api/resources/subscription/RawSubscriptionClient.java @@ -46,12 +46,16 @@ public NewscatcherApiHttpResponse get() { * Retrieves information about your subscription plan. */ public NewscatcherApiHttpResponse get(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/subscription") - .build(); + .addPathSegments("api/subscription"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("GET", null) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json") @@ -62,12 +66,12 @@ public NewscatcherApiHttpResponse get(RequestOptions re } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -95,11 +99,9 @@ public NewscatcherApiHttpResponse get(RequestOptions re } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } @@ -116,12 +118,16 @@ public NewscatcherApiHttpResponse post() { * Retrieves information about your subscription plan. */ public NewscatcherApiHttpResponse post(RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) .newBuilder() - .addPathSegments("api/subscription") - .build(); + .addPathSegments("api/subscription"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((_key, _value) -> { + httpUrl.addQueryParameter(_key, _value); + }); + } Request okhttpRequest = new Request.Builder() - .url(httpUrl) + .url(httpUrl.build()) .method("POST", RequestBody.create("", null)) .headers(Headers.of(clientOptions.headers(requestOptions))) .addHeader("Accept", "application/json") @@ -132,12 +138,12 @@ public NewscatcherApiHttpResponse post(RequestOptions r } try (Response response = client.newCall(okhttpRequest).execute()) { ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; if (response.isSuccessful()) { return new NewscatcherApiHttpResponse<>( - ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscriptionResponseDto.class), + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, SubscriptionResponseDto.class), response); } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; try { switch (response.code()) { case 400: @@ -165,11 +171,9 @@ public NewscatcherApiHttpResponse post(RequestOptions r } catch (JsonProcessingException ignored) { // unable to map error response, throwing generic error } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); throw new NewscatcherApiApiException( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), - response); + "Error with status code " + response.code(), response.code(), errorBody, response); } catch (IOException e) { throw new NewscatcherApiException("Network error executing HTTP request", e); } diff --git a/src/main/java/com/newscatcher/api/types/AdditionalDomainInfoEntity.java b/src/main/java/com/newscatcher/api/types/AdditionalDomainInfoEntity.java index a462712..b3434b1 100644 --- a/src/main/java/com/newscatcher/api/types/AdditionalDomainInfoEntity.java +++ b/src/main/java/com/newscatcher/api/types/AdditionalDomainInfoEntity.java @@ -159,5 +159,15 @@ public Builder newsDomainType(String newsDomainType) { public AdditionalDomainInfoEntity build() { return new AdditionalDomainInfoEntity(isNewsDomain, newsType, newsDomainType, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/AdditionalSourceInfo.java b/src/main/java/com/newscatcher/api/types/AdditionalSourceInfo.java index 08a68e9..6b06446 100644 --- a/src/main/java/com/newscatcher/api/types/AdditionalSourceInfo.java +++ b/src/main/java/com/newscatcher/api/types/AdditionalSourceInfo.java @@ -32,6 +32,8 @@ public final class AdditionalSourceInfo { private final Optional newsType; + private final Optional robotsCompliant; + private final Map additionalProperties; private AdditionalSourceInfo( @@ -41,6 +43,7 @@ private AdditionalSourceInfo( Optional isNewsDomain, Optional newsDomainType, Optional newsType, + Optional robotsCompliant, Map additionalProperties) { this.nbArticlesFor7D = nbArticlesFor7D; this.country = country; @@ -48,6 +51,7 @@ private AdditionalSourceInfo( this.isNewsDomain = isNewsDomain; this.newsDomainType = newsDomainType; this.newsType = newsType; + this.robotsCompliant = robotsCompliant; this.additionalProperties = additionalProperties; } @@ -99,6 +103,14 @@ public Optional getNewsType() { return newsType; } + /** + * @return Percentage of domain articles that comply with robots.txt scraping rules (0-100%). + */ + @JsonProperty("robots_compliant") + public Optional getRobotsCompliant() { + return robotsCompliant; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -116,13 +128,20 @@ private boolean equalTo(AdditionalSourceInfo other) { && rank.equals(other.rank) && isNewsDomain.equals(other.isNewsDomain) && newsDomainType.equals(other.newsDomainType) - && newsType.equals(other.newsType); + && newsType.equals(other.newsType) + && robotsCompliant.equals(other.robotsCompliant); } @java.lang.Override public int hashCode() { return Objects.hash( - this.nbArticlesFor7D, this.country, this.rank, this.isNewsDomain, this.newsDomainType, this.newsType); + this.nbArticlesFor7D, + this.country, + this.rank, + this.isNewsDomain, + this.newsDomainType, + this.newsType, + this.robotsCompliant); } @java.lang.Override @@ -148,6 +167,8 @@ public static final class Builder { private Optional newsType = Optional.empty(); + private Optional robotsCompliant = Optional.empty(); + @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -160,6 +181,7 @@ public Builder from(AdditionalSourceInfo other) { isNewsDomain(other.getIsNewsDomain()); newsDomainType(other.getNewsDomainType()); newsType(other.getNewsType()); + robotsCompliant(other.getRobotsCompliant()); return this; } @@ -247,9 +269,40 @@ public Builder newsType(String newsType) { return this; } + /** + *

Percentage of domain articles that comply with robots.txt scraping rules (0-100%).

+ */ + @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) + public Builder robotsCompliant(Optional robotsCompliant) { + this.robotsCompliant = robotsCompliant; + return this; + } + + public Builder robotsCompliant(String robotsCompliant) { + this.robotsCompliant = Optional.ofNullable(robotsCompliant); + return this; + } + public AdditionalSourceInfo build() { return new AdditionalSourceInfo( - nbArticlesFor7D, country, rank, isNewsDomain, newsDomainType, newsType, additionalProperties); + nbArticlesFor7D, + country, + rank, + isNewsDomain, + newsDomainType, + newsType, + robotsCompliant, + additionalProperties); + } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; } } } diff --git a/src/main/java/com/newscatcher/api/types/AggregationBy.java b/src/main/java/com/newscatcher/api/types/AggregationBy.java index 1aaaa08..2f0e778 100644 --- a/src/main/java/com/newscatcher/api/types/AggregationBy.java +++ b/src/main/java/com/newscatcher/api/types/AggregationBy.java @@ -3,24 +3,91 @@ */ package com.newscatcher.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum AggregationBy { - DAY("day"), +public final class AggregationBy { + public static final AggregationBy MONTH = new AggregationBy(Value.MONTH, "month"); - HOUR("hour"), + public static final AggregationBy DAY = new AggregationBy(Value.DAY, "day"); - MONTH("month"); + public static final AggregationBy HOUR = new AggregationBy(Value.HOUR, "hour"); - private final String value; + private final Value value; - AggregationBy(String value) { + private final String string; + + AggregationBy(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof AggregationBy && this.string.equals(((AggregationBy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case MONTH: + return visitor.visitMonth(); + case DAY: + return visitor.visitDay(); + case HOUR: + return visitor.visitHour(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static AggregationBy valueOf(String value) { + switch (value) { + case "month": + return MONTH; + case "day": + return DAY; + case "hour": + return HOUR; + default: + return new AggregationBy(Value.UNKNOWN, value); + } + } + + public enum Value { + DAY, + + HOUR, + + MONTH, + + UNKNOWN + } + + public interface Visitor { + T visitDay(); + + T visitHour(); + + T visitMonth(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/newscatcher/api/types/AggregationCountResponseDto.java b/src/main/java/com/newscatcher/api/types/AggregationCountResponseDto.java index b5df155..0a7c5d9 100644 --- a/src/main/java/com/newscatcher/api/types/AggregationCountResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/AggregationCountResponseDto.java @@ -31,7 +31,7 @@ public final class AggregationCountResponseDto implements IBaseSearchResponseDto private final int pageSize; - private final Optional aggregations; + private final Optional aggregations; private final Optional> userInput; @@ -43,7 +43,7 @@ private AggregationCountResponseDto( int page, int totalPages, int pageSize, - Optional aggregations, + Optional aggregations, Optional> userInput, Map additionalProperties) { this.status = status; @@ -105,7 +105,7 @@ public int getPageSize() { * @return The aggregation results. Can be either a dictionary or a list of dictionaries. */ @JsonProperty("aggregations") - public Optional getAggregations() { + public Optional getAggregations() { return aggregations; } @@ -196,12 +196,16 @@ public interface PageSizeStage { public interface _FinalStage { AggregationCountResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

The aggregation results. Can be either a dictionary or a list of dictionaries.

*/ - _FinalStage aggregations(Optional aggregations); + _FinalStage aggregations(Optional aggregations); - _FinalStage aggregations(Aggregations aggregations); + _FinalStage aggregations(AggregationCountResponseDtoAggregations aggregations); _FinalStage userInput(Optional> userInput); @@ -223,7 +227,7 @@ public static final class Builder private Optional> userInput = Optional.empty(); - private Optional aggregations = Optional.empty(); + private Optional aggregations = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -320,7 +324,7 @@ public _FinalStage userInput(Optional> userInput) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage aggregations(Aggregations aggregations) { + public _FinalStage aggregations(AggregationCountResponseDtoAggregations aggregations) { this.aggregations = Optional.ofNullable(aggregations); return this; } @@ -330,7 +334,7 @@ public _FinalStage aggregations(Aggregations aggregations) { */ @java.lang.Override @JsonSetter(value = "aggregations", nulls = Nulls.SKIP) - public _FinalStage aggregations(Optional aggregations) { + public _FinalStage aggregations(Optional aggregations) { this.aggregations = aggregations; return this; } @@ -340,5 +344,17 @@ public AggregationCountResponseDto build() { return new AggregationCountResponseDto( status, totalHits, page, totalPages, pageSize, aggregations, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/Aggregations.java b/src/main/java/com/newscatcher/api/types/AggregationCountResponseDtoAggregations.java similarity index 69% rename from src/main/java/com/newscatcher/api/types/Aggregations.java rename to src/main/java/com/newscatcher/api/types/AggregationCountResponseDtoAggregations.java index 6fdc0ec..7a1a0be 100644 --- a/src/main/java/com/newscatcher/api/types/Aggregations.java +++ b/src/main/java/com/newscatcher/api/types/AggregationCountResponseDtoAggregations.java @@ -15,13 +15,13 @@ import java.util.List; import java.util.Objects; -@JsonDeserialize(using = Aggregations.Deserializer.class) -public final class Aggregations { +@JsonDeserialize(using = AggregationCountResponseDtoAggregations.Deserializer.class) +public final class AggregationCountResponseDtoAggregations { private final Object value; private final int type; - private Aggregations(Object value, int type) { + private AggregationCountResponseDtoAggregations(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,11 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof Aggregations && equalTo((Aggregations) other); + return other instanceof AggregationCountResponseDtoAggregations + && equalTo((AggregationCountResponseDtoAggregations) other); } - private boolean equalTo(Aggregations other) { + private boolean equalTo(AggregationCountResponseDtoAggregations other) { return value.equals(other.value); } @@ -61,12 +62,12 @@ public String toString() { return this.value.toString(); } - public static Aggregations of(AggregationItem value) { - return new Aggregations(value, 0); + public static AggregationCountResponseDtoAggregations of(AggregationItem value) { + return new AggregationCountResponseDtoAggregations(value, 0); } - public static Aggregations of(List value) { - return new Aggregations(value, 1); + public static AggregationCountResponseDtoAggregations of(List value) { + return new AggregationCountResponseDtoAggregations(value, 1); } public interface Visitor { @@ -75,13 +76,14 @@ public interface Visitor { T visit(List value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(Aggregations.class); + super(AggregationCountResponseDtoAggregations.class); } @java.lang.Override - public Aggregations deserialize(JsonParser p, DeserializationContext context) throws IOException { + public AggregationCountResponseDtoAggregations deserialize(JsonParser p, DeserializationContext context) + throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, AggregationItem.class)); diff --git a/src/main/java/com/newscatcher/api/types/AggregationItem.java b/src/main/java/com/newscatcher/api/types/AggregationItem.java index 1b74031..8b97873 100644 --- a/src/main/java/com/newscatcher/api/types/AggregationItem.java +++ b/src/main/java/com/newscatcher/api/types/AggregationItem.java @@ -87,7 +87,9 @@ public Builder from(AggregationItem other) { @JsonSetter(value = "aggregation_count", nulls = Nulls.SKIP) public Builder aggregationCount(List aggregationCount) { this.aggregationCount.clear(); - this.aggregationCount.addAll(aggregationCount); + if (aggregationCount != null) { + this.aggregationCount.addAll(aggregationCount); + } return this; } @@ -97,12 +99,24 @@ public Builder addAggregationCount(TimeFrameCount aggregationCount) { } public Builder addAllAggregationCount(List aggregationCount) { - this.aggregationCount.addAll(aggregationCount); + if (aggregationCount != null) { + this.aggregationCount.addAll(aggregationCount); + } return this; } public AggregationItem build() { return new AggregationItem(aggregationCount, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/AllLinksDataItem.java b/src/main/java/com/newscatcher/api/types/AllLinksDataItem.java new file mode 100644 index 0000000..f514954 --- /dev/null +++ b/src/main/java/com/newscatcher/api/types/AllLinksDataItem.java @@ -0,0 +1,195 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = AllLinksDataItem.Builder.class) +public final class AllLinksDataItem { + private final String domainUrl; + + private final String link; + + private final String text; + + private final Map additionalProperties; + + private AllLinksDataItem(String domainUrl, String link, String text, Map additionalProperties) { + this.domainUrl = domainUrl; + this.link = link; + this.text = text; + this.additionalProperties = additionalProperties; + } + + /** + * @return The domain of the linked URL. + */ + @JsonProperty("domain_url") + public String getDomainUrl() { + return domainUrl; + } + + /** + * @return The complete URL of the link. + */ + @JsonProperty("link") + public String getLink() { + return link; + } + + /** + * @return The anchor text of the link. + */ + @JsonProperty("text") + public String getText() { + return text; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof AllLinksDataItem && equalTo((AllLinksDataItem) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(AllLinksDataItem other) { + return domainUrl.equals(other.domainUrl) && link.equals(other.link) && text.equals(other.text); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.domainUrl, this.link, this.text); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static DomainUrlStage builder() { + return new Builder(); + } + + public interface DomainUrlStage { + /** + *

The domain of the linked URL.

+ */ + LinkStage domainUrl(@NotNull String domainUrl); + + Builder from(AllLinksDataItem other); + } + + public interface LinkStage { + /** + *

The complete URL of the link.

+ */ + TextStage link(@NotNull String link); + } + + public interface TextStage { + /** + *

The anchor text of the link.

+ */ + _FinalStage text(@NotNull String text); + } + + public interface _FinalStage { + AllLinksDataItem build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements DomainUrlStage, LinkStage, TextStage, _FinalStage { + private String domainUrl; + + private String link; + + private String text; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(AllLinksDataItem other) { + domainUrl(other.getDomainUrl()); + link(other.getLink()); + text(other.getText()); + return this; + } + + /** + *

The domain of the linked URL.

+ *

The domain of the linked URL.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("domain_url") + public LinkStage domainUrl(@NotNull String domainUrl) { + this.domainUrl = Objects.requireNonNull(domainUrl, "domainUrl must not be null"); + return this; + } + + /** + *

The complete URL of the link.

+ *

The complete URL of the link.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("link") + public TextStage link(@NotNull String link) { + this.link = Objects.requireNonNull(link, "link must not be null"); + return this; + } + + /** + *

The anchor text of the link.

+ *

The anchor text of the link.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + @JsonSetter("text") + public _FinalStage text(@NotNull String text) { + this.text = Objects.requireNonNull(text, "text must not be null"); + return this; + } + + @java.lang.Override + public AllLinksDataItem build() { + return new AllLinksDataItem(domainUrl, link, text, additionalProperties); + } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } + } +} diff --git a/src/main/java/com/newscatcher/api/types/Theme.java b/src/main/java/com/newscatcher/api/types/AllLinksText.java similarity index 76% rename from src/main/java/com/newscatcher/api/types/Theme.java rename to src/main/java/com/newscatcher/api/types/AllLinksText.java index 72c634e..8ce67a9 100644 --- a/src/main/java/com/newscatcher/api/types/Theme.java +++ b/src/main/java/com/newscatcher/api/types/AllLinksText.java @@ -15,13 +15,13 @@ import java.util.List; import java.util.Objects; -@JsonDeserialize(using = Theme.Deserializer.class) -public final class Theme { +@JsonDeserialize(using = AllLinksText.Deserializer.class) +public final class AllLinksText { private final Object value; private final int type; - private Theme(Object value, int type) { + private AllLinksText(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof Theme && equalTo((Theme) other); + return other instanceof AllLinksText && equalTo((AllLinksText) other); } - private boolean equalTo(Theme other) { + private boolean equalTo(AllLinksText other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static Theme of(String value) { - return new Theme(value, 0); + public static AllLinksText of(String value) { + return new AllLinksText(value, 0); } - public static Theme of(List value) { - return new Theme(value, 1); + public static AllLinksText of(List value) { + return new AllLinksText(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(List value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(Theme.class); + super(AllLinksText.class); } @java.lang.Override - public Theme deserialize(JsonParser p, DeserializationContext context) throws IOException { + public AllLinksText deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); diff --git a/src/main/java/com/newscatcher/api/types/ArticleEntity.java b/src/main/java/com/newscatcher/api/types/ArticleEntity.java index fc879ad..ab7d4ee 100644 --- a/src/main/java/com/newscatcher/api/types/ArticleEntity.java +++ b/src/main/java/com/newscatcher/api/types/ArticleEntity.java @@ -5,12 +5,15 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.api.core.Nullable; +import com.newscatcher.api.core.NullableNonemptyFilter; import com.newscatcher.api.core.ObjectMappers; import java.util.HashMap; import java.util.List; @@ -21,14 +24,14 @@ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonDeserialize(builder = ArticleEntity.Builder.class) -public final class ArticleEntity implements IArticleEntity { +public final class ArticleEntity { private final String title; private final Optional author; - private final Optional authors; + private final Optional authors; - private final Optional journalists; + private final Optional journalists; private final Optional publishedDate; @@ -66,7 +69,7 @@ public final class ArticleEntity implements IArticleEntity { private final Optional description; - private final String content; + private final Optional content; private final Optional titleTranslatedEn; @@ -82,6 +85,8 @@ public final class ArticleEntity implements IArticleEntity { private final Optional allDomainLinks; + private final Optional> allLinksData; + private final Optional nlp; private final String id; @@ -99,8 +104,8 @@ public final class ArticleEntity implements IArticleEntity { private ArticleEntity( String title, Optional author, - Optional authors, - Optional journalists, + Optional authors, + Optional journalists, Optional publishedDate, Optional publishedDatePrecision, Optional updatedDate, @@ -119,7 +124,7 @@ private ArticleEntity( Optional media, Optional language, Optional description, - String content, + Optional content, Optional titleTranslatedEn, Optional contentTranslatedEn, Optional wordCount, @@ -127,6 +132,7 @@ private ArticleEntity( Optional twitterAccount, Optional allLinks, Optional allDomainLinks, + Optional> allLinksData, Optional nlp, String id, double score, @@ -164,6 +170,7 @@ private ArticleEntity( this.twitterAccount = twitterAccount; this.allLinks = allLinks; this.allDomainLinks = allDomainLinks; + this.allLinksData = allLinksData; this.nlp = nlp; this.id = id; this.score = score; @@ -177,7 +184,6 @@ private ArticleEntity( * @return The title of the article. */ @JsonProperty("title") - @java.lang.Override public String getTitle() { return title; } @@ -186,7 +192,6 @@ public String getTitle() { * @return The primary author of the article. */ @JsonProperty("author") - @java.lang.Override public Optional getAuthor() { return author; } @@ -195,15 +200,18 @@ public Optional getAuthor() { * @return A list of authors of the article. */ @JsonProperty("authors") - public Optional getAuthors() { + public Optional getAuthors() { return authors; } /** * @return A list of journalists associated with the article. */ - @JsonProperty("journalists") - public Optional getJournalists() { + @JsonIgnore + public Optional getJournalists() { + if (journalists == null) { + return Optional.empty(); + } return journalists; } @@ -211,7 +219,6 @@ public Optional getJournalists() { * @return The date the article was published. */ @JsonProperty("published_date") - @java.lang.Override public Optional getPublishedDate() { return publishedDate; } @@ -220,7 +227,6 @@ public Optional getPublishedDate() { * @return The precision of the published date. */ @JsonProperty("published_date_precision") - @java.lang.Override public Optional getPublishedDatePrecision() { return publishedDatePrecision; } @@ -228,27 +234,33 @@ public Optional getPublishedDatePrecision() { /** * @return The date the article was last updated. */ - @JsonProperty("updated_date") - @java.lang.Override + @JsonIgnore public Optional getUpdatedDate() { + if (updatedDate == null) { + return Optional.empty(); + } return updatedDate; } /** * @return The precision of the updated date. */ - @JsonProperty("updated_date_precision") - @java.lang.Override + @JsonIgnore public Optional getUpdatedDatePrecision() { + if (updatedDatePrecision == null) { + return Optional.empty(); + } return updatedDatePrecision; } /** * @return The date the article was parsed. */ - @JsonProperty("parse_date") - @java.lang.Override + @JsonIgnore public Optional getParseDate() { + if (parseDate == null) { + return Optional.empty(); + } return parseDate; } @@ -256,7 +268,6 @@ public Optional getParseDate() { * @return The URL link to the article. */ @JsonProperty("link") - @java.lang.Override public String getLink() { return link; } @@ -265,7 +276,6 @@ public String getLink() { * @return The domain URL of the article. */ @JsonProperty("domain_url") - @java.lang.Override public String getDomainUrl() { return domainUrl; } @@ -274,7 +284,6 @@ public String getDomainUrl() { * @return The full domain URL of the article. */ @JsonProperty("full_domain_url") - @java.lang.Override public String getFullDomainUrl() { return fullDomainUrl; } @@ -283,7 +292,6 @@ public String getFullDomainUrl() { * @return The name of the source where the article was published. */ @JsonProperty("name_source") - @java.lang.Override public Optional getNameSource() { return nameSource; } @@ -292,16 +300,14 @@ public Optional getNameSource() { * @return Indicates if the article is a headline. */ @JsonProperty("is_headline") - @java.lang.Override public Optional getIsHeadline() { return isHeadline; } /** - * @return Indicates if the article is paid content. + * @return Indicates whether the source labels the article as paywalled or requiring a subscription for full access. */ @JsonProperty("paid_content") - @java.lang.Override public Optional getPaidContent() { return paidContent; } @@ -310,7 +316,6 @@ public Optional getPaidContent() { * @return The categorical URL of the article. */ @JsonProperty("parent_url") - @java.lang.Override public String getParentUrl() { return parentUrl; } @@ -319,7 +324,6 @@ public String getParentUrl() { * @return The country where the article was published. */ @JsonProperty("country") - @java.lang.Override public Optional getCountry() { return country; } @@ -328,7 +332,6 @@ public Optional getCountry() { * @return The rights information for the article. */ @JsonProperty("rights") - @java.lang.Override public Optional getRights() { return rights; } @@ -337,7 +340,6 @@ public Optional getRights() { * @return The rank of the article's source. */ @JsonProperty("rank") - @java.lang.Override public int getRank() { return rank; } @@ -346,7 +348,6 @@ public int getRank() { * @return The media associated with the article. */ @JsonProperty("media") - @java.lang.Override public Optional getMedia() { return media; } @@ -355,7 +356,6 @@ public Optional getMedia() { * @return The language in which the article is written. */ @JsonProperty("language") - @java.lang.Override public Optional getLanguage() { return language; } @@ -364,7 +364,6 @@ public Optional getLanguage() { * @return A brief description of the article. */ @JsonProperty("description") - @java.lang.Override public Optional getDescription() { return description; } @@ -373,26 +372,29 @@ public Optional getDescription() { * @return The content of the article. */ @JsonProperty("content") - @java.lang.Override - public String getContent() { + public Optional getContent() { return content; } /** * @return English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true. */ - @JsonProperty("title_translated_en") - @java.lang.Override + @JsonIgnore public Optional getTitleTranslatedEn() { + if (titleTranslatedEn == null) { + return Optional.empty(); + } return titleTranslatedEn; } /** * @return English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true. */ - @JsonProperty("content_translated_en") - @java.lang.Override + @JsonIgnore public Optional getContentTranslatedEn() { + if (contentTranslatedEn == null) { + return Optional.empty(); + } return contentTranslatedEn; } @@ -400,7 +402,6 @@ public Optional getContentTranslatedEn() { * @return The word count of the article. */ @JsonProperty("word_count") - @java.lang.Override public Optional getWordCount() { return wordCount; } @@ -409,7 +410,6 @@ public Optional getWordCount() { * @return Indicates if the article is an opinion piece. */ @JsonProperty("is_opinion") - @java.lang.Override public Optional getIsOpinion() { return isOpinion; } @@ -417,9 +417,11 @@ public Optional getIsOpinion() { /** * @return The Twitter account associated with the article. */ - @JsonProperty("twitter_account") - @java.lang.Override + @JsonIgnore public Optional getTwitterAccount() { + if (twitterAccount == null) { + return Optional.empty(); + } return twitterAccount; } @@ -439,8 +441,15 @@ public Optional getAllDomainLinks() { return allDomainLinks; } + /** + * @return Detailed information about all links mentioned in the article, including link URL, domain, and anchor text. Only present when the all_links_text parameter is used in the request. + */ + @JsonProperty("all_links_data") + public Optional> getAllLinksData() { + return allLinksData; + } + @JsonProperty("nlp") - @java.lang.Override public Optional getNlp() { return nlp; } @@ -449,7 +458,6 @@ public Optional getNlp() { * @return The unique identifier for the article. */ @JsonProperty("id") - @java.lang.Override public String getId() { return id; } @@ -458,7 +466,6 @@ public String getId() { * @return The relevance score of the article. */ @JsonProperty("score") - @java.lang.Override public double getScore() { return score; } @@ -467,7 +474,6 @@ public double getScore() { * @return True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise. */ @JsonProperty("robots_compliant") - @java.lang.Override public Optional getRobotsCompliant() { return robotsCompliant; } @@ -476,17 +482,57 @@ public Optional getRobotsCompliant() { * @return An object that contains custom tags associated with an article, where each key is a taxonomy name, and the value is an array of tags. */ @JsonProperty("custom_tags") - @java.lang.Override public Optional>> getCustomTags() { return customTags; } @JsonProperty("additional_domain_info") - @java.lang.Override public Optional getAdditionalDomainInfo() { return additionalDomainInfo; } + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("journalists") + private Optional _getJournalists() { + return journalists; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("updated_date") + private Optional _getUpdatedDate() { + return updatedDate; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("updated_date_precision") + private Optional _getUpdatedDatePrecision() { + return updatedDatePrecision; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("parse_date") + private Optional _getParseDate() { + return parseDate; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("title_translated_en") + private Optional _getTitleTranslatedEn() { + return titleTranslatedEn; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("content_translated_en") + private Optional _getContentTranslatedEn() { + return contentTranslatedEn; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("twitter_account") + private Optional _getTwitterAccount() { + return twitterAccount; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -529,6 +575,7 @@ private boolean equalTo(ArticleEntity other) { && twitterAccount.equals(other.twitterAccount) && allLinks.equals(other.allLinks) && allDomainLinks.equals(other.allDomainLinks) + && allLinksData.equals(other.allLinksData) && nlp.equals(other.nlp) && id.equals(other.id) && score == other.score @@ -570,6 +617,7 @@ public int hashCode() { this.twitterAccount, this.allLinks, this.allDomainLinks, + this.allLinksData, this.nlp, this.id, this.score, @@ -628,14 +676,7 @@ public interface RankStage { /** *

The rank of the article's source.

*/ - ContentStage rank(int rank); - } - - public interface ContentStage { - /** - *

The content of the article.

- */ - IdStage content(@NotNull String content); + IdStage rank(int rank); } public interface IdStage { @@ -655,6 +696,10 @@ public interface ScoreStage { public interface _FinalStage { ArticleEntity build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

The primary author of the article.

*/ @@ -665,16 +710,18 @@ public interface _FinalStage { /** *

A list of authors of the article.

*/ - _FinalStage authors(Optional authors); + _FinalStage authors(Optional authors); - _FinalStage authors(Authors authors); + _FinalStage authors(ArticleEntityAuthors authors); /** *

A list of journalists associated with the article.

*/ - _FinalStage journalists(Optional journalists); + _FinalStage journalists(Optional journalists); + + _FinalStage journalists(ArticleEntityJournalists journalists); - _FinalStage journalists(Journalists journalists); + _FinalStage journalists(Nullable journalists); /** *

The date the article was published.

@@ -697,6 +744,8 @@ public interface _FinalStage { _FinalStage updatedDate(String updatedDate); + _FinalStage updatedDate(Nullable updatedDate); + /** *

The precision of the updated date.

*/ @@ -704,6 +753,8 @@ public interface _FinalStage { _FinalStage updatedDatePrecision(String updatedDatePrecision); + _FinalStage updatedDatePrecision(Nullable updatedDatePrecision); + /** *

The date the article was parsed.

*/ @@ -711,6 +762,8 @@ public interface _FinalStage { _FinalStage parseDate(String parseDate); + _FinalStage parseDate(Nullable parseDate); + /** *

The name of the source where the article was published.

*/ @@ -726,7 +779,7 @@ public interface _FinalStage { _FinalStage isHeadline(Boolean isHeadline); /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

*/ _FinalStage paidContent(Optional paidContent); @@ -767,6 +820,13 @@ public interface _FinalStage { _FinalStage description(String description); + /** + *

The content of the article.

+ */ + _FinalStage content(Optional content); + + _FinalStage content(String content); + /** *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

*/ @@ -774,6 +834,8 @@ public interface _FinalStage { _FinalStage titleTranslatedEn(String titleTranslatedEn); + _FinalStage titleTranslatedEn(Nullable titleTranslatedEn); + /** *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

*/ @@ -781,6 +843,8 @@ public interface _FinalStage { _FinalStage contentTranslatedEn(String contentTranslatedEn); + _FinalStage contentTranslatedEn(Nullable contentTranslatedEn); + /** *

The word count of the article.

*/ @@ -802,6 +866,8 @@ public interface _FinalStage { _FinalStage twitterAccount(String twitterAccount); + _FinalStage twitterAccount(Nullable twitterAccount); + /** *

A list of all URLs mentioned in the article.

*/ @@ -816,6 +882,13 @@ public interface _FinalStage { _FinalStage allDomainLinks(ArticleEntityAllDomainLinks allDomainLinks); + /** + *

Detailed information about all links mentioned in the article, including link URL, domain, and anchor text. Only present when the all_links_text parameter is used in the request.

+ */ + _FinalStage allLinksData(Optional> allLinksData); + + _FinalStage allLinksData(List allLinksData); + _FinalStage nlp(Optional nlp); _FinalStage nlp(NlpDataEntity nlp); @@ -847,7 +920,6 @@ public static final class Builder FullDomainUrlStage, ParentUrlStage, RankStage, - ContentStage, IdStage, ScoreStage, _FinalStage { @@ -863,8 +935,6 @@ public static final class Builder private int rank; - private String content; - private String id; private double score; @@ -877,6 +947,8 @@ public static final class Builder private Optional nlp = Optional.empty(); + private Optional> allLinksData = Optional.empty(); + private Optional allDomainLinks = Optional.empty(); private Optional allLinks = Optional.empty(); @@ -891,6 +963,8 @@ public static final class Builder private Optional titleTranslatedEn = Optional.empty(); + private Optional content = Optional.empty(); + private Optional description = Optional.empty(); private Optional language = Optional.empty(); @@ -917,9 +991,9 @@ public static final class Builder private Optional publishedDate = Optional.empty(); - private Optional journalists = Optional.empty(); + private Optional journalists = Optional.empty(); - private Optional authors = Optional.empty(); + private Optional authors = Optional.empty(); private Optional author = Optional.empty(); @@ -960,6 +1034,7 @@ public Builder from(ArticleEntity other) { twitterAccount(other.getTwitterAccount()); allLinks(other.getAllLinks()); allDomainLinks(other.getAllDomainLinks()); + allLinksData(other.getAllLinksData()); nlp(other.getNlp()); id(other.getId()); score(other.getScore()); @@ -1036,23 +1111,11 @@ public RankStage parentUrl(@NotNull String parentUrl) { */ @java.lang.Override @JsonSetter("rank") - public ContentStage rank(int rank) { + public IdStage rank(int rank) { this.rank = rank; return this; } - /** - *

The content of the article.

- *

The content of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public IdStage content(@NotNull String content) { - this.content = Objects.requireNonNull(content, "content must not be null"); - return this; - } - /** *

The unique identifier for the article.

*

The unique identifier for the article.

@@ -1143,6 +1206,26 @@ public _FinalStage nlp(Optional nlp) { return this; } + /** + *

Detailed information about all links mentioned in the article, including link URL, domain, and anchor text. Only present when the all_links_text parameter is used in the request.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage allLinksData(List allLinksData) { + this.allLinksData = Optional.ofNullable(allLinksData); + return this; + } + + /** + *

Detailed information about all links mentioned in the article, including link URL, domain, and anchor text. Only present when the all_links_text parameter is used in the request.

+ */ + @java.lang.Override + @JsonSetter(value = "all_links_data", nulls = Nulls.SKIP) + public _FinalStage allLinksData(Optional> allLinksData) { + this.allLinksData = allLinksData; + return this; + } + /** *

A list of all domain URLs mentioned in the article.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1183,6 +1266,22 @@ public _FinalStage allLinks(Optional allLinks) { return this; } + /** + *

The Twitter account associated with the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage twitterAccount(Nullable twitterAccount) { + if (twitterAccount.isNull()) { + this.twitterAccount = null; + } else if (twitterAccount.isEmpty()) { + this.twitterAccount = Optional.empty(); + } else { + this.twitterAccount = Optional.of(twitterAccount.get()); + } + return this; + } + /** *

The Twitter account associated with the article.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1243,6 +1342,22 @@ public _FinalStage wordCount(Optional wordCount) { return this; } + /** + *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage contentTranslatedEn(Nullable contentTranslatedEn) { + if (contentTranslatedEn.isNull()) { + this.contentTranslatedEn = null; + } else if (contentTranslatedEn.isEmpty()) { + this.contentTranslatedEn = Optional.empty(); + } else { + this.contentTranslatedEn = Optional.of(contentTranslatedEn.get()); + } + return this; + } + /** *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1263,6 +1378,22 @@ public _FinalStage contentTranslatedEn(Optional contentTranslatedEn) { return this; } + /** + *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage titleTranslatedEn(Nullable titleTranslatedEn) { + if (titleTranslatedEn.isNull()) { + this.titleTranslatedEn = null; + } else if (titleTranslatedEn.isEmpty()) { + this.titleTranslatedEn = Optional.empty(); + } else { + this.titleTranslatedEn = Optional.of(titleTranslatedEn.get()); + } + return this; + } + /** *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1283,6 +1414,26 @@ public _FinalStage titleTranslatedEn(Optional titleTranslatedEn) { return this; } + /** + *

The content of the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage content(String content) { + this.content = Optional.ofNullable(content); + return this; + } + + /** + *

The content of the article.

+ */ + @java.lang.Override + @JsonSetter(value = "content", nulls = Nulls.SKIP) + public _FinalStage content(Optional content) { + this.content = content; + return this; + } + /** *

A brief description of the article.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1384,7 +1535,7 @@ public _FinalStage country(Optional country) { } /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1394,7 +1545,7 @@ public _FinalStage paidContent(Boolean paidContent) { } /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

*/ @java.lang.Override @JsonSetter(value = "paid_content", nulls = Nulls.SKIP) @@ -1443,6 +1594,22 @@ public _FinalStage nameSource(Optional nameSource) { return this; } + /** + *

The date the article was parsed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parseDate(Nullable parseDate) { + if (parseDate.isNull()) { + this.parseDate = null; + } else if (parseDate.isEmpty()) { + this.parseDate = Optional.empty(); + } else { + this.parseDate = Optional.of(parseDate.get()); + } + return this; + } + /** *

The date the article was parsed.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1463,6 +1630,22 @@ public _FinalStage parseDate(Optional parseDate) { return this; } + /** + *

The precision of the updated date.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedDatePrecision(Nullable updatedDatePrecision) { + if (updatedDatePrecision.isNull()) { + this.updatedDatePrecision = null; + } else if (updatedDatePrecision.isEmpty()) { + this.updatedDatePrecision = Optional.empty(); + } else { + this.updatedDatePrecision = Optional.of(updatedDatePrecision.get()); + } + return this; + } + /** *

The precision of the updated date.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1483,6 +1666,22 @@ public _FinalStage updatedDatePrecision(Optional updatedDatePrecision) { return this; } + /** + *

The date the article was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedDate(Nullable updatedDate) { + if (updatedDate.isNull()) { + this.updatedDate = null; + } else if (updatedDate.isEmpty()) { + this.updatedDate = Optional.empty(); + } else { + this.updatedDate = Optional.of(updatedDate.get()); + } + return this; + } + /** *

The date the article was last updated.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1548,7 +1747,23 @@ public _FinalStage publishedDate(Optional publishedDate) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage journalists(Journalists journalists) { + public _FinalStage journalists(Nullable journalists) { + if (journalists.isNull()) { + this.journalists = null; + } else if (journalists.isEmpty()) { + this.journalists = Optional.empty(); + } else { + this.journalists = Optional.of(journalists.get()); + } + return this; + } + + /** + *

A list of journalists associated with the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage journalists(ArticleEntityJournalists journalists) { this.journalists = Optional.ofNullable(journalists); return this; } @@ -1558,7 +1773,7 @@ public _FinalStage journalists(Journalists journalists) { */ @java.lang.Override @JsonSetter(value = "journalists", nulls = Nulls.SKIP) - public _FinalStage journalists(Optional journalists) { + public _FinalStage journalists(Optional journalists) { this.journalists = journalists; return this; } @@ -1568,7 +1783,7 @@ public _FinalStage journalists(Optional journalists) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage authors(Authors authors) { + public _FinalStage authors(ArticleEntityAuthors authors) { this.authors = Optional.ofNullable(authors); return this; } @@ -1578,7 +1793,7 @@ public _FinalStage authors(Authors authors) { */ @java.lang.Override @JsonSetter(value = "authors", nulls = Nulls.SKIP) - public _FinalStage authors(Optional authors) { + public _FinalStage authors(Optional authors) { this.authors = authors; return this; } @@ -1636,6 +1851,7 @@ public ArticleEntity build() { twitterAccount, allLinks, allDomainLinks, + allLinksData, nlp, id, score, @@ -1644,5 +1860,17 @@ public ArticleEntity build() { additionalDomainInfo, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/Journalists.java b/src/main/java/com/newscatcher/api/types/ArticleEntityAuthors.java similarity index 73% rename from src/main/java/com/newscatcher/api/types/Journalists.java rename to src/main/java/com/newscatcher/api/types/ArticleEntityAuthors.java index f16f31e..342306a 100644 --- a/src/main/java/com/newscatcher/api/types/Journalists.java +++ b/src/main/java/com/newscatcher/api/types/ArticleEntityAuthors.java @@ -15,13 +15,13 @@ import java.util.List; import java.util.Objects; -@JsonDeserialize(using = Journalists.Deserializer.class) -public final class Journalists { +@JsonDeserialize(using = ArticleEntityAuthors.Deserializer.class) +public final class ArticleEntityAuthors { private final Object value; private final int type; - private Journalists(Object value, int type) { + private ArticleEntityAuthors(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof Journalists && equalTo((Journalists) other); + return other instanceof ArticleEntityAuthors && equalTo((ArticleEntityAuthors) other); } - private boolean equalTo(Journalists other) { + private boolean equalTo(ArticleEntityAuthors other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static Journalists of(List value) { - return new Journalists(value, 0); + public static ArticleEntityAuthors of(List value) { + return new ArticleEntityAuthors(value, 0); } - public static Journalists of(String value) { - return new Journalists(value, 1); + public static ArticleEntityAuthors of(String value) { + return new ArticleEntityAuthors(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(String value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(Journalists.class); + super(ArticleEntityAuthors.class); } @java.lang.Override - public Journalists deserialize(JsonParser p, DeserializationContext context) throws IOException { + public ArticleEntityAuthors deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); diff --git a/src/main/java/com/newscatcher/api/types/Authors.java b/src/main/java/com/newscatcher/api/types/ArticleEntityJournalists.java similarity index 72% rename from src/main/java/com/newscatcher/api/types/Authors.java rename to src/main/java/com/newscatcher/api/types/ArticleEntityJournalists.java index 470a768..802f846 100644 --- a/src/main/java/com/newscatcher/api/types/Authors.java +++ b/src/main/java/com/newscatcher/api/types/ArticleEntityJournalists.java @@ -15,13 +15,13 @@ import java.util.List; import java.util.Objects; -@JsonDeserialize(using = Authors.Deserializer.class) -public final class Authors { +@JsonDeserialize(using = ArticleEntityJournalists.Deserializer.class) +public final class ArticleEntityJournalists { private final Object value; private final int type; - private Authors(Object value, int type) { + private ArticleEntityJournalists(Object value, int type) { this.value = value; this.type = type; } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof Authors && equalTo((Authors) other); + return other instanceof ArticleEntityJournalists && equalTo((ArticleEntityJournalists) other); } - private boolean equalTo(Authors other) { + private boolean equalTo(ArticleEntityJournalists other) { return value.equals(other.value); } @@ -61,12 +61,12 @@ public String toString() { return this.value.toString(); } - public static Authors of(List value) { - return new Authors(value, 0); + public static ArticleEntityJournalists of(List value) { + return new ArticleEntityJournalists(value, 0); } - public static Authors of(String value) { - return new Authors(value, 1); + public static ArticleEntityJournalists of(String value) { + return new ArticleEntityJournalists(value, 1); } public interface Visitor { @@ -75,13 +75,13 @@ public interface Visitor { T visit(String value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(Authors.class); + super(ArticleEntityJournalists.class); } @java.lang.Override - public Authors deserialize(JsonParser p, DeserializationContext context) throws IOException { + public ArticleEntityJournalists deserialize(JsonParser p, DeserializationContext context) throws IOException { Object value = p.readValueAs(Object.class); try { return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); diff --git a/src/main/java/com/newscatcher/api/types/BaseSearchResponseDto.java b/src/main/java/com/newscatcher/api/types/BaseSearchResponseDto.java index 1f2e8b0..634553c 100644 --- a/src/main/java/com/newscatcher/api/types/BaseSearchResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/BaseSearchResponseDto.java @@ -163,6 +163,10 @@ public interface PageSizeStage { public interface _FinalStage { BaseSearchResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -257,5 +261,17 @@ public _FinalStage pageSize(int pageSize) { public BaseSearchResponseDto build() { return new BaseSearchResponseDto(status, totalHits, page, totalPages, pageSize, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntity.java b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntity.java index c2cb9c8..27b6cdb 100644 --- a/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntity.java +++ b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntity.java @@ -5,12 +5,15 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.newscatcher.api.core.Nullable; +import com.newscatcher.api.core.NullableNonemptyFilter; import com.newscatcher.api.core.ObjectMappers; import java.util.HashMap; import java.util.Map; @@ -25,9 +28,9 @@ public final class BreakingNewsArticleEntity { private final Optional author; - private final Optional authors; + private final Optional authors; - private final Optional journalists; + private final Optional journalists; private final Optional publishedDate; @@ -65,7 +68,11 @@ public final class BreakingNewsArticleEntity { private final Optional description; - private final String content; + private final Optional content; + + private final Optional titleTranslatedEn; + + private final Optional contentTranslatedEn; private final Optional wordCount; @@ -83,15 +90,13 @@ public final class BreakingNewsArticleEntity { private final double score; - private final Optional robotsCompliant; - private final Map additionalProperties; private BreakingNewsArticleEntity( String title, Optional author, - Optional authors, - Optional journalists, + Optional authors, + Optional journalists, Optional publishedDate, Optional publishedDatePrecision, Optional updatedDate, @@ -110,7 +115,9 @@ private BreakingNewsArticleEntity( Optional media, Optional language, Optional description, - String content, + Optional content, + Optional titleTranslatedEn, + Optional contentTranslatedEn, Optional wordCount, Optional isOpinion, Optional twitterAccount, @@ -119,7 +126,6 @@ private BreakingNewsArticleEntity( Optional nlp, String id, double score, - Optional robotsCompliant, Map additionalProperties) { this.title = title; this.author = author; @@ -144,6 +150,8 @@ private BreakingNewsArticleEntity( this.language = language; this.description = description; this.content = content; + this.titleTranslatedEn = titleTranslatedEn; + this.contentTranslatedEn = contentTranslatedEn; this.wordCount = wordCount; this.isOpinion = isOpinion; this.twitterAccount = twitterAccount; @@ -152,7 +160,6 @@ private BreakingNewsArticleEntity( this.nlp = nlp; this.id = id; this.score = score; - this.robotsCompliant = robotsCompliant; this.additionalProperties = additionalProperties; } @@ -176,15 +183,18 @@ public Optional getAuthor() { * @return A list of authors of the article. */ @JsonProperty("authors") - public Optional getAuthors() { + public Optional getAuthors() { return authors; } /** * @return A list of journalists associated with the article. */ - @JsonProperty("journalists") - public Optional getJournalists() { + @JsonIgnore + public Optional getJournalists() { + if (journalists == null) { + return Optional.empty(); + } return journalists; } @@ -207,24 +217,33 @@ public Optional getPublishedDatePrecision() { /** * @return The date the article was last updated. */ - @JsonProperty("updated_date") + @JsonIgnore public Optional getUpdatedDate() { + if (updatedDate == null) { + return Optional.empty(); + } return updatedDate; } /** * @return The precision of the updated date. */ - @JsonProperty("updated_date_precision") + @JsonIgnore public Optional getUpdatedDatePrecision() { + if (updatedDatePrecision == null) { + return Optional.empty(); + } return updatedDatePrecision; } /** * @return The date the article was parsed. */ - @JsonProperty("parse_date") + @JsonIgnore public Optional getParseDate() { + if (parseDate == null) { + return Optional.empty(); + } return parseDate; } @@ -269,7 +288,7 @@ public Optional getIsHeadline() { } /** - * @return Indicates if the article is paid content. + * @return Indicates whether the source labels the article as paywalled or requiring a subscription for full access. */ @JsonProperty("paid_content") public Optional getPaidContent() { @@ -336,10 +355,32 @@ public Optional getDescription() { * @return The content of the article. */ @JsonProperty("content") - public String getContent() { + public Optional getContent() { return content; } + /** + * @return English translation of the article title. Available when setting the include_translation_fields parameter to true. + */ + @JsonIgnore + public Optional getTitleTranslatedEn() { + if (titleTranslatedEn == null) { + return Optional.empty(); + } + return titleTranslatedEn; + } + + /** + * @return English translation of the article content. Available when setting the include_translation_fields parameter to true. + */ + @JsonIgnore + public Optional getContentTranslatedEn() { + if (contentTranslatedEn == null) { + return Optional.empty(); + } + return contentTranslatedEn; + } + /** * @return The word count of the article. */ @@ -359,8 +400,11 @@ public Optional getIsOpinion() { /** * @return The Twitter account associated with the article. */ - @JsonProperty("twitter_account") + @JsonIgnore public Optional getTwitterAccount() { + if (twitterAccount == null) { + return Optional.empty(); + } return twitterAccount; } @@ -401,12 +445,46 @@ public double getScore() { return score; } - /** - * @return True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise. - */ - @JsonProperty("robots_compliant") - public Optional getRobotsCompliant() { - return robotsCompliant; + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("journalists") + private Optional _getJournalists() { + return journalists; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("updated_date") + private Optional _getUpdatedDate() { + return updatedDate; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("updated_date_precision") + private Optional _getUpdatedDatePrecision() { + return updatedDatePrecision; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("parse_date") + private Optional _getParseDate() { + return parseDate; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("title_translated_en") + private Optional _getTitleTranslatedEn() { + return titleTranslatedEn; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("content_translated_en") + private Optional _getContentTranslatedEn() { + return contentTranslatedEn; + } + + @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NullableNonemptyFilter.class) + @JsonProperty("twitter_account") + private Optional _getTwitterAccount() { + return twitterAccount; } @java.lang.Override @@ -444,6 +522,8 @@ private boolean equalTo(BreakingNewsArticleEntity other) { && language.equals(other.language) && description.equals(other.description) && content.equals(other.content) + && titleTranslatedEn.equals(other.titleTranslatedEn) + && contentTranslatedEn.equals(other.contentTranslatedEn) && wordCount.equals(other.wordCount) && isOpinion.equals(other.isOpinion) && twitterAccount.equals(other.twitterAccount) @@ -451,8 +531,7 @@ private boolean equalTo(BreakingNewsArticleEntity other) { && allDomainLinks.equals(other.allDomainLinks) && nlp.equals(other.nlp) && id.equals(other.id) - && score == other.score - && robotsCompliant.equals(other.robotsCompliant); + && score == other.score; } @java.lang.Override @@ -481,6 +560,8 @@ public int hashCode() { this.language, this.description, this.content, + this.titleTranslatedEn, + this.contentTranslatedEn, this.wordCount, this.isOpinion, this.twitterAccount, @@ -488,8 +569,7 @@ public int hashCode() { this.allDomainLinks, this.nlp, this.id, - this.score, - this.robotsCompliant); + this.score); } @java.lang.Override @@ -542,14 +622,7 @@ public interface RankStage { /** *

The rank of the article's source.

*/ - ContentStage rank(int rank); - } - - public interface ContentStage { - /** - *

The content of the article.

- */ - IdStage content(@NotNull String content); + IdStage rank(int rank); } public interface IdStage { @@ -569,6 +642,10 @@ public interface ScoreStage { public interface _FinalStage { BreakingNewsArticleEntity build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

The primary author of the article.

*/ @@ -579,16 +656,18 @@ public interface _FinalStage { /** *

A list of authors of the article.

*/ - _FinalStage authors(Optional authors); + _FinalStage authors(Optional authors); - _FinalStage authors(Authors authors); + _FinalStage authors(BreakingNewsArticleEntityAuthors authors); /** *

A list of journalists associated with the article.

*/ - _FinalStage journalists(Optional journalists); + _FinalStage journalists(Optional journalists); - _FinalStage journalists(Journalists journalists); + _FinalStage journalists(BreakingNewsArticleEntityJournalists journalists); + + _FinalStage journalists(Nullable journalists); /** *

The date the article was published.

@@ -611,6 +690,8 @@ public interface _FinalStage { _FinalStage updatedDate(String updatedDate); + _FinalStage updatedDate(Nullable updatedDate); + /** *

The precision of the updated date.

*/ @@ -618,6 +699,8 @@ public interface _FinalStage { _FinalStage updatedDatePrecision(String updatedDatePrecision); + _FinalStage updatedDatePrecision(Nullable updatedDatePrecision); + /** *

The date the article was parsed.

*/ @@ -625,6 +708,8 @@ public interface _FinalStage { _FinalStage parseDate(String parseDate); + _FinalStage parseDate(Nullable parseDate); + /** *

The name of the source where the article was published.

*/ @@ -640,7 +725,7 @@ public interface _FinalStage { _FinalStage isHeadline(Boolean isHeadline); /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

*/ _FinalStage paidContent(Optional paidContent); @@ -681,6 +766,31 @@ public interface _FinalStage { _FinalStage description(String description); + /** + *

The content of the article.

+ */ + _FinalStage content(Optional content); + + _FinalStage content(String content); + + /** + *

English translation of the article title. Available when setting the include_translation_fields parameter to true.

+ */ + _FinalStage titleTranslatedEn(Optional titleTranslatedEn); + + _FinalStage titleTranslatedEn(String titleTranslatedEn); + + _FinalStage titleTranslatedEn(Nullable titleTranslatedEn); + + /** + *

English translation of the article content. Available when setting the include_translation_fields parameter to true.

+ */ + _FinalStage contentTranslatedEn(Optional contentTranslatedEn); + + _FinalStage contentTranslatedEn(String contentTranslatedEn); + + _FinalStage contentTranslatedEn(Nullable contentTranslatedEn); + /** *

The word count of the article.

*/ @@ -702,6 +812,8 @@ public interface _FinalStage { _FinalStage twitterAccount(String twitterAccount); + _FinalStage twitterAccount(Nullable twitterAccount); + /** *

A list of all URLs mentioned in the article.

*/ @@ -719,13 +831,6 @@ public interface _FinalStage { _FinalStage nlp(Optional nlp); _FinalStage nlp(NlpDataEntity nlp); - - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- */ - _FinalStage robotsCompliant(Optional robotsCompliant); - - _FinalStage robotsCompliant(Boolean robotsCompliant); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -736,7 +841,6 @@ public static final class Builder FullDomainUrlStage, ParentUrlStage, RankStage, - ContentStage, IdStage, ScoreStage, _FinalStage { @@ -752,14 +856,10 @@ public static final class Builder private int rank; - private String content; - private String id; private double score; - private Optional robotsCompliant = Optional.empty(); - private Optional nlp = Optional.empty(); private Optional allDomainLinks = Optional.empty(); @@ -772,6 +872,12 @@ public static final class Builder private Optional wordCount = Optional.empty(); + private Optional contentTranslatedEn = Optional.empty(); + + private Optional titleTranslatedEn = Optional.empty(); + + private Optional content = Optional.empty(); + private Optional description = Optional.empty(); private Optional language = Optional.empty(); @@ -798,9 +904,9 @@ public static final class Builder private Optional publishedDate = Optional.empty(); - private Optional journalists = Optional.empty(); + private Optional journalists = Optional.empty(); - private Optional authors = Optional.empty(); + private Optional authors = Optional.empty(); private Optional author = Optional.empty(); @@ -834,6 +940,8 @@ public Builder from(BreakingNewsArticleEntity other) { language(other.getLanguage()); description(other.getDescription()); content(other.getContent()); + titleTranslatedEn(other.getTitleTranslatedEn()); + contentTranslatedEn(other.getContentTranslatedEn()); wordCount(other.getWordCount()); isOpinion(other.getIsOpinion()); twitterAccount(other.getTwitterAccount()); @@ -842,7 +950,6 @@ public Builder from(BreakingNewsArticleEntity other) { nlp(other.getNlp()); id(other.getId()); score(other.getScore()); - robotsCompliant(other.getRobotsCompliant()); return this; } @@ -913,23 +1020,11 @@ public RankStage parentUrl(@NotNull String parentUrl) { */ @java.lang.Override @JsonSetter("rank") - public ContentStage rank(int rank) { + public IdStage rank(int rank) { this.rank = rank; return this; } - /** - *

The content of the article.

- *

The content of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public IdStage content(@NotNull String content) { - this.content = Objects.requireNonNull(content, "content must not be null"); - return this; - } - /** *

The unique identifier for the article.

*

The unique identifier for the article.

@@ -954,26 +1049,6 @@ public _FinalStage score(double score) { return this; } - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- */ - @java.lang.Override - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public _FinalStage robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - @java.lang.Override public _FinalStage nlp(NlpDataEntity nlp) { this.nlp = Optional.ofNullable(nlp); @@ -1027,6 +1102,22 @@ public _FinalStage allLinks(Optional allLinks return this; } + /** + *

The Twitter account associated with the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage twitterAccount(Nullable twitterAccount) { + if (twitterAccount.isNull()) { + this.twitterAccount = null; + } else if (twitterAccount.isEmpty()) { + this.twitterAccount = Optional.empty(); + } else { + this.twitterAccount = Optional.of(twitterAccount.get()); + } + return this; + } + /** *

The Twitter account associated with the article.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1087,6 +1178,98 @@ public _FinalStage wordCount(Optional wordCount) { return this; } + /** + *

English translation of the article content. Available when setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage contentTranslatedEn(Nullable contentTranslatedEn) { + if (contentTranslatedEn.isNull()) { + this.contentTranslatedEn = null; + } else if (contentTranslatedEn.isEmpty()) { + this.contentTranslatedEn = Optional.empty(); + } else { + this.contentTranslatedEn = Optional.of(contentTranslatedEn.get()); + } + return this; + } + + /** + *

English translation of the article content. Available when setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage contentTranslatedEn(String contentTranslatedEn) { + this.contentTranslatedEn = Optional.ofNullable(contentTranslatedEn); + return this; + } + + /** + *

English translation of the article content. Available when setting the include_translation_fields parameter to true.

+ */ + @java.lang.Override + @JsonSetter(value = "content_translated_en", nulls = Nulls.SKIP) + public _FinalStage contentTranslatedEn(Optional contentTranslatedEn) { + this.contentTranslatedEn = contentTranslatedEn; + return this; + } + + /** + *

English translation of the article title. Available when setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage titleTranslatedEn(Nullable titleTranslatedEn) { + if (titleTranslatedEn.isNull()) { + this.titleTranslatedEn = null; + } else if (titleTranslatedEn.isEmpty()) { + this.titleTranslatedEn = Optional.empty(); + } else { + this.titleTranslatedEn = Optional.of(titleTranslatedEn.get()); + } + return this; + } + + /** + *

English translation of the article title. Available when setting the include_translation_fields parameter to true.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage titleTranslatedEn(String titleTranslatedEn) { + this.titleTranslatedEn = Optional.ofNullable(titleTranslatedEn); + return this; + } + + /** + *

English translation of the article title. Available when setting the include_translation_fields parameter to true.

+ */ + @java.lang.Override + @JsonSetter(value = "title_translated_en", nulls = Nulls.SKIP) + public _FinalStage titleTranslatedEn(Optional titleTranslatedEn) { + this.titleTranslatedEn = titleTranslatedEn; + return this; + } + + /** + *

The content of the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage content(String content) { + this.content = Optional.ofNullable(content); + return this; + } + + /** + *

The content of the article.

+ */ + @java.lang.Override + @JsonSetter(value = "content", nulls = Nulls.SKIP) + public _FinalStage content(Optional content) { + this.content = content; + return this; + } + /** *

A brief description of the article.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1188,7 +1371,7 @@ public _FinalStage country(Optional country) { } /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

* @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override @@ -1198,7 +1381,7 @@ public _FinalStage paidContent(Boolean paidContent) { } /** - *

Indicates if the article is paid content.

+ *

Indicates whether the source labels the article as paywalled or requiring a subscription for full access.

*/ @java.lang.Override @JsonSetter(value = "paid_content", nulls = Nulls.SKIP) @@ -1247,6 +1430,22 @@ public _FinalStage nameSource(Optional nameSource) { return this; } + /** + *

The date the article was parsed.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage parseDate(Nullable parseDate) { + if (parseDate.isNull()) { + this.parseDate = null; + } else if (parseDate.isEmpty()) { + this.parseDate = Optional.empty(); + } else { + this.parseDate = Optional.of(parseDate.get()); + } + return this; + } + /** *

The date the article was parsed.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1267,6 +1466,22 @@ public _FinalStage parseDate(Optional parseDate) { return this; } + /** + *

The precision of the updated date.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedDatePrecision(Nullable updatedDatePrecision) { + if (updatedDatePrecision.isNull()) { + this.updatedDatePrecision = null; + } else if (updatedDatePrecision.isEmpty()) { + this.updatedDatePrecision = Optional.empty(); + } else { + this.updatedDatePrecision = Optional.of(updatedDatePrecision.get()); + } + return this; + } + /** *

The precision of the updated date.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1287,6 +1502,22 @@ public _FinalStage updatedDatePrecision(Optional updatedDatePrecision) { return this; } + /** + *

The date the article was last updated.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage updatedDate(Nullable updatedDate) { + if (updatedDate.isNull()) { + this.updatedDate = null; + } else if (updatedDate.isEmpty()) { + this.updatedDate = Optional.empty(); + } else { + this.updatedDate = Optional.of(updatedDate.get()); + } + return this; + } + /** *

The date the article was last updated.

* @return Reference to {@code this} so that method calls can be chained together. @@ -1352,7 +1583,23 @@ public _FinalStage publishedDate(Optional publishedDate) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage journalists(Journalists journalists) { + public _FinalStage journalists(Nullable journalists) { + if (journalists.isNull()) { + this.journalists = null; + } else if (journalists.isEmpty()) { + this.journalists = Optional.empty(); + } else { + this.journalists = Optional.of(journalists.get()); + } + return this; + } + + /** + *

A list of journalists associated with the article.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage journalists(BreakingNewsArticleEntityJournalists journalists) { this.journalists = Optional.ofNullable(journalists); return this; } @@ -1362,7 +1609,7 @@ public _FinalStage journalists(Journalists journalists) { */ @java.lang.Override @JsonSetter(value = "journalists", nulls = Nulls.SKIP) - public _FinalStage journalists(Optional journalists) { + public _FinalStage journalists(Optional journalists) { this.journalists = journalists; return this; } @@ -1372,7 +1619,7 @@ public _FinalStage journalists(Optional journalists) { * @return Reference to {@code this} so that method calls can be chained together. */ @java.lang.Override - public _FinalStage authors(Authors authors) { + public _FinalStage authors(BreakingNewsArticleEntityAuthors authors) { this.authors = Optional.ofNullable(authors); return this; } @@ -1382,7 +1629,7 @@ public _FinalStage authors(Authors authors) { */ @java.lang.Override @JsonSetter(value = "authors", nulls = Nulls.SKIP) - public _FinalStage authors(Optional authors) { + public _FinalStage authors(Optional authors) { this.authors = authors; return this; } @@ -1433,6 +1680,8 @@ public BreakingNewsArticleEntity build() { language, description, content, + titleTranslatedEn, + contentTranslatedEn, wordCount, isOpinion, twitterAccount, @@ -1441,8 +1690,19 @@ public BreakingNewsArticleEntity build() { nlp, id, score, - robotsCompliant, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/NotTheme.java b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityAuthors.java similarity index 70% rename from src/main/java/com/newscatcher/api/types/NotTheme.java rename to src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityAuthors.java index 0427b6d..88282ea 100644 --- a/src/main/java/com/newscatcher/api/types/NotTheme.java +++ b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityAuthors.java @@ -15,13 +15,13 @@ import java.util.List; import java.util.Objects; -@JsonDeserialize(using = NotTheme.Deserializer.class) -public final class NotTheme { +@JsonDeserialize(using = BreakingNewsArticleEntityAuthors.Deserializer.class) +public final class BreakingNewsArticleEntityAuthors { private final Object value; private final int type; - private NotTheme(Object value, int type) { + private BreakingNewsArticleEntityAuthors(Object value, int type) { this.value = value; this.type = type; } @@ -34,9 +34,9 @@ public Object get() { @SuppressWarnings("unchecked") public T visit(Visitor visitor) { if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { return visitor.visit((List) this.value); + } else if (this.type == 1) { + return visitor.visit((String) this.value); } throw new IllegalStateException("Failed to visit value. This should never happen."); } @@ -44,10 +44,10 @@ public T visit(Visitor visitor) { @java.lang.Override public boolean equals(Object other) { if (this == other) return true; - return other instanceof NotTheme && equalTo((NotTheme) other); + return other instanceof BreakingNewsArticleEntityAuthors && equalTo((BreakingNewsArticleEntityAuthors) other); } - private boolean equalTo(NotTheme other) { + private boolean equalTo(BreakingNewsArticleEntityAuthors other) { return value.equals(other.value); } @@ -61,34 +61,35 @@ public String toString() { return this.value.toString(); } - public static NotTheme of(String value) { - return new NotTheme(value, 0); + public static BreakingNewsArticleEntityAuthors of(List value) { + return new BreakingNewsArticleEntityAuthors(value, 0); } - public static NotTheme of(List value) { - return new NotTheme(value, 1); + public static BreakingNewsArticleEntityAuthors of(String value) { + return new BreakingNewsArticleEntityAuthors(value, 1); } public interface Visitor { - T visit(String value); - T visit(List value); + + T visit(String value); } - static final class Deserializer extends StdDeserializer { + static final class Deserializer extends StdDeserializer { Deserializer() { - super(NotTheme.class); + super(BreakingNewsArticleEntityAuthors.class); } @java.lang.Override - public NotTheme deserialize(JsonParser p, DeserializationContext context) throws IOException { + public BreakingNewsArticleEntityAuthors deserialize(JsonParser p, DeserializationContext context) + throws IOException { Object value = p.readValueAs(Object.class); try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); } catch (RuntimeException e) { } try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); } catch (RuntimeException e) { } throw new JsonParseException(p, "Failed to deserialize"); diff --git a/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityJournalists.java b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityJournalists.java new file mode 100644 index 0000000..668c292 --- /dev/null +++ b/src/main/java/com/newscatcher/api/types/BreakingNewsArticleEntityJournalists.java @@ -0,0 +1,99 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.newscatcher.api.types; + +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.newscatcher.api.core.ObjectMappers; +import java.io.IOException; +import java.util.List; +import java.util.Objects; + +@JsonDeserialize(using = BreakingNewsArticleEntityJournalists.Deserializer.class) +public final class BreakingNewsArticleEntityJournalists { + private final Object value; + + private final int type; + + private BreakingNewsArticleEntityJournalists(Object value, int type) { + this.value = value; + this.type = type; + } + + @JsonValue + public Object get() { + return this.value; + } + + @SuppressWarnings("unchecked") + public T visit(Visitor visitor) { + if (this.type == 0) { + return visitor.visit((List) this.value); + } else if (this.type == 1) { + return visitor.visit((String) this.value); + } + throw new IllegalStateException("Failed to visit value. This should never happen."); + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof BreakingNewsArticleEntityJournalists + && equalTo((BreakingNewsArticleEntityJournalists) other); + } + + private boolean equalTo(BreakingNewsArticleEntityJournalists other) { + return value.equals(other.value); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.value); + } + + @java.lang.Override + public String toString() { + return this.value.toString(); + } + + public static BreakingNewsArticleEntityJournalists of(List value) { + return new BreakingNewsArticleEntityJournalists(value, 0); + } + + public static BreakingNewsArticleEntityJournalists of(String value) { + return new BreakingNewsArticleEntityJournalists(value, 1); + } + + public interface Visitor { + T visit(List value); + + T visit(String value); + } + + static final class Deserializer extends StdDeserializer { + Deserializer() { + super(BreakingNewsArticleEntityJournalists.class); + } + + @java.lang.Override + public BreakingNewsArticleEntityJournalists deserialize(JsonParser p, DeserializationContext context) + throws IOException { + Object value = p.readValueAs(Object.class); + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); + } catch (RuntimeException e) { + } + try { + return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); + } catch (RuntimeException e) { + } + throw new JsonParseException(p, "Failed to deserialize"); + } + } +} diff --git a/src/main/java/com/newscatcher/api/types/BreakingNewsEventEntity.java b/src/main/java/com/newscatcher/api/types/BreakingNewsEventEntity.java index 40f0d11..595c78b 100644 --- a/src/main/java/com/newscatcher/api/types/BreakingNewsEventEntity.java +++ b/src/main/java/com/newscatcher/api/types/BreakingNewsEventEntity.java @@ -113,6 +113,10 @@ public interface ArticlesCountStage { public interface _FinalStage { BreakingNewsEventEntity build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

The articles associated with this breaking news event.

*/ @@ -174,7 +178,9 @@ public _FinalStage articlesCount(int articlesCount) { */ @java.lang.Override public _FinalStage addAllArticles(List articles) { - this.articles.addAll(articles); + if (articles != null) { + this.articles.addAll(articles); + } return this; } @@ -195,7 +201,9 @@ public _FinalStage addArticles(BreakingNewsArticleEntity articles) { @JsonSetter(value = "articles", nulls = Nulls.SKIP) public _FinalStage articles(List articles) { this.articles.clear(); - this.articles.addAll(articles); + if (articles != null) { + this.articles.addAll(articles); + } return this; } @@ -203,5 +211,17 @@ public _FinalStage articles(List articles) { public BreakingNewsEventEntity build() { return new BreakingNewsEventEntity(eventId, articlesCount, articles, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/BreakingNewsResponseDto.java b/src/main/java/com/newscatcher/api/types/BreakingNewsResponseDto.java index 97c7c1b..27ca1b8 100644 --- a/src/main/java/com/newscatcher/api/types/BreakingNewsResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/BreakingNewsResponseDto.java @@ -197,6 +197,10 @@ public interface PageSizeStage { public interface _FinalStage { BreakingNewsResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

A list of breaking news events, each containing relevant articles.

*/ @@ -341,5 +345,17 @@ public BreakingNewsResponseDto build() { return new BreakingNewsResponseDto( status, totalHits, page, totalPages, pageSize, breakingNewsEvents, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/ClusterEntity.java b/src/main/java/com/newscatcher/api/types/ClusterEntity.java index 7a85aab..a647b16 100644 --- a/src/main/java/com/newscatcher/api/types/ClusterEntity.java +++ b/src/main/java/com/newscatcher/api/types/ClusterEntity.java @@ -110,6 +110,10 @@ public interface ClusterSizeStage { public interface _FinalStage { ClusterEntity build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

A list of articles in the cluster.

*/ @@ -171,7 +175,9 @@ public _FinalStage clusterSize(int clusterSize) { */ @java.lang.Override public _FinalStage addAllArticles(List articles) { - this.articles.addAll(articles); + if (articles != null) { + this.articles.addAll(articles); + } return this; } @@ -192,7 +198,9 @@ public _FinalStage addArticles(ArticleEntity articles) { @JsonSetter(value = "articles", nulls = Nulls.SKIP) public _FinalStage articles(List articles) { this.articles.clear(); - this.articles.addAll(articles); + if (articles != null) { + this.articles.addAll(articles); + } return this; } @@ -200,5 +208,17 @@ public _FinalStage articles(List articles) { public ClusterEntity build() { return new ClusterEntity(clusterId, clusterSize, articles, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/ClusteredArticlesDto.java b/src/main/java/com/newscatcher/api/types/ClusteredArticlesDto.java index 9b8bdea..a3c40d2 100644 --- a/src/main/java/com/newscatcher/api/types/ClusteredArticlesDto.java +++ b/src/main/java/com/newscatcher/api/types/ClusteredArticlesDto.java @@ -93,6 +93,10 @@ public interface ClustersCountStage { public interface _FinalStage { ClusteredArticlesDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

A list of clusters found in the search results.

*/ @@ -139,7 +143,9 @@ public _FinalStage clustersCount(int clustersCount) { */ @java.lang.Override public _FinalStage addAllClusters(List clusters) { - this.clusters.addAll(clusters); + if (clusters != null) { + this.clusters.addAll(clusters); + } return this; } @@ -160,7 +166,9 @@ public _FinalStage addClusters(ClusterEntity clusters) { @JsonSetter(value = "clusters", nulls = Nulls.SKIP) public _FinalStage clusters(List clusters) { this.clusters.clear(); - this.clusters.addAll(clusters); + if (clusters != null) { + this.clusters.addAll(clusters); + } return this; } @@ -168,5 +176,17 @@ public _FinalStage clusters(List clusters) { public ClusteredArticlesDto build() { return new ClusteredArticlesDto(clustersCount, clusters, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/ClusteredSearchResponseDto.java b/src/main/java/com/newscatcher/api/types/ClusteredSearchResponseDto.java index 97c8a8e..3bae523 100644 --- a/src/main/java/com/newscatcher/api/types/ClusteredSearchResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/ClusteredSearchResponseDto.java @@ -221,6 +221,10 @@ public interface ClustersCountStage { public interface _FinalStage { ClusteredSearchResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

A list of clusters found in the search results.

*/ @@ -369,7 +373,9 @@ public _FinalStage userInput(Optional> userInput) { */ @java.lang.Override public _FinalStage addAllClusters(List clusters) { - this.clusters.addAll(clusters); + if (clusters != null) { + this.clusters.addAll(clusters); + } return this; } @@ -390,7 +396,9 @@ public _FinalStage addClusters(ClusterEntity clusters) { @JsonSetter(value = "clusters", nulls = Nulls.SKIP) public _FinalStage clusters(List clusters) { this.clusters.clear(); - this.clusters.addAll(clusters); + if (clusters != null) { + this.clusters.addAll(clusters); + } return this; } @@ -407,5 +415,17 @@ public ClusteredSearchResponseDto build() { userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/ClusteringVariable.java b/src/main/java/com/newscatcher/api/types/ClusteringVariable.java index ceb1d77..6e6cb9d 100644 --- a/src/main/java/com/newscatcher/api/types/ClusteringVariable.java +++ b/src/main/java/com/newscatcher/api/types/ClusteringVariable.java @@ -3,24 +3,91 @@ */ package com.newscatcher.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum ClusteringVariable { - CONTENT("content"), +public final class ClusteringVariable { + public static final ClusteringVariable CONTENT = new ClusteringVariable(Value.CONTENT, "content"); - TITLE("title"), + public static final ClusteringVariable TITLE = new ClusteringVariable(Value.TITLE, "title"); - SUMMARY("summary"); + public static final ClusteringVariable SUMMARY = new ClusteringVariable(Value.SUMMARY, "summary"); - private final String value; + private final Value value; - ClusteringVariable(String value) { + private final String string; + + ClusteringVariable(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof ClusteringVariable && this.string.equals(((ClusteringVariable) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case CONTENT: + return visitor.visitContent(); + case TITLE: + return visitor.visitTitle(); + case SUMMARY: + return visitor.visitSummary(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static ClusteringVariable valueOf(String value) { + switch (value) { + case "content": + return CONTENT; + case "title": + return TITLE; + case "summary": + return SUMMARY; + default: + return new ClusteringVariable(Value.UNKNOWN, value); + } + } + + public enum Value { + CONTENT, + + TITLE, + + SUMMARY, + + UNKNOWN + } + + public interface Visitor { + T visitContent(); + + T visitTitle(); + + T visitSummary(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/newscatcher/api/types/Error.java b/src/main/java/com/newscatcher/api/types/Error.java index 31b066e..0681e39 100644 --- a/src/main/java/com/newscatcher/api/types/Error.java +++ b/src/main/java/com/newscatcher/api/types/Error.java @@ -112,6 +112,10 @@ public interface StatusStage { public interface _FinalStage { Error build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -175,5 +179,17 @@ public _FinalStage status(@NotNull String status) { public Error build() { return new Error(message, statusCode, status, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/FailedAggregationCountResponseDto.java b/src/main/java/com/newscatcher/api/types/FailedAggregationCountResponseDto.java index 8f0ab97..f9aa009 100644 --- a/src/main/java/com/newscatcher/api/types/FailedAggregationCountResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/FailedAggregationCountResponseDto.java @@ -176,6 +176,10 @@ public interface PageSizeStage { public interface _FinalStage { FailedAggregationCountResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + _FinalStage userInput(Optional> userInput); _FinalStage userInput(Map userInput); @@ -290,5 +294,17 @@ public FailedAggregationCountResponseDto build() { return new FailedAggregationCountResponseDto( status, totalHits, page, totalPages, pageSize, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/FailedAuthorsResponseDto.java b/src/main/java/com/newscatcher/api/types/FailedAuthorsResponseDto.java index a913ffb..29ebf63 100644 --- a/src/main/java/com/newscatcher/api/types/FailedAuthorsResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/FailedAuthorsResponseDto.java @@ -191,6 +191,10 @@ public interface PageSizeStage { public interface _FinalStage { FailedAuthorsResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

An empty list of articles, as no matches were found.

*/ @@ -335,5 +339,17 @@ public FailedAuthorsResponseDto build() { return new FailedAuthorsResponseDto( status, totalHits, page, totalPages, pageSize, articles, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/FailedSearchSimilarResponseDto.java b/src/main/java/com/newscatcher/api/types/FailedSearchSimilarResponseDto.java deleted file mode 100644 index e695976..0000000 --- a/src/main/java/com/newscatcher/api/types/FailedSearchSimilarResponseDto.java +++ /dev/null @@ -1,339 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = FailedSearchSimilarResponseDto.Builder.class) -public final class FailedSearchSimilarResponseDto implements IBaseSearchResponseDto { - private final String status; - - private final int totalHits; - - private final int page; - - private final int totalPages; - - private final int pageSize; - - private final Optional>> articles; - - private final Optional> userInput; - - private final Map additionalProperties; - - private FailedSearchSimilarResponseDto( - String status, - int totalHits, - int page, - int totalPages, - int pageSize, - Optional>> articles, - Optional> userInput, - Map additionalProperties) { - this.status = status; - this.totalHits = totalHits; - this.page = page; - this.totalPages = totalPages; - this.pageSize = pageSize; - this.articles = articles; - this.userInput = userInput; - this.additionalProperties = additionalProperties; - } - - /** - * @return The status of the response. - */ - @JsonProperty("status") - @java.lang.Override - public String getStatus() { - return status; - } - - /** - * @return The total number of articles matching the search criteria. - */ - @JsonProperty("total_hits") - @java.lang.Override - public int getTotalHits() { - return totalHits; - } - - /** - * @return The current page number of the results. - */ - @JsonProperty("page") - @java.lang.Override - public int getPage() { - return page; - } - - /** - * @return The total number of pages available for the given search criteria. - */ - @JsonProperty("total_pages") - @java.lang.Override - public int getTotalPages() { - return totalPages; - } - - /** - * @return The number of articles per page. - */ - @JsonProperty("page_size") - @java.lang.Override - public int getPageSize() { - return pageSize; - } - - /** - * @return An empty list of articles, as no matches were found. - */ - @JsonProperty("articles") - public Optional>> getArticles() { - return articles; - } - - @JsonProperty("user_input") - public Optional> getUserInput() { - return userInput; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof FailedSearchSimilarResponseDto && equalTo((FailedSearchSimilarResponseDto) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(FailedSearchSimilarResponseDto other) { - return status.equals(other.status) - && totalHits == other.totalHits - && page == other.page - && totalPages == other.totalPages - && pageSize == other.pageSize - && articles.equals(other.articles) - && userInput.equals(other.userInput); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.status, this.totalHits, this.page, this.totalPages, this.pageSize, this.articles, this.userInput); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - /** - *

The status of the response.

- */ - TotalHitsStage status(@NotNull String status); - - Builder from(FailedSearchSimilarResponseDto other); - } - - public interface TotalHitsStage { - /** - *

The total number of articles matching the search criteria.

- */ - PageStage totalHits(int totalHits); - } - - public interface PageStage { - /** - *

The current page number of the results.

- */ - TotalPagesStage page(int page); - } - - public interface TotalPagesStage { - /** - *

The total number of pages available for the given search criteria.

- */ - PageSizeStage totalPages(int totalPages); - } - - public interface PageSizeStage { - /** - *

The number of articles per page.

- */ - _FinalStage pageSize(int pageSize); - } - - public interface _FinalStage { - FailedSearchSimilarResponseDto build(); - - /** - *

An empty list of articles, as no matches were found.

- */ - _FinalStage articles(Optional>> articles); - - _FinalStage articles(List> articles); - - _FinalStage userInput(Optional> userInput); - - _FinalStage userInput(Map userInput); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements StatusStage, TotalHitsStage, PageStage, TotalPagesStage, PageSizeStage, _FinalStage { - private String status; - - private int totalHits; - - private int page; - - private int totalPages; - - private int pageSize; - - private Optional> userInput = Optional.empty(); - - private Optional>> articles = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(FailedSearchSimilarResponseDto other) { - status(other.getStatus()); - totalHits(other.getTotalHits()); - page(other.getPage()); - totalPages(other.getTotalPages()); - pageSize(other.getPageSize()); - articles(other.getArticles()); - userInput(other.getUserInput()); - return this; - } - - /** - *

The status of the response.

- *

The status of the response.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("status") - public TotalHitsStage status(@NotNull String status) { - this.status = Objects.requireNonNull(status, "status must not be null"); - return this; - } - - /** - *

The total number of articles matching the search criteria.

- *

The total number of articles matching the search criteria.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("total_hits") - public PageStage totalHits(int totalHits) { - this.totalHits = totalHits; - return this; - } - - /** - *

The current page number of the results.

- *

The current page number of the results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("page") - public TotalPagesStage page(int page) { - this.page = page; - return this; - } - - /** - *

The total number of pages available for the given search criteria.

- *

The total number of pages available for the given search criteria.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("total_pages") - public PageSizeStage totalPages(int totalPages) { - this.totalPages = totalPages; - return this; - } - - /** - *

The number of articles per page.

- *

The number of articles per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("page_size") - public _FinalStage pageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @java.lang.Override - public _FinalStage userInput(Map userInput) { - this.userInput = Optional.ofNullable(userInput); - return this; - } - - @java.lang.Override - @JsonSetter(value = "user_input", nulls = Nulls.SKIP) - public _FinalStage userInput(Optional> userInput) { - this.userInput = userInput; - return this; - } - - /** - *

An empty list of articles, as no matches were found.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage articles(List> articles) { - this.articles = Optional.ofNullable(articles); - return this; - } - - /** - *

An empty list of articles, as no matches were found.

- */ - @java.lang.Override - @JsonSetter(value = "articles", nulls = Nulls.SKIP) - public _FinalStage articles(Optional>> articles) { - this.articles = articles; - return this; - } - - @java.lang.Override - public FailedSearchSimilarResponseDto build() { - return new FailedSearchSimilarResponseDto( - status, totalHits, page, totalPages, pageSize, articles, userInput, additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/types/IArticleEntity.java b/src/main/java/com/newscatcher/api/types/IArticleEntity.java deleted file mode 100644 index f147c20..0000000 --- a/src/main/java/com/newscatcher/api/types/IArticleEntity.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import java.util.List; -import java.util.Map; -import java.util.Optional; - -public interface IArticleEntity { - String getTitle(); - - Optional getAuthor(); - - Optional getAuthors(); - - Optional getJournalists(); - - Optional getPublishedDate(); - - Optional getPublishedDatePrecision(); - - Optional getUpdatedDate(); - - Optional getUpdatedDatePrecision(); - - Optional getParseDate(); - - String getLink(); - - String getDomainUrl(); - - String getFullDomainUrl(); - - Optional getNameSource(); - - Optional getIsHeadline(); - - Optional getPaidContent(); - - String getParentUrl(); - - Optional getCountry(); - - Optional getRights(); - - int getRank(); - - Optional getMedia(); - - Optional getLanguage(); - - Optional getDescription(); - - String getContent(); - - Optional getTitleTranslatedEn(); - - Optional getContentTranslatedEn(); - - Optional getWordCount(); - - Optional getIsOpinion(); - - Optional getTwitterAccount(); - - Optional getAllLinks(); - - Optional getAllDomainLinks(); - - Optional getNlp(); - - String getId(); - - double getScore(); - - Optional getRobotsCompliant(); - - Optional>> getCustomTags(); - - Optional getAdditionalDomainInfo(); -} diff --git a/src/main/java/com/newscatcher/api/types/NamedEntityListItem.java b/src/main/java/com/newscatcher/api/types/NamedEntityListItem.java index 2f673d4..1bc0a95 100644 --- a/src/main/java/com/newscatcher/api/types/NamedEntityListItem.java +++ b/src/main/java/com/newscatcher/api/types/NamedEntityListItem.java @@ -126,5 +126,15 @@ public Builder count(Integer count) { public NamedEntityListItem build() { return new NamedEntityListItem(entityName, count, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/NewsDomainType.java b/src/main/java/com/newscatcher/api/types/NewsDomainType.java index e3f08fd..488835c 100644 --- a/src/main/java/com/newscatcher/api/types/NewsDomainType.java +++ b/src/main/java/com/newscatcher/api/types/NewsDomainType.java @@ -3,28 +3,112 @@ */ package com.newscatcher.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum NewsDomainType { - ORIGINAL_CONTENT("Original Content"), +public final class NewsDomainType { + public static final NewsDomainType PRESS_RELEASES = new NewsDomainType(Value.PRESS_RELEASES, "Press Releases"); - AGGREGATOR("Aggregator"), + public static final NewsDomainType AGGREGATOR = new NewsDomainType(Value.AGGREGATOR, "Aggregator"); - PRESS_RELEASES("Press Releases"), + public static final NewsDomainType REPUBLISHER = new NewsDomainType(Value.REPUBLISHER, "Republisher"); - REPUBLISHER("Republisher"), + public static final NewsDomainType OTHER = new NewsDomainType(Value.OTHER, "Other"); - OTHER("Other"); + public static final NewsDomainType ORIGINAL_CONTENT = + new NewsDomainType(Value.ORIGINAL_CONTENT, "Original Content"); - private final String value; + private final Value value; - NewsDomainType(String value) { + private final String string; + + NewsDomainType(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) + || (other instanceof NewsDomainType && this.string.equals(((NewsDomainType) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case PRESS_RELEASES: + return visitor.visitPressReleases(); + case AGGREGATOR: + return visitor.visitAggregator(); + case REPUBLISHER: + return visitor.visitRepublisher(); + case OTHER: + return visitor.visitOther(); + case ORIGINAL_CONTENT: + return visitor.visitOriginalContent(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static NewsDomainType valueOf(String value) { + switch (value) { + case "Press Releases": + return PRESS_RELEASES; + case "Aggregator": + return AGGREGATOR; + case "Republisher": + return REPUBLISHER; + case "Other": + return OTHER; + case "Original Content": + return ORIGINAL_CONTENT; + default: + return new NewsDomainType(Value.UNKNOWN, value); + } + } + + public enum Value { + ORIGINAL_CONTENT, + + AGGREGATOR, + + PRESS_RELEASES, + + REPUBLISHER, + + OTHER, + + UNKNOWN + } + + public interface Visitor { + T visitOriginalContent(); + + T visitAggregator(); + + T visitPressReleases(); + + T visitRepublisher(); + + T visitOther(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/newscatcher/api/types/NlpDataEntity.java b/src/main/java/com/newscatcher/api/types/NlpDataEntity.java index e9fa876..3115d0c 100644 --- a/src/main/java/com/newscatcher/api/types/NlpDataEntity.java +++ b/src/main/java/com/newscatcher/api/types/NlpDataEntity.java @@ -123,7 +123,7 @@ public Optional getSentiment() { /** * @return A dense 1024-dimensional vector representation of the article content, generated using the multilingual-e5-large model. - *

Note: The new_embedding field is only available in the v3_local_news_nlp_embeddings subscription plan.

+ *

Note: The new_embedding field is only available in the v3_nlp_embeddings subscription plan.

*/ @JsonProperty("new_embedding") public Optional> getNewEmbedding() { @@ -395,7 +395,7 @@ public Builder sentiment(SentimentScores sentiment) { /** *

A dense 1024-dimensional vector representation of the article content, generated using the multilingual-e5-large model.

- *

Note: The new_embedding field is only available in the v3_local_news_nlp_embeddings subscription plan.

+ *

Note: The new_embedding field is only available in the v3_nlp_embeddings subscription plan.

*/ @JsonSetter(value = "new_embedding", nulls = Nulls.SKIP) public Builder newEmbedding(Optional> newEmbedding) { @@ -585,5 +585,15 @@ public NlpDataEntity build() { iabTagsName, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/PublishedDatePrecision.java b/src/main/java/com/newscatcher/api/types/PublishedDatePrecision.java deleted file mode 100644 index d246f29..0000000 --- a/src/main/java/com/newscatcher/api/types/PublishedDatePrecision.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PublishedDatePrecision { - FULL("full"), - - TIMEZONE_UNKNOWN("timezone unknown"), - - DATE("date"); - - private final String value; - - PublishedDatePrecision(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/newscatcher/api/types/SearchResponseDto.java b/src/main/java/com/newscatcher/api/types/SearchResponseDto.java index dc7e8e9..c9450e2 100644 --- a/src/main/java/com/newscatcher/api/types/SearchResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/SearchResponseDto.java @@ -188,6 +188,10 @@ public interface PageSizeStage { public interface _FinalStage { SearchResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + _FinalStage articles(Optional> articles); _FinalStage articles(List articles); @@ -322,5 +326,17 @@ public SearchResponseDto build() { return new SearchResponseDto( status, totalHits, page, totalPages, pageSize, articles, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/SearchSimilarResponseDto.java b/src/main/java/com/newscatcher/api/types/SearchSimilarResponseDto.java deleted file mode 100644 index 866ce83..0000000 --- a/src/main/java/com/newscatcher/api/types/SearchSimilarResponseDto.java +++ /dev/null @@ -1,339 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SearchSimilarResponseDto.Builder.class) -public final class SearchSimilarResponseDto implements IBaseSearchResponseDto { - private final String status; - - private final int totalHits; - - private final int page; - - private final int totalPages; - - private final int pageSize; - - private final Optional> articles; - - private final Optional> userInput; - - private final Map additionalProperties; - - private SearchSimilarResponseDto( - String status, - int totalHits, - int page, - int totalPages, - int pageSize, - Optional> articles, - Optional> userInput, - Map additionalProperties) { - this.status = status; - this.totalHits = totalHits; - this.page = page; - this.totalPages = totalPages; - this.pageSize = pageSize; - this.articles = articles; - this.userInput = userInput; - this.additionalProperties = additionalProperties; - } - - /** - * @return The status of the response. - */ - @JsonProperty("status") - @java.lang.Override - public String getStatus() { - return status; - } - - /** - * @return The total number of articles matching the search criteria. - */ - @JsonProperty("total_hits") - @java.lang.Override - public int getTotalHits() { - return totalHits; - } - - /** - * @return The current page number of the results. - */ - @JsonProperty("page") - @java.lang.Override - public int getPage() { - return page; - } - - /** - * @return The total number of pages available for the given search criteria. - */ - @JsonProperty("total_pages") - @java.lang.Override - public int getTotalPages() { - return totalPages; - } - - /** - * @return The number of articles per page. - */ - @JsonProperty("page_size") - @java.lang.Override - public int getPageSize() { - return pageSize; - } - - /** - * @return A list of articles matching the search criteria. - */ - @JsonProperty("articles") - public Optional> getArticles() { - return articles; - } - - @JsonProperty("user_input") - public Optional> getUserInput() { - return userInput; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SearchSimilarResponseDto && equalTo((SearchSimilarResponseDto) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SearchSimilarResponseDto other) { - return status.equals(other.status) - && totalHits == other.totalHits - && page == other.page - && totalPages == other.totalPages - && pageSize == other.pageSize - && articles.equals(other.articles) - && userInput.equals(other.userInput); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.status, this.totalHits, this.page, this.totalPages, this.pageSize, this.articles, this.userInput); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - /** - *

The status of the response.

- */ - TotalHitsStage status(@NotNull String status); - - Builder from(SearchSimilarResponseDto other); - } - - public interface TotalHitsStage { - /** - *

The total number of articles matching the search criteria.

- */ - PageStage totalHits(int totalHits); - } - - public interface PageStage { - /** - *

The current page number of the results.

- */ - TotalPagesStage page(int page); - } - - public interface TotalPagesStage { - /** - *

The total number of pages available for the given search criteria.

- */ - PageSizeStage totalPages(int totalPages); - } - - public interface PageSizeStage { - /** - *

The number of articles per page.

- */ - _FinalStage pageSize(int pageSize); - } - - public interface _FinalStage { - SearchSimilarResponseDto build(); - - /** - *

A list of articles matching the search criteria.

- */ - _FinalStage articles(Optional> articles); - - _FinalStage articles(List articles); - - _FinalStage userInput(Optional> userInput); - - _FinalStage userInput(Map userInput); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements StatusStage, TotalHitsStage, PageStage, TotalPagesStage, PageSizeStage, _FinalStage { - private String status; - - private int totalHits; - - private int page; - - private int totalPages; - - private int pageSize; - - private Optional> userInput = Optional.empty(); - - private Optional> articles = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SearchSimilarResponseDto other) { - status(other.getStatus()); - totalHits(other.getTotalHits()); - page(other.getPage()); - totalPages(other.getTotalPages()); - pageSize(other.getPageSize()); - articles(other.getArticles()); - userInput(other.getUserInput()); - return this; - } - - /** - *

The status of the response.

- *

The status of the response.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("status") - public TotalHitsStage status(@NotNull String status) { - this.status = Objects.requireNonNull(status, "status must not be null"); - return this; - } - - /** - *

The total number of articles matching the search criteria.

- *

The total number of articles matching the search criteria.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("total_hits") - public PageStage totalHits(int totalHits) { - this.totalHits = totalHits; - return this; - } - - /** - *

The current page number of the results.

- *

The current page number of the results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("page") - public TotalPagesStage page(int page) { - this.page = page; - return this; - } - - /** - *

The total number of pages available for the given search criteria.

- *

The total number of pages available for the given search criteria.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("total_pages") - public PageSizeStage totalPages(int totalPages) { - this.totalPages = totalPages; - return this; - } - - /** - *

The number of articles per page.

- *

The number of articles per page.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("page_size") - public _FinalStage pageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - @java.lang.Override - public _FinalStage userInput(Map userInput) { - this.userInput = Optional.ofNullable(userInput); - return this; - } - - @java.lang.Override - @JsonSetter(value = "user_input", nulls = Nulls.SKIP) - public _FinalStage userInput(Optional> userInput) { - this.userInput = userInput; - return this; - } - - /** - *

A list of articles matching the search criteria.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage articles(List articles) { - this.articles = Optional.ofNullable(articles); - return this; - } - - /** - *

A list of articles matching the search criteria.

- */ - @java.lang.Override - @JsonSetter(value = "articles", nulls = Nulls.SKIP) - public _FinalStage articles(Optional> articles) { - this.articles = articles; - return this; - } - - @java.lang.Override - public SearchSimilarResponseDto build() { - return new SearchSimilarResponseDto( - status, totalHits, page, totalPages, pageSize, articles, userInput, additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/types/SentimentScores.java b/src/main/java/com/newscatcher/api/types/SentimentScores.java index 3738ee7..5828c9b 100644 --- a/src/main/java/com/newscatcher/api/types/SentimentScores.java +++ b/src/main/java/com/newscatcher/api/types/SentimentScores.java @@ -125,5 +125,15 @@ public Builder content(Float content) { public SentimentScores build() { return new SentimentScores(title, content, additionalProperties); } + + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/SimilarArticleEntity.java b/src/main/java/com/newscatcher/api/types/SimilarArticleEntity.java deleted file mode 100644 index 2048fef..0000000 --- a/src/main/java/com/newscatcher/api/types/SimilarArticleEntity.java +++ /dev/null @@ -1,1693 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SimilarArticleEntity.Builder.class) -public final class SimilarArticleEntity implements IArticleEntity { - private final String title; - - private final Optional author; - - private final Optional authors; - - private final Optional journalists; - - private final Optional publishedDate; - - private final Optional publishedDatePrecision; - - private final Optional updatedDate; - - private final Optional updatedDatePrecision; - - private final Optional parseDate; - - private final String link; - - private final String domainUrl; - - private final String fullDomainUrl; - - private final Optional nameSource; - - private final Optional isHeadline; - - private final Optional paidContent; - - private final String parentUrl; - - private final Optional country; - - private final Optional rights; - - private final int rank; - - private final Optional media; - - private final Optional language; - - private final Optional description; - - private final String content; - - private final Optional titleTranslatedEn; - - private final Optional contentTranslatedEn; - - private final Optional wordCount; - - private final Optional isOpinion; - - private final Optional twitterAccount; - - private final Optional allLinks; - - private final Optional allDomainLinks; - - private final Optional nlp; - - private final String id; - - private final double score; - - private final Optional robotsCompliant; - - private final Optional>> customTags; - - private final Optional additionalDomainInfo; - - private final Optional> similarDocuments; - - private final Map additionalProperties; - - private SimilarArticleEntity( - String title, - Optional author, - Optional authors, - Optional journalists, - Optional publishedDate, - Optional publishedDatePrecision, - Optional updatedDate, - Optional updatedDatePrecision, - Optional parseDate, - String link, - String domainUrl, - String fullDomainUrl, - Optional nameSource, - Optional isHeadline, - Optional paidContent, - String parentUrl, - Optional country, - Optional rights, - int rank, - Optional media, - Optional language, - Optional description, - String content, - Optional titleTranslatedEn, - Optional contentTranslatedEn, - Optional wordCount, - Optional isOpinion, - Optional twitterAccount, - Optional allLinks, - Optional allDomainLinks, - Optional nlp, - String id, - double score, - Optional robotsCompliant, - Optional>> customTags, - Optional additionalDomainInfo, - Optional> similarDocuments, - Map additionalProperties) { - this.title = title; - this.author = author; - this.authors = authors; - this.journalists = journalists; - this.publishedDate = publishedDate; - this.publishedDatePrecision = publishedDatePrecision; - this.updatedDate = updatedDate; - this.updatedDatePrecision = updatedDatePrecision; - this.parseDate = parseDate; - this.link = link; - this.domainUrl = domainUrl; - this.fullDomainUrl = fullDomainUrl; - this.nameSource = nameSource; - this.isHeadline = isHeadline; - this.paidContent = paidContent; - this.parentUrl = parentUrl; - this.country = country; - this.rights = rights; - this.rank = rank; - this.media = media; - this.language = language; - this.description = description; - this.content = content; - this.titleTranslatedEn = titleTranslatedEn; - this.contentTranslatedEn = contentTranslatedEn; - this.wordCount = wordCount; - this.isOpinion = isOpinion; - this.twitterAccount = twitterAccount; - this.allLinks = allLinks; - this.allDomainLinks = allDomainLinks; - this.nlp = nlp; - this.id = id; - this.score = score; - this.robotsCompliant = robotsCompliant; - this.customTags = customTags; - this.additionalDomainInfo = additionalDomainInfo; - this.similarDocuments = similarDocuments; - this.additionalProperties = additionalProperties; - } - - /** - * @return The title of the article. - */ - @JsonProperty("title") - @java.lang.Override - public String getTitle() { - return title; - } - - /** - * @return The primary author of the article. - */ - @JsonProperty("author") - @java.lang.Override - public Optional getAuthor() { - return author; - } - - /** - * @return A list of authors of the article. - */ - @JsonProperty("authors") - public Optional getAuthors() { - return authors; - } - - /** - * @return A list of journalists associated with the article. - */ - @JsonProperty("journalists") - public Optional getJournalists() { - return journalists; - } - - /** - * @return The date the article was published. - */ - @JsonProperty("published_date") - @java.lang.Override - public Optional getPublishedDate() { - return publishedDate; - } - - /** - * @return The precision of the published date. - */ - @JsonProperty("published_date_precision") - @java.lang.Override - public Optional getPublishedDatePrecision() { - return publishedDatePrecision; - } - - /** - * @return The date the article was last updated. - */ - @JsonProperty("updated_date") - @java.lang.Override - public Optional getUpdatedDate() { - return updatedDate; - } - - /** - * @return The precision of the updated date. - */ - @JsonProperty("updated_date_precision") - @java.lang.Override - public Optional getUpdatedDatePrecision() { - return updatedDatePrecision; - } - - /** - * @return The date the article was parsed. - */ - @JsonProperty("parse_date") - @java.lang.Override - public Optional getParseDate() { - return parseDate; - } - - /** - * @return The URL link to the article. - */ - @JsonProperty("link") - @java.lang.Override - public String getLink() { - return link; - } - - /** - * @return The domain URL of the article. - */ - @JsonProperty("domain_url") - @java.lang.Override - public String getDomainUrl() { - return domainUrl; - } - - /** - * @return The full domain URL of the article. - */ - @JsonProperty("full_domain_url") - @java.lang.Override - public String getFullDomainUrl() { - return fullDomainUrl; - } - - /** - * @return The name of the source where the article was published. - */ - @JsonProperty("name_source") - @java.lang.Override - public Optional getNameSource() { - return nameSource; - } - - /** - * @return Indicates if the article is a headline. - */ - @JsonProperty("is_headline") - @java.lang.Override - public Optional getIsHeadline() { - return isHeadline; - } - - /** - * @return Indicates if the article is paid content. - */ - @JsonProperty("paid_content") - @java.lang.Override - public Optional getPaidContent() { - return paidContent; - } - - /** - * @return The categorical URL of the article. - */ - @JsonProperty("parent_url") - @java.lang.Override - public String getParentUrl() { - return parentUrl; - } - - /** - * @return The country where the article was published. - */ - @JsonProperty("country") - @java.lang.Override - public Optional getCountry() { - return country; - } - - /** - * @return The rights information for the article. - */ - @JsonProperty("rights") - @java.lang.Override - public Optional getRights() { - return rights; - } - - /** - * @return The rank of the article's source. - */ - @JsonProperty("rank") - @java.lang.Override - public int getRank() { - return rank; - } - - /** - * @return The media associated with the article. - */ - @JsonProperty("media") - @java.lang.Override - public Optional getMedia() { - return media; - } - - /** - * @return The language in which the article is written. - */ - @JsonProperty("language") - @java.lang.Override - public Optional getLanguage() { - return language; - } - - /** - * @return A brief description of the article. - */ - @JsonProperty("description") - @java.lang.Override - public Optional getDescription() { - return description; - } - - /** - * @return The content of the article. - */ - @JsonProperty("content") - @java.lang.Override - public String getContent() { - return content; - } - - /** - * @return English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true. - */ - @JsonProperty("title_translated_en") - @java.lang.Override - public Optional getTitleTranslatedEn() { - return titleTranslatedEn; - } - - /** - * @return English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true. - */ - @JsonProperty("content_translated_en") - @java.lang.Override - public Optional getContentTranslatedEn() { - return contentTranslatedEn; - } - - /** - * @return The word count of the article. - */ - @JsonProperty("word_count") - @java.lang.Override - public Optional getWordCount() { - return wordCount; - } - - /** - * @return Indicates if the article is an opinion piece. - */ - @JsonProperty("is_opinion") - @java.lang.Override - public Optional getIsOpinion() { - return isOpinion; - } - - /** - * @return The Twitter account associated with the article. - */ - @JsonProperty("twitter_account") - @java.lang.Override - public Optional getTwitterAccount() { - return twitterAccount; - } - - /** - * @return A list of all URLs mentioned in the article. - */ - @JsonProperty("all_links") - public Optional getAllLinks() { - return allLinks; - } - - /** - * @return A list of all domain URLs mentioned in the article. - */ - @JsonProperty("all_domain_links") - public Optional getAllDomainLinks() { - return allDomainLinks; - } - - @JsonProperty("nlp") - @java.lang.Override - public Optional getNlp() { - return nlp; - } - - /** - * @return The unique identifier for the article. - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The relevance score of the article. - */ - @JsonProperty("score") - @java.lang.Override - public double getScore() { - return score; - } - - /** - * @return True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise. - */ - @JsonProperty("robots_compliant") - @java.lang.Override - public Optional getRobotsCompliant() { - return robotsCompliant; - } - - /** - * @return An object that contains custom tags associated with an article, where each key is a taxonomy name, and the value is an array of tags. - */ - @JsonProperty("custom_tags") - @java.lang.Override - public Optional>> getCustomTags() { - return customTags; - } - - @JsonProperty("additional_domain_info") - @java.lang.Override - public Optional getAdditionalDomainInfo() { - return additionalDomainInfo; - } - - /** - * @return A list of documents similar to the article. - */ - @JsonProperty("similar_documents") - public Optional> getSimilarDocuments() { - return similarDocuments; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SimilarArticleEntity && equalTo((SimilarArticleEntity) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SimilarArticleEntity other) { - return title.equals(other.title) - && author.equals(other.author) - && authors.equals(other.authors) - && journalists.equals(other.journalists) - && publishedDate.equals(other.publishedDate) - && publishedDatePrecision.equals(other.publishedDatePrecision) - && updatedDate.equals(other.updatedDate) - && updatedDatePrecision.equals(other.updatedDatePrecision) - && parseDate.equals(other.parseDate) - && link.equals(other.link) - && domainUrl.equals(other.domainUrl) - && fullDomainUrl.equals(other.fullDomainUrl) - && nameSource.equals(other.nameSource) - && isHeadline.equals(other.isHeadline) - && paidContent.equals(other.paidContent) - && parentUrl.equals(other.parentUrl) - && country.equals(other.country) - && rights.equals(other.rights) - && rank == other.rank - && media.equals(other.media) - && language.equals(other.language) - && description.equals(other.description) - && content.equals(other.content) - && titleTranslatedEn.equals(other.titleTranslatedEn) - && contentTranslatedEn.equals(other.contentTranslatedEn) - && wordCount.equals(other.wordCount) - && isOpinion.equals(other.isOpinion) - && twitterAccount.equals(other.twitterAccount) - && allLinks.equals(other.allLinks) - && allDomainLinks.equals(other.allDomainLinks) - && nlp.equals(other.nlp) - && id.equals(other.id) - && score == other.score - && robotsCompliant.equals(other.robotsCompliant) - && customTags.equals(other.customTags) - && additionalDomainInfo.equals(other.additionalDomainInfo) - && similarDocuments.equals(other.similarDocuments); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.title, - this.author, - this.authors, - this.journalists, - this.publishedDate, - this.publishedDatePrecision, - this.updatedDate, - this.updatedDatePrecision, - this.parseDate, - this.link, - this.domainUrl, - this.fullDomainUrl, - this.nameSource, - this.isHeadline, - this.paidContent, - this.parentUrl, - this.country, - this.rights, - this.rank, - this.media, - this.language, - this.description, - this.content, - this.titleTranslatedEn, - this.contentTranslatedEn, - this.wordCount, - this.isOpinion, - this.twitterAccount, - this.allLinks, - this.allDomainLinks, - this.nlp, - this.id, - this.score, - this.robotsCompliant, - this.customTags, - this.additionalDomainInfo, - this.similarDocuments); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TitleStage builder() { - return new Builder(); - } - - public interface TitleStage { - /** - *

The title of the article.

- */ - LinkStage title(@NotNull String title); - - Builder from(SimilarArticleEntity other); - } - - public interface LinkStage { - /** - *

The URL link to the article.

- */ - DomainUrlStage link(@NotNull String link); - } - - public interface DomainUrlStage { - /** - *

The domain URL of the article.

- */ - FullDomainUrlStage domainUrl(@NotNull String domainUrl); - } - - public interface FullDomainUrlStage { - /** - *

The full domain URL of the article.

- */ - ParentUrlStage fullDomainUrl(@NotNull String fullDomainUrl); - } - - public interface ParentUrlStage { - /** - *

The categorical URL of the article.

- */ - RankStage parentUrl(@NotNull String parentUrl); - } - - public interface RankStage { - /** - *

The rank of the article's source.

- */ - ContentStage rank(int rank); - } - - public interface ContentStage { - /** - *

The content of the article.

- */ - IdStage content(@NotNull String content); - } - - public interface IdStage { - /** - *

The unique identifier for the article.

- */ - ScoreStage id(@NotNull String id); - } - - public interface ScoreStage { - /** - *

The relevance score of the article.

- */ - _FinalStage score(double score); - } - - public interface _FinalStage { - SimilarArticleEntity build(); - - /** - *

The primary author of the article.

- */ - _FinalStage author(Optional author); - - _FinalStage author(String author); - - /** - *

A list of authors of the article.

- */ - _FinalStage authors(Optional authors); - - _FinalStage authors(Authors authors); - - /** - *

A list of journalists associated with the article.

- */ - _FinalStage journalists(Optional journalists); - - _FinalStage journalists(Journalists journalists); - - /** - *

The date the article was published.

- */ - _FinalStage publishedDate(Optional publishedDate); - - _FinalStage publishedDate(String publishedDate); - - /** - *

The precision of the published date.

- */ - _FinalStage publishedDatePrecision(Optional publishedDatePrecision); - - _FinalStage publishedDatePrecision(String publishedDatePrecision); - - /** - *

The date the article was last updated.

- */ - _FinalStage updatedDate(Optional updatedDate); - - _FinalStage updatedDate(String updatedDate); - - /** - *

The precision of the updated date.

- */ - _FinalStage updatedDatePrecision(Optional updatedDatePrecision); - - _FinalStage updatedDatePrecision(String updatedDatePrecision); - - /** - *

The date the article was parsed.

- */ - _FinalStage parseDate(Optional parseDate); - - _FinalStage parseDate(String parseDate); - - /** - *

The name of the source where the article was published.

- */ - _FinalStage nameSource(Optional nameSource); - - _FinalStage nameSource(String nameSource); - - /** - *

Indicates if the article is a headline.

- */ - _FinalStage isHeadline(Optional isHeadline); - - _FinalStage isHeadline(Boolean isHeadline); - - /** - *

Indicates if the article is paid content.

- */ - _FinalStage paidContent(Optional paidContent); - - _FinalStage paidContent(Boolean paidContent); - - /** - *

The country where the article was published.

- */ - _FinalStage country(Optional country); - - _FinalStage country(String country); - - /** - *

The rights information for the article.

- */ - _FinalStage rights(Optional rights); - - _FinalStage rights(String rights); - - /** - *

The media associated with the article.

- */ - _FinalStage media(Optional media); - - _FinalStage media(String media); - - /** - *

The language in which the article is written.

- */ - _FinalStage language(Optional language); - - _FinalStage language(String language); - - /** - *

A brief description of the article.

- */ - _FinalStage description(Optional description); - - _FinalStage description(String description); - - /** - *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

- */ - _FinalStage titleTranslatedEn(Optional titleTranslatedEn); - - _FinalStage titleTranslatedEn(String titleTranslatedEn); - - /** - *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

- */ - _FinalStage contentTranslatedEn(Optional contentTranslatedEn); - - _FinalStage contentTranslatedEn(String contentTranslatedEn); - - /** - *

The word count of the article.

- */ - _FinalStage wordCount(Optional wordCount); - - _FinalStage wordCount(Integer wordCount); - - /** - *

Indicates if the article is an opinion piece.

- */ - _FinalStage isOpinion(Optional isOpinion); - - _FinalStage isOpinion(Boolean isOpinion); - - /** - *

The Twitter account associated with the article.

- */ - _FinalStage twitterAccount(Optional twitterAccount); - - _FinalStage twitterAccount(String twitterAccount); - - /** - *

A list of all URLs mentioned in the article.

- */ - _FinalStage allLinks(Optional allLinks); - - _FinalStage allLinks(ArticleEntityAllLinks allLinks); - - /** - *

A list of all domain URLs mentioned in the article.

- */ - _FinalStage allDomainLinks(Optional allDomainLinks); - - _FinalStage allDomainLinks(ArticleEntityAllDomainLinks allDomainLinks); - - _FinalStage nlp(Optional nlp); - - _FinalStage nlp(NlpDataEntity nlp); - - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- */ - _FinalStage robotsCompliant(Optional robotsCompliant); - - _FinalStage robotsCompliant(Boolean robotsCompliant); - - /** - *

An object that contains custom tags associated with an article, where each key is a taxonomy name, and the value is an array of tags.

- */ - _FinalStage customTags(Optional>> customTags); - - _FinalStage customTags(Map> customTags); - - _FinalStage additionalDomainInfo(Optional additionalDomainInfo); - - _FinalStage additionalDomainInfo(AdditionalDomainInfoEntity additionalDomainInfo); - - /** - *

A list of documents similar to the article.

- */ - _FinalStage similarDocuments(Optional> similarDocuments); - - _FinalStage similarDocuments(List similarDocuments); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements TitleStage, - LinkStage, - DomainUrlStage, - FullDomainUrlStage, - ParentUrlStage, - RankStage, - ContentStage, - IdStage, - ScoreStage, - _FinalStage { - private String title; - - private String link; - - private String domainUrl; - - private String fullDomainUrl; - - private String parentUrl; - - private int rank; - - private String content; - - private String id; - - private double score; - - private Optional> similarDocuments = Optional.empty(); - - private Optional additionalDomainInfo = Optional.empty(); - - private Optional>> customTags = Optional.empty(); - - private Optional robotsCompliant = Optional.empty(); - - private Optional nlp = Optional.empty(); - - private Optional allDomainLinks = Optional.empty(); - - private Optional allLinks = Optional.empty(); - - private Optional twitterAccount = Optional.empty(); - - private Optional isOpinion = Optional.empty(); - - private Optional wordCount = Optional.empty(); - - private Optional contentTranslatedEn = Optional.empty(); - - private Optional titleTranslatedEn = Optional.empty(); - - private Optional description = Optional.empty(); - - private Optional language = Optional.empty(); - - private Optional media = Optional.empty(); - - private Optional rights = Optional.empty(); - - private Optional country = Optional.empty(); - - private Optional paidContent = Optional.empty(); - - private Optional isHeadline = Optional.empty(); - - private Optional nameSource = Optional.empty(); - - private Optional parseDate = Optional.empty(); - - private Optional updatedDatePrecision = Optional.empty(); - - private Optional updatedDate = Optional.empty(); - - private Optional publishedDatePrecision = Optional.empty(); - - private Optional publishedDate = Optional.empty(); - - private Optional journalists = Optional.empty(); - - private Optional authors = Optional.empty(); - - private Optional author = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SimilarArticleEntity other) { - title(other.getTitle()); - author(other.getAuthor()); - authors(other.getAuthors()); - journalists(other.getJournalists()); - publishedDate(other.getPublishedDate()); - publishedDatePrecision(other.getPublishedDatePrecision()); - updatedDate(other.getUpdatedDate()); - updatedDatePrecision(other.getUpdatedDatePrecision()); - parseDate(other.getParseDate()); - link(other.getLink()); - domainUrl(other.getDomainUrl()); - fullDomainUrl(other.getFullDomainUrl()); - nameSource(other.getNameSource()); - isHeadline(other.getIsHeadline()); - paidContent(other.getPaidContent()); - parentUrl(other.getParentUrl()); - country(other.getCountry()); - rights(other.getRights()); - rank(other.getRank()); - media(other.getMedia()); - language(other.getLanguage()); - description(other.getDescription()); - content(other.getContent()); - titleTranslatedEn(other.getTitleTranslatedEn()); - contentTranslatedEn(other.getContentTranslatedEn()); - wordCount(other.getWordCount()); - isOpinion(other.getIsOpinion()); - twitterAccount(other.getTwitterAccount()); - allLinks(other.getAllLinks()); - allDomainLinks(other.getAllDomainLinks()); - nlp(other.getNlp()); - id(other.getId()); - score(other.getScore()); - robotsCompliant(other.getRobotsCompliant()); - customTags(other.getCustomTags()); - additionalDomainInfo(other.getAdditionalDomainInfo()); - similarDocuments(other.getSimilarDocuments()); - return this; - } - - /** - *

The title of the article.

- *

The title of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("title") - public LinkStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); - return this; - } - - /** - *

The URL link to the article.

- *

The URL link to the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("link") - public DomainUrlStage link(@NotNull String link) { - this.link = Objects.requireNonNull(link, "link must not be null"); - return this; - } - - /** - *

The domain URL of the article.

- *

The domain URL of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("domain_url") - public FullDomainUrlStage domainUrl(@NotNull String domainUrl) { - this.domainUrl = Objects.requireNonNull(domainUrl, "domainUrl must not be null"); - return this; - } - - /** - *

The full domain URL of the article.

- *

The full domain URL of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("full_domain_url") - public ParentUrlStage fullDomainUrl(@NotNull String fullDomainUrl) { - this.fullDomainUrl = Objects.requireNonNull(fullDomainUrl, "fullDomainUrl must not be null"); - return this; - } - - /** - *

The categorical URL of the article.

- *

The categorical URL of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("parent_url") - public RankStage parentUrl(@NotNull String parentUrl) { - this.parentUrl = Objects.requireNonNull(parentUrl, "parentUrl must not be null"); - return this; - } - - /** - *

The rank of the article's source.

- *

The rank of the article's source.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("rank") - public ContentStage rank(int rank) { - this.rank = rank; - return this; - } - - /** - *

The content of the article.

- *

The content of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public IdStage content(@NotNull String content) { - this.content = Objects.requireNonNull(content, "content must not be null"); - return this; - } - - /** - *

The unique identifier for the article.

- *

The unique identifier for the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public ScoreStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); - return this; - } - - /** - *

The relevance score of the article.

- *

The relevance score of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("score") - public _FinalStage score(double score) { - this.score = score; - return this; - } - - /** - *

A list of documents similar to the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage similarDocuments(List similarDocuments) { - this.similarDocuments = Optional.ofNullable(similarDocuments); - return this; - } - - /** - *

A list of documents similar to the article.

- */ - @java.lang.Override - @JsonSetter(value = "similar_documents", nulls = Nulls.SKIP) - public _FinalStage similarDocuments(Optional> similarDocuments) { - this.similarDocuments = similarDocuments; - return this; - } - - @java.lang.Override - public _FinalStage additionalDomainInfo(AdditionalDomainInfoEntity additionalDomainInfo) { - this.additionalDomainInfo = Optional.ofNullable(additionalDomainInfo); - return this; - } - - @java.lang.Override - @JsonSetter(value = "additional_domain_info", nulls = Nulls.SKIP) - public _FinalStage additionalDomainInfo(Optional additionalDomainInfo) { - this.additionalDomainInfo = additionalDomainInfo; - return this; - } - - /** - *

An object that contains custom tags associated with an article, where each key is a taxonomy name, and the value is an array of tags.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customTags(Map> customTags) { - this.customTags = Optional.ofNullable(customTags); - return this; - } - - /** - *

An object that contains custom tags associated with an article, where each key is a taxonomy name, and the value is an array of tags.

- */ - @java.lang.Override - @JsonSetter(value = "custom_tags", nulls = Nulls.SKIP) - public _FinalStage customTags(Optional>> customTags) { - this.customTags = customTags; - return this; - } - - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage robotsCompliant(Boolean robotsCompliant) { - this.robotsCompliant = Optional.ofNullable(robotsCompliant); - return this; - } - - /** - *

True if the article content can be safely accessed according to the publisher's robots.txt rules; false otherwise.

- */ - @java.lang.Override - @JsonSetter(value = "robots_compliant", nulls = Nulls.SKIP) - public _FinalStage robotsCompliant(Optional robotsCompliant) { - this.robotsCompliant = robotsCompliant; - return this; - } - - @java.lang.Override - public _FinalStage nlp(NlpDataEntity nlp) { - this.nlp = Optional.ofNullable(nlp); - return this; - } - - @java.lang.Override - @JsonSetter(value = "nlp", nulls = Nulls.SKIP) - public _FinalStage nlp(Optional nlp) { - this.nlp = nlp; - return this; - } - - /** - *

A list of all domain URLs mentioned in the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allDomainLinks(ArticleEntityAllDomainLinks allDomainLinks) { - this.allDomainLinks = Optional.ofNullable(allDomainLinks); - return this; - } - - /** - *

A list of all domain URLs mentioned in the article.

- */ - @java.lang.Override - @JsonSetter(value = "all_domain_links", nulls = Nulls.SKIP) - public _FinalStage allDomainLinks(Optional allDomainLinks) { - this.allDomainLinks = allDomainLinks; - return this; - } - - /** - *

A list of all URLs mentioned in the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage allLinks(ArticleEntityAllLinks allLinks) { - this.allLinks = Optional.ofNullable(allLinks); - return this; - } - - /** - *

A list of all URLs mentioned in the article.

- */ - @java.lang.Override - @JsonSetter(value = "all_links", nulls = Nulls.SKIP) - public _FinalStage allLinks(Optional allLinks) { - this.allLinks = allLinks; - return this; - } - - /** - *

The Twitter account associated with the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage twitterAccount(String twitterAccount) { - this.twitterAccount = Optional.ofNullable(twitterAccount); - return this; - } - - /** - *

The Twitter account associated with the article.

- */ - @java.lang.Override - @JsonSetter(value = "twitter_account", nulls = Nulls.SKIP) - public _FinalStage twitterAccount(Optional twitterAccount) { - this.twitterAccount = twitterAccount; - return this; - } - - /** - *

Indicates if the article is an opinion piece.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isOpinion(Boolean isOpinion) { - this.isOpinion = Optional.ofNullable(isOpinion); - return this; - } - - /** - *

Indicates if the article is an opinion piece.

- */ - @java.lang.Override - @JsonSetter(value = "is_opinion", nulls = Nulls.SKIP) - public _FinalStage isOpinion(Optional isOpinion) { - this.isOpinion = isOpinion; - return this; - } - - /** - *

The word count of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage wordCount(Integer wordCount) { - this.wordCount = Optional.ofNullable(wordCount); - return this; - } - - /** - *

The word count of the article.

- */ - @java.lang.Override - @JsonSetter(value = "word_count", nulls = Nulls.SKIP) - public _FinalStage wordCount(Optional wordCount) { - this.wordCount = wordCount; - return this; - } - - /** - *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage contentTranslatedEn(String contentTranslatedEn) { - this.contentTranslatedEn = Optional.ofNullable(contentTranslatedEn); - return this; - } - - /** - *

English translation of the article content. Available when using the search_in parameter with the content_translated option or by setting the include_translation_fields parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "content_translated_en", nulls = Nulls.SKIP) - public _FinalStage contentTranslatedEn(Optional contentTranslatedEn) { - this.contentTranslatedEn = contentTranslatedEn; - return this; - } - - /** - *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage titleTranslatedEn(String titleTranslatedEn) { - this.titleTranslatedEn = Optional.ofNullable(titleTranslatedEn); - return this; - } - - /** - *

English translation of the article title. Available when using the search_in parameter with the title_translated option or by setting the include_translation_fields parameter to true.

- */ - @java.lang.Override - @JsonSetter(value = "title_translated_en", nulls = Nulls.SKIP) - public _FinalStage titleTranslatedEn(Optional titleTranslatedEn) { - this.titleTranslatedEn = titleTranslatedEn; - return this; - } - - /** - *

A brief description of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage description(String description) { - this.description = Optional.ofNullable(description); - return this; - } - - /** - *

A brief description of the article.

- */ - @java.lang.Override - @JsonSetter(value = "description", nulls = Nulls.SKIP) - public _FinalStage description(Optional description) { - this.description = description; - return this; - } - - /** - *

The language in which the article is written.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage language(String language) { - this.language = Optional.ofNullable(language); - return this; - } - - /** - *

The language in which the article is written.

- */ - @java.lang.Override - @JsonSetter(value = "language", nulls = Nulls.SKIP) - public _FinalStage language(Optional language) { - this.language = language; - return this; - } - - /** - *

The media associated with the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage media(String media) { - this.media = Optional.ofNullable(media); - return this; - } - - /** - *

The media associated with the article.

- */ - @java.lang.Override - @JsonSetter(value = "media", nulls = Nulls.SKIP) - public _FinalStage media(Optional media) { - this.media = media; - return this; - } - - /** - *

The rights information for the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage rights(String rights) { - this.rights = Optional.ofNullable(rights); - return this; - } - - /** - *

The rights information for the article.

- */ - @java.lang.Override - @JsonSetter(value = "rights", nulls = Nulls.SKIP) - public _FinalStage rights(Optional rights) { - this.rights = rights; - return this; - } - - /** - *

The country where the article was published.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage country(String country) { - this.country = Optional.ofNullable(country); - return this; - } - - /** - *

The country where the article was published.

- */ - @java.lang.Override - @JsonSetter(value = "country", nulls = Nulls.SKIP) - public _FinalStage country(Optional country) { - this.country = country; - return this; - } - - /** - *

Indicates if the article is paid content.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage paidContent(Boolean paidContent) { - this.paidContent = Optional.ofNullable(paidContent); - return this; - } - - /** - *

Indicates if the article is paid content.

- */ - @java.lang.Override - @JsonSetter(value = "paid_content", nulls = Nulls.SKIP) - public _FinalStage paidContent(Optional paidContent) { - this.paidContent = paidContent; - return this; - } - - /** - *

Indicates if the article is a headline.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage isHeadline(Boolean isHeadline) { - this.isHeadline = Optional.ofNullable(isHeadline); - return this; - } - - /** - *

Indicates if the article is a headline.

- */ - @java.lang.Override - @JsonSetter(value = "is_headline", nulls = Nulls.SKIP) - public _FinalStage isHeadline(Optional isHeadline) { - this.isHeadline = isHeadline; - return this; - } - - /** - *

The name of the source where the article was published.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nameSource(String nameSource) { - this.nameSource = Optional.ofNullable(nameSource); - return this; - } - - /** - *

The name of the source where the article was published.

- */ - @java.lang.Override - @JsonSetter(value = "name_source", nulls = Nulls.SKIP) - public _FinalStage nameSource(Optional nameSource) { - this.nameSource = nameSource; - return this; - } - - /** - *

The date the article was parsed.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage parseDate(String parseDate) { - this.parseDate = Optional.ofNullable(parseDate); - return this; - } - - /** - *

The date the article was parsed.

- */ - @java.lang.Override - @JsonSetter(value = "parse_date", nulls = Nulls.SKIP) - public _FinalStage parseDate(Optional parseDate) { - this.parseDate = parseDate; - return this; - } - - /** - *

The precision of the updated date.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedDatePrecision(String updatedDatePrecision) { - this.updatedDatePrecision = Optional.ofNullable(updatedDatePrecision); - return this; - } - - /** - *

The precision of the updated date.

- */ - @java.lang.Override - @JsonSetter(value = "updated_date_precision", nulls = Nulls.SKIP) - public _FinalStage updatedDatePrecision(Optional updatedDatePrecision) { - this.updatedDatePrecision = updatedDatePrecision; - return this; - } - - /** - *

The date the article was last updated.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage updatedDate(String updatedDate) { - this.updatedDate = Optional.ofNullable(updatedDate); - return this; - } - - /** - *

The date the article was last updated.

- */ - @java.lang.Override - @JsonSetter(value = "updated_date", nulls = Nulls.SKIP) - public _FinalStage updatedDate(Optional updatedDate) { - this.updatedDate = updatedDate; - return this; - } - - /** - *

The precision of the published date.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage publishedDatePrecision(String publishedDatePrecision) { - this.publishedDatePrecision = Optional.ofNullable(publishedDatePrecision); - return this; - } - - /** - *

The precision of the published date.

- */ - @java.lang.Override - @JsonSetter(value = "published_date_precision", nulls = Nulls.SKIP) - public _FinalStage publishedDatePrecision(Optional publishedDatePrecision) { - this.publishedDatePrecision = publishedDatePrecision; - return this; - } - - /** - *

The date the article was published.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage publishedDate(String publishedDate) { - this.publishedDate = Optional.ofNullable(publishedDate); - return this; - } - - /** - *

The date the article was published.

- */ - @java.lang.Override - @JsonSetter(value = "published_date", nulls = Nulls.SKIP) - public _FinalStage publishedDate(Optional publishedDate) { - this.publishedDate = publishedDate; - return this; - } - - /** - *

A list of journalists associated with the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage journalists(Journalists journalists) { - this.journalists = Optional.ofNullable(journalists); - return this; - } - - /** - *

A list of journalists associated with the article.

- */ - @java.lang.Override - @JsonSetter(value = "journalists", nulls = Nulls.SKIP) - public _FinalStage journalists(Optional journalists) { - this.journalists = journalists; - return this; - } - - /** - *

A list of authors of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage authors(Authors authors) { - this.authors = Optional.ofNullable(authors); - return this; - } - - /** - *

A list of authors of the article.

- */ - @java.lang.Override - @JsonSetter(value = "authors", nulls = Nulls.SKIP) - public _FinalStage authors(Optional authors) { - this.authors = authors; - return this; - } - - /** - *

The primary author of the article.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage author(String author) { - this.author = Optional.ofNullable(author); - return this; - } - - /** - *

The primary author of the article.

- */ - @java.lang.Override - @JsonSetter(value = "author", nulls = Nulls.SKIP) - public _FinalStage author(Optional author) { - this.author = author; - return this; - } - - @java.lang.Override - public SimilarArticleEntity build() { - return new SimilarArticleEntity( - title, - author, - authors, - journalists, - publishedDate, - publishedDatePrecision, - updatedDate, - updatedDatePrecision, - parseDate, - link, - domainUrl, - fullDomainUrl, - nameSource, - isHeadline, - paidContent, - parentUrl, - country, - rights, - rank, - media, - language, - description, - content, - titleTranslatedEn, - contentTranslatedEn, - wordCount, - isOpinion, - twitterAccount, - allLinks, - allDomainLinks, - nlp, - id, - score, - robotsCompliant, - customTags, - additionalDomainInfo, - similarDocuments, - additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/types/SimilarDocument.java b/src/main/java/com/newscatcher/api/types/SimilarDocument.java deleted file mode 100644 index 23c7005..0000000 --- a/src/main/java/com/newscatcher/api/types/SimilarDocument.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.newscatcher.api.types; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.newscatcher.api.core.ObjectMappers; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; - -@JsonInclude(JsonInclude.Include.NON_ABSENT) -@JsonDeserialize(builder = SimilarDocument.Builder.class) -public final class SimilarDocument { - private final String id; - - private final double score; - - private final String title; - - private final String link; - - private final Map additionalProperties; - - private SimilarDocument( - String id, double score, String title, String link, Map additionalProperties) { - this.id = id; - this.score = score; - this.title = title; - this.link = link; - this.additionalProperties = additionalProperties; - } - - /** - * @return The unique identifier of the similar document. - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return The relevance score of the similar document. - */ - @JsonProperty("score") - public double getScore() { - return score; - } - - /** - * @return The title of the similar document. - */ - @JsonProperty("title") - public String getTitle() { - return title; - } - - /** - * @return The link to the similar document. - */ - @JsonProperty("link") - public String getLink() { - return link; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SimilarDocument && equalTo((SimilarDocument) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SimilarDocument other) { - return id.equals(other.id) && score == other.score && title.equals(other.title) && link.equals(other.link); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.score, this.title, this.link); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - /** - *

The unique identifier of the similar document.

- */ - ScoreStage id(@NotNull String id); - - Builder from(SimilarDocument other); - } - - public interface ScoreStage { - /** - *

The relevance score of the similar document.

- */ - TitleStage score(double score); - } - - public interface TitleStage { - /** - *

The title of the similar document.

- */ - LinkStage title(@NotNull String title); - } - - public interface LinkStage { - /** - *

The link to the similar document.

- */ - _FinalStage link(@NotNull String link); - } - - public interface _FinalStage { - SimilarDocument build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, ScoreStage, TitleStage, LinkStage, _FinalStage { - private String id; - - private double score; - - private String title; - - private String link; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SimilarDocument other) { - id(other.getId()); - score(other.getScore()); - title(other.getTitle()); - link(other.getLink()); - return this; - } - - /** - *

The unique identifier of the similar document.

- *

The unique identifier of the similar document.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public ScoreStage id(@NotNull String id) { - this.id = Objects.requireNonNull(id, "id must not be null"); - return this; - } - - /** - *

The relevance score of the similar document.

- *

The relevance score of the similar document.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("score") - public TitleStage score(double score) { - this.score = score; - return this; - } - - /** - *

The title of the similar document.

- *

The title of the similar document.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("title") - public LinkStage title(@NotNull String title) { - this.title = Objects.requireNonNull(title, "title must not be null"); - return this; - } - - /** - *

The link to the similar document.

- *

The link to the similar document.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("link") - public _FinalStage link(@NotNull String link) { - this.link = Objects.requireNonNull(link, "link must not be null"); - return this; - } - - @java.lang.Override - public SimilarDocument build() { - return new SimilarDocument(id, score, title, link, additionalProperties); - } - } -} diff --git a/src/main/java/com/newscatcher/api/types/SortBy.java b/src/main/java/com/newscatcher/api/types/SortBy.java index d83999c..a55ccef 100644 --- a/src/main/java/com/newscatcher/api/types/SortBy.java +++ b/src/main/java/com/newscatcher/api/types/SortBy.java @@ -3,24 +3,90 @@ */ package com.newscatcher.api.types; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; -public enum SortBy { - RELEVANCY("relevancy"), +public final class SortBy { + public static final SortBy RANK = new SortBy(Value.RANK, "rank"); - DATE("date"), + public static final SortBy DATE = new SortBy(Value.DATE, "date"); - RANK("rank"); + public static final SortBy RELEVANCY = new SortBy(Value.RELEVANCY, "relevancy"); - private final String value; + private final Value value; - SortBy(String value) { + private final String string; + + SortBy(Value value, String string) { this.value = value; + this.string = string; + } + + public Value getEnumValue() { + return value; } - @JsonValue @java.lang.Override + @JsonValue public String toString() { - return this.value; + return this.string; + } + + @java.lang.Override + public boolean equals(Object other) { + return (this == other) || (other instanceof SortBy && this.string.equals(((SortBy) other).string)); + } + + @java.lang.Override + public int hashCode() { + return this.string.hashCode(); + } + + public T visit(Visitor visitor) { + switch (value) { + case RANK: + return visitor.visitRank(); + case DATE: + return visitor.visitDate(); + case RELEVANCY: + return visitor.visitRelevancy(); + case UNKNOWN: + default: + return visitor.visitUnknown(string); + } + } + + @JsonCreator(mode = JsonCreator.Mode.DELEGATING) + public static SortBy valueOf(String value) { + switch (value) { + case "rank": + return RANK; + case "date": + return DATE; + case "relevancy": + return RELEVANCY; + default: + return new SortBy(Value.UNKNOWN, value); + } + } + + public enum Value { + RELEVANCY, + + DATE, + + RANK, + + UNKNOWN + } + + public interface Visitor { + T visitRelevancy(); + + T visitDate(); + + T visitRank(); + + T visitUnknown(String unknownType); } } diff --git a/src/main/java/com/newscatcher/api/types/SourceInfo.java b/src/main/java/com/newscatcher/api/types/SourceInfo.java index c7e5655..0e8b869 100644 --- a/src/main/java/com/newscatcher/api/types/SourceInfo.java +++ b/src/main/java/com/newscatcher/api/types/SourceInfo.java @@ -117,6 +117,10 @@ public interface DomainUrlStage { public interface _FinalStage { SourceInfo build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

The name of the news source.

*/ @@ -229,5 +233,17 @@ public _FinalStage nameSource(Optional nameSource) { public SourceInfo build() { return new SourceInfo(nameSource, domainUrl, logo, additionalInfo, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/SourcesResponseDto.java b/src/main/java/com/newscatcher/api/types/SourcesResponseDto.java index c93ecf9..c079f71 100644 --- a/src/main/java/com/newscatcher/api/types/SourcesResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/SourcesResponseDto.java @@ -107,6 +107,10 @@ public interface MessageStage { public interface _FinalStage { SourcesResponseDto build(); + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); + /** *

A list of news sources that match the specified criteria.

*/ @@ -175,7 +179,9 @@ public _FinalStage userInput(String key, Object value) { */ @java.lang.Override public _FinalStage putAllUserInput(Map userInput) { - this.userInput.putAll(userInput); + if (userInput != null) { + this.userInput.putAll(userInput); + } return this; } @@ -186,7 +192,9 @@ public _FinalStage putAllUserInput(Map userInput) { @JsonSetter(value = "user_input", nulls = Nulls.SKIP) public _FinalStage userInput(Map userInput) { this.userInput.clear(); - this.userInput.putAll(userInput); + if (userInput != null) { + this.userInput.putAll(userInput); + } return this; } @@ -196,7 +204,9 @@ public _FinalStage userInput(Map userInput) { */ @java.lang.Override public _FinalStage addAllSources(List sources) { - this.sources.addAll(sources); + if (sources != null) { + this.sources.addAll(sources); + } return this; } @@ -217,7 +227,9 @@ public _FinalStage addSources(SourcesResponseDtoSourcesItem sources) { @JsonSetter(value = "sources", nulls = Nulls.SKIP) public _FinalStage sources(List sources) { this.sources.clear(); - this.sources.addAll(sources); + if (sources != null) { + this.sources.addAll(sources); + } return this; } @@ -225,5 +237,17 @@ public _FinalStage sources(List sources) { public SourcesResponseDto build() { return new SourcesResponseDto(message, sources, userInput, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/SubscriptionResponseDto.java b/src/main/java/com/newscatcher/api/types/SubscriptionResponseDto.java index 8319789..e1c1e02 100644 --- a/src/main/java/com/newscatcher/api/types/SubscriptionResponseDto.java +++ b/src/main/java/com/newscatcher/api/types/SubscriptionResponseDto.java @@ -179,6 +179,10 @@ public interface HistoricalDaysStage { public interface _FinalStage { SubscriptionResponseDto build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -295,5 +299,17 @@ public SubscriptionResponseDto build() { return new SubscriptionResponseDto( active, concurrentCalls, plan, planCalls, remainingCalls, historicalDays, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/main/java/com/newscatcher/api/types/TimeFrameCount.java b/src/main/java/com/newscatcher/api/types/TimeFrameCount.java index 46770a6..5646c72 100644 --- a/src/main/java/com/newscatcher/api/types/TimeFrameCount.java +++ b/src/main/java/com/newscatcher/api/types/TimeFrameCount.java @@ -95,6 +95,10 @@ public interface ArticleCountStage { public interface _FinalStage { TimeFrameCount build(); + + _FinalStage additionalProperty(String key, Object value); + + _FinalStage additionalProperties(Map additionalProperties); } @JsonIgnoreProperties(ignoreUnknown = true) @@ -143,5 +147,17 @@ public _FinalStage articleCount(int articleCount) { public TimeFrameCount build() { return new TimeFrameCount(timeFrame, articleCount, additionalProperties); } + + @java.lang.Override + public Builder additionalProperty(String key, Object value) { + this.additionalProperties.put(key, value); + return this; + } + + @java.lang.Override + public Builder additionalProperties(Map additionalProperties) { + this.additionalProperties.putAll(additionalProperties); + return this; + } } } diff --git a/src/test/java/com/newscatcher/api/StreamTest.java b/src/test/java/com/newscatcher/api/StreamTest.java index 7ce0e64..a52a959 100644 --- a/src/test/java/com/newscatcher/api/StreamTest.java +++ b/src/test/java/com/newscatcher/api/StreamTest.java @@ -9,6 +9,9 @@ import com.newscatcher.api.core.Stream; import java.io.IOException; import java.io.StringReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -17,8 +20,9 @@ public final class StreamTest { @Test public void testJsonStream() { - List messages = List.of(Map.of("message", "hello"), Map.of("message", "world")); - List jsonStrings = messages.stream().map(StreamTest::mapToJson).collect(Collectors.toList()); + List> messages = + Arrays.asList(createMap("message", "hello"), createMap("message", "world")); + List jsonStrings = messages.stream().map(StreamTest::mapToJson).collect(Collectors.toList()); String input = String.join("\n", jsonStrings); StringReader jsonInput = new StringReader(input); Stream jsonStream = Stream.fromJson(Map.class, jsonInput); @@ -33,8 +37,8 @@ public void testJsonStream() { @Test public void testSseStream() { - List events = List.of(Map.of("event", "start"), Map.of("event", "end")); - List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + List> events = Arrays.asList(createMap("event", "start"), createMap("event", "end")); + List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); String input = String.join("\n" + "\n", sseStrings); StringReader sseInput = new StringReader(input); Stream sseStream = Stream.fromSse(Map.class, sseInput); @@ -49,8 +53,9 @@ public void testSseStream() { @Test public void testSseStreamWithTerminator() { - List events = List.of(Map.of("message", "first"), Map.of("message", "second")); - List sseStrings = events.stream().map(StreamTest::mapToSse).collect(Collectors.toList()); + List> events = Arrays.asList(createMap("message", "first"), createMap("message", "second")); + List sseStrings = + new ArrayList<>(events.stream().map(StreamTest::mapToSse).collect(Collectors.toList())); sseStrings.add("data: [DONE]"); String input = String.join("\n" + "\n", sseStrings); StringReader sseInput = new StringReader(input); @@ -64,6 +69,25 @@ public void testSseStreamWithTerminator() { assertEquals(expectedEvents, actualEvents); } + @Test + public void testSseEventDiscriminatedStream() { + List sseStrings = Arrays.asList( + mapToSseWithEvent("start", createMap("status", "pending")), + mapToSseWithEvent("end", createMap("status", "complete"))); + String input = String.join("\n" + "\n", sseStrings); + StringReader sseInput = new StringReader(input); + Stream sseStream = Stream.fromSseWithEventDiscrimination(Map.class, sseInput, "event"); + int expectedEvents = 2; + int actualEvents = 0; + for (Map eventData : sseStream) { + actualEvents++; + // Event-level discrimination includes the event field in the parsed result + assertTrue(eventData.containsKey("event")); + assertTrue(eventData.containsKey("data")); + } + assertEquals(expectedEvents, actualEvents); + } + @Test public void testStreamResourceManagement() throws IOException { StringReader testInput = new StringReader("{\"test\":\"data\"}"); @@ -83,4 +107,14 @@ private static String mapToJson(Map map) { private static String mapToSse(Map map) { return "data: " + mapToJson(map); } + + private static String mapToSseWithEvent(String eventType, Map data) { + return "event: " + eventType + "\n" + "data: " + mapToJson(data); + } + + private static Map createMap(String key, String value) { + Map map = new HashMap<>(); + map.put(key, value); + return map; + } }