diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml
index a599124..9e634cb 100644
--- a/.github/workflows/publish-sonatype.yml
+++ b/.github/workflows/publish-sonatype.yml
@@ -33,7 +33,7 @@ jobs:
export -- GPG_SIGNING_KEY_ID
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
- ./gradlew publish --no-configuration-cache
+ ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
env:
SONATYPE_USERNAME: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 3d2ac0b..10f3091 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0"
+ ".": "0.2.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 9f265c5..58aca93 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 115
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-af60c455e2c8579c3d7f0e33c07c0b8332aa3fe8869688c47b2fbf151e271235.yml
-openapi_spec_hash: a49d40286e54da6a4978a103b118d33f
-config_hash: cec075ca53645b9620ec200be71bdc48
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-3b2c6c771ad1da0bbfeb0af115972929ed2c7fcd5e47a79556d66cd21431b224.yml
+openapi_spec_hash: de2890233b68387bf5f9b6d19e7d87dc
+config_hash: 8894c96caeb6df84c9394518810221bd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0613480..2239e78 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## 0.2.0 (2026-04-01)
+
+Full Changelog: [v0.1.0...v0.2.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.1.0...v0.2.0)
+
+### Features
+
+* **api:** api update ([31b819a](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/31b819aeae39651f9f9204561f6be9719c7a8d6a))
+* **api:** api update ([30ac688](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/30ac6883a272290b03f5baa499ae2b61ac168259))
+
+
+### Chores
+
+* update SDK settings ([e22bccf](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/e22bccf3d47dfd11929924969cb5438b131069f7))
+
## 0.1.0 (2026-03-30)
Full Changelog: [v0.0.1...v0.1.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.0.1...v0.1.0)
diff --git a/README.md b/README.md
index 3ae77da..39d4d2e 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,20 @@
-[](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1.0)
-[](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1.0)
+[](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0)
+[](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0)
The X Twitter Scraper Java SDK provides convenient access to the [X Twitter Scraper REST API](https://xquik.com) from applications written in Java.
+The X Twitter Scraper Java SDK is similar to the X Twitter Scraper Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.
+
It is generated with [Stainless](https://www.stainless.com/).
-The REST API documentation can be found on [xquik.com](https://xquik.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1.0).
+The REST API documentation can be found on [xquik.com](https://xquik.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0).
@@ -24,7 +26,7 @@ The REST API documentation can be found on [xquik.com](https://xquik.com). Javad
### Gradle
```kotlin
-implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.1.0")
+implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0")
```
### Maven
@@ -33,7 +35,7 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.1.0")
com.x_twitter_scraper.api
x-twitter-scraper-java
- 0.1.0
+ 0.2.0
```
@@ -48,8 +50,8 @@ This library requires Java 8 or later.
```java
import com.x_twitter_scraper.api.client.XTwitterScraperClient;
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient;
-import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
// Or configures using the `X_TWITTER_SCRAPER_API_KEY`, `X_TWITTER_SCRAPER_BEARER_TOKEN` and `X_TWITTER_SCRAPER_BASE_URL` environment variables
@@ -59,7 +61,7 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
-PaginatedTweets paginatedTweets = client.x().tweets().search(params);
+TweetSearchResponse response = client.x().tweets().search(params);
```
## Client configuration
@@ -134,7 +136,7 @@ The `withOptions()` method does not affect the original client or service.
To send a request to the X Twitter Scraper API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
-For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `PaginatedTweets`.
+For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `TweetSearchResponse`.
## Immutability
@@ -151,8 +153,8 @@ The default client is synchronous. To switch to asynchronous execution, call the
```java
import com.x_twitter_scraper.api.client.XTwitterScraperClient;
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient;
-import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
import java.util.concurrent.CompletableFuture;
// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
@@ -163,7 +165,7 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
-CompletableFuture paginatedTweets = client.async().x().tweets().search(params);
+CompletableFuture response = client.async().x().tweets().search(params);
```
Or create an asynchronous client from the beginning:
@@ -171,8 +173,8 @@ Or create an asynchronous client from the beginning:
```java
import com.x_twitter_scraper.api.client.XTwitterScraperClientAsync;
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync;
-import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
import java.util.concurrent.CompletableFuture;
// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
@@ -183,7 +185,7 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
-CompletableFuture paginatedTweets = client.x().tweets().search(params);
+CompletableFuture response = client.x().tweets().search(params);
```
The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
@@ -309,25 +311,25 @@ To access this data, prefix any HTTP method call on a client or service with `wi
```java
import com.x_twitter_scraper.api.core.http.Headers;
import com.x_twitter_scraper.api.core.http.HttpResponseFor;
-import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
-HttpResponseFor paginatedTweets = client.x().tweets().withRawResponse().search(params);
+HttpResponseFor response = client.x().tweets().withRawResponse().search(params);
-int statusCode = paginatedTweets.statusCode();
-Headers headers = paginatedTweets.headers();
+int statusCode = response.statusCode();
+Headers headers = response.headers();
```
You can still deserialize the response into an instance of a Java class if needed:
```java
-import com.x_twitter_scraper.api.models.PaginatedTweets;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
-PaginatedTweets parsedPaginatedTweets = paginatedTweets.parse();
+TweetSearchResponse parsedResponse = response.parse();
```
## Error handling
@@ -425,9 +427,9 @@ Requests time out after 1 minute by default.
To set a custom timeout, configure the method call using the `timeout` method:
```java
-import com.x_twitter_scraper.api.models.PaginatedTweets;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
-PaginatedTweets paginatedTweets = client.x().tweets().search(
+TweetSearchResponse response = client.x().tweets().search(
params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()
);
```
@@ -703,17 +705,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`XT
If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:
```java
-import com.x_twitter_scraper.api.models.PaginatedTweets;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
-PaginatedTweets paginatedTweets = client.x().tweets().search(params).validate();
+TweetSearchResponse response = client.x().tweets().search(params).validate();
```
Or configure the method call to validate the response using the `responseValidation` method:
```java
-import com.x_twitter_scraper.api.models.PaginatedTweets;
+import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
-PaginatedTweets paginatedTweets = client.x().tweets().search(
+TweetSearchResponse response = client.x().tweets().search(
params, RequestOptions.builder().responseValidation(true).build()
);
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 9022e4c..81f4172 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,5 +1,4 @@
plugins {
- id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.jetbrains.dokka") version "2.0.0"
}
@@ -9,7 +8,7 @@ repositories {
allprojects {
group = "com.x_twitter_scraper.api"
- version = "0.1.0" // x-release-please-version
+ version = "0.2.0" // x-release-please-version
}
subprojects {
@@ -35,15 +34,3 @@ tasks.named("dokkaJavadocCollector").configure {
.filter { it.project.name != "x-twitter-scraper-java" && it.name == "dokkaJavadocJar" }
.forEach { mustRunAfter(it) }
}
-
-nexusPublishing {
- repositories {
- sonatype {
- nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
- snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
-
- username.set(System.getenv("SONATYPE_USERNAME"))
- password.set(System.getenv("SONATYPE_PASSWORD"))
- }
- }
-}
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 0b14135..c6dc92e 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -1,12 +1,15 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.9.20"
+ id("com.vanniktech.maven.publish") version "0.28.0"
}
repositories {
gradlePluginPortal()
+ mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
+ implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
}
diff --git a/buildSrc/src/main/kotlin/x-twitter-scraper.java.gradle.kts b/buildSrc/src/main/kotlin/x-twitter-scraper.java.gradle.kts
index a3cfe28..8f4f902 100644
--- a/buildSrc/src/main/kotlin/x-twitter-scraper.java.gradle.kts
+++ b/buildSrc/src/main/kotlin/x-twitter-scraper.java.gradle.kts
@@ -8,11 +8,6 @@ repositories {
mavenCentral()
}
-configure {
- withJavadocJar()
- withSourcesJar()
-}
-
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
@@ -27,10 +22,6 @@ tasks.withType().configureEach {
options.release.set(8)
}
-tasks.named("javadocJar") {
- setZip64(true)
-}
-
tasks.named("jar") {
manifest {
attributes(mapOf(
diff --git a/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts b/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts
index 9edc4d2..b0ad2e8 100644
--- a/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts
+++ b/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts
@@ -1,69 +1,72 @@
+import com.vanniktech.maven.publish.JavadocJar
+import com.vanniktech.maven.publish.KotlinJvm
+import com.vanniktech.maven.publish.MavenPublishBaseExtension
+import com.vanniktech.maven.publish.SonatypeHost
+
plugins {
- `maven-publish`
- signing
+ id("com.vanniktech.maven.publish")
+}
+
+publishing {
+ repositories {
+ if (project.hasProperty("publishLocal")) {
+ maven {
+ name = "LocalFileSystem"
+ url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo")
+ }
+ }
+ }
}
-configure {
- publications {
- register("maven") {
- from(components["java"])
+repositories {
+ gradlePluginPortal()
+ mavenCentral()
+}
- pom {
- name.set("Xquik API")
- description.set("X real-time data platform — extractions, giveaway draws, monitoring, webhooks.")
- url.set("https://xquik.com")
+extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
+extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
+extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")
- licenses {
- license {
- name.set("Apache-2.0")
- }
- }
+configure {
+ if (!project.hasProperty("publishLocal")) {
+ signAllPublications()
+ publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
+ }
- developers {
- developer {
- name.set("X Twitter Scraper")
- email.set("support@xquik.com")
- }
- }
+ coordinates(project.group.toString(), project.name, project.version.toString())
+ configure(
+ KotlinJvm(
+ javadocJar = JavadocJar.Dokka("dokkaJavadoc"),
+ sourcesJar = true,
+ )
+ )
- scm {
- connection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git")
- developerConnection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git")
- url.set("https://github.com/Xquik-dev/x-twitter-scraper-java")
- }
+ pom {
+ name.set("Xquik API")
+ description.set("X real-time data platform — extractions, giveaway draws, monitoring, webhooks.")
+ url.set("https://xquik.com")
- versionMapping {
- allVariants {
- fromResolutionResult()
- }
- }
+ licenses {
+ license {
+ name.set("Apache-2.0")
}
}
- }
- repositories {
- if (project.hasProperty("publishLocal")) {
- maven {
- name = "LocalFileSystem"
- url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo")
+
+ developers {
+ developer {
+ name.set("X Twitter Scraper")
+ email.set("support@xquik.com")
}
}
- }
-}
-signing {
- val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null }
- val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null }
- val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null }
- if (signingKey != null && signingPassword != null) {
- useInMemoryPgpKeys(
- signingKeyId,
- signingKey,
- signingPassword,
- )
- sign(publishing.publications["maven"])
+ scm {
+ connection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git")
+ developerConnection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git")
+ url.set("https://github.com/Xquik-dev/x-twitter-scraper-java")
+ }
}
}
-tasks.named("publish") {
- dependsOn(":closeAndReleaseSonatypeStagingRepository")
+tasks.withType().configureEach {
+ isZip64 = true
}
diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt
index 5e8f256..2880aa9 100644
--- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt
+++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt
@@ -14,9 +14,9 @@ import com.x_twitter_scraper.api.core.checkKnown
import com.x_twitter_scraper.api.core.checkRequired
import com.x_twitter_scraper.api.core.toImmutable
import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException
-import com.x_twitter_scraper.api.models.x.tweets.SearchTweet
import java.util.Collections
import java.util.Objects
+import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class PaginatedTweets
@@ -24,7 +24,7 @@ class PaginatedTweets
private constructor(
private val hasNextPage: JsonField,
private val nextCursor: JsonField,
- private val tweets: JsonField>,
+ private val tweets: JsonField>,
private val additionalProperties: MutableMap,
) {
@@ -36,9 +36,7 @@ private constructor(
@JsonProperty("next_cursor")
@ExcludeMissing
nextCursor: JsonField = JsonMissing.of(),
- @JsonProperty("tweets")
- @ExcludeMissing
- tweets: JsonField> = JsonMissing.of(),
+ @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(),
) : this(hasNextPage, nextCursor, tweets, mutableMapOf())
/**
@@ -57,7 +55,7 @@ private constructor(
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
- fun tweets(): List = tweets.getRequired("tweets")
+ fun tweets(): List = tweets.getRequired("tweets")
/**
* Returns the raw JSON value of [hasNextPage].
@@ -80,7 +78,7 @@ private constructor(
*
* Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type.
*/
- @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets
+ @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
@@ -114,7 +112,7 @@ private constructor(
private var hasNextPage: JsonField? = null
private var nextCursor: JsonField? = null
- private var tweets: JsonField>? = null
+ private var tweets: JsonField>? = null
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -147,25 +145,25 @@ private constructor(
*/
fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor }
- fun tweets(tweets: List) = tweets(JsonField.of(tweets))
+ fun tweets(tweets: List) = tweets(JsonField.of(tweets))
/**
* Sets [Builder.tweets] to an arbitrary JSON value.
*
- * You should usually call [Builder.tweets] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
+ * You should usually call [Builder.tweets] with a well-typed `List` value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
*/
- fun tweets(tweets: JsonField>) = apply {
+ fun tweets(tweets: JsonField>) = apply {
this.tweets = tweets.map { it.toMutableList() }
}
/**
- * Adds a single [SearchTweet] to [tweets].
+ * Adds a single [Tweet] to [tweets].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
- fun addTweet(tweet: SearchTweet) = apply {
+ fun addTweet(tweet: Tweet) = apply {
tweets =
(tweets ?: JsonField.of(mutableListOf())).also {
checkKnown("tweets", it).add(tweet)
@@ -246,6 +244,776 @@ private constructor(
(if (nextCursor.asKnown().isPresent) 1 else 0) +
(tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+ class Tweet
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val id: JsonField,
+ private val text: JsonField,
+ private val author: JsonField,
+ private val bookmarkCount: JsonField,
+ private val createdAt: JsonField,
+ private val likeCount: JsonField,
+ private val quoteCount: JsonField,
+ private val replyCount: JsonField,
+ private val retweetCount: JsonField,
+ private val viewCount: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(),
+ @JsonProperty("author") @ExcludeMissing author: JsonField = JsonMissing.of(),
+ @JsonProperty("bookmarkCount")
+ @ExcludeMissing
+ bookmarkCount: JsonField = JsonMissing.of(),
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("likeCount")
+ @ExcludeMissing
+ likeCount: JsonField = JsonMissing.of(),
+ @JsonProperty("quoteCount")
+ @ExcludeMissing
+ quoteCount: JsonField = JsonMissing.of(),
+ @JsonProperty("replyCount")
+ @ExcludeMissing
+ replyCount: JsonField = JsonMissing.of(),
+ @JsonProperty("retweetCount")
+ @ExcludeMissing
+ retweetCount: JsonField = JsonMissing.of(),
+ @JsonProperty("viewCount") @ExcludeMissing viewCount: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ text,
+ author,
+ bookmarkCount,
+ createdAt,
+ likeCount,
+ quoteCount,
+ replyCount,
+ retweetCount,
+ viewCount,
+ mutableMapOf(),
+ )
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun text(): String = text.getRequired("text")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun author(): Optional = author.getOptional("author")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun bookmarkCount(): Optional = bookmarkCount.getOptional("bookmarkCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun createdAt(): Optional = createdAt.getOptional("createdAt")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun likeCount(): Optional = likeCount.getOptional("likeCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun quoteCount(): Optional = quoteCount.getOptional("quoteCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun replyCount(): Optional = replyCount.getOptional("replyCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun retweetCount(): Optional = retweetCount.getOptional("retweetCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun viewCount(): Optional = viewCount.getOptional("viewCount")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [text].
+ *
+ * Unlike [text], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text
+
+ /**
+ * Returns the raw JSON value of [author].
+ *
+ * Unlike [author], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("author") @ExcludeMissing fun _author(): JsonField = author
+
+ /**
+ * Returns the raw JSON value of [bookmarkCount].
+ *
+ * Unlike [bookmarkCount], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("bookmarkCount")
+ @ExcludeMissing
+ fun _bookmarkCount(): JsonField = bookmarkCount
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt
+
+ /**
+ * Returns the raw JSON value of [likeCount].
+ *
+ * Unlike [likeCount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("likeCount") @ExcludeMissing fun _likeCount(): JsonField = likeCount
+
+ /**
+ * Returns the raw JSON value of [quoteCount].
+ *
+ * Unlike [quoteCount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("quoteCount") @ExcludeMissing fun _quoteCount(): JsonField = quoteCount
+
+ /**
+ * Returns the raw JSON value of [replyCount].
+ *
+ * Unlike [replyCount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("replyCount") @ExcludeMissing fun _replyCount(): JsonField = replyCount
+
+ /**
+ * Returns the raw JSON value of [retweetCount].
+ *
+ * Unlike [retweetCount], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("retweetCount")
+ @ExcludeMissing
+ fun _retweetCount(): JsonField = retweetCount
+
+ /**
+ * Returns the raw JSON value of [viewCount].
+ *
+ * Unlike [viewCount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("viewCount") @ExcludeMissing fun _viewCount(): JsonField = viewCount
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Tweet].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .text()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Tweet]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var text: JsonField? = null
+ private var author: JsonField = JsonMissing.of()
+ private var bookmarkCount: JsonField = JsonMissing.of()
+ private var createdAt: JsonField = JsonMissing.of()
+ private var likeCount: JsonField = JsonMissing.of()
+ private var quoteCount: JsonField = JsonMissing.of()
+ private var replyCount: JsonField = JsonMissing.of()
+ private var retweetCount: JsonField = JsonMissing.of()
+ private var viewCount: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(tweet: Tweet) = apply {
+ id = tweet.id
+ text = tweet.text
+ author = tweet.author
+ bookmarkCount = tweet.bookmarkCount
+ createdAt = tweet.createdAt
+ likeCount = tweet.likeCount
+ quoteCount = tweet.quoteCount
+ replyCount = tweet.replyCount
+ retweetCount = tweet.retweetCount
+ viewCount = tweet.viewCount
+ additionalProperties = tweet.additionalProperties.toMutableMap()
+ }
+
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun text(text: String) = text(JsonField.of(text))
+
+ /**
+ * Sets [Builder.text] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.text] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun text(text: JsonField) = apply { this.text = text }
+
+ fun author(author: Author) = author(JsonField.of(author))
+
+ /**
+ * Sets [Builder.author] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.author] with a well-typed [Author] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun author(author: JsonField) = apply { this.author = author }
+
+ fun bookmarkCount(bookmarkCount: Long) = bookmarkCount(JsonField.of(bookmarkCount))
+
+ /**
+ * Sets [Builder.bookmarkCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.bookmarkCount] with a well-typed [Long] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun bookmarkCount(bookmarkCount: JsonField) = apply {
+ this.bookmarkCount = bookmarkCount
+ }
+
+ fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt))
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }
+
+ fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount))
+
+ /**
+ * Sets [Builder.likeCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.likeCount] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun likeCount(likeCount: JsonField) = apply { this.likeCount = likeCount }
+
+ fun quoteCount(quoteCount: Long) = quoteCount(JsonField.of(quoteCount))
+
+ /**
+ * Sets [Builder.quoteCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.quoteCount] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun quoteCount(quoteCount: JsonField) = apply { this.quoteCount = quoteCount }
+
+ fun replyCount(replyCount: Long) = replyCount(JsonField.of(replyCount))
+
+ /**
+ * Sets [Builder.replyCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.replyCount] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun replyCount(replyCount: JsonField) = apply { this.replyCount = replyCount }
+
+ fun retweetCount(retweetCount: Long) = retweetCount(JsonField.of(retweetCount))
+
+ /**
+ * Sets [Builder.retweetCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.retweetCount] with a well-typed [Long] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun retweetCount(retweetCount: JsonField) = apply {
+ this.retweetCount = retweetCount
+ }
+
+ fun viewCount(viewCount: Long) = viewCount(JsonField.of(viewCount))
+
+ /**
+ * Sets [Builder.viewCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.viewCount] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun viewCount(viewCount: JsonField) = apply { this.viewCount = viewCount }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Tweet].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .text()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Tweet =
+ Tweet(
+ checkRequired("id", id),
+ checkRequired("text", text),
+ author,
+ bookmarkCount,
+ createdAt,
+ likeCount,
+ quoteCount,
+ replyCount,
+ retweetCount,
+ viewCount,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Tweet = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ text()
+ author().ifPresent { it.validate() }
+ bookmarkCount()
+ createdAt()
+ likeCount()
+ quoteCount()
+ replyCount()
+ retweetCount()
+ viewCount()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: XTwitterScraperInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (id.asKnown().isPresent) 1 else 0) +
+ (if (text.asKnown().isPresent) 1 else 0) +
+ (author.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (bookmarkCount.asKnown().isPresent) 1 else 0) +
+ (if (createdAt.asKnown().isPresent) 1 else 0) +
+ (if (likeCount.asKnown().isPresent) 1 else 0) +
+ (if (quoteCount.asKnown().isPresent) 1 else 0) +
+ (if (replyCount.asKnown().isPresent) 1 else 0) +
+ (if (retweetCount.asKnown().isPresent) 1 else 0) +
+ (if (viewCount.asKnown().isPresent) 1 else 0)
+
+ class Author
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val id: JsonField,
+ private val name: JsonField,
+ private val username: JsonField,
+ private val verified: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
+ @JsonProperty("username")
+ @ExcludeMissing
+ username: JsonField = JsonMissing.of(),
+ @JsonProperty("verified")
+ @ExcludeMissing
+ verified: JsonField = JsonMissing.of(),
+ ) : this(id, name, username, verified, mutableMapOf())
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * or is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * or is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun name(): String = name.getRequired("name")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * or is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun username(): String = username.getRequired("username")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun verified(): Optional = verified.getOptional("verified")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [name].
+ *
+ * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
+
+ /**
+ * Returns the raw JSON value of [username].
+ *
+ * Unlike [username], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username
+
+ /**
+ * Returns the raw JSON value of [verified].
+ *
+ * Unlike [verified], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("verified") @ExcludeMissing fun _verified(): JsonField = verified
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [Author].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .name()
+ * .username()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Author]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var name: JsonField? = null
+ private var username: JsonField? = null
+ private var verified: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(author: Author) = apply {
+ id = author.id
+ name = author.name
+ username = author.username
+ verified = author.verified
+ additionalProperties = author.additionalProperties.toMutableMap()
+ }
+
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun name(name: String) = name(JsonField.of(name))
+
+ /**
+ * Sets [Builder.name] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.name] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun name(name: JsonField) = apply { this.name = name }
+
+ fun username(username: String) = username(JsonField.of(username))
+
+ /**
+ * Sets [Builder.username] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.username] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun username(username: JsonField) = apply { this.username = username }
+
+ fun verified(verified: Boolean) = verified(JsonField.of(verified))
+
+ /**
+ * Sets [Builder.verified] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.verified] with a well-typed [Boolean] value
+ * instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun verified(verified: JsonField) = apply { this.verified = verified }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [Author].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .name()
+ * .username()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): Author =
+ Author(
+ checkRequired("id", id),
+ checkRequired("name", name),
+ checkRequired("username", username),
+ verified,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Author = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ name()
+ username()
+ verified()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: XTwitterScraperInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (id.asKnown().isPresent) 1 else 0) +
+ (if (name.asKnown().isPresent) 1 else 0) +
+ (if (username.asKnown().isPresent) 1 else 0) +
+ (if (verified.asKnown().isPresent) 1 else 0)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Author &&
+ id == other.id &&
+ name == other.name &&
+ username == other.username &&
+ verified == other.verified &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(id, name, username, verified, additionalProperties)
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Author{id=$id, name=$name, username=$username, verified=$verified, additionalProperties=$additionalProperties}"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is Tweet &&
+ id == other.id &&
+ text == other.text &&
+ author == other.author &&
+ bookmarkCount == other.bookmarkCount &&
+ createdAt == other.createdAt &&
+ likeCount == other.likeCount &&
+ quoteCount == other.quoteCount &&
+ replyCount == other.replyCount &&
+ retweetCount == other.retweetCount &&
+ viewCount == other.viewCount &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ id,
+ text,
+ author,
+ bookmarkCount,
+ createdAt,
+ likeCount,
+ quoteCount,
+ replyCount,
+ retweetCount,
+ viewCount,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}"
+ }
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt
index 50b15e7..c3e969c 100644
--- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt
+++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt
@@ -14,9 +14,9 @@ import com.x_twitter_scraper.api.core.checkKnown
import com.x_twitter_scraper.api.core.checkRequired
import com.x_twitter_scraper.api.core.toImmutable
import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException
-import com.x_twitter_scraper.api.models.x.users.UserProfile
import java.util.Collections
import java.util.Objects
+import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class PaginatedUsers
@@ -24,7 +24,7 @@ class PaginatedUsers
private constructor(
private val hasNextPage: JsonField,
private val nextCursor: JsonField,
- private val users: JsonField>,
+ private val users: JsonField>,
private val additionalProperties: MutableMap,
) {
@@ -36,9 +36,7 @@ private constructor(
@JsonProperty("next_cursor")
@ExcludeMissing
nextCursor: JsonField = JsonMissing.of(),
- @JsonProperty("users")
- @ExcludeMissing
- users: JsonField> = JsonMissing.of(),
+ @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(),
) : this(hasNextPage, nextCursor, users, mutableMapOf())
/**
@@ -57,7 +55,7 @@ private constructor(
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
- fun users(): List = users.getRequired("users")
+ fun users(): List = users.getRequired("users")
/**
* Returns the raw JSON value of [hasNextPage].
@@ -80,7 +78,7 @@ private constructor(
*
* Unlike [users], this method doesn't throw if the JSON field has an unexpected type.
*/
- @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users
+ @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
@@ -114,7 +112,7 @@ private constructor(
private var hasNextPage: JsonField? = null
private var nextCursor: JsonField? = null
- private var users: JsonField>? = null
+ private var users: JsonField>? = null
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -147,25 +145,25 @@ private constructor(
*/
fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor }
- fun users(users: List) = users(JsonField.of(users))
+ fun users(users: List) = users(JsonField.of(users))
/**
* Sets [Builder.users] to an arbitrary JSON value.
*
- * You should usually call [Builder.users] with a well-typed `List` value
- * instead. This method is primarily for setting the field to an undocumented or not yet
- * supported value.
+ * You should usually call [Builder.users] with a well-typed `List` value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
*/
- fun users(users: JsonField>) = apply {
+ fun users(users: JsonField>) = apply {
this.users = users.map { it.toMutableList() }
}
/**
- * Adds a single [UserProfile] to [users].
+ * Adds a single [User] to [users].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
- fun addUser(user: UserProfile) = apply {
+ fun addUser(user: User) = apply {
users =
(users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) }
}
@@ -244,6 +242,552 @@ private constructor(
(if (nextCursor.asKnown().isPresent) 1 else 0) +
(users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+ class User
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val id: JsonField,
+ private val name: JsonField,
+ private val username: JsonField,
+ private val createdAt: JsonField,
+ private val description: JsonField,
+ private val followers: JsonField,
+ private val following: JsonField,
+ private val location: JsonField,
+ private val profilePicture: JsonField,
+ private val statusesCount: JsonField,
+ private val verified: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
+ @JsonProperty("username")
+ @ExcludeMissing
+ username: JsonField = JsonMissing.of(),
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("description")
+ @ExcludeMissing
+ description: JsonField = JsonMissing.of(),
+ @JsonProperty("followers")
+ @ExcludeMissing
+ followers: JsonField = JsonMissing.of(),
+ @JsonProperty("following")
+ @ExcludeMissing
+ following: JsonField = JsonMissing.of(),
+ @JsonProperty("location")
+ @ExcludeMissing
+ location: JsonField = JsonMissing.of(),
+ @JsonProperty("profilePicture")
+ @ExcludeMissing
+ profilePicture: JsonField = JsonMissing.of(),
+ @JsonProperty("statusesCount")
+ @ExcludeMissing
+ statusesCount: JsonField = JsonMissing.of(),
+ @JsonProperty("verified")
+ @ExcludeMissing
+ verified: JsonField = JsonMissing.of(),
+ ) : this(
+ id,
+ name,
+ username,
+ createdAt,
+ description,
+ followers,
+ following,
+ location,
+ profilePicture,
+ statusesCount,
+ verified,
+ mutableMapOf(),
+ )
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun name(): String = name.getRequired("name")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun username(): String = username.getRequired("username")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun createdAt(): Optional = createdAt.getOptional("createdAt")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun description(): Optional = description.getOptional("description")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun followers(): Optional = followers.getOptional("followers")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun following(): Optional = following.getOptional("following")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun location(): Optional = location.getOptional("location")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun profilePicture(): Optional = profilePicture.getOptional("profilePicture")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun statusesCount(): Optional = statusesCount.getOptional("statusesCount")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun verified(): Optional = verified.getOptional("verified")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id
+
+ /**
+ * Returns the raw JSON value of [name].
+ *
+ * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
+
+ /**
+ * Returns the raw JSON value of [username].
+ *
+ * Unlike [username], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username
+
+ /**
+ * Returns the raw JSON value of [createdAt].
+ *
+ * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt
+
+ /**
+ * Returns the raw JSON value of [description].
+ *
+ * Unlike [description], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("description")
+ @ExcludeMissing
+ fun _description(): JsonField = description
+
+ /**
+ * Returns the raw JSON value of [followers].
+ *
+ * Unlike [followers], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("followers") @ExcludeMissing fun _followers(): JsonField = followers
+
+ /**
+ * Returns the raw JSON value of [following].
+ *
+ * Unlike [following], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("following") @ExcludeMissing fun _following(): JsonField = following
+
+ /**
+ * Returns the raw JSON value of [location].
+ *
+ * Unlike [location], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location
+
+ /**
+ * Returns the raw JSON value of [profilePicture].
+ *
+ * Unlike [profilePicture], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("profilePicture")
+ @ExcludeMissing
+ fun _profilePicture(): JsonField = profilePicture
+
+ /**
+ * Returns the raw JSON value of [statusesCount].
+ *
+ * Unlike [statusesCount], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("statusesCount")
+ @ExcludeMissing
+ fun _statusesCount(): JsonField = statusesCount
+
+ /**
+ * Returns the raw JSON value of [verified].
+ *
+ * Unlike [verified], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("verified") @ExcludeMissing fun _verified(): JsonField = verified
+
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
+
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
+
+ fun toBuilder() = Builder().from(this)
+
+ companion object {
+
+ /**
+ * Returns a mutable builder for constructing an instance of [User].
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .name()
+ * .username()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [User]. */
+ class Builder internal constructor() {
+
+ private var id: JsonField? = null
+ private var name: JsonField? = null
+ private var username: JsonField? = null
+ private var createdAt: JsonField = JsonMissing.of()
+ private var description: JsonField = JsonMissing.of()
+ private var followers: JsonField = JsonMissing.of()
+ private var following: JsonField = JsonMissing.of()
+ private var location: JsonField = JsonMissing.of()
+ private var profilePicture: JsonField = JsonMissing.of()
+ private var statusesCount: JsonField = JsonMissing.of()
+ private var verified: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(user: User) = apply {
+ id = user.id
+ name = user.name
+ username = user.username
+ createdAt = user.createdAt
+ description = user.description
+ followers = user.followers
+ following = user.following
+ location = user.location
+ profilePicture = user.profilePicture
+ statusesCount = user.statusesCount
+ verified = user.verified
+ additionalProperties = user.additionalProperties.toMutableMap()
+ }
+
+ fun id(id: String) = id(JsonField.of(id))
+
+ /**
+ * Sets [Builder.id] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.id] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun id(id: JsonField) = apply { this.id = id }
+
+ fun name(name: String) = name(JsonField.of(name))
+
+ /**
+ * Sets [Builder.name] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.name] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun name(name: JsonField) = apply { this.name = name }
+
+ fun username(username: String) = username(JsonField.of(username))
+
+ /**
+ * Sets [Builder.username] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.username] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun username(username: JsonField) = apply { this.username = username }
+
+ fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt))
+
+ /**
+ * Sets [Builder.createdAt] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.createdAt] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }
+
+ fun description(description: String) = description(JsonField.of(description))
+
+ /**
+ * Sets [Builder.description] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.description] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun description(description: JsonField) = apply {
+ this.description = description
+ }
+
+ fun followers(followers: Long) = followers(JsonField.of(followers))
+
+ /**
+ * Sets [Builder.followers] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.followers] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun followers(followers: JsonField) = apply { this.followers = followers }
+
+ fun following(following: Long) = following(JsonField.of(following))
+
+ /**
+ * Sets [Builder.following] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.following] with a well-typed [Long] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun following(following: JsonField) = apply { this.following = following }
+
+ fun location(location: String) = location(JsonField.of(location))
+
+ /**
+ * Sets [Builder.location] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.location] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun location(location: JsonField) = apply { this.location = location }
+
+ fun profilePicture(profilePicture: String) =
+ profilePicture(JsonField.of(profilePicture))
+
+ /**
+ * Sets [Builder.profilePicture] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.profilePicture] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun profilePicture(profilePicture: JsonField) = apply {
+ this.profilePicture = profilePicture
+ }
+
+ fun statusesCount(statusesCount: Long) = statusesCount(JsonField.of(statusesCount))
+
+ /**
+ * Sets [Builder.statusesCount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.statusesCount] with a well-typed [Long] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun statusesCount(statusesCount: JsonField) = apply {
+ this.statusesCount = statusesCount
+ }
+
+ fun verified(verified: Boolean) = verified(JsonField.of(verified))
+
+ /**
+ * Sets [Builder.verified] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.verified] with a well-typed [Boolean] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun verified(verified: JsonField) = apply { this.verified = verified }
+
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
+
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
+
+ fun putAllAdditionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
+
+ fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
+
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
+
+ /**
+ * Returns an immutable instance of [User].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .id()
+ * .name()
+ * .username()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): User =
+ User(
+ checkRequired("id", id),
+ checkRequired("name", name),
+ checkRequired("username", username),
+ createdAt,
+ description,
+ followers,
+ following,
+ location,
+ profilePicture,
+ statusesCount,
+ verified,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): User = apply {
+ if (validated) {
+ return@apply
+ }
+
+ id()
+ name()
+ username()
+ createdAt()
+ description()
+ followers()
+ following()
+ location()
+ profilePicture()
+ statusesCount()
+ verified()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: XTwitterScraperInvalidDataException) {
+ false
+ }
+
+ /**
+ * Returns a score indicating how many valid values are contained in this object
+ * recursively.
+ *
+ * Used for best match union deserialization.
+ */
+ @JvmSynthetic
+ internal fun validity(): Int =
+ (if (id.asKnown().isPresent) 1 else 0) +
+ (if (name.asKnown().isPresent) 1 else 0) +
+ (if (username.asKnown().isPresent) 1 else 0) +
+ (if (createdAt.asKnown().isPresent) 1 else 0) +
+ (if (description.asKnown().isPresent) 1 else 0) +
+ (if (followers.asKnown().isPresent) 1 else 0) +
+ (if (following.asKnown().isPresent) 1 else 0) +
+ (if (location.asKnown().isPresent) 1 else 0) +
+ (if (profilePicture.asKnown().isPresent) 1 else 0) +
+ (if (statusesCount.asKnown().isPresent) 1 else 0) +
+ (if (verified.asKnown().isPresent) 1 else 0)
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
+
+ return other is User &&
+ id == other.id &&
+ name == other.name &&
+ username == other.username &&
+ createdAt == other.createdAt &&
+ description == other.description &&
+ followers == other.followers &&
+ following == other.following &&
+ location == other.location &&
+ profilePicture == other.profilePicture &&
+ statusesCount == other.statusesCount &&
+ verified == other.verified &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ id,
+ name,
+ username,
+ createdAt,
+ description,
+ followers,
+ following,
+ location,
+ profilePicture,
+ statusesCount,
+ verified,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "User{id=$id, name=$name, username=$username, createdAt=$createdAt, description=$description, followers=$followers, following=$following, location=$location, profilePicture=$profilePicture, statusesCount=$statusesCount, verified=$verified, additionalProperties=$additionalProperties}"
+ }
+
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt
index dc1a8f1..cc46a86 100644
--- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt
+++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt
@@ -14,34 +14,36 @@ import com.x_twitter_scraper.api.core.checkKnown
import com.x_twitter_scraper.api.core.checkRequired
import com.x_twitter_scraper.api.core.toImmutable
import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException
+import java.time.OffsetDateTime
import java.util.Collections
import java.util.Objects
+import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class ApiKeyListResponse
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
- private val keys: JsonField>,
+ private val keys: JsonField>,
private val additionalProperties: MutableMap,
) {
@JsonCreator
private constructor(
- @JsonProperty("keys") @ExcludeMissing keys: JsonField> = JsonMissing.of()
+ @JsonProperty("keys") @ExcludeMissing keys: JsonField> = JsonMissing.of()
) : this(keys, mutableMapOf())
/**
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
*/
- fun keys(): List = keys.getRequired("keys")
+ fun keys(): List = keys.getRequired("keys")
/**
* Returns the raw JSON value of [keys].
*
* Unlike [keys], this method doesn't throw if the JSON field has an unexpected type.
*/
- @JsonProperty("keys") @ExcludeMissing fun _keys(): JsonField> = keys
+ @JsonProperty("keys") @ExcludeMissing fun _keys(): JsonField> = keys
@JsonAnySetter
private fun putAdditionalProperty(key: String, value: JsonValue) {
@@ -71,7 +73,7 @@ private constructor(
/** A builder for [ApiKeyListResponse]. */
class Builder internal constructor() {
- private var keys: JsonField>? = null
+ private var keys: JsonField>? = null
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
@@ -80,25 +82,22 @@ private constructor(
additionalProperties = apiKeyListResponse.additionalProperties.toMutableMap()
}
- fun keys(keys: List) = keys(JsonField.of(keys))
+ fun keys(keys: List) = keys(JsonField.of(keys))
/**
* Sets [Builder.keys] to an arbitrary JSON value.
*
- * You should usually call [Builder.keys] with a well-typed `List` value instead.
- * This method is primarily for setting the field to an undocumented or not yet supported
- * value.
+ * You should usually call [Builder.keys] with a well-typed `List` value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
*/
- fun keys(keys: JsonField>) = apply {
- this.keys = keys.map { it.toMutableList() }
- }
+ fun keys(keys: JsonField>) = apply { this.keys = keys.map { it.toMutableList() } }
/**
- * Adds a single [ApiKey] to [keys].
+ * Adds a single [Key] to [keys].
*
* @throws IllegalStateException if the field was previously set to a non-list.
*/
- fun addKey(key: ApiKey) = apply {
+ fun addKey(key: Key) = apply {
keys = (keys ?: JsonField.of(mutableListOf())).also { checkKnown("keys", it).add(key) }
}
@@ -168,6 +167,353 @@ private constructor(
internal fun validity(): Int =
(keys.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+ class Key
+ @JsonCreator(mode = JsonCreator.Mode.DISABLED)
+ private constructor(
+ private val id: JsonField,
+ private val createdAt: JsonField,
+ private val isActive: JsonField,
+ private val name: JsonField,
+ private val prefix: JsonField,
+ private val lastUsedAt: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(),
+ @JsonProperty("createdAt")
+ @ExcludeMissing
+ createdAt: JsonField = JsonMissing.of(),
+ @JsonProperty("isActive")
+ @ExcludeMissing
+ isActive: JsonField = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
+ @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(),
+ @JsonProperty("lastUsedAt")
+ @ExcludeMissing
+ lastUsedAt: JsonField = JsonMissing.of(),
+ ) : this(id, createdAt, isActive, name, prefix, lastUsedAt, mutableMapOf())
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun id(): String = id.getRequired("id")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun isActive(): Boolean = isActive.getRequired("isActive")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun name(): String = name.getRequired("name")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or
+ * is unexpectedly missing or null (e.g. if the server responded with an unexpected
+ * value).
+ */
+ fun prefix(): String = prefix.getRequired("prefix")
+
+ /**
+ * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type
+ * (e.g. if the server responded with an unexpected value).
+ */
+ fun lastUsedAt(): Optional = lastUsedAt.getOptional("lastUsedAt")
+
+ /**
+ * Returns the raw JSON value of [id].
+ *
+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField