diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..6b7b74c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 58aca93..d99ab81 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-3b2c6c771ad1da0bbfeb0af115972929ed2c7fcd5e47a79556d66cd21431b224.yml -openapi_spec_hash: de2890233b68387bf5f9b6d19e7d87dc +configured_endpoints: 102 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-ec9b23603f987503f8837da5992b5db4c59a2bc627b090557539791a2b2b64a5.yml +openapi_spec_hash: faf6a6deaadba884a07e970fd05ac570 config_hash: 8894c96caeb6df84c9394518810221bd diff --git a/CHANGELOG.md b/CHANGELOG.md index 2239e78..f61ae42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## 0.3.0 (2026-04-08) + +Full Changelog: [v0.2.0...v0.3.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.2.0...v0.3.0) + +### Features + +* **api:** api update ([85f6788](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/85f67881300bb5cdb912fe7c59edcd0af640a14f)) +* **api:** api update ([d4be9ff](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/d4be9ff16190320b7cdaffae495057ee2ceda50c)) +* **api:** api update ([f8f5138](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/f8f51380d7cb3d07a0be410e69492edf9fba07cc)) +* **api:** api update ([be5b4f9](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/be5b4f9f89ea2e7606d57cb7f0ea809c17c4096f)) +* **api:** api update ([a4e0acd](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/a4e0acdd9e95507a2d69d05b50c5b8c114c7cd0b)) + ## 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) diff --git a/README.md b/README.md index 39d4d2e..8d50a20 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java)](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0) -[![javadoc](https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0/javadoc.svg)](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java)](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0) +[![javadoc](https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0) @@ -15,7 +15,7 @@ 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.2.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.3.0). @@ -26,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.2.0") +implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.3.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0") com.x_twitter_scraper.api x-twitter-scraper-java - 0.2.0 + 0.3.0 ``` @@ -202,7 +202,7 @@ import com.x_twitter_scraper.api.models.x.media.MediaUploadResponse; import java.nio.file.Paths; MediaUploadParams params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file(Paths.get("/path/to/file")) .build(); MediaUploadResponse response = client.x().media().upload(params); @@ -216,7 +216,7 @@ import com.x_twitter_scraper.api.models.x.media.MediaUploadResponse; import java.net.URL; MediaUploadParams params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file(new URL("https://example.com//path/to/file").openStream()) .build(); MediaUploadResponse response = client.x().media().upload(params); @@ -229,7 +229,7 @@ import com.x_twitter_scraper.api.models.x.media.MediaUploadParams; import com.x_twitter_scraper.api.models.x.media.MediaUploadResponse; MediaUploadParams params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("content".getBytes()) .build(); MediaUploadResponse response = client.x().media().upload(params); @@ -245,7 +245,7 @@ import java.io.InputStream; import java.net.URL; MediaUploadParams params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file(MultipartField.builder() .value(new URL("https://example.com//path/to/file").openStream()) .filename("/path/to/file") diff --git a/build.gradle.kts b/build.gradle.kts index 81f4172..93d1d37 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.x_twitter_scraper.api" - version = "0.2.0" // x-release-please-version + version = "0.3.0" // x-release-please-version } subprojects { 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 b0ad2e8..c59ccf8 100644 --- a/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts @@ -43,7 +43,7 @@ configure { pom { name.set("Xquik API") - description.set("X real-time data platform — extractions, giveaway draws, monitoring, webhooks.") + description.set("Xquik is an all-in-one X (Twitter) automation API with 40+ endpoints for\nreading, writing, and monitoring X data. **Read endpoints** let you look up\ntweets, search tweets, fetch user profiles, list followers & following, browse\ntimelines, bookmarks, notifications, communities, lists, trending topics, and\ndownload media. **Write endpoints** let you post tweets, reply, like, unlike,\nretweet, unretweet, follow, unfollow, send DMs, upload media, update profiles,\nand manage communities. **Automation endpoints** power bulk data extractions (20\ntool types), giveaway draws from tweet replies, real-time account monitoring\nwith webhooks & Telegram integrations, tweet composition with AI, and writing\nstyle analysis. Authenticate with an API key or OAuth 2.1 bearer token.\nPay-per-use endpoints are also available without an account.") url.set("https://xquik.com") licenses { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/Error.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/Error.kt index cb6ccba..6356b08 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/Error.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/Error.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Error response containing a machine-readable error code. */ class Error @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/EventType.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/EventType.kt index 4f21ed7..fad6c19 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/EventType.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/EventType.kt @@ -7,6 +7,7 @@ import com.x_twitter_scraper.api.core.Enum import com.x_twitter_scraper.api.core.JsonField import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +/** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** 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 2880aa9..80222dd 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 @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class PaginatedTweets @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { 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 c3e969c..7d6465f 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 @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of user profiles with cursor-based navigation. */ class PaginatedUsers @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -242,6 +243,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** X user profile with bio, follower counts, and verification status. */ class User @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKey.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKey.kt index f4edb41..f7477af 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKey.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKey.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** API key metadata returned when listing keys. */ class ApiKey @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( 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 cc46a86..edd6128 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 @@ -167,6 +167,7 @@ private constructor( internal fun validity(): Int = (keys.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** API key metadata returned when listing keys. */ class Key @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponse.kt index 2687153..34478fb 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponse.kt @@ -3,23 +3,112 @@ package com.x_twitter_scraper.api.models.compose import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing import com.x_twitter_scraper.api.core.JsonValue +import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class ComposeCreateResponse -@JsonCreator +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val feedback: JsonField, + private val score: JsonField, + private val suggestions: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("feedback") @ExcludeMissing feedback: JsonField = JsonMissing.of(), + @JsonProperty("score") @ExcludeMissing score: JsonField = JsonMissing.of(), + @JsonProperty("suggestions") + @ExcludeMissing + suggestions: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(feedback, score, suggestions, text, mutableMapOf()) + + /** + * AI feedback on the draft + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feedback(): Optional = feedback.getOptional("feedback") + + /** + * Engagement score (0-100) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun score(): Optional = score.getOptional("score") + + /** + * Improvement suggestions + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun suggestions(): Optional> = suggestions.getOptional("suggestions") + + /** + * Generated or refined tweet text + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [feedback]. + * + * Unlike [feedback], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feedback") @ExcludeMissing fun _feedback(): JsonField = feedback + + /** + * Returns the raw JSON value of [score]. + * + * Unlike [score], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("score") @ExcludeMissing fun _score(): JsonField = score + + /** + * Returns the raw JSON value of [suggestions]. + * + * Unlike [suggestions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("suggestions") + @ExcludeMissing + fun _suggestions(): JsonField> = suggestions + + /** + * 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 + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) @@ -32,13 +121,80 @@ private constructor( /** A builder for [ComposeCreateResponse]. */ class Builder internal constructor() { + private var feedback: JsonField = JsonMissing.of() + private var score: JsonField = JsonMissing.of() + private var suggestions: JsonField>? = null + private var text: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(composeCreateResponse: ComposeCreateResponse) = apply { + feedback = composeCreateResponse.feedback + score = composeCreateResponse.score + suggestions = composeCreateResponse.suggestions.map { it.toMutableList() } + text = composeCreateResponse.text additionalProperties = composeCreateResponse.additionalProperties.toMutableMap() } + /** AI feedback on the draft */ + fun feedback(feedback: String) = feedback(JsonField.of(feedback)) + + /** + * Sets [Builder.feedback] to an arbitrary JSON value. + * + * You should usually call [Builder.feedback] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun feedback(feedback: JsonField) = apply { this.feedback = feedback } + + /** Engagement score (0-100) */ + fun score(score: Double) = score(JsonField.of(score)) + + /** + * Sets [Builder.score] to an arbitrary JSON value. + * + * You should usually call [Builder.score] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun score(score: JsonField) = apply { this.score = score } + + /** Improvement suggestions */ + fun suggestions(suggestions: List) = suggestions(JsonField.of(suggestions)) + + /** + * Sets [Builder.suggestions] to an arbitrary JSON value. + * + * You should usually call [Builder.suggestions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun suggestions(suggestions: JsonField>) = apply { + this.suggestions = suggestions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [suggestions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSuggestion(suggestion: String) = apply { + suggestions = + (suggestions ?: JsonField.of(mutableListOf())).also { + checkKnown("suggestions", it).add(suggestion) + } + } + + /** Generated or refined tweet text */ + 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 additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -64,7 +220,13 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): ComposeCreateResponse = - ComposeCreateResponse(additionalProperties.toImmutable()) + ComposeCreateResponse( + feedback, + score, + (suggestions ?: JsonMissing.of()).map { it.toImmutable() }, + text, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -74,6 +236,10 @@ private constructor( return@apply } + feedback() + score() + suggestions() + text() validated = true } @@ -92,19 +258,30 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + (if (feedback.asKnown().isPresent) 1 else 0) + + (if (score.asKnown().isPresent) 1 else 0) + + (suggestions.asKnown().getOrNull()?.size ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ComposeCreateResponse && additionalProperties == other.additionalProperties + return other is ComposeCreateResponse && + feedback == other.feedback && + score == other.score && + suggestions == other.suggestions && + text == other.text && + additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(feedback, score, suggestions, text, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "ComposeCreateResponse{additionalProperties=$additionalProperties}" + override fun toString() = + "ComposeCreateResponse{feedback=$feedback, score=$score, suggestions=$suggestions, text=$text, additionalProperties=$additionalProperties}" } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/Draft.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/Draft.kt index 40c2080..81ebb82 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/Draft.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/Draft.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Saved tweet draft with optional topic and goal. */ class Draft @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt index 37fd934..db3edc3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full tweet draft including update timestamp. */ class DraftCreateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetail.kt index 3a80f3d..e4c8ebd 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetail.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetail.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full tweet draft including update timestamp. */ class DraftDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListParams.kt index 727ae92..791ebf8 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListParams.kt @@ -21,6 +21,7 @@ private constructor( /** Cursor for pagination */ fun afterCursor(): Optional = Optional.ofNullable(afterCursor) + /** Maximum number of items to return (1-100, default 50) */ fun limit(): Optional = Optional.ofNullable(limit) /** Additional headers to send with the request. */ @@ -61,6 +62,7 @@ private constructor( /** Alias for calling [Builder.afterCursor] with `afterCursor.orElse(null)`. */ fun afterCursor(afterCursor: Optional) = afterCursor(afterCursor.getOrNull()) + /** Maximum number of items to return (1-100, default 50) */ fun limit(limit: Long?) = apply { this.limit = limit } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponse.kt index da62295..95098f6 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponse.kt @@ -236,6 +236,7 @@ private constructor( (if (hasMore.asKnown().isPresent) 1 else 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + /** Saved tweet draft with optional topic and goal. */ class Draft @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt index 45f2c57..23e4330 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full tweet draft including update timestamp. */ class DraftRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetail.kt index 330c1b4..ee79d40 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetail.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetail.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full giveaway draw with tweet metrics, entries, and timing. */ class DrawDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawExportParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawExportParams.kt index 9071e39..d37a0b7 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawExportParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawExportParams.kt @@ -25,6 +25,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) + /** Export output format */ fun format(): Optional = Optional.ofNullable(format) /** Export winners or all entries */ @@ -69,6 +70,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) + /** Export output format */ fun format(format: Format?) = apply { this.format = format } /** Alias for calling [Builder.format] with `format.orElse(null)`. */ @@ -210,6 +212,7 @@ private constructor( } .build() + /** Export output format */ class Format @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListItem.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListItem.kt index 3297fd6..050b004 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListItem.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListItem.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Giveaway draw summary with entry counts and status. */ class DrawListItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListParams.kt index 1676adb..ab4f65a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListParams.kt @@ -18,9 +18,10 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(): Optional = Optional.ofNullable(after) + /** Maximum number of items to return (1-100, default 50) */ fun limit(): Optional = Optional.ofNullable(limit) /** Additional headers to send with the request. */ @@ -55,12 +56,13 @@ private constructor( additionalQueryParams = drawListParams.additionalQueryParams.toBuilder() } - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(after: String?) = apply { this.after = after } /** Alias for calling [Builder.after] with `after.orElse(null)`. */ fun after(after: Optional) = after(after.getOrNull()) + /** Maximum number of items to return (1-100, default 50) */ fun limit(limit: Long?) = apply { this.limit = limit } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponse.kt index fd73ddd..9dff273 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponse.kt @@ -234,6 +234,7 @@ private constructor( (if (hasMore.asKnown().isPresent) 1 else 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + /** Giveaway draw summary with entry counts and status. */ class Draw @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt index 28fe343..32280b4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt @@ -35,6 +35,8 @@ private constructor( ) : this(draw, winners, mutableMapOf()) /** + * Full giveaway draw with tweet metrics, entries, and timing. + * * @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). */ @@ -100,6 +102,7 @@ private constructor( additionalProperties = drawRetrieveResponse.additionalProperties.toMutableMap() } + /** Full giveaway draw with tweet metrics, entries, and timing. */ fun draw(draw: Draw) = draw(JsonField.of(draw)) /** @@ -205,6 +208,7 @@ private constructor( (draw.asKnown().getOrNull()?.validity() ?: 0) + (winners.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Full giveaway draw with tweet metrics, entries, and timing. */ class Draw @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -915,6 +919,7 @@ private constructor( "Draw{id=$id, createdAt=$createdAt, status=$status, totalEntries=$totalEntries, tweetAuthorUsername=$tweetAuthorUsername, tweetId=$tweetId, tweetLikeCount=$tweetLikeCount, tweetQuoteCount=$tweetQuoteCount, tweetReplyCount=$tweetReplyCount, tweetRetweetCount=$tweetRetweetCount, tweetText=$tweetText, tweetUrl=$tweetUrl, validEntries=$validEntries, drawnAt=$drawnAt, additionalProperties=$additionalProperties}" } + /** Giveaway draw winner with position and backup flag. */ class Winner @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt index 0c4883f..7b4874a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt @@ -309,6 +309,7 @@ private constructor( (if (validEntries.asKnown().isPresent) 1 else 0) + (winners.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Giveaway draw winner with position and backup flag. */ class Winner @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/Winner.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/Winner.kt index 186f724..f2b9e45 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/Winner.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/Winner.kt @@ -15,6 +15,7 @@ import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException import java.util.Collections import java.util.Objects +/** Giveaway draw winner with position and backup flag. */ class Winner @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt index ec20d19..90905c5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt @@ -19,6 +19,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Monitor event summary with type, username, and occurrence time. */ class Event @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -68,6 +69,8 @@ private constructor( fun occurredAt(): OffsetDateTime = occurredAt.getRequired("occurredAt") /** + * Type of monitor event fired when account activity occurs. + * * @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). */ @@ -219,6 +222,7 @@ private constructor( this.occurredAt = occurredAt } + /** Type of monitor event fired when account activity occurs. */ fun type(type: Type) = type(JsonField.of(type)) /** @@ -424,6 +428,7 @@ private constructor( override fun toString() = "Data{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventDetail.kt index c6b2f6b..94a9651 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventDetail.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventDetail.kt @@ -20,6 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Full monitor event including payload data and optional X event ID. */ class EventDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -53,6 +54,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Event payload — shape varies by event type (JSON) + * * @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). */ @@ -71,6 +74,8 @@ private constructor( fun occurredAt(): OffsetDateTime = occurredAt.getRequired("occurredAt") /** + * Type of monitor event fired when account activity occurs. + * * @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). */ @@ -203,6 +208,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Event payload — shape varies by event type (JSON) */ fun data(data: Data) = data(JsonField.of(data)) /** @@ -237,6 +243,7 @@ private constructor( this.occurredAt = occurredAt } + /** Type of monitor event fired when account activity occurs. */ fun type(type: Type) = type(JsonField.of(type)) /** @@ -356,6 +363,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xEventId.asKnown().isPresent) 1 else 0) + /** Event payload — shape varies by event type (JSON) */ class Data @JsonCreator private constructor( @@ -455,6 +463,7 @@ private constructor( override fun toString() = "Data{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListParams.kt index f61e383..64661e3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListParams.kt @@ -24,13 +24,16 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(): Optional = Optional.ofNullable(after) + /** Filter events by type */ fun eventType(): Optional = Optional.ofNullable(eventType) + /** Maximum number of items to return (1-100, default 50) */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter events by monitor ID */ fun monitorId(): Optional = Optional.ofNullable(monitorId) /** Additional headers to send with the request. */ @@ -69,17 +72,19 @@ private constructor( additionalQueryParams = eventListParams.additionalQueryParams.toBuilder() } - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(after: String?) = apply { this.after = after } /** Alias for calling [Builder.after] with `after.orElse(null)`. */ fun after(after: Optional) = after(after.getOrNull()) + /** Filter events by type */ fun eventType(eventType: EventType?) = apply { this.eventType = eventType } /** Alias for calling [Builder.eventType] with `eventType.orElse(null)`. */ fun eventType(eventType: Optional) = eventType(eventType.getOrNull()) + /** Maximum number of items to return (1-100, default 50) */ fun limit(limit: Long?) = apply { this.limit = limit } /** @@ -92,6 +97,7 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + /** Filter events by monitor ID */ fun monitorId(monitorId: String?) = apply { this.monitorId = monitorId } /** Alias for calling [Builder.monitorId] with `monitorId.orElse(null)`. */ @@ -224,6 +230,7 @@ private constructor( } .build() + /** Filter events by type */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListResponse.kt index 32fc614..8d5eb62 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListResponse.kt @@ -237,6 +237,7 @@ private constructor( (if (hasMore.asKnown().isPresent) 1 else 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + /** Monitor event summary with type, username, and occurrence time. */ class Event @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -292,6 +293,8 @@ private constructor( fun occurredAt(): OffsetDateTime = occurredAt.getRequired("occurredAt") /** + * Type of monitor event fired when account activity occurs. + * * @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). @@ -447,6 +450,7 @@ private constructor( this.occurredAt = occurredAt } + /** Type of monitor event fired when account activity occurs. */ fun type(type: Type) = type(JsonField.of(type)) /** @@ -658,6 +662,7 @@ private constructor( override fun toString() = "Data{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt index e3ccc73..977dfa6 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Full monitor event including payload data and optional X event ID. */ class EventRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -53,6 +54,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Event payload — shape varies by event type (JSON) + * * @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). */ @@ -71,6 +74,8 @@ private constructor( fun occurredAt(): OffsetDateTime = occurredAt.getRequired("occurredAt") /** + * Type of monitor event fired when account activity occurs. + * * @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). */ @@ -203,6 +208,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Event payload — shape varies by event type (JSON) */ fun data(data: Data) = data(JsonField.of(data)) /** @@ -237,6 +243,7 @@ private constructor( this.occurredAt = occurredAt } + /** Type of monitor event fired when account activity occurs. */ fun type(type: Type) = type(JsonField.of(type)) /** @@ -356,6 +363,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xEventId.asKnown().isPresent) 1 else 0) + /** Event payload — shape varies by event type (JSON) */ class Data @JsonCreator private constructor( @@ -455,6 +463,7 @@ private constructor( override fun toString() = "Data{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParams.kt index 5dbf9e1..de3f924 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParams.kt @@ -30,13 +30,15 @@ private constructor( ) : Params { /** + * Identifier for the extraction tool used to run a job. + * * @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 toolType(): ToolType = body.toolType() /** - * Raw advanced search query appended as-is (tweet_search_extractor) + * Raw advanced query string appended to the estimate (tweet_search_extractor) * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -44,7 +46,7 @@ private constructor( fun advancedQuery(): Optional = body.advancedQuery() /** - * Exact phrase to match (tweet_search_extractor) + * Exact phrase filter for search estimation * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -52,7 +54,7 @@ private constructor( fun exactPhrase(): Optional = body.exactPhrase() /** - * Words to exclude from results (tweet_search_extractor) + * Words excluded from estimated search results * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -217,6 +219,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = apply { body.toolType(toolType) } /** @@ -228,7 +231,7 @@ private constructor( */ fun toolType(toolType: JsonField) = apply { body.toolType(toolType) } - /** Raw advanced search query appended as-is (tweet_search_extractor) */ + /** Raw advanced query string appended to the estimate (tweet_search_extractor) */ fun advancedQuery(advancedQuery: String) = apply { body.advancedQuery(advancedQuery) } /** @@ -242,7 +245,7 @@ private constructor( body.advancedQuery(advancedQuery) } - /** Exact phrase to match (tweet_search_extractor) */ + /** Exact phrase filter for search estimation */ fun exactPhrase(exactPhrase: String) = apply { body.exactPhrase(exactPhrase) } /** @@ -254,7 +257,7 @@ private constructor( */ fun exactPhrase(exactPhrase: JsonField) = apply { body.exactPhrase(exactPhrase) } - /** Words to exclude from results (tweet_search_extractor) */ + /** Words excluded from estimated search results */ fun excludeWords(excludeWords: String) = apply { body.excludeWords(excludeWords) } /** @@ -552,6 +555,8 @@ private constructor( ) /** + * Identifier for the extraction tool used to run a job. + * * @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). @@ -559,7 +564,7 @@ private constructor( fun toolType(): ToolType = toolType.getRequired("toolType") /** - * Raw advanced search query appended as-is (tweet_search_extractor) + * Raw advanced query string appended to the estimate (tweet_search_extractor) * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -567,7 +572,7 @@ private constructor( fun advancedQuery(): Optional = advancedQuery.getOptional("advancedQuery") /** - * Exact phrase to match (tweet_search_extractor) + * Exact phrase filter for search estimation * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -575,7 +580,7 @@ private constructor( fun exactPhrase(): Optional = exactPhrase.getOptional("exactPhrase") /** - * Words to exclude from results (tweet_search_extractor) + * Words excluded from estimated search results * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -769,6 +774,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = toolType(JsonField.of(toolType)) /** @@ -780,7 +786,7 @@ private constructor( */ fun toolType(toolType: JsonField) = apply { this.toolType = toolType } - /** Raw advanced search query appended as-is (tweet_search_extractor) */ + /** Raw advanced query string appended to the estimate (tweet_search_extractor) */ fun advancedQuery(advancedQuery: String) = advancedQuery(JsonField.of(advancedQuery)) /** @@ -794,7 +800,7 @@ private constructor( this.advancedQuery = advancedQuery } - /** Exact phrase to match (tweet_search_extractor) */ + /** Exact phrase filter for search estimation */ fun exactPhrase(exactPhrase: String) = exactPhrase(JsonField.of(exactPhrase)) /** @@ -808,7 +814,7 @@ private constructor( this.exactPhrase = exactPhrase } - /** Words to exclude from results (tweet_search_extractor) */ + /** Words excluded from estimated search results */ fun excludeWords(excludeWords: String) = excludeWords(JsonField.of(excludeWords)) /** @@ -1037,6 +1043,7 @@ private constructor( "Body{toolType=$toolType, advancedQuery=$advancedQuery, exactPhrase=$exactPhrase, excludeWords=$excludeWords, searchQuery=$searchQuery, targetCommunityId=$targetCommunityId, targetListId=$targetListId, targetSpaceId=$targetSpaceId, targetTweetId=$targetTweetId, targetUsername=$targetUsername, additionalProperties=$additionalProperties}" } + /** Identifier for the extraction tool used to run a job. */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionExportResultsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionExportResultsParams.kt index b43fdda..15900b3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionExportResultsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionExportResultsParams.kt @@ -24,6 +24,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) + /** Export file format */ fun format(): Optional = Optional.ofNullable(format) /** Additional headers to send with the request. */ @@ -66,6 +67,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) + /** Export file format */ fun format(format: Format?) = apply { this.format = format } /** Alias for calling [Builder.format] with `format.orElse(null)`. */ @@ -199,6 +201,7 @@ private constructor( } .build() + /** Export file format */ class Format @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJob.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJob.kt index fa48bb8..eb6d678 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJob.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJob.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Extraction job tracking status, tool type, and result count. */ class ExtractionJob @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -66,6 +67,8 @@ private constructor( fun status(): Status = status.getRequired("status") /** + * Identifier for the extraction tool used to run a job. + * * @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). */ @@ -213,6 +216,7 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = toolType(JsonField.of(toolType)) /** @@ -466,6 +470,7 @@ private constructor( override fun toString() = value.toString() } + /** Identifier for the extraction tool used to run a job. */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParams.kt index c0769c4..2c0627e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParams.kt @@ -24,13 +24,16 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(): Optional = Optional.ofNullable(after) + /** Maximum number of items to return (1-100, default 50) */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter by job status */ fun status(): Optional = Optional.ofNullable(status) + /** Filter by extraction tool type */ fun toolType(): Optional = Optional.ofNullable(toolType) /** Additional headers to send with the request. */ @@ -69,12 +72,13 @@ private constructor( additionalQueryParams = extractionListParams.additionalQueryParams.toBuilder() } - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(after: String?) = apply { this.after = after } /** Alias for calling [Builder.after] with `after.orElse(null)`. */ fun after(after: Optional) = after(after.getOrNull()) + /** Maximum number of items to return (1-100, default 50) */ fun limit(limit: Long?) = apply { this.limit = limit } /** @@ -87,11 +91,13 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + /** Filter by job status */ fun status(status: Status?) = apply { this.status = status } /** Alias for calling [Builder.status] with `status.orElse(null)`. */ fun status(status: Optional) = status(status.getOrNull()) + /** Filter by extraction tool type */ fun toolType(toolType: ToolType?) = apply { this.toolType = toolType } /** Alias for calling [Builder.toolType] with `toolType.orElse(null)`. */ @@ -224,6 +230,7 @@ private constructor( } .build() + /** Filter by job status */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -357,6 +364,7 @@ private constructor( override fun toString() = value.toString() } + /** Filter by extraction tool type */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponse.kt index 86aadc7..bfc4718 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponse.kt @@ -241,6 +241,7 @@ private constructor( (if (hasMore.asKnown().isPresent) 1 else 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + /** Extraction job tracking status, tool type, and result count. */ class Extraction @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -293,6 +294,8 @@ private constructor( fun status(): Status = status.getRequired("status") /** + * Identifier for the extraction tool used to run a job. + * * @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). @@ -447,6 +450,7 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = toolType(JsonField.of(toolType)) /** @@ -705,6 +709,7 @@ private constructor( override fun toString() = value.toString() } + /** Identifier for the extraction tool used to run a job. */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveParams.kt index 4daafbd..7b4c2c3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveParams.kt @@ -21,9 +21,10 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(): Optional = Optional.ofNullable(after) + /** Maximum number of results to return (1-1000, default 100) */ fun limit(): Optional = Optional.ofNullable(limit) /** Additional headers to send with the request. */ @@ -65,12 +66,13 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Cursor for pagination */ + /** Cursor for keyset pagination */ fun after(after: String?) = apply { this.after = after } /** Alias for calling [Builder.after] with `after.orElse(null)`. */ fun after(after: Optional) = after(after.getOrNull()) + /** Maximum number of results to return (1-1000, default 100) */ fun limit(limit: Long?) = apply { this.limit = limit } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponse.kt index c5b275d..488f5a1 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponse.kt @@ -46,6 +46,8 @@ private constructor( fun hasMore(): Boolean = hasMore.getRequired("hasMore") /** + * Extraction job metadata — shape varies by tool type (JSON) + * * @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). */ @@ -146,6 +148,7 @@ private constructor( */ fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + /** Extraction job metadata — shape varies by tool type (JSON) */ fun job(job: Job) = job(JsonField.of(job)) /** @@ -269,6 +272,7 @@ private constructor( (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (nextCursor.asKnown().isPresent) 1 else 0) + /** Extraction job metadata — shape varies by tool type (JSON) */ class Job @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParams.kt index 96d2335..ff38946 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParams.kt @@ -30,6 +30,8 @@ private constructor( ) : Params { /** + * Identifier for the extraction tool used to run a job. + * * @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). */ @@ -217,6 +219,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = apply { body.toolType(toolType) } /** @@ -552,6 +555,8 @@ private constructor( ) /** + * Identifier for the extraction tool used to run a job. + * * @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). @@ -769,6 +774,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = toolType(JsonField.of(toolType)) /** @@ -1037,6 +1043,7 @@ private constructor( "Body{toolType=$toolType, advancedQuery=$advancedQuery, exactPhrase=$exactPhrase, excludeWords=$excludeWords, searchQuery=$searchQuery, targetCommunityId=$targetCommunityId, targetListId=$targetListId, targetSpaceId=$targetSpaceId, targetTweetId=$targetTweetId, targetUsername=$targetUsername, additionalProperties=$additionalProperties}" } + /** Identifier for the extraction tool used to run a job. */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponse.kt index efcace5..3d384ed 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponse.kt @@ -46,6 +46,8 @@ private constructor( fun status(): Status = status.getRequired("status") /** + * Identifier for the extraction tool used to run a job. + * * @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). */ @@ -135,6 +137,7 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } + /** Identifier for the extraction tool used to run a job. */ fun toolType(toolType: ToolType) = toolType(JsonField.of(toolType)) /** @@ -341,6 +344,7 @@ private constructor( override fun toString() = value.toString() } + /** Identifier for the extraction tool used to run a job. */ class ToolType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt index d5e93ca..a00121a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt @@ -21,6 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Third-party integration (e.g. Telegram) subscribed to monitor events. */ class Integration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -83,6 +84,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Integration config — shape varies by type (JSON) + * * @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). */ @@ -95,6 +98,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -119,6 +124,8 @@ private constructor( fun type(): Type = type.getRequired("type") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -301,6 +308,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Integration config — shape varies by type (JSON) */ fun config(config: Config) = config(JsonField.of(config)) /** @@ -322,6 +330,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -378,6 +387,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -529,6 +539,7 @@ private constructor( (if (scopeAllMonitors.asKnown().isPresent) 1 else 0) + (if (silentPush.asKnown().isPresent) 1 else 0) + /** Integration config — shape varies by type (JSON) */ class Config @JsonCreator private constructor( @@ -628,6 +639,7 @@ private constructor( override fun toString() = "Config{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -902,6 +914,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParams.kt index da00f53..1081983 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParams.kt @@ -39,6 +39,8 @@ private constructor( fun config(): Config = body.config() /** + * Array of event types to subscribe to. + * * @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). */ @@ -147,6 +149,7 @@ private constructor( */ fun config(config: JsonField) = apply { body.config(config) } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -363,6 +366,8 @@ private constructor( fun config(): Config = config.getRequired("config") /** + * Array of event types to subscribe to. + * * @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). @@ -471,6 +476,7 @@ private constructor( */ fun config(config: JsonField) = apply { this.config = config } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -775,6 +781,7 @@ private constructor( "Config{chatId=$chatId, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt index ce362aa..0eff30a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt @@ -21,6 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Third-party integration (e.g. Telegram) subscribed to monitor events. */ class IntegrationCreateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -83,6 +84,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Integration config — shape varies by type (JSON) + * * @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). */ @@ -95,6 +98,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -119,6 +124,8 @@ private constructor( fun type(): Type = type.getRequired("type") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -301,6 +308,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Integration config — shape varies by type (JSON) */ fun config(config: Config) = config(JsonField.of(config)) /** @@ -322,6 +330,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -378,6 +387,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -529,6 +539,7 @@ private constructor( (if (scopeAllMonitors.asKnown().isPresent) 1 else 0) + (if (silentPush.asKnown().isPresent) 1 else 0) + /** Integration config — shape varies by type (JSON) */ class Config @JsonCreator private constructor( @@ -628,6 +639,7 @@ private constructor( override fun toString() = "Config{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -902,6 +914,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDelivery.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDelivery.kt index ae1dcc6..9fc6c54 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDelivery.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDelivery.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Integration delivery attempt record with status and retry count. */ class IntegrationDelivery @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesParams.kt index b5eee15..be7b04c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesParams.kt @@ -20,6 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) + /** Maximum number of items to return (1-100, default 50) */ fun limit(): Optional = Optional.ofNullable(limit) /** Additional headers to send with the request. */ @@ -64,6 +65,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) + /** Maximum number of items to return (1-100, default 50) */ fun limit(limit: Long?) = apply { this.limit = limit } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponse.kt index 6caf9f4..b595f38 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponse.kt @@ -180,6 +180,7 @@ private constructor( internal fun validity(): Int = (deliveries.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Integration delivery attempt record with status and retry count. */ class Delivery @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt index c75b31a..a74eb0e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt @@ -178,6 +178,7 @@ private constructor( internal fun validity(): Int = (integrations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Third-party integration (e.g. Telegram) subscribed to monitor events. */ class Integration @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -243,6 +244,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Integration config — shape varies by type (JSON) + * * @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). @@ -257,6 +260,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). @@ -285,6 +290,8 @@ private constructor( fun type(): Type = type.getRequired("type") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -471,6 +478,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Integration config — shape varies by type (JSON) */ fun config(config: Config) = config(JsonField.of(config)) /** @@ -495,6 +503,7 @@ private constructor( this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -553,6 +562,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -706,6 +716,7 @@ private constructor( (if (scopeAllMonitors.asKnown().isPresent) 1 else 0) + (if (silentPush.asKnown().isPresent) 1 else 0) + /** Integration config — shape varies by type (JSON) */ class Config @JsonCreator private constructor( @@ -808,6 +819,7 @@ private constructor( override fun toString() = "Config{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1084,6 +1096,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt index fa24dc8..9484811 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt @@ -21,6 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Third-party integration (e.g. Telegram) subscribed to monitor events. */ class IntegrationRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -83,6 +84,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Integration config — shape varies by type (JSON) + * * @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). */ @@ -95,6 +98,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -119,6 +124,8 @@ private constructor( fun type(): Type = type.getRequired("type") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -301,6 +308,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Integration config — shape varies by type (JSON) */ fun config(config: Config) = config(JsonField.of(config)) /** @@ -322,6 +330,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -378,6 +387,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -529,6 +539,7 @@ private constructor( (if (scopeAllMonitors.asKnown().isPresent) 1 else 0) + (if (silentPush.asKnown().isPresent) 1 else 0) + /** Integration config — shape varies by type (JSON) */ class Config @JsonCreator private constructor( @@ -628,6 +639,7 @@ private constructor( override fun toString() = "Config{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -902,6 +914,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParams.kt index ed6d8cb..4188c51 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParams.kt @@ -34,12 +34,16 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun eventTypes(): Optional> = body.eventTypes() /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -52,6 +56,8 @@ private constructor( fun isActive(): Optional = body.isActive() /** + * Custom message template (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -178,6 +184,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -198,6 +205,7 @@ private constructor( */ fun addEventType(eventType: EventType) = apply { body.addEventType(eventType) } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = apply { body.filters(filters) } /** @@ -219,6 +227,7 @@ private constructor( */ fun isActive(isActive: JsonField) = apply { body.isActive(isActive) } + /** Custom message template (JSON) */ fun messageTemplate(messageTemplate: MessageTemplate) = apply { body.messageTemplate(messageTemplate) } @@ -457,12 +466,16 @@ private constructor( ) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ fun eventTypes(): Optional> = eventTypes.getOptional("eventTypes") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -475,6 +488,8 @@ private constructor( fun isActive(): Optional = isActive.getOptional("isActive") /** + * Custom message template (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -600,6 +615,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -625,6 +641,7 @@ private constructor( } } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -647,6 +664,7 @@ private constructor( */ fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + /** Custom message template (JSON) */ fun messageTemplate(messageTemplate: MessageTemplate) = messageTemplate(JsonField.of(messageTemplate)) @@ -810,6 +828,7 @@ private constructor( "Body{eventTypes=$eventTypes, filters=$filters, isActive=$isActive, messageTemplate=$messageTemplate, name=$name, scopeAllMonitors=$scopeAllMonitors, silentPush=$silentPush, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -963,6 +982,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( @@ -1062,6 +1082,7 @@ private constructor( override fun toString() = "Filters{additionalProperties=$additionalProperties}" } + /** Custom message template (JSON) */ class MessageTemplate @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt index 46c510e..97dc95e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt @@ -21,6 +21,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Third-party integration (e.g. Telegram) subscribed to monitor events. */ class IntegrationUpdateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -83,6 +84,8 @@ private constructor( fun id(): String = id.getRequired("id") /** + * Integration config — shape varies by type (JSON) + * * @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). */ @@ -95,6 +98,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -119,6 +124,8 @@ private constructor( fun type(): Type = type.getRequired("type") /** + * Event filter rules (JSON) + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -301,6 +308,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Integration config — shape varies by type (JSON) */ fun config(config: Config) = config(JsonField.of(config)) /** @@ -322,6 +330,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -378,6 +387,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -529,6 +539,7 @@ private constructor( (if (scopeAllMonitors.asKnown().isPresent) 1 else 0) + (if (silentPush.asKnown().isPresent) 1 else 0) + /** Integration config — shape varies by type (JSON) */ class Config @JsonCreator private constructor( @@ -628,6 +639,7 @@ private constructor( override fun toString() = "Config{additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -902,6 +914,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/Monitor.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/Monitor.kt index 264356a..d5e2352 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/Monitor.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/Monitor.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Account monitor that tracks activity for a given X user. */ class Monitor @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -59,6 +60,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -201,6 +204,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -343,6 +347,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xUserId.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParams.kt index 7afdf68..3444b93 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParams.kt @@ -31,6 +31,8 @@ private constructor( ) : Params { /** + * Array of event types to subscribe to. + * * @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). */ @@ -106,6 +108,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -298,6 +301,8 @@ private constructor( ) : this(eventTypes, username, mutableMapOf()) /** + * Array of event types to subscribe to. + * * @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). @@ -369,6 +374,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -498,6 +504,7 @@ private constructor( "Body{eventTypes=$eventTypes, username=$username, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponse.kt index 97199ba..a91144e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponse.kt @@ -57,6 +57,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -183,6 +185,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -310,6 +313,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xUserId.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponse.kt index 74fb015..122f2f3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponse.kt @@ -207,6 +207,7 @@ private constructor( (monitors.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (total.asKnown().isPresent) 1 else 0) + /** Account monitor that tracks activity for a given X user. */ class Monitor @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +253,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). @@ -401,6 +404,7 @@ private constructor( this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -546,6 +550,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xUserId.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt index 43a9471..73895f8 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Account monitor that tracks activity for a given X user. */ class MonitorRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -59,6 +60,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -201,6 +204,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -343,6 +347,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xUserId.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateParams.kt index 03f85bf..5b5dc4f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateParams.kt @@ -34,6 +34,8 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -108,6 +110,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -301,6 +304,8 @@ private constructor( ) : this(eventTypes, isActive, mutableMapOf()) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -360,6 +365,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -480,6 +486,7 @@ private constructor( "Body{eventTypes=$eventTypes, isActive=$isActive, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt index 84a791c..51e4cbc 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Account monitor that tracks activity for a given X user. */ class MonitorUpdateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -59,6 +60,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -201,6 +204,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -343,6 +347,7 @@ private constructor( (if (username.asKnown().isPresent) 1 else 0) + (if (xUserId.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarItem.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarItem.kt index 153dea2..7231e8e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarItem.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarItem.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Trending topic with score, category, source, and region. */ class RadarItem @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParams.kt index 9c74f5c..a00f5fb 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParams.kt @@ -2,9 +2,13 @@ package com.x_twitter_scraper.api.models.radar +import com.fasterxml.jackson.annotation.JsonCreator +import com.x_twitter_scraper.api.core.Enum +import com.x_twitter_scraper.api.core.JsonField import com.x_twitter_scraper.api.core.Params import com.x_twitter_scraper.api.core.http.Headers import com.x_twitter_scraper.api.core.http.QueryParams +import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -16,7 +20,7 @@ private constructor( private val count: Long?, private val hours: Long?, private val region: String?, - private val source: String?, + private val source: Source?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -37,7 +41,7 @@ private constructor( * Source filter. One of: github, google_trends, hacker_news, polymarket, reddit, trustmrr, * wikipedia */ - fun source(): Optional = Optional.ofNullable(source) + fun source(): Optional = Optional.ofNullable(source) /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -65,7 +69,7 @@ private constructor( private var count: Long? = null private var hours: Long? = null private var region: String? = null - private var source: String? = null + private var source: Source? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -124,10 +128,10 @@ private constructor( * Source filter. One of: github, google_trends, hacker_news, polymarket, reddit, trustmrr, * wikipedia */ - fun source(source: String?) = apply { this.source = source } + fun source(source: Source?) = apply { this.source = source } /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) + fun source(source: Optional) = source(source.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -253,11 +257,172 @@ private constructor( count?.let { put("count", it.toString()) } hours?.let { put("hours", it.toString()) } region?.let { put("region", it) } - source?.let { put("source", it) } + source?.let { put("source", it.toString()) } putAll(additionalQueryParams) } .build() + /** + * Source filter. One of: github, google_trends, hacker_news, polymarket, reddit, trustmrr, + * wikipedia + */ + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GITHUB = of("github") + + @JvmField val GOOGLE_TRENDS = of("google_trends") + + @JvmField val HACKER_NEWS = of("hacker_news") + + @JvmField val POLYMARKET = of("polymarket") + + @JvmField val REDDIT = of("reddit") + + @JvmField val TRUSTMRR = of("trustmrr") + + @JvmField val WIKIPEDIA = of("wikipedia") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + GITHUB, + GOOGLE_TRENDS, + HACKER_NEWS, + POLYMARKET, + REDDIT, + TRUSTMRR, + WIKIPEDIA, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GITHUB, + GOOGLE_TRENDS, + HACKER_NEWS, + POLYMARKET, + REDDIT, + TRUSTMRR, + WIKIPEDIA, + /** An enum member indicating that [Source] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GITHUB -> Value.GITHUB + GOOGLE_TRENDS -> Value.GOOGLE_TRENDS + HACKER_NEWS -> Value.HACKER_NEWS + POLYMARKET -> Value.POLYMARKET + REDDIT -> Value.REDDIT + TRUSTMRR -> Value.TRUSTMRR + WIKIPEDIA -> Value.WIKIPEDIA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws XTwitterScraperInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GITHUB -> Known.GITHUB + GOOGLE_TRENDS -> Known.GOOGLE_TRENDS + HACKER_NEWS -> Known.HACKER_NEWS + POLYMARKET -> Known.POLYMARKET + REDDIT -> Known.REDDIT + TRUSTMRR -> Known.TRUSTMRR + WIKIPEDIA -> Known.WIKIPEDIA + else -> throw XTwitterScraperInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws XTwitterScraperInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + XTwitterScraperInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + 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/radar/RadarRetrieveTrendingTopicsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponse.kt index ee848b7..8a4834d 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponse.kt @@ -207,6 +207,7 @@ private constructor( (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (total.asKnown().isPresent) 1 else 0) + /** Trending topic with score, category, source, and region. */ class Item @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponse.kt index 8f7c1c5..9276b0a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Full style profile with sampled tweets used for tone analysis. */ class StyleAnalyzeResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt index e42856e..90baaa7 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt @@ -35,12 +35,16 @@ private constructor( ) : this(style1, style2, mutableMapOf()) /** + * Full style profile with sampled tweets used for tone analysis. + * * @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 style1(): Style1 = style1.getRequired("style1") /** + * Full style profile with sampled tweets used for tone analysis. + * * @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). */ @@ -100,6 +104,7 @@ private constructor( additionalProperties = styleCompareResponse.additionalProperties.toMutableMap() } + /** Full style profile with sampled tweets used for tone analysis. */ fun style1(style1: Style1) = style1(JsonField.of(style1)) /** @@ -110,6 +115,7 @@ private constructor( */ fun style1(style1: JsonField) = apply { this.style1 = style1 } + /** Full style profile with sampled tweets used for tone analysis. */ fun style2(style2: Style2) = style2(JsonField.of(style2)) /** @@ -190,6 +196,7 @@ private constructor( (style1.asKnown().getOrNull()?.validity() ?: 0) + (style2.asKnown().getOrNull()?.validity() ?: 0) + /** Full style profile with sampled tweets used for tone analysis. */ class Style1 @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -807,6 +814,7 @@ private constructor( "Style1{fetchedAt=$fetchedAt, isOwnAccount=$isOwnAccount, tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" } + /** Full style profile with sampled tweets used for tone analysis. */ class Style2 @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt deleted file mode 100644 index 73c092b..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete a style profile */ -class StyleDeleteParams -private constructor( - private val username: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun username(): Optional = Optional.ofNullable(username) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): StyleDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [StyleDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleDeleteParams]. */ - class Builder internal constructor() { - - private var username: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(styleDeleteParams: StyleDeleteParams) = apply { - username = styleDeleteParams.username - additionalHeaders = styleDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = styleDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = styleDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun username(username: String?) = apply { this.username = username } - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [StyleDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StyleDeleteParams = - StyleDeleteParams( - username, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> username ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleDeleteParams && - username == other.username && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(username, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "StyleDeleteParams{username=$username, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt deleted file mode 100644 index 4194c20..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt +++ /dev/null @@ -1,195 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get engagement metrics for style tweets */ -class StyleGetPerformanceParams -private constructor( - private val username: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun username(): Optional = Optional.ofNullable(username) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): StyleGetPerformanceParams = builder().build() - - /** - * Returns a mutable builder for constructing an instance of [StyleGetPerformanceParams]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleGetPerformanceParams]. */ - class Builder internal constructor() { - - private var username: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(styleGetPerformanceParams: StyleGetPerformanceParams) = apply { - username = styleGetPerformanceParams.username - additionalHeaders = styleGetPerformanceParams.additionalHeaders.toBuilder() - additionalQueryParams = styleGetPerformanceParams.additionalQueryParams.toBuilder() - } - - fun username(username: String?) = apply { this.username = username } - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [StyleGetPerformanceParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StyleGetPerformanceParams = - StyleGetPerformanceParams( - username, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> username ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleGetPerformanceParams && - username == other.username && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(username, additionalHeaders, additionalQueryParams) - - override fun toString() = - "StyleGetPerformanceParams{username=$username, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponse.kt deleted file mode 100644 index b6f4a57..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponse.kt +++ /dev/null @@ -1,647 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -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.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class StyleGetPerformanceResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val tweetCount: JsonField, - private val tweets: JsonField>, - private val xUsername: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("tweetCount") @ExcludeMissing tweetCount: JsonField = JsonMissing.of(), - @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), - @JsonProperty("xUsername") @ExcludeMissing xUsername: JsonField = JsonMissing.of(), - ) : this(tweetCount, tweets, xUsername, 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 tweetCount(): Long = tweetCount.getRequired("tweetCount") - - /** - * @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") - - /** - * @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 xUsername(): String = xUsername.getRequired("xUsername") - - /** - * Returns the raw JSON value of [tweetCount]. - * - * Unlike [tweetCount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetCount") @ExcludeMissing fun _tweetCount(): JsonField = tweetCount - - /** - * Returns the raw JSON value of [tweets]. - * - * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets - - /** - * Returns the raw JSON value of [xUsername]. - * - * Unlike [xUsername], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUsername") @ExcludeMissing fun _xUsername(): JsonField = xUsername - - @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 [StyleGetPerformanceResponse]. - * - * The following fields are required: - * ```java - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleGetPerformanceResponse]. */ - class Builder internal constructor() { - - private var tweetCount: JsonField? = null - private var tweets: JsonField>? = null - private var xUsername: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(styleGetPerformanceResponse: StyleGetPerformanceResponse) = apply { - tweetCount = styleGetPerformanceResponse.tweetCount - tweets = styleGetPerformanceResponse.tweets.map { it.toMutableList() } - xUsername = styleGetPerformanceResponse.xUsername - additionalProperties = styleGetPerformanceResponse.additionalProperties.toMutableMap() - } - - fun tweetCount(tweetCount: Long) = tweetCount(JsonField.of(tweetCount)) - - /** - * Sets [Builder.tweetCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetCount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tweetCount(tweetCount: JsonField) = apply { this.tweetCount = tweetCount } - - 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. - */ - fun tweets(tweets: JsonField>) = apply { - this.tweets = tweets.map { it.toMutableList() } - } - - /** - * Adds a single [Tweet] to [tweets]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTweet(tweet: Tweet) = apply { - tweets = - (tweets ?: JsonField.of(mutableListOf())).also { - checkKnown("tweets", it).add(tweet) - } - } - - fun xUsername(xUsername: String) = xUsername(JsonField.of(xUsername)) - - /** - * Sets [Builder.xUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.xUsername] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun xUsername(xUsername: JsonField) = apply { this.xUsername = xUsername } - - 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 [StyleGetPerformanceResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StyleGetPerformanceResponse = - StyleGetPerformanceResponse( - checkRequired("tweetCount", tweetCount), - checkRequired("tweets", tweets).map { it.toImmutable() }, - checkRequired("xUsername", xUsername), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): StyleGetPerformanceResponse = apply { - if (validated) { - return@apply - } - - tweetCount() - tweets().forEach { it.validate() } - xUsername() - 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 (tweetCount.asKnown().isPresent) 1 else 0) + - (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (xUsername.asKnown().isPresent) 1 else 0) - - class Tweet - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val text: JsonField, - private val createdAt: JsonField, - private val likeCount: 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("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("likeCount") - @ExcludeMissing - likeCount: 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, - createdAt, - likeCount, - 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 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 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 [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 [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 createdAt: JsonField = JsonMissing.of() - private var likeCount: 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 - createdAt = tweet.createdAt - likeCount = tweet.likeCount - 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 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 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), - createdAt, - likeCount, - replyCount, - retweetCount, - viewCount, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tweet = apply { - if (validated) { - return@apply - } - - id() - text() - createdAt() - likeCount() - 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) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (likeCount.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) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tweet && - id == other.id && - text == other.text && - createdAt == other.createdAt && - likeCount == other.likeCount && - replyCount == other.replyCount && - retweetCount == other.retweetCount && - viewCount == other.viewCount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - text, - createdAt, - likeCount, - replyCount, - retweetCount, - viewCount, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tweet{id=$id, text=$text, createdAt=$createdAt, likeCount=$likeCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleGetPerformanceResponse && - tweetCount == other.tweetCount && - tweets == other.tweets && - xUsername == other.xUsername && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tweetCount, tweets, xUsername, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StyleGetPerformanceResponse{tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponse.kt index 0b2a049..f1402b5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponse.kt @@ -172,6 +172,7 @@ private constructor( internal fun validity(): Int = (styles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Style profile summary with tweet count and ownership flag. */ class Style @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfile.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfile.kt index 153cbb9..fcdc81b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfile.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfile.kt @@ -20,6 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Full style profile with sampled tweets used for tone analysis. */ class StyleProfile @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummary.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummary.kt index 64583eb..acf1f15 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummary.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummary.kt @@ -16,6 +16,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +/** Style profile summary with tweet count and ownership flag. */ class StyleProfileSummary @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParams.kt deleted file mode 100644 index b4264f9..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get cached style profile */ -class StyleRetrieveParams -private constructor( - private val username: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun username(): Optional = Optional.ofNullable(username) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): StyleRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [StyleRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleRetrieveParams]. */ - class Builder internal constructor() { - - private var username: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(styleRetrieveParams: StyleRetrieveParams) = apply { - username = styleRetrieveParams.username - additionalHeaders = styleRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = styleRetrieveParams.additionalQueryParams.toBuilder() - } - - fun username(username: String?) = apply { this.username = username } - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [StyleRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StyleRetrieveParams = - StyleRetrieveParams(username, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> username ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleRetrieveParams && - username == other.username && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(username, additionalHeaders, additionalQueryParams) - - override fun toString() = - "StyleRetrieveParams{username=$username, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponse.kt deleted file mode 100644 index c4c594c..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponse.kt +++ /dev/null @@ -1,609 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -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 StyleRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val fetchedAt: JsonField, - private val isOwnAccount: JsonField, - private val tweetCount: JsonField, - private val tweets: JsonField>, - private val xUsername: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("fetchedAt") - @ExcludeMissing - fetchedAt: JsonField = JsonMissing.of(), - @JsonProperty("isOwnAccount") - @ExcludeMissing - isOwnAccount: JsonField = JsonMissing.of(), - @JsonProperty("tweetCount") @ExcludeMissing tweetCount: JsonField = JsonMissing.of(), - @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), - @JsonProperty("xUsername") @ExcludeMissing xUsername: JsonField = JsonMissing.of(), - ) : this(fetchedAt, isOwnAccount, tweetCount, tweets, xUsername, 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 fetchedAt(): OffsetDateTime = fetchedAt.getRequired("fetchedAt") - - /** - * @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 isOwnAccount(): Boolean = isOwnAccount.getRequired("isOwnAccount") - - /** - * @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 tweetCount(): Long = tweetCount.getRequired("tweetCount") - - /** - * @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") - - /** - * @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 xUsername(): String = xUsername.getRequired("xUsername") - - /** - * Returns the raw JSON value of [fetchedAt]. - * - * Unlike [fetchedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fetchedAt") - @ExcludeMissing - fun _fetchedAt(): JsonField = fetchedAt - - /** - * Returns the raw JSON value of [isOwnAccount]. - * - * Unlike [isOwnAccount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isOwnAccount") - @ExcludeMissing - fun _isOwnAccount(): JsonField = isOwnAccount - - /** - * Returns the raw JSON value of [tweetCount]. - * - * Unlike [tweetCount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetCount") @ExcludeMissing fun _tweetCount(): JsonField = tweetCount - - /** - * Returns the raw JSON value of [tweets]. - * - * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets - - /** - * Returns the raw JSON value of [xUsername]. - * - * Unlike [xUsername], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUsername") @ExcludeMissing fun _xUsername(): JsonField = xUsername - - @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 [StyleRetrieveResponse]. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleRetrieveResponse]. */ - class Builder internal constructor() { - - private var fetchedAt: JsonField? = null - private var isOwnAccount: JsonField? = null - private var tweetCount: JsonField? = null - private var tweets: JsonField>? = null - private var xUsername: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(styleRetrieveResponse: StyleRetrieveResponse) = apply { - fetchedAt = styleRetrieveResponse.fetchedAt - isOwnAccount = styleRetrieveResponse.isOwnAccount - tweetCount = styleRetrieveResponse.tweetCount - tweets = styleRetrieveResponse.tweets.map { it.toMutableList() } - xUsername = styleRetrieveResponse.xUsername - additionalProperties = styleRetrieveResponse.additionalProperties.toMutableMap() - } - - fun fetchedAt(fetchedAt: OffsetDateTime) = fetchedAt(JsonField.of(fetchedAt)) - - /** - * Sets [Builder.fetchedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.fetchedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fetchedAt(fetchedAt: JsonField) = apply { this.fetchedAt = fetchedAt } - - fun isOwnAccount(isOwnAccount: Boolean) = isOwnAccount(JsonField.of(isOwnAccount)) - - /** - * Sets [Builder.isOwnAccount] to an arbitrary JSON value. - * - * You should usually call [Builder.isOwnAccount] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isOwnAccount(isOwnAccount: JsonField) = apply { - this.isOwnAccount = isOwnAccount - } - - fun tweetCount(tweetCount: Long) = tweetCount(JsonField.of(tweetCount)) - - /** - * Sets [Builder.tweetCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetCount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tweetCount(tweetCount: JsonField) = apply { this.tweetCount = tweetCount } - - 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. - */ - fun tweets(tweets: JsonField>) = apply { - this.tweets = tweets.map { it.toMutableList() } - } - - /** - * Adds a single [Tweet] to [tweets]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTweet(tweet: Tweet) = apply { - tweets = - (tweets ?: JsonField.of(mutableListOf())).also { - checkKnown("tweets", it).add(tweet) - } - } - - fun xUsername(xUsername: String) = xUsername(JsonField.of(xUsername)) - - /** - * Sets [Builder.xUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.xUsername] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun xUsername(xUsername: JsonField) = apply { this.xUsername = xUsername } - - 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 [StyleRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StyleRetrieveResponse = - StyleRetrieveResponse( - checkRequired("fetchedAt", fetchedAt), - checkRequired("isOwnAccount", isOwnAccount), - checkRequired("tweetCount", tweetCount), - checkRequired("tweets", tweets).map { it.toImmutable() }, - checkRequired("xUsername", xUsername), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): StyleRetrieveResponse = apply { - if (validated) { - return@apply - } - - fetchedAt() - isOwnAccount() - tweetCount() - tweets().forEach { it.validate() } - xUsername() - 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 (fetchedAt.asKnown().isPresent) 1 else 0) + - (if (isOwnAccount.asKnown().isPresent) 1 else 0) + - (if (tweetCount.asKnown().isPresent) 1 else 0) + - (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (xUsername.asKnown().isPresent) 1 else 0) - - class Tweet - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val text: JsonField, - private val authorUsername: JsonField, - private val createdAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("authorUsername") - @ExcludeMissing - authorUsername: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - ) : this(id, text, authorUsername, createdAt, 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 authorUsername(): Optional = authorUsername.getOptional("authorUsername") - - /** - * @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") - - /** - * 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 [authorUsername]. - * - * Unlike [authorUsername], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("authorUsername") - @ExcludeMissing - fun _authorUsername(): JsonField = authorUsername - - /** - * 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 - - @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 authorUsername: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweet: Tweet) = apply { - id = tweet.id - text = tweet.text - authorUsername = tweet.authorUsername - createdAt = tweet.createdAt - 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 authorUsername(authorUsername: String) = - authorUsername(JsonField.of(authorUsername)) - - /** - * Sets [Builder.authorUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.authorUsername] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun authorUsername(authorUsername: JsonField) = apply { - this.authorUsername = authorUsername - } - - 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 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), - authorUsername, - createdAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tweet = apply { - if (validated) { - return@apply - } - - id() - text() - authorUsername() - createdAt() - 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) + - (if (authorUsername.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tweet && - id == other.id && - text == other.text && - authorUsername == other.authorUsername && - createdAt == other.createdAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, text, authorUsername, createdAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tweet{id=$id, text=$text, authorUsername=$authorUsername, createdAt=$createdAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleRetrieveResponse && - fetchedAt == other.fetchedAt && - isOwnAccount == other.isOwnAccount && - tweetCount == other.tweetCount && - tweets == other.tweets && - xUsername == other.xUsername && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(fetchedAt, isOwnAccount, tweetCount, tweets, xUsername, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StyleRetrieveResponse{fetchedAt=$fetchedAt, isOwnAccount=$isOwnAccount, tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParams.kt deleted file mode 100644 index 5abc700..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParams.kt +++ /dev/null @@ -1,688 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkKnown -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.core.toImmutable -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Save style profile with custom tweets */ -class StyleUpdateParams -private constructor( - private val username: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun username(): Optional = Optional.ofNullable(username) - - /** - * Display label for the style - * - * @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 label(): String = body.label() - - /** - * Array of tweet objects - * - * @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 = body.tweets() - - /** - * Returns the raw JSON value of [label]. - * - * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _label(): JsonField = body._label() - - /** - * Returns the raw JSON value of [tweets]. - * - * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _tweets(): JsonField> = body._tweets() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [StyleUpdateParams]. - * - * The following fields are required: - * ```java - * .label() - * .tweets() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleUpdateParams]. */ - class Builder internal constructor() { - - private var username: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(styleUpdateParams: StyleUpdateParams) = apply { - username = styleUpdateParams.username - body = styleUpdateParams.body.toBuilder() - additionalHeaders = styleUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = styleUpdateParams.additionalQueryParams.toBuilder() - } - - fun username(username: String?) = apply { this.username = username } - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [label] - * - [tweets] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Display label for the style */ - fun label(label: String) = apply { body.label(label) } - - /** - * Sets [Builder.label] to an arbitrary JSON value. - * - * You should usually call [Builder.label] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun label(label: JsonField) = apply { body.label(label) } - - /** Array of tweet objects */ - fun tweets(tweets: List) = apply { body.tweets(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. - */ - fun tweets(tweets: JsonField>) = apply { body.tweets(tweets) } - - /** - * Adds a single [Tweet] to [tweets]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTweet(tweet: Tweet) = apply { body.addTweet(tweet) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [StyleUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .label() - * .tweets() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StyleUpdateParams = - StyleUpdateParams( - username, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> username ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val label: JsonField, - private val tweets: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), - @JsonProperty("tweets") - @ExcludeMissing - tweets: JsonField> = JsonMissing.of(), - ) : this(label, tweets, mutableMapOf()) - - /** - * Display label for the style - * - * @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 label(): String = label.getRequired("label") - - /** - * Array of tweet objects - * - * @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") - - /** - * Returns the raw JSON value of [label]. - * - * Unlike [label], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("label") @ExcludeMissing fun _label(): JsonField = label - - /** - * Returns the raw JSON value of [tweets]. - * - * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets - - @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 [Body]. - * - * The following fields are required: - * ```java - * .label() - * .tweets() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var label: JsonField? = null - private var tweets: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - label = body.label - tweets = body.tweets.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Display label for the style */ - fun label(label: String) = label(JsonField.of(label)) - - /** - * Sets [Builder.label] to an arbitrary JSON value. - * - * You should usually call [Builder.label] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun label(label: JsonField) = apply { this.label = label } - - /** Array of tweet objects */ - 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. - */ - fun tweets(tweets: JsonField>) = apply { - this.tweets = tweets.map { it.toMutableList() } - } - - /** - * Adds a single [Tweet] to [tweets]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTweet(tweet: Tweet) = apply { - tweets = - (tweets ?: JsonField.of(mutableListOf())).also { - checkKnown("tweets", it).add(tweet) - } - } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .label() - * .tweets() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("label", label), - checkRequired("tweets", tweets).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - label() - tweets().forEach { it.validate() } - 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 (label.asKnown().isPresent) 1 else 0) + - (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - label == other.label && - tweets == other.tweets && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(label, tweets, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{label=$label, tweets=$tweets, additionalProperties=$additionalProperties}" - } - - class Tweet - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of() - ) : this(text, 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 text(): String = text.getRequired("text") - - /** - * 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 - - @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 - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tweet]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweet: Tweet) = apply { - text = tweet.text - additionalProperties = tweet.additionalProperties.toMutableMap() - } - - 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 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 - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tweet = - Tweet(checkRequired("text", text), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Tweet = apply { - if (validated) { - return@apply - } - - text() - 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 (text.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tweet && - text == other.text && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(text, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Tweet{text=$text, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleUpdateParams && - username == other.username && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(username, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "StyleUpdateParams{username=$username, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponse.kt deleted file mode 100644 index 270fe73..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponse.kt +++ /dev/null @@ -1,609 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -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 StyleUpdateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val fetchedAt: JsonField, - private val isOwnAccount: JsonField, - private val tweetCount: JsonField, - private val tweets: JsonField>, - private val xUsername: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("fetchedAt") - @ExcludeMissing - fetchedAt: JsonField = JsonMissing.of(), - @JsonProperty("isOwnAccount") - @ExcludeMissing - isOwnAccount: JsonField = JsonMissing.of(), - @JsonProperty("tweetCount") @ExcludeMissing tweetCount: JsonField = JsonMissing.of(), - @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), - @JsonProperty("xUsername") @ExcludeMissing xUsername: JsonField = JsonMissing.of(), - ) : this(fetchedAt, isOwnAccount, tweetCount, tweets, xUsername, 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 fetchedAt(): OffsetDateTime = fetchedAt.getRequired("fetchedAt") - - /** - * @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 isOwnAccount(): Boolean = isOwnAccount.getRequired("isOwnAccount") - - /** - * @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 tweetCount(): Long = tweetCount.getRequired("tweetCount") - - /** - * @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") - - /** - * @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 xUsername(): String = xUsername.getRequired("xUsername") - - /** - * Returns the raw JSON value of [fetchedAt]. - * - * Unlike [fetchedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("fetchedAt") - @ExcludeMissing - fun _fetchedAt(): JsonField = fetchedAt - - /** - * Returns the raw JSON value of [isOwnAccount]. - * - * Unlike [isOwnAccount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isOwnAccount") - @ExcludeMissing - fun _isOwnAccount(): JsonField = isOwnAccount - - /** - * Returns the raw JSON value of [tweetCount]. - * - * Unlike [tweetCount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetCount") @ExcludeMissing fun _tweetCount(): JsonField = tweetCount - - /** - * Returns the raw JSON value of [tweets]. - * - * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets - - /** - * Returns the raw JSON value of [xUsername]. - * - * Unlike [xUsername], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUsername") @ExcludeMissing fun _xUsername(): JsonField = xUsername - - @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 [StyleUpdateResponse]. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StyleUpdateResponse]. */ - class Builder internal constructor() { - - private var fetchedAt: JsonField? = null - private var isOwnAccount: JsonField? = null - private var tweetCount: JsonField? = null - private var tweets: JsonField>? = null - private var xUsername: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(styleUpdateResponse: StyleUpdateResponse) = apply { - fetchedAt = styleUpdateResponse.fetchedAt - isOwnAccount = styleUpdateResponse.isOwnAccount - tweetCount = styleUpdateResponse.tweetCount - tweets = styleUpdateResponse.tweets.map { it.toMutableList() } - xUsername = styleUpdateResponse.xUsername - additionalProperties = styleUpdateResponse.additionalProperties.toMutableMap() - } - - fun fetchedAt(fetchedAt: OffsetDateTime) = fetchedAt(JsonField.of(fetchedAt)) - - /** - * Sets [Builder.fetchedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.fetchedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun fetchedAt(fetchedAt: JsonField) = apply { this.fetchedAt = fetchedAt } - - fun isOwnAccount(isOwnAccount: Boolean) = isOwnAccount(JsonField.of(isOwnAccount)) - - /** - * Sets [Builder.isOwnAccount] to an arbitrary JSON value. - * - * You should usually call [Builder.isOwnAccount] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isOwnAccount(isOwnAccount: JsonField) = apply { - this.isOwnAccount = isOwnAccount - } - - fun tweetCount(tweetCount: Long) = tweetCount(JsonField.of(tweetCount)) - - /** - * Sets [Builder.tweetCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetCount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tweetCount(tweetCount: JsonField) = apply { this.tweetCount = tweetCount } - - 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. - */ - fun tweets(tweets: JsonField>) = apply { - this.tweets = tweets.map { it.toMutableList() } - } - - /** - * Adds a single [Tweet] to [tweets]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTweet(tweet: Tweet) = apply { - tweets = - (tweets ?: JsonField.of(mutableListOf())).also { - checkKnown("tweets", it).add(tweet) - } - } - - fun xUsername(xUsername: String) = xUsername(JsonField.of(xUsername)) - - /** - * Sets [Builder.xUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.xUsername] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun xUsername(xUsername: JsonField) = apply { this.xUsername = xUsername } - - 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 [StyleUpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): StyleUpdateResponse = - StyleUpdateResponse( - checkRequired("fetchedAt", fetchedAt), - checkRequired("isOwnAccount", isOwnAccount), - checkRequired("tweetCount", tweetCount), - checkRequired("tweets", tweets).map { it.toImmutable() }, - checkRequired("xUsername", xUsername), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): StyleUpdateResponse = apply { - if (validated) { - return@apply - } - - fetchedAt() - isOwnAccount() - tweetCount() - tweets().forEach { it.validate() } - xUsername() - 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 (fetchedAt.asKnown().isPresent) 1 else 0) + - (if (isOwnAccount.asKnown().isPresent) 1 else 0) + - (if (tweetCount.asKnown().isPresent) 1 else 0) + - (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (xUsername.asKnown().isPresent) 1 else 0) - - class Tweet - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val text: JsonField, - private val authorUsername: JsonField, - private val createdAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("authorUsername") - @ExcludeMissing - authorUsername: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - ) : this(id, text, authorUsername, createdAt, 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 authorUsername(): Optional = authorUsername.getOptional("authorUsername") - - /** - * @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") - - /** - * 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 [authorUsername]. - * - * Unlike [authorUsername], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("authorUsername") - @ExcludeMissing - fun _authorUsername(): JsonField = authorUsername - - /** - * 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 - - @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 authorUsername: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweet: Tweet) = apply { - id = tweet.id - text = tweet.text - authorUsername = tweet.authorUsername - createdAt = tweet.createdAt - 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 authorUsername(authorUsername: String) = - authorUsername(JsonField.of(authorUsername)) - - /** - * Sets [Builder.authorUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.authorUsername] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun authorUsername(authorUsername: JsonField) = apply { - this.authorUsername = authorUsername - } - - 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 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), - authorUsername, - createdAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tweet = apply { - if (validated) { - return@apply - } - - id() - text() - authorUsername() - createdAt() - 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) + - (if (authorUsername.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tweet && - id == other.id && - text == other.text && - authorUsername == other.authorUsername && - createdAt == other.createdAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, text, authorUsername, createdAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tweet{id=$id, text=$text, authorUsername=$authorUsername, createdAt=$createdAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StyleUpdateResponse && - fetchedAt == other.fetchedAt && - isOwnAccount == other.isOwnAccount && - tweetCount == other.tweetCount && - tweets == other.tweets && - xUsername == other.xUsername && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(fetchedAt, isOwnAccount, tweetCount, tweets, xUsername, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StyleUpdateResponse{fetchedAt=$fetchedAt, isOwnAccount=$isOwnAccount, tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/trends/TrendListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/trends/TrendListParams.kt index 0a778ad..60f5ab4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/trends/TrendListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/trends/TrendListParams.kt @@ -9,7 +9,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Get trending topics */ +/** Get regional trending topics */ class TrendListParams private constructor( private val count: Long?, @@ -18,6 +18,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** Number of trending topics to return (1-50, default 30) */ fun count(): Optional = Optional.ofNullable(count) /** Region WOEID (1=Worldwide, 23424977=US, 23424975=UK, 23424969=Turkey) */ @@ -55,6 +56,7 @@ private constructor( additionalQueryParams = trendListParams.additionalQueryParams.toBuilder() } + /** Number of trending topics to return (1-50, default 30) */ fun count(count: Long?) = apply { this.count = count } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Delivery.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Delivery.kt index 8cbe1b5..eff3088 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Delivery.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Delivery.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Webhook delivery attempt record with status and retry count. */ class Delivery @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Webhook.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Webhook.kt index 24a0270..be98f49 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Webhook.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/Webhook.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Webhook endpoint registered to receive event deliveries. */ class Webhook @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -57,6 +58,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -183,6 +186,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -311,6 +315,7 @@ private constructor( (if (isActive.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParams.kt index 94dd940..8e6dd3f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParams.kt @@ -31,6 +31,8 @@ private constructor( ) : Params { /** + * Array of event types to subscribe to. + * * @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). */ @@ -106,6 +108,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -298,6 +301,8 @@ private constructor( ) : this(eventTypes, url, mutableMapOf()) /** + * Array of event types to subscribe to. + * * @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). @@ -369,6 +374,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -496,6 +502,7 @@ private constructor( "Body{eventTypes=$eventTypes, url=$url, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponse.kt index 4d0a980..94891ec 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponse.kt @@ -57,6 +57,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -183,6 +185,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -310,6 +313,7 @@ private constructor( (if (secret.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListDeliveriesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListDeliveriesResponse.kt index ab5d217..0cedc96 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListDeliveriesResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListDeliveriesResponse.kt @@ -178,6 +178,7 @@ private constructor( internal fun validity(): Int = (deliveries.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Webhook delivery attempt record with status and retry count. */ class Delivery @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponse.kt index 77b42a8..e4ac2bf 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponse.kt @@ -175,6 +175,7 @@ private constructor( internal fun validity(): Int = (webhooks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Webhook endpoint registered to receive event deliveries. */ class Webhook @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -216,6 +217,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). @@ -348,6 +351,7 @@ private constructor( this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -478,6 +482,7 @@ private constructor( (if (isActive.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParams.kt index 955cab6..b7baad4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParams.kt @@ -34,6 +34,8 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -122,6 +124,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** @@ -327,6 +330,8 @@ private constructor( ) : this(eventTypes, isActive, url, mutableMapOf()) /** + * Array of event types to subscribe to. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ @@ -401,6 +406,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -536,6 +542,7 @@ private constructor( "Body{eventTypes=$eventTypes, isActive=$isActive, url=$url, additionalProperties=$additionalProperties}" } + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponse.kt index 1a0194a..de782d7 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponse.kt @@ -20,6 +20,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull +/** Webhook endpoint registered to receive event deliveries. */ class WebhookUpdateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -57,6 +58,8 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") /** + * Array of event types to subscribe to. + * * @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). */ @@ -183,6 +186,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -311,6 +315,7 @@ private constructor( (if (isActive.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + /** Type of monitor event fired when account activity occurs. */ class EventType @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponse.kt index ad4f22b..fdd64e8 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponse.kt @@ -40,6 +40,8 @@ private constructor( fun article(): Article = article.getRequired("article") /** + * Author of a tweet with follower count and verification status. + * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -108,6 +110,7 @@ private constructor( */ fun article(article: JsonField
) = apply { this.article = article } + /** Author of a tweet with follower count and verification status. */ fun author(author: Author) = author(JsonField.of(author)) /** @@ -930,6 +933,7 @@ private constructor( "Article{contents=$contents, coverImageUrl=$coverImageUrl, createdAt=$createdAt, likeCount=$likeCount, previewText=$previewText, quoteCount=$quoteCount, replyCount=$replyCount, title=$title, viewCount=$viewCount, additionalProperties=$additionalProperties}" } + /** Author of a tweet with follower count and verification status. */ class Author @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineParams.kt index 9cf925b..1e95dd4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineParams.kt @@ -18,7 +18,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Pagination cursor from previous response */ + /** Pagination cursor for timeline */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Comma-separated tweet IDs to exclude from results */ @@ -56,7 +56,7 @@ private constructor( additionalQueryParams = xGetHomeTimelineParams.additionalQueryParams.toBuilder() } - /** Pagination cursor from previous response */ + /** Pagination cursor for timeline */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt index 5947b26..d14ca00 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class XGetHomeTimelineResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsParams.kt index 4e3cb65..839e916 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsParams.kt @@ -22,7 +22,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Pagination cursor from previous response */ + /** Pagination cursor for notifications */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Notification type filter */ @@ -60,7 +60,7 @@ private constructor( additionalQueryParams = xGetNotificationsParams.additionalQueryParams.toBuilder() } - /** Pagination cursor from previous response */ + /** Pagination cursor for notifications */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponse.kt new file mode 100644 index 0000000..95481c9 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponse.kt @@ -0,0 +1,520 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class XGetTrendsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField, + private val trends: JsonField>, + private val woeid: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("trends") @ExcludeMissing trends: JsonField> = JsonMissing.of(), + @JsonProperty("woeid") @ExcludeMissing woeid: JsonField = JsonMissing.of(), + ) : this(count, trends, woeid, 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 count(): Long = count.getRequired("count") + + /** + * @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 trends(): List = trends.getRequired("trends") + + /** + * @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 woeid(): Long = woeid.getRequired("woeid") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [trends]. + * + * Unlike [trends], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trends") @ExcludeMissing fun _trends(): JsonField> = trends + + /** + * Returns the raw JSON value of [woeid]. + * + * Unlike [woeid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("woeid") @ExcludeMissing fun _woeid(): JsonField = woeid + + @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 [XGetTrendsResponse]. + * + * The following fields are required: + * ```java + * .count() + * .trends() + * .woeid() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [XGetTrendsResponse]. */ + class Builder internal constructor() { + + private var count: JsonField? = null + private var trends: JsonField>? = null + private var woeid: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(xGetTrendsResponse: XGetTrendsResponse) = apply { + count = xGetTrendsResponse.count + trends = xGetTrendsResponse.trends.map { it.toMutableList() } + woeid = xGetTrendsResponse.woeid + additionalProperties = xGetTrendsResponse.additionalProperties.toMutableMap() + } + + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun trends(trends: List) = trends(JsonField.of(trends)) + + /** + * Sets [Builder.trends] to an arbitrary JSON value. + * + * You should usually call [Builder.trends] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun trends(trends: JsonField>) = apply { + this.trends = trends.map { it.toMutableList() } + } + + /** + * Adds a single [Trend] to [trends]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTrend(trend: Trend) = apply { + trends = + (trends ?: JsonField.of(mutableListOf())).also { + checkKnown("trends", it).add(trend) + } + } + + fun woeid(woeid: Long) = woeid(JsonField.of(woeid)) + + /** + * Sets [Builder.woeid] to an arbitrary JSON value. + * + * You should usually call [Builder.woeid] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun woeid(woeid: JsonField) = apply { this.woeid = woeid } + + 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 [XGetTrendsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .count() + * .trends() + * .woeid() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): XGetTrendsResponse = + XGetTrendsResponse( + checkRequired("count", count), + checkRequired("trends", trends).map { it.toImmutable() }, + checkRequired("woeid", woeid), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): XGetTrendsResponse = apply { + if (validated) { + return@apply + } + + count() + trends().forEach { it.validate() } + woeid() + 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 (count.asKnown().isPresent) 1 else 0) + + (trends.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (woeid.asKnown().isPresent) 1 else 0) + + class Trend + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val description: JsonField, + private val query: JsonField, + private val rank: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("rank") @ExcludeMissing rank: JsonField = JsonMissing.of(), + ) : this(name, description, query, rank, 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 name(): String = name.getRequired("name") + + /** + * @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 query(): Optional = query.getOptional("query") + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rank(): Optional = rank.getOptional("rank") + + /** + * 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 [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 [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [rank]. + * + * Unlike [rank], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rank") @ExcludeMissing fun _rank(): JsonField = rank + + @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 [Trend]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Trend]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var query: JsonField = JsonMissing.of() + private var rank: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trend: Trend) = apply { + name = trend.name + description = trend.description + query = trend.query + rank = trend.rank + additionalProperties = trend.additionalProperties.toMutableMap() + } + + 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 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 query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + fun rank(rank: Long) = rank(JsonField.of(rank)) + + /** + * Sets [Builder.rank] to an arbitrary JSON value. + * + * You should usually call [Builder.rank] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rank(rank: JsonField) = apply { this.rank = rank } + + 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 [Trend]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Trend = + Trend( + checkRequired("name", name), + description, + query, + rank, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Trend = apply { + if (validated) { + return@apply + } + + name() + description() + query() + rank() + 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 (name.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (query.asKnown().isPresent) 1 else 0) + + (if (rank.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Trend && + name == other.name && + description == other.description && + query == other.query && + rank == other.rank && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, description, query, rank, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Trend{name=$name, description=$description, query=$query, rank=$rank, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is XGetTrendsResponse && + count == other.count && + trends == other.trends && + woeid == other.woeid && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, trends, woeid, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "XGetTrendsResponse{count=$count, trends=$trends, woeid=$woeid, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponse.kt index 480da54..85c78b8 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponse.kt @@ -174,6 +174,7 @@ private constructor( internal fun validity(): Int = (accounts.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Linked X account summary with username and connection status. */ class Account @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParams.kt index cbed767..b40e086 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParams.kt @@ -32,7 +32,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * Account password + * Updated account password * * @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). @@ -40,7 +40,7 @@ private constructor( fun password(): String = body.password() /** - * TOTP secret for 2FA + * TOTP secret for 2FA re-authentication * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -115,7 +115,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** Account password */ + /** Updated account password */ fun password(password: String) = apply { body.password(password) } /** @@ -126,7 +126,7 @@ private constructor( */ fun password(password: JsonField) = apply { body.password(password) } - /** TOTP secret for 2FA */ + /** TOTP secret for 2FA re-authentication */ fun totpSecret(totpSecret: String) = apply { body.totpSecret(totpSecret) } /** @@ -307,7 +307,7 @@ private constructor( ) : this(password, totpSecret, mutableMapOf()) /** - * Account password + * Updated account password * * @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 @@ -316,7 +316,7 @@ private constructor( fun password(): String = password.getRequired("password") /** - * TOTP secret for 2FA + * TOTP secret for 2FA re-authentication * * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -378,7 +378,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** Account password */ + /** Updated account password */ fun password(password: String) = password(JsonField.of(password)) /** @@ -390,7 +390,7 @@ private constructor( */ fun password(password: JsonField) = apply { this.password = password } - /** TOTP secret for 2FA */ + /** TOTP secret for 2FA re-authentication */ fun totpSecret(totpSecret: String) = totpSecret(JsonField.of(totpSecret)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponse.kt index 9d59eaa..4c9c603 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponse.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full X account details including proxy, cookies, and update timestamp. */ class AccountRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccount.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccount.kt index 4d540b6..fab341e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccount.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccount.kt @@ -16,6 +16,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +/** Linked X account summary with username and connection status. */ class XAccount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetail.kt index 5d964f3..a984393 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetail.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetail.kt @@ -17,6 +17,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Full X account details including proxy, cookies, and update timestamp. */ class XAccountDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParams.kt index fcc194a..1ab94bd 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParams.kt @@ -18,7 +18,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Pagination cursor from previous response */ + /** Pagination cursor for bookmarks */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Optional bookmark folder ID */ @@ -56,7 +56,7 @@ private constructor( additionalQueryParams = bookmarkListParams.additionalQueryParams.toBuilder() } - /** Pagination cursor from previous response */ + /** Pagination cursor for bookmarks */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt index d228cae..cfcd947 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class BookmarkListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResult.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResult.kt index 5d58447..ff5d032 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResult.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResult.kt @@ -15,6 +15,7 @@ import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException import java.util.Collections import java.util.Objects +/** Result of a community join or leave action. */ class CommunityActionResult @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParams.kt index b5276e7..39ad39c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParams.kt @@ -28,7 +28,7 @@ private constructor( ) : Params { /** - * X account (@username or account ID) + * X account (@username or ID) creating the community * * @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). @@ -121,7 +121,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) creating the community */ fun account(account: String) = apply { body.account(account) } /** @@ -318,7 +318,7 @@ private constructor( ) : this(account, name, description, mutableMapOf()) /** - * X account (@username or account ID) + * X account (@username or ID) creating the community * * @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 @@ -408,7 +408,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) creating the community */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParams.kt index e22ea15..caf9608 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParams.kt @@ -32,7 +32,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * X account (@username or account ID) + * X account (@username or ID) deleting the community * * @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). @@ -116,7 +116,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) deleting the community */ fun account(account: String) = apply { body.account(account) } /** @@ -309,7 +309,7 @@ private constructor( ) : this(account, communityName, mutableMapOf()) /** - * X account (@username or account ID) + * X account (@username or ID) deleting the community * * @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 @@ -383,7 +383,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) deleting the community */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponse.kt index 0a800cd..f90e66f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponse.kt @@ -7,34 +7,46 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField import com.x_twitter_scraper.api.core.JsonMissing import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class CommunityRetrieveInfoResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val community: JsonValue, + private val community: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("community") @ExcludeMissing community: JsonValue = JsonMissing.of() + @JsonProperty("community") + @ExcludeMissing + community: JsonField = JsonMissing.of() ) : this(community, mutableMapOf()) /** * Community info object * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = communityRetrieveInfoResponse.community().convert(MyClass.class); - * ``` + * @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). */ - @JsonProperty("community") @ExcludeMissing fun _community(): JsonValue = community + fun community(): Community = community.getRequired("community") + + /** + * Returns the raw JSON value of [community]. + * + * Unlike [community], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("community") @ExcludeMissing fun _community(): JsonField = community @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -65,7 +77,7 @@ private constructor( /** A builder for [CommunityRetrieveInfoResponse]. */ class Builder internal constructor() { - private var community: JsonValue? = null + private var community: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -75,7 +87,16 @@ private constructor( } /** Community info object */ - fun community(community: JsonValue) = apply { this.community = community } + fun community(community: Community) = community(JsonField.of(community)) + + /** + * Sets [Builder.community] to an arbitrary JSON value. + * + * You should usually call [Builder.community] with a well-typed [Community] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun community(community: JsonField) = apply { this.community = community } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -122,6 +143,7 @@ private constructor( return@apply } + community().validate() validated = true } @@ -138,7 +160,946 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = 0 + @JvmSynthetic internal fun validity(): Int = (community.asKnown().getOrNull()?.validity() ?: 0) + + /** Community info object */ + class Community + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val bannerUrl: JsonField, + private val createdAt: JsonField, + private val description: JsonField, + private val joinPolicy: JsonField, + private val memberCount: JsonField, + private val moderatorCount: JsonField, + private val name: JsonField, + private val primaryTopic: JsonField, + private val rules: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("banner_url") + @ExcludeMissing + bannerUrl: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("join_policy") + @ExcludeMissing + joinPolicy: JsonField = JsonMissing.of(), + @JsonProperty("member_count") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("moderator_count") + @ExcludeMissing + moderatorCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("primary_topic") + @ExcludeMissing + primaryTopic: JsonField = JsonMissing.of(), + @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), + ) : this( + id, + bannerUrl, + createdAt, + description, + joinPolicy, + memberCount, + moderatorCount, + name, + primaryTopic, + rules, + mutableMapOf(), + ) + + /** + * Unique community identifier + * + * @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") + + /** + * Community banner image URL + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun bannerUrl(): Optional = bannerUrl.getOptional("banner_url") + + /** + * Community creation timestamp + * + * @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("created_at") + + /** + * About text for the community + * + * @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") + + /** + * Join policy (open or restricted) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun joinPolicy(): Optional = joinPolicy.getOptional("join_policy") + + /** + * Total member count + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun memberCount(): Optional = memberCount.getOptional("member_count") + + /** + * Total moderator count + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun moderatorCount(): Optional = moderatorCount.getOptional("moderator_count") + + /** + * Display name of the community + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Primary topic + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun primaryTopic(): Optional = primaryTopic.getOptional("primary_topic") + + /** + * Community rules + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rules(): Optional> = rules.getOptional("rules") + + /** + * 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 [bannerUrl]. + * + * Unlike [bannerUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("banner_url") @ExcludeMissing fun _bannerUrl(): JsonField = bannerUrl + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @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 [joinPolicy]. + * + * Unlike [joinPolicy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("join_policy") + @ExcludeMissing + fun _joinPolicy(): JsonField = joinPolicy + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("member_count") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * Returns the raw JSON value of [moderatorCount]. + * + * Unlike [moderatorCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("moderator_count") + @ExcludeMissing + fun _moderatorCount(): JsonField = moderatorCount + + /** + * 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 [primaryTopic]. + * + * Unlike [primaryTopic], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("primary_topic") + @ExcludeMissing + fun _primaryTopic(): JsonField = primaryTopic + + /** + * Returns the raw JSON value of [rules]. + * + * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + + @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 [Community]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Community]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var bannerUrl: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var joinPolicy: JsonField = JsonMissing.of() + private var memberCount: JsonField = JsonMissing.of() + private var moderatorCount: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var primaryTopic: JsonField = JsonMissing.of() + private var rules: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(community: Community) = apply { + id = community.id + bannerUrl = community.bannerUrl + createdAt = community.createdAt + description = community.description + joinPolicy = community.joinPolicy + memberCount = community.memberCount + moderatorCount = community.moderatorCount + name = community.name + primaryTopic = community.primaryTopic + rules = community.rules.map { it.toMutableList() } + additionalProperties = community.additionalProperties.toMutableMap() + } + + /** Unique community identifier */ + 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 } + + /** Community banner image URL */ + fun bannerUrl(bannerUrl: String) = bannerUrl(JsonField.of(bannerUrl)) + + /** + * Sets [Builder.bannerUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.bannerUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bannerUrl(bannerUrl: JsonField) = apply { this.bannerUrl = bannerUrl } + + /** Community creation timestamp */ + 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 } + + /** About text for the community */ + 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 + } + + /** Join policy (open or restricted) */ + fun joinPolicy(joinPolicy: String) = joinPolicy(JsonField.of(joinPolicy)) + + /** + * Sets [Builder.joinPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.joinPolicy] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun joinPolicy(joinPolicy: JsonField) = apply { this.joinPolicy = joinPolicy } + + /** Total member count */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** Total moderator count */ + fun moderatorCount(moderatorCount: Long) = moderatorCount(JsonField.of(moderatorCount)) + + /** + * Sets [Builder.moderatorCount] to an arbitrary JSON value. + * + * You should usually call [Builder.moderatorCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun moderatorCount(moderatorCount: JsonField) = apply { + this.moderatorCount = moderatorCount + } + + /** Display name of the community */ + 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 } + + /** Primary topic */ + fun primaryTopic(primaryTopic: PrimaryTopic) = primaryTopic(JsonField.of(primaryTopic)) + + /** + * Sets [Builder.primaryTopic] to an arbitrary JSON value. + * + * You should usually call [Builder.primaryTopic] with a well-typed [PrimaryTopic] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun primaryTopic(primaryTopic: JsonField) = apply { + this.primaryTopic = primaryTopic + } + + /** Community rules */ + fun rules(rules: List) = rules(JsonField.of(rules)) + + /** + * Sets [Builder.rules] to an arbitrary JSON value. + * + * You should usually call [Builder.rules] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rules(rules: JsonField>) = apply { + this.rules = rules.map { it.toMutableList() } + } + + /** + * Adds a single [Rule] to [rules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRule(rule: Rule) = apply { + rules = + (rules ?: JsonField.of(mutableListOf())).also { + checkKnown("rules", it).add(rule) + } + } + + 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 [Community]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Community = + Community( + checkRequired("id", id), + bannerUrl, + createdAt, + description, + joinPolicy, + memberCount, + moderatorCount, + name, + primaryTopic, + (rules ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Community = apply { + if (validated) { + return@apply + } + + id() + bannerUrl() + createdAt() + description() + joinPolicy() + memberCount() + moderatorCount() + name() + primaryTopic().ifPresent { it.validate() } + rules().ifPresent { it.forEach { it.validate() } } + 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 (bannerUrl.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (joinPolicy.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (moderatorCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (primaryTopic.asKnown().getOrNull()?.validity() ?: 0) + + (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Primary topic */ + class PrimaryTopic + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * 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 + + @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 [PrimaryTopic]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PrimaryTopic]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(primaryTopic: PrimaryTopic) = apply { + id = primaryTopic.id + name = primaryTopic.name + additionalProperties = primaryTopic.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 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 [PrimaryTopic]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PrimaryTopic = + PrimaryTopic(id, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): PrimaryTopic = apply { + if (validated) { + return@apply + } + + id() + name() + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PrimaryTopic && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PrimaryTopic{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + class Rule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val description: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, description, name, mutableMapOf()) + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @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 name(): Optional = name.getOptional("name") + + /** + * 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 [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 [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [Rule]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rule]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rule: Rule) = apply { + id = rule.id + description = rule.description + name = rule.name + additionalProperties = rule.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 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 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 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 [Rule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Rule = Rule(id, description, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Rule = apply { + if (validated) { + return@apply + } + + id() + description() + name() + 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 (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rule && + id == other.id && + description == other.description && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, description, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rule{id=$id, description=$description, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Community && + id == other.id && + bannerUrl == other.bannerUrl && + createdAt == other.createdAt && + description == other.description && + joinPolicy == other.joinPolicy && + memberCount == other.memberCount && + moderatorCount == other.moderatorCount && + name == other.name && + primaryTopic == other.primaryTopic && + rules == other.rules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + bannerUrl, + createdAt, + description, + joinPolicy, + memberCount, + moderatorCount, + name, + primaryTopic, + rules, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Community{id=$id, bannerUrl=$bannerUrl, createdAt=$createdAt, description=$description, joinPolicy=$joinPolicy, memberCount=$memberCount, moderatorCount=$moderatorCount, name=$name, primaryTopic=$primaryTopic, rules=$rules, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponse.kt new file mode 100644 index 0000000..d1af901 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponse.kt @@ -0,0 +1,816 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class CommunityRetrieveMembersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [CommunityRetrieveMembersResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommunityRetrieveMembersResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(communityRetrieveMembersResponse: CommunityRetrieveMembersResponse) = + apply { + hasNextPage = communityRetrieveMembersResponse.hasNextPage + nextCursor = communityRetrieveMembersResponse.nextCursor + users = communityRetrieveMembersResponse.users.map { it.toMutableList() } + additionalProperties = + communityRetrieveMembersResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [CommunityRetrieveMembersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommunityRetrieveMembersResponse = + CommunityRetrieveMembersResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommunityRetrieveMembersResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is CommunityRetrieveMembersResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommunityRetrieveMembersResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsParams.kt index 61bb062..a4a087b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for community moderators */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -65,7 +65,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for community moderators */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponse.kt new file mode 100644 index 0000000..4753e36 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponse.kt @@ -0,0 +1,817 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class CommunityRetrieveModeratorsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [CommunityRetrieveModeratorsResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommunityRetrieveModeratorsResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + communityRetrieveModeratorsResponse: CommunityRetrieveModeratorsResponse + ) = apply { + hasNextPage = communityRetrieveModeratorsResponse.hasNextPage + nextCursor = communityRetrieveModeratorsResponse.nextCursor + users = communityRetrieveModeratorsResponse.users.map { it.toMutableList() } + additionalProperties = + communityRetrieveModeratorsResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [CommunityRetrieveModeratorsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommunityRetrieveModeratorsResponse = + CommunityRetrieveModeratorsResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommunityRetrieveModeratorsResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is CommunityRetrieveModeratorsResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommunityRetrieveModeratorsResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchParams.kt index 108cefa..d44f20d 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchParams.kt @@ -23,7 +23,7 @@ private constructor( /** Search query */ fun q(): String = q - /** Pagination cursor */ + /** Pagination cursor for community search */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Sort order (Latest or Top) */ @@ -72,7 +72,7 @@ private constructor( /** Search query */ fun q(q: String) = apply { this.q = q } - /** Pagination cursor */ + /** Pagination cursor for community search */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponse.kt new file mode 100644 index 0000000..5b5ac5e --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponse.kt @@ -0,0 +1,1085 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of tweets with cursor-based navigation. */ +class CommunityRetrieveSearchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val tweets: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, tweets, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [tweets]. + * + * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets + + @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 + * [CommunityRetrieveSearchResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommunityRetrieveSearchResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var tweets: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(communityRetrieveSearchResponse: CommunityRetrieveSearchResponse) = + apply { + hasNextPage = communityRetrieveSearchResponse.hasNextPage + nextCursor = communityRetrieveSearchResponse.nextCursor + tweets = communityRetrieveSearchResponse.tweets.map { it.toMutableList() } + additionalProperties = + communityRetrieveSearchResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun tweets(tweets: JsonField>) = apply { + this.tweets = tweets.map { it.toMutableList() } + } + + /** + * Adds a single [Tweet] to [tweets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTweet(tweet: Tweet) = apply { + tweets = + (tweets ?: JsonField.of(mutableListOf())).also { + checkKnown("tweets", it).add(tweet) + } + } + + 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 [CommunityRetrieveSearchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommunityRetrieveSearchResponse = + CommunityRetrieveSearchResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("tweets", tweets).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommunityRetrieveSearchResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + tweets().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Tweet returned from search results with inline author info. */ + 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 isNoteTweet: 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("isNoteTweet") + @ExcludeMissing + isNoteTweet: 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, + isNoteTweet, + 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") + + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + + /** + * @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 [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + + /** + * 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 isNoteTweet: 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 + isNoteTweet = tweet.isNoteTweet + 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 } + + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + + 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, + isNoteTweet, + 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() + isNoteTweet() + 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 (isNoteTweet.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 && + isNoteTweet == other.isNoteTweet && + 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, + isNoteTweet, + 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, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommunityRetrieveSearchResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + tweets == other.tweets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, tweets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommunityRetrieveSearchResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, tweets=$tweets, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParams.kt index 7d15f97..52050a1 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParams.kt @@ -32,7 +32,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * X account (@username or account ID) + * X account identifier (@username or account 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). @@ -99,7 +99,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account identifier (@username or account ID) */ fun account(account: String) = apply { body.account(account) } /** @@ -260,6 +260,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** Request body identifying an X account by username or ID. */ class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -273,7 +274,7 @@ private constructor( ) : this(account, mutableMapOf()) /** - * X account (@username or account ID) + * X account identifier (@username or account 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 @@ -325,7 +326,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account identifier (@username or account ID) */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponse.kt index 646126b..390e3f4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponse.kt @@ -15,6 +15,7 @@ import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException import java.util.Collections import java.util.Objects +/** Result of a community join or leave action. */ class JoinCreateResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParams.kt index ce602ef..d7354db 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParams.kt @@ -32,7 +32,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) /** - * X account (@username or account ID) + * X account identifier (@username or account 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). @@ -99,7 +99,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account identifier (@username or account ID) */ fun account(account: String) = apply { body.account(account) } /** @@ -260,6 +260,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + /** Request body identifying an X account by username or ID. */ class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -273,7 +274,7 @@ private constructor( ) : this(account, mutableMapOf()) /** - * X account (@username or account ID) + * X account identifier (@username or account 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 @@ -325,7 +326,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account identifier (@username or account ID) */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponse.kt index 0ffefbf..a2929ed 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponse.kt @@ -15,6 +15,7 @@ import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException import java.util.Collections import java.util.Objects +/** Result of a community join or leave action. */ class JoinDeleteAllResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListParams.kt index 9cb5028..a90aee5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListParams.kt @@ -20,13 +20,13 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Search query */ + /** Search query for cross-community tweets */ fun q(): String = q - /** Pagination cursor */ + /** Pagination cursor for cross-community results */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Sort order (Latest or Top) */ + /** Sort order for cross-community results (Latest or Top) */ fun queryType(): Optional = Optional.ofNullable(queryType) /** Additional headers to send with the request. */ @@ -68,16 +68,16 @@ private constructor( additionalQueryParams = tweetListParams.additionalQueryParams.toBuilder() } - /** Search query */ + /** Search query for cross-community tweets */ fun q(q: String) = apply { this.q = q } - /** Pagination cursor */ + /** Pagination cursor for cross-community results */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Sort order (Latest or Top) */ + /** Sort order for cross-community results (Latest or Top) */ fun queryType(queryType: String?) = apply { this.queryType = queryType } /** Alias for calling [Builder.queryType] with `queryType.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponse.kt new file mode 100644 index 0000000..45dfba6 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponse.kt @@ -0,0 +1,1082 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities.tweets + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of tweets with cursor-based navigation. */ +class TweetListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val tweets: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, tweets, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [tweets]. + * + * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets + + @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 [TweetListResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TweetListResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var tweets: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tweetListResponse: TweetListResponse) = apply { + hasNextPage = tweetListResponse.hasNextPage + nextCursor = tweetListResponse.nextCursor + tweets = tweetListResponse.tweets.map { it.toMutableList() } + additionalProperties = tweetListResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun tweets(tweets: JsonField>) = apply { + this.tweets = tweets.map { it.toMutableList() } + } + + /** + * Adds a single [Tweet] to [tweets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTweet(tweet: Tweet) = apply { + tweets = + (tweets ?: JsonField.of(mutableListOf())).also { + checkKnown("tweets", it).add(tweet) + } + } + + 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 [TweetListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TweetListResponse = + TweetListResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("tweets", tweets).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TweetListResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + tweets().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Tweet returned from search results with inline author info. */ + 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 isNoteTweet: 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("isNoteTweet") + @ExcludeMissing + isNoteTweet: 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, + isNoteTweet, + 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") + + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + + /** + * @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 [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + + /** + * 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 isNoteTweet: 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 + isNoteTweet = tweet.isNoteTweet + 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 } + + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + + 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, + isNoteTweet, + 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() + isNoteTweet() + 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 (isNoteTweet.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 && + isNoteTweet == other.isNoteTweet && + 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, + isNoteTweet, + 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, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TweetListResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + tweets == other.tweets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, tweets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TweetListResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, tweets=$tweets, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryParams.kt index 24981f8..0e15b25 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryParams.kt @@ -21,7 +21,7 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId) - /** Pagination cursor from previous response */ + /** Pagination cursor for DM history */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Legacy pagination cursor (backward compat) */ @@ -66,7 +66,7 @@ private constructor( /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ fun userId(userId: Optional) = userId(userId.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for DM history */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParams.kt index 6342c3d..b5dc0e6 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParams.kt @@ -34,7 +34,7 @@ private constructor( fun userId(): Optional = Optional.ofNullable(userId) /** - * X account (@username or account ID) + * X account (@username or ID) sending the DM * * @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). @@ -145,7 +145,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) sending the DM */ fun account(account: String) = apply { body.account(account) } /** @@ -373,7 +373,7 @@ private constructor( ) : this(account, text, mediaIds, replyToMessageId, mutableMapOf()) /** - * X account (@username or account ID) + * X account (@username or ID) sending the DM * * @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 @@ -478,7 +478,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) sending the DM */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersParams.kt index ac870bd..4342b44 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for list followers */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -62,7 +62,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for list followers */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponse.kt new file mode 100644 index 0000000..2454718 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponse.kt @@ -0,0 +1,814 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class ListRetrieveFollowersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [ListRetrieveFollowersResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveFollowersResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listRetrieveFollowersResponse: ListRetrieveFollowersResponse) = apply { + hasNextPage = listRetrieveFollowersResponse.hasNextPage + nextCursor = listRetrieveFollowersResponse.nextCursor + users = listRetrieveFollowersResponse.users.map { it.toMutableList() } + additionalProperties = listRetrieveFollowersResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [ListRetrieveFollowersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListRetrieveFollowersResponse = + ListRetrieveFollowersResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListRetrieveFollowersResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is ListRetrieveFollowersResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListRetrieveFollowersResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersParams.kt index d6079b8..513c702 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for list members */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -62,7 +62,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for list members */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponse.kt new file mode 100644 index 0000000..8bc21a4 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponse.kt @@ -0,0 +1,813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class ListRetrieveMembersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 [ListRetrieveMembersResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveMembersResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listRetrieveMembersResponse: ListRetrieveMembersResponse) = apply { + hasNextPage = listRetrieveMembersResponse.hasNextPage + nextCursor = listRetrieveMembersResponse.nextCursor + users = listRetrieveMembersResponse.users.map { it.toMutableList() } + additionalProperties = listRetrieveMembersResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [ListRetrieveMembersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListRetrieveMembersResponse = + ListRetrieveMembersResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListRetrieveMembersResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is ListRetrieveMembersResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListRetrieveMembersResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsParams.kt index 72f2e92..1ebcb62 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsParams.kt @@ -23,7 +23,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for list tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Include replies (default false) */ @@ -78,7 +78,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for list tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponse.kt new file mode 100644 index 0000000..739c207 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponse.kt @@ -0,0 +1,1082 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of tweets with cursor-based navigation. */ +class ListRetrieveTweetsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val tweets: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, tweets, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [tweets]. + * + * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets + + @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 [ListRetrieveTweetsResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveTweetsResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var tweets: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listRetrieveTweetsResponse: ListRetrieveTweetsResponse) = apply { + hasNextPage = listRetrieveTweetsResponse.hasNextPage + nextCursor = listRetrieveTweetsResponse.nextCursor + tweets = listRetrieveTweetsResponse.tweets.map { it.toMutableList() } + additionalProperties = listRetrieveTweetsResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun tweets(tweets: JsonField>) = apply { + this.tweets = tweets.map { it.toMutableList() } + } + + /** + * Adds a single [Tweet] to [tweets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTweet(tweet: Tweet) = apply { + tweets = + (tweets ?: JsonField.of(mutableListOf())).also { + checkKnown("tweets", it).add(tweet) + } + } + + 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 [ListRetrieveTweetsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListRetrieveTweetsResponse = + ListRetrieveTweetsResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("tweets", tweets).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListRetrieveTweetsResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + tweets().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Tweet returned from search results with inline author info. */ + 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 isNoteTweet: 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("isNoteTweet") + @ExcludeMissing + isNoteTweet: 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, + isNoteTweet, + 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") + + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + + /** + * @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 [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + + /** + * 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 isNoteTweet: 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 + isNoteTweet = tweet.isNoteTweet + 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 } + + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + + 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, + isNoteTweet, + 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() + isNoteTweet() + 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 (isNoteTweet.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 && + isNoteTweet == other.isNoteTweet && + 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, + isNoteTweet, + 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, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListRetrieveTweetsResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + tweets == other.tweets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, tweets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListRetrieveTweetsResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, tweets=$tweets, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParams.kt index eeff1fb..7fec7e3 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParams.kt @@ -31,7 +31,7 @@ private constructor( ) : Params { /** - * X account (@username or account ID) + * X account (@username or ID) uploading media * * @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). @@ -123,7 +123,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) uploading media */ fun account(account: String) = apply { body.account(account) } /** @@ -321,7 +321,7 @@ private constructor( ) { /** - * X account (@username or account ID) + * X account (@username or ID) uploading media * * @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 @@ -411,7 +411,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) uploading media */ fun account(account: String) = account(MultipartField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParams.kt index 872d5b3..1b80732 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParams.kt @@ -30,7 +30,7 @@ private constructor( ) : Params { /** - * X account (@username or account ID) + * X account (@username or ID) for avatar update * * @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). @@ -107,7 +107,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) for avatar update */ fun account(account: String) = apply { body.account(account) } /** @@ -291,7 +291,7 @@ private constructor( ) { /** - * X account (@username or account ID) + * X account (@username or ID) for avatar update * * @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 @@ -363,7 +363,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) for avatar update */ fun account(account: String) = account(MultipartField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParams.kt index ee77f41..8d259cd 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParams.kt @@ -30,7 +30,7 @@ private constructor( ) : Params { /** - * X account (@username or account ID) + * X account (@username or ID) for banner update * * @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). @@ -107,7 +107,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) for banner update */ fun account(account: String) = apply { body.account(account) } /** @@ -291,7 +291,7 @@ private constructor( ) { /** - * X account (@username or account ID) + * X account (@username or ID) for banner update * * @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 @@ -363,7 +363,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) for banner update */ fun account(account: String) = account(MultipartField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParams.kt index d7b87f5..5c9c726 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParams.kt @@ -28,7 +28,7 @@ private constructor( ) : Params { /** - * X account (@username or account ID) + * X account (@username or ID) to update profile * * @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). @@ -151,7 +151,7 @@ private constructor( */ fun body(body: Body) = apply { this.body = body.toBuilder() } - /** X account (@username or account ID) */ + /** X account (@username or ID) to update profile */ fun account(account: String) = apply { body.account(account) } /** @@ -374,7 +374,7 @@ private constructor( ) : this(account, description, location, name, url, mutableMapOf()) /** - * X account (@username or account ID) + * X account (@username or ID) to update profile * * @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 @@ -494,7 +494,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - /** X account (@username or account ID) */ + /** X account (@username or ID) to update profile */ fun account(account: String) = account(JsonField.of(account)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweet.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweet.kt index c4f15ff..6bea90b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweet.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweet.kt @@ -17,6 +17,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Tweet returned from search results with inline author info. */ class SearchTweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -25,6 +26,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -42,6 +44,9 @@ private constructor( @ExcludeMissing bookmarkCount: JsonField = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @JsonProperty("quoteCount") @ExcludeMissing quoteCount: JsonField = JsonMissing.of(), @JsonProperty("replyCount") @ExcludeMissing replyCount: JsonField = JsonMissing.of(), @@ -55,6 +60,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -93,6 +99,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -160,6 +174,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -231,6 +254,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -245,6 +269,7 @@ private constructor( author = searchTweet.author bookmarkCount = searchTweet.bookmarkCount createdAt = searchTweet.createdAt + isNoteTweet = searchTweet.isNoteTweet likeCount = searchTweet.likeCount quoteCount = searchTweet.quoteCount replyCount = searchTweet.replyCount @@ -307,6 +332,18 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { this.isNoteTweet = isNoteTweet } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -397,6 +434,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -418,6 +456,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -446,6 +485,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -730,6 +770,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -745,6 +786,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -757,5 +799,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SearchTweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" + "SearchTweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthor.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthor.kt index 59970d8..3aaa7bf 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthor.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthor.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** Author of a tweet with follower count and verification status. */ class TweetAuthor @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParams.kt deleted file mode 100644 index f08578a..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete tweet */ -class TweetDeleteParams -private constructor( - private val tweetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TweetDeleteParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TweetDeleteParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tweetDeleteParams: TweetDeleteParams) = apply { - tweetId = tweetDeleteParams.tweetId - body = tweetDeleteParams.body.toBuilder() - additionalHeaders = tweetDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = tweetDeleteParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TweetDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TweetDeleteParams = - TweetDeleteParams( - tweetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TweetDeleteParams && - tweetId == other.tweetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tweetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TweetDeleteParams{tweetId=$tweetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponse.kt deleted file mode 100644 index 9b94e60..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class TweetDeleteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [TweetDeleteResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TweetDeleteResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweetDeleteResponse: TweetDeleteResponse) = apply { - success = tweetDeleteResponse.success - additionalProperties = tweetDeleteResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [TweetDeleteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TweetDeleteResponse = - TweetDeleteResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): TweetDeleteResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TweetDeleteResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TweetDeleteResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt index e1c572b..b3164be 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt @@ -6,16 +6,21 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.Enum import com.x_twitter_scraper.api.core.ExcludeMissing import com.x_twitter_scraper.api.core.JsonField import com.x_twitter_scraper.api.core.JsonMissing import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull +/** Full tweet with text, engagement metrics, media, and metadata. */ class TweetDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -27,7 +32,15 @@ private constructor( private val retweetCount: JsonField, private val text: JsonField, private val viewCount: JsonField, + private val conversationId: JsonField, private val createdAt: JsonField, + private val entities: JsonField, + private val isNoteTweet: JsonField, + private val isQuoteStatus: JsonField, + private val isReply: JsonField, + private val media: JsonField>, + private val quotedTweet: JsonField, + private val source: JsonField, private val additionalProperties: MutableMap, ) { @@ -45,7 +58,23 @@ private constructor( retweetCount: JsonField = JsonMissing.of(), @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), @JsonProperty("viewCount") @ExcludeMissing viewCount: JsonField = JsonMissing.of(), + @JsonProperty("conversationId") + @ExcludeMissing + conversationId: JsonField = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("entities") @ExcludeMissing entities: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), + @JsonProperty("isQuoteStatus") + @ExcludeMissing + isQuoteStatus: JsonField = JsonMissing.of(), + @JsonProperty("isReply") @ExcludeMissing isReply: JsonField = JsonMissing.of(), + @JsonProperty("media") @ExcludeMissing media: JsonField> = JsonMissing.of(), + @JsonProperty("quoted_tweet") + @ExcludeMissing + quotedTweet: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), ) : this( id, bookmarkCount, @@ -55,7 +84,15 @@ private constructor( retweetCount, text, viewCount, + conversationId, createdAt, + entities, + isNoteTweet, + isQuoteStatus, + isReply, + media, + quotedTweet, + source, mutableMapOf(), ) @@ -107,12 +144,76 @@ private constructor( */ fun viewCount(): Long = viewCount.getRequired("viewCount") + /** + * ID of the root tweet in the conversation thread + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun conversationId(): Optional = conversationId.getOptional("conversationId") + /** * @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") + /** + * Parsed entities from the tweet text (URLs, mentions, hashtags, media) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun entities(): Optional = entities.getOptional("entities") + + /** + * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + + /** + * Whether this tweet quotes another tweet + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isQuoteStatus(): Optional = isQuoteStatus.getOptional("isQuoteStatus") + + /** + * Whether this tweet is a reply to another tweet + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun isReply(): Optional = isReply.getOptional("isReply") + + /** + * Attached media items, omitted when the tweet has no media + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun media(): Optional> = media.getOptional("media") + + /** + * The quoted tweet object, present when isQuoteStatus is true + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quotedTweet(): Optional = quotedTweet.getOptional("quoted_tweet") + + /** + * Client application used to post this tweet + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + /** * Returns the raw JSON value of [id]. * @@ -173,6 +274,15 @@ private constructor( */ @JsonProperty("viewCount") @ExcludeMissing fun _viewCount(): JsonField = viewCount + /** + * Returns the raw JSON value of [conversationId]. + * + * Unlike [conversationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("conversationId") + @ExcludeMissing + fun _conversationId(): JsonField = conversationId + /** * Returns the raw JSON value of [createdAt]. * @@ -180,6 +290,61 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [entities]. + * + * Unlike [entities], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entities") @ExcludeMissing fun _entities(): JsonField = entities + + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + + /** + * Returns the raw JSON value of [isQuoteStatus]. + * + * Unlike [isQuoteStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isQuoteStatus") + @ExcludeMissing + fun _isQuoteStatus(): JsonField = isQuoteStatus + + /** + * Returns the raw JSON value of [isReply]. + * + * Unlike [isReply], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isReply") @ExcludeMissing fun _isReply(): JsonField = isReply + + /** + * Returns the raw JSON value of [media]. + * + * Unlike [media], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("media") @ExcludeMissing fun _media(): JsonField> = media + + /** + * Returns the raw JSON value of [quotedTweet]. + * + * Unlike [quotedTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quoted_tweet") + @ExcludeMissing + fun _quotedTweet(): JsonField = quotedTweet + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -223,7 +388,15 @@ private constructor( private var retweetCount: JsonField? = null private var text: JsonField? = null private var viewCount: JsonField? = null + private var conversationId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var entities: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() + private var isQuoteStatus: JsonField = JsonMissing.of() + private var isReply: JsonField = JsonMissing.of() + private var media: JsonField>? = null + private var quotedTweet: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -236,7 +409,15 @@ private constructor( retweetCount = tweetDetail.retweetCount text = tweetDetail.text viewCount = tweetDetail.viewCount + conversationId = tweetDetail.conversationId createdAt = tweetDetail.createdAt + entities = tweetDetail.entities + isNoteTweet = tweetDetail.isNoteTweet + isQuoteStatus = tweetDetail.isQuoteStatus + isReply = tweetDetail.isReply + media = tweetDetail.media.map { it.toMutableList() } + quotedTweet = tweetDetail.quotedTweet + source = tweetDetail.source additionalProperties = tweetDetail.additionalProperties.toMutableMap() } @@ -324,6 +505,20 @@ private constructor( */ fun viewCount(viewCount: JsonField) = apply { this.viewCount = viewCount } + /** ID of the root tweet in the conversation thread */ + fun conversationId(conversationId: String) = conversationId(JsonField.of(conversationId)) + + /** + * Sets [Builder.conversationId] to an arbitrary JSON value. + * + * You should usually call [Builder.conversationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun conversationId(conversationId: JsonField) = apply { + this.conversationId = conversationId + } + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) /** @@ -335,6 +530,106 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Parsed entities from the tweet text (URLs, mentions, hashtags, media) */ + fun entities(entities: Entities) = entities(JsonField.of(entities)) + + /** + * Sets [Builder.entities] to an arbitrary JSON value. + * + * You should usually call [Builder.entities] with a well-typed [Entities] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entities(entities: JsonField) = apply { this.entities = entities } + + /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { this.isNoteTweet = isNoteTweet } + + /** Whether this tweet quotes another tweet */ + fun isQuoteStatus(isQuoteStatus: Boolean) = isQuoteStatus(JsonField.of(isQuoteStatus)) + + /** + * Sets [Builder.isQuoteStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.isQuoteStatus] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isQuoteStatus(isQuoteStatus: JsonField) = apply { + this.isQuoteStatus = isQuoteStatus + } + + /** Whether this tweet is a reply to another tweet */ + fun isReply(isReply: Boolean) = isReply(JsonField.of(isReply)) + + /** + * Sets [Builder.isReply] to an arbitrary JSON value. + * + * You should usually call [Builder.isReply] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun isReply(isReply: JsonField) = apply { this.isReply = isReply } + + /** Attached media items, omitted when the tweet has no media */ + fun media(media: List) = media(JsonField.of(media)) + + /** + * Sets [Builder.media] to an arbitrary JSON value. + * + * You should usually call [Builder.media] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun media(media: JsonField>) = apply { + this.media = media.map { it.toMutableList() } + } + + /** + * Adds a single [Media] to [Builder.media]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMedia(media: Media) = apply { + this.media = + (this.media ?: JsonField.of(mutableListOf())).also { + checkKnown("media", it).add(media) + } + } + + /** The quoted tweet object, present when isQuoteStatus is true */ + fun quotedTweet(quotedTweet: QuotedTweet) = quotedTweet(JsonField.of(quotedTweet)) + + /** + * Sets [Builder.quotedTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.quotedTweet] with a well-typed [QuotedTweet] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quotedTweet(quotedTweet: JsonField) = apply { + this.quotedTweet = quotedTweet + } + + /** Client application used to post this tweet */ + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -383,7 +678,15 @@ private constructor( checkRequired("retweetCount", retweetCount), checkRequired("text", text), checkRequired("viewCount", viewCount), + conversationId, createdAt, + entities, + isNoteTweet, + isQuoteStatus, + isReply, + (media ?: JsonMissing.of()).map { it.toImmutable() }, + quotedTweet, + source, additionalProperties.toMutableMap(), ) } @@ -403,7 +706,15 @@ private constructor( retweetCount() text() viewCount() + conversationId() createdAt() + entities().ifPresent { it.validate() } + isNoteTweet() + isQuoteStatus() + isReply() + media().ifPresent { it.forEach { it.validate() } } + quotedTweet().ifPresent { it.validate() } + source() validated = true } @@ -430,7 +741,554 @@ private constructor( (if (retweetCount.asKnown().isPresent) 1 else 0) + (if (text.asKnown().isPresent) 1 else 0) + (if (viewCount.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + (if (conversationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (entities.asKnown().getOrNull()?.validity() ?: 0) + + (if (isNoteTweet.asKnown().isPresent) 1 else 0) + + (if (isQuoteStatus.asKnown().isPresent) 1 else 0) + + (if (isReply.asKnown().isPresent) 1 else 0) + + (media.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (quotedTweet.asKnown().getOrNull()?.validity() ?: 0) + + (if (source.asKnown().isPresent) 1 else 0) + + /** Parsed entities from the tweet text (URLs, mentions, hashtags, media) */ + class Entities + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Entities]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Entities]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entities: Entities) = apply { + additionalProperties = entities.additionalProperties.toMutableMap() + } + + 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 [Entities]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Entities = Entities(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Entities = apply { + if (validated) { + return@apply + } + + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Entities && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Entities{additionalProperties=$additionalProperties}" + } + + class Media + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mediaUrl: JsonField, + private val type: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("mediaUrl") + @ExcludeMissing + mediaUrl: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(mediaUrl, type, url, mutableMapOf()) + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun mediaUrl(): Optional = mediaUrl.getOptional("mediaUrl") + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [mediaUrl]. + * + * Unlike [mediaUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mediaUrl") @ExcludeMissing fun _mediaUrl(): JsonField = mediaUrl + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [Media]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Media]. */ + class Builder internal constructor() { + + private var mediaUrl: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(media: Media) = apply { + mediaUrl = media.mediaUrl + type = media.type + url = media.url + additionalProperties = media.additionalProperties.toMutableMap() + } + + fun mediaUrl(mediaUrl: String) = mediaUrl(JsonField.of(mediaUrl)) + + /** + * Sets [Builder.mediaUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mediaUrl(mediaUrl: JsonField) = apply { this.mediaUrl = mediaUrl } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + 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 [Media]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Media = Media(mediaUrl, type, url, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Media = apply { + if (validated) { + return@apply + } + + mediaUrl() + type().ifPresent { it.validate() } + url() + 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 (mediaUrl.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PHOTO = of("photo") + + @JvmField val VIDEO = of("video") + + @JvmField val ANIMATED_GIF = of("animated_gif") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PHOTO, + VIDEO, + ANIMATED_GIF, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PHOTO, + VIDEO, + ANIMATED_GIF, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PHOTO -> Value.PHOTO + VIDEO -> Value.VIDEO + ANIMATED_GIF -> Value.ANIMATED_GIF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws XTwitterScraperInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PHOTO -> Known.PHOTO + VIDEO -> Known.VIDEO + ANIMATED_GIF -> Known.ANIMATED_GIF + else -> throw XTwitterScraperInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws XTwitterScraperInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + XTwitterScraperInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + 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 (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Media && + mediaUrl == other.mediaUrl && + type == other.type && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(mediaUrl, type, url, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Media{mediaUrl=$mediaUrl, type=$type, url=$url, additionalProperties=$additionalProperties}" + } + + /** The quoted tweet object, present when isQuoteStatus is true */ + class QuotedTweet + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [QuotedTweet]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [QuotedTweet]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(quotedTweet: QuotedTweet) = apply { + additionalProperties = quotedTweet.additionalProperties.toMutableMap() + } + + 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 [QuotedTweet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): QuotedTweet = QuotedTweet(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): QuotedTweet = apply { + if (validated) { + return@apply + } + + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QuotedTweet && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "QuotedTweet{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -446,7 +1304,15 @@ private constructor( retweetCount == other.retweetCount && text == other.text && viewCount == other.viewCount && + conversationId == other.conversationId && createdAt == other.createdAt && + entities == other.entities && + isNoteTweet == other.isNoteTweet && + isQuoteStatus == other.isQuoteStatus && + isReply == other.isReply && + media == other.media && + quotedTweet == other.quotedTweet && + source == other.source && additionalProperties == other.additionalProperties } @@ -460,7 +1326,15 @@ private constructor( retweetCount, text, viewCount, + conversationId, createdAt, + entities, + isNoteTweet, + isQuoteStatus, + isReply, + media, + quotedTweet, + source, additionalProperties, ) } @@ -468,5 +1342,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TweetDetail{id=$id, bookmarkCount=$bookmarkCount, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, text=$text, viewCount=$viewCount, createdAt=$createdAt, additionalProperties=$additionalProperties}" + "TweetDetail{id=$id, bookmarkCount=$bookmarkCount, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, text=$text, viewCount=$viewCount, conversationId=$conversationId, createdAt=$createdAt, entities=$entities, isNoteTweet=$isNoteTweet, isQuoteStatus=$isQuoteStatus, isReply=$isReply, media=$media, quotedTweet=$quotedTweet, source=$source, additionalProperties=$additionalProperties}" } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersParams.kt index ad19610..595011c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor from previous response */ + /** Pagination cursor for favoriters */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -60,7 +60,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for favoriters */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponse.kt index d4b2016..b28c417 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of user profiles with cursor-based navigation. */ class TweetGetFavoritersResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -242,6 +243,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** X user profile with bio, follower counts, and verification status. */ class User @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesParams.kt index 67a8916..ef872dc 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesParams.kt @@ -23,16 +23,16 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for quote tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Include replies (default false) */ + /** Include reply quotes (default false) */ fun includeReplies(): Optional = Optional.ofNullable(includeReplies) - /** Unix timestamp - filter after */ + /** Unix timestamp - return quotes posted after this time */ fun sinceTime(): Optional = Optional.ofNullable(sinceTime) - /** Unix timestamp - filter before */ + /** Unix timestamp - return quotes posted before this time */ fun untilTime(): Optional = Optional.ofNullable(untilTime) /** Additional headers to send with the request. */ @@ -78,13 +78,13 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for quote tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Include replies (default false) */ + /** Include reply quotes (default false) */ fun includeReplies(includeReplies: Boolean?) = apply { this.includeReplies = includeReplies } @@ -100,13 +100,13 @@ private constructor( fun includeReplies(includeReplies: Optional) = includeReplies(includeReplies.getOrNull()) - /** Unix timestamp - filter after */ + /** Unix timestamp - return quotes posted after this time */ fun sinceTime(sinceTime: String?) = apply { this.sinceTime = sinceTime } /** Alias for calling [Builder.sinceTime] with `sinceTime.orElse(null)`. */ fun sinceTime(sinceTime: Optional) = sinceTime(sinceTime.getOrNull()) - /** Unix timestamp - filter before */ + /** Unix timestamp - return quotes posted before this time */ fun untilTime(untilTime: String?) = apply { this.untilTime = untilTime } /** Alias for calling [Builder.untilTime] with `untilTime.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt index 193f45b..31da19f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class TweetGetQuotesResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesParams.kt index 449d9fe..66d93b6 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesParams.kt @@ -22,13 +22,13 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for tweet replies */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Unix timestamp - filter after */ + /** Unix timestamp - return replies posted after this time */ fun sinceTime(): Optional = Optional.ofNullable(sinceTime) - /** Unix timestamp - filter before */ + /** Unix timestamp - return replies posted before this time */ fun untilTime(): Optional = Optional.ofNullable(untilTime) /** Additional headers to send with the request. */ @@ -72,19 +72,19 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for tweet replies */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Unix timestamp - filter after */ + /** Unix timestamp - return replies posted after this time */ fun sinceTime(sinceTime: String?) = apply { this.sinceTime = sinceTime } /** Alias for calling [Builder.sinceTime] with `sinceTime.orElse(null)`. */ fun sinceTime(sinceTime: Optional) = sinceTime(sinceTime.getOrNull()) - /** Unix timestamp - filter before */ + /** Unix timestamp - return replies posted before this time */ fun untilTime(untilTime: String?) = apply { this.untilTime = untilTime } /** Alias for calling [Builder.untilTime] with `untilTime.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt index cfcb6ae..bdb2ced 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class TweetGetRepliesResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersParams.kt index 4e741e3..b964411 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for retweeters */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -60,7 +60,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for retweeters */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponse.kt index 859fa6b..d6e699a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of user profiles with cursor-based navigation. */ class TweetGetRetweetersResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -242,6 +243,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** X user profile with bio, follower counts, and verification status. */ class User @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadParams.kt index 95108cc..a58f7dc 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for thread tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -60,7 +60,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for thread tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt index 13a5560..b65f38c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class TweetGetThreadResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt similarity index 51% rename from x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt rename to x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt index 08d6b1a..e8c3be9 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt @@ -10,52 +10,76 @@ import com.x_twitter_scraper.api.core.ExcludeMissing import com.x_twitter_scraper.api.core.JsonField import com.x_twitter_scraper.api.core.JsonMissing import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class TweetRetrieveResponse +/** Paginated list of tweets with cursor-based navigation. */ +class TweetListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val tweet: JsonField, - private val author: JsonField, + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val tweets: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("tweet") @ExcludeMissing tweet: JsonField = JsonMissing.of(), - @JsonProperty("author") @ExcludeMissing author: JsonField = JsonMissing.of(), - ) : this(tweet, author, mutableMapOf()) + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, tweets, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") /** * @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 tweet(): Tweet = tweet.getRequired("tweet") + fun nextCursor(): String = nextCursor.getRequired("next_cursor") /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @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 author(): Optional = author.getOptional("author") + fun tweets(): List = tweets.getRequired("tweets") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage /** - * Returns the raw JSON value of [tweet]. + * Returns the raw JSON value of [nextCursor]. * - * Unlike [tweet], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tweet") @ExcludeMissing fun _tweet(): JsonField = tweet + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor /** - * Returns the raw JSON value of [author]. + * Returns the raw JSON value of [tweets]. * - * Unlike [author], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("author") @ExcludeMissing fun _author(): JsonField = author + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -72,49 +96,80 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TweetRetrieveResponse]. + * Returns a mutable builder for constructing an instance of [TweetListResponse]. * * The following fields are required: * ```java - * .tweet() + * .hasNextPage() + * .nextCursor() + * .tweets() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TweetRetrieveResponse]. */ + /** A builder for [TweetListResponse]. */ class Builder internal constructor() { - private var tweet: JsonField? = null - private var author: JsonField = JsonMissing.of() + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var tweets: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tweetRetrieveResponse: TweetRetrieveResponse) = apply { - tweet = tweetRetrieveResponse.tweet - author = tweetRetrieveResponse.author - additionalProperties = tweetRetrieveResponse.additionalProperties.toMutableMap() + internal fun from(tweetListResponse: TweetListResponse) = apply { + hasNextPage = tweetListResponse.hasNextPage + nextCursor = tweetListResponse.nextCursor + tweets = tweetListResponse.tweets.map { it.toMutableList() } + additionalProperties = tweetListResponse.additionalProperties.toMutableMap() } - fun tweet(tweet: Tweet) = tweet(JsonField.of(tweet)) + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) /** - * Sets [Builder.tweet] to an arbitrary JSON value. + * Sets [Builder.hasNextPage] to an arbitrary JSON value. * - * You should usually call [Builder.tweet] with a well-typed [Tweet] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun tweet(tweet: JsonField) = apply { this.tweet = tweet } + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } - fun author(author: Author) = author(JsonField.of(author)) + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) /** - * Sets [Builder.author] to an arbitrary JSON value. + * Sets [Builder.nextCursor] 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. + * You should usually call [Builder.nextCursor] with a well-typed [String] 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 nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun tweets(tweets: JsonField>) = apply { + this.tweets = tweets.map { it.toMutableList() } + } + + /** + * Adds a single [Tweet] to [tweets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTweet(tweet: Tweet) = apply { + tweets = + (tweets ?: JsonField.of(mutableListOf())).also { + checkKnown("tweets", it).add(tweet) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -136,34 +191,38 @@ private constructor( } /** - * Returns an immutable instance of [TweetRetrieveResponse]. + * Returns an immutable instance of [TweetListResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .tweet() + * .hasNextPage() + * .nextCursor() + * .tweets() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TweetRetrieveResponse = - TweetRetrieveResponse( - checkRequired("tweet", tweet), - author, + fun build(): TweetListResponse = + TweetListResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("tweets", tweets).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TweetRetrieveResponse = apply { + fun validate(): TweetListResponse = apply { if (validated) { return@apply } - tweet().validate() - author().ifPresent { it.validate() } + hasNextPage() + nextCursor() + tweets().forEach { it.validate() } validated = true } @@ -182,30 +241,42 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (tweet.asKnown().getOrNull()?.validity() ?: 0) + - (author.asKnown().getOrNull()?.validity() ?: 0) + (if (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ 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 isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, private val retweetCount: JsonField, - private val text: JsonField, private val viewCount: JsonField, - private val createdAt: 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("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -218,23 +289,19 @@ private constructor( @JsonProperty("retweetCount") @ExcludeMissing retweetCount: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("viewCount") - @ExcludeMissing - viewCount: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), + @JsonProperty("viewCount") @ExcludeMissing viewCount: JsonField = JsonMissing.of(), ) : this( id, + text, + author, bookmarkCount, + createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, retweetCount, - text, viewCount, - createdAt, mutableMapOf(), ) @@ -250,55 +317,63 @@ private constructor( * is unexpectedly missing or null (e.g. if the server responded with an unexpected * value). */ - fun bookmarkCount(): Long = bookmarkCount.getRequired("bookmarkCount") + fun text(): String = text.getRequired("text") /** - * @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). + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun likeCount(): Long = likeCount.getRequired("likeCount") + fun author(): Optional = author.getOptional("author") /** - * @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). + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun quoteCount(): Long = quoteCount.getRequired("quoteCount") + fun bookmarkCount(): Optional = bookmarkCount.getOptional("bookmarkCount") /** - * @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). + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun replyCount(): Long = replyCount.getRequired("replyCount") + fun createdAt(): Optional = createdAt.getOptional("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). + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun retweetCount(): Long = retweetCount.getRequired("retweetCount") + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") /** - * @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). + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun text(): String = text.getRequired("text") + fun likeCount(): Optional = likeCount.getOptional("likeCount") /** - * @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). + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - fun viewCount(): Long = viewCount.getRequired("viewCount") + 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 createdAt(): Optional = createdAt.getOptional("createdAt") + 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]. @@ -307,6 +382,20 @@ private constructor( */ @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]. * @@ -317,6 +406,22 @@ private constructor( @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 [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -348,13 +453,6 @@ private constructor( @ExcludeMissing fun _retweetCount(): JsonField = retweetCount - /** - * 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 [viewCount]. * @@ -362,13 +460,6 @@ private constructor( */ @JsonProperty("viewCount") @ExcludeMissing fun _viewCount(): JsonField = viewCount - /** - * 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 - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -389,13 +480,7 @@ private constructor( * The following fields are required: * ```java * .id() - * .bookmarkCount() - * .likeCount() - * .quoteCount() - * .replyCount() - * .retweetCount() * .text() - * .viewCount() * ``` */ @JvmStatic fun builder() = Builder() @@ -405,27 +490,31 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var bookmarkCount: JsonField? = null - private var likeCount: JsonField? = null - private var quoteCount: JsonField? = null - private var replyCount: JsonField? = null - private var retweetCount: JsonField? = null private var text: JsonField? = null - private var viewCount: JsonField? = null + private var author: JsonField = JsonMissing.of() + private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: 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 + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount retweetCount = tweet.retweetCount - text = tweet.text viewCount = tweet.viewCount - createdAt = tweet.createdAt additionalProperties = tweet.additionalProperties.toMutableMap() } @@ -440,6 +529,28 @@ private constructor( */ 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)) /** @@ -453,6 +564,31 @@ private constructor( 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 } + + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -499,17 +635,6 @@ private constructor( this.retweetCount = retweetCount } - 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 viewCount(viewCount: Long) = viewCount(JsonField.of(viewCount)) /** @@ -521,17 +646,6 @@ private constructor( */ fun viewCount(viewCount: JsonField) = apply { this.viewCount = viewCount } - 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 additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -559,13 +673,7 @@ private constructor( * The following fields are required: * ```java * .id() - * .bookmarkCount() - * .likeCount() - * .quoteCount() - * .replyCount() - * .retweetCount() * .text() - * .viewCount() * ``` * * @throws IllegalStateException if any required field is unset. @@ -573,14 +681,16 @@ private constructor( fun build(): Tweet = Tweet( checkRequired("id", id), - checkRequired("bookmarkCount", bookmarkCount), - checkRequired("likeCount", likeCount), - checkRequired("quoteCount", quoteCount), - checkRequired("replyCount", replyCount), - checkRequired("retweetCount", retweetCount), checkRequired("text", text), - checkRequired("viewCount", viewCount), + author, + bookmarkCount, createdAt, + isNoteTweet, + likeCount, + quoteCount, + replyCount, + retweetCount, + viewCount, additionalProperties.toMutableMap(), ) } @@ -593,14 +703,16 @@ private constructor( } id() + text() + author().ifPresent { it.validate() } bookmarkCount() + createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() retweetCount() - text() viewCount() - createdAt() validated = true } @@ -621,364 +733,330 @@ private constructor( @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 (isNoteTweet.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 (text.asKnown().isPresent) 1 else 0) + - (if (viewCount.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tweet && - id == other.id && - bookmarkCount == other.bookmarkCount && - likeCount == other.likeCount && - quoteCount == other.quoteCount && - replyCount == other.replyCount && - retweetCount == other.retweetCount && - text == other.text && - viewCount == other.viewCount && - createdAt == other.createdAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - bookmarkCount, - likeCount, - quoteCount, - replyCount, - retweetCount, - text, - viewCount, - createdAt, - additionalProperties, - ) - } + (if (viewCount.asKnown().isPresent) 1 else 0) - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tweet{id=$id, bookmarkCount=$bookmarkCount, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, text=$text, viewCount=$viewCount, createdAt=$createdAt, additionalProperties=$additionalProperties}" - } - - class Author - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val followers: JsonField, - private val username: JsonField, - private val verified: JsonField, - private val profilePicture: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator + class Author + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("followers") - @ExcludeMissing - followers: JsonField = JsonMissing.of(), - @JsonProperty("username") - @ExcludeMissing - username: JsonField = JsonMissing.of(), - @JsonProperty("verified") - @ExcludeMissing - verified: JsonField = JsonMissing.of(), - @JsonProperty("profilePicture") - @ExcludeMissing - profilePicture: JsonField = JsonMissing.of(), - ) : this(id, followers, username, verified, profilePicture, 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 followers(): Long = followers.getRequired("followers") - - /** - * @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 or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun verified(): Boolean = verified.getRequired("verified") - - /** - * @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") - - /** - * 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 [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 [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 - - /** - * 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 - - @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 { + 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()) /** - * Returns a mutable builder for constructing an instance of [Author]. - * - * The following fields are required: - * ```java - * .id() - * .followers() - * .username() - * .verified() - * ``` + * @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). */ - @JvmStatic fun builder() = Builder() - } + fun id(): String = id.getRequired("id") - /** A builder for [Author]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var followers: JsonField? = null - private var username: JsonField? = null - private var verified: JsonField? = null - private var profilePicture: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(author: Author) = apply { - id = author.id - followers = author.followers - username = author.username - verified = author.verified - profilePicture = author.profilePicture - additionalProperties = author.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(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") /** - * 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. + * @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(id: JsonField) = apply { this.id = id } + fun username(): String = username.getRequired("username") - fun followers(followers: Long) = followers(JsonField.of(followers)) + /** + * @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") /** - * Sets [Builder.followers] to an arbitrary JSON value. + * Returns the raw JSON value of [id]. * - * 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. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun followers(followers: JsonField) = apply { this.followers = followers } - - fun username(username: String) = username(JsonField.of(username)) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Sets [Builder.username] to an arbitrary JSON value. + * Returns the raw JSON value of [name]. * - * 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. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun username(username: JsonField) = apply { this.username = username } - - fun verified(verified: Boolean) = verified(JsonField.of(verified)) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Sets [Builder.verified] to an arbitrary JSON value. + * Returns the raw JSON value of [username]. * - * 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. + * Unlike [username], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun verified(verified: JsonField) = apply { this.verified = verified } - - fun profilePicture(profilePicture: String) = - profilePicture(JsonField.of(profilePicture)) + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username /** - * Sets [Builder.profilePicture] to an arbitrary JSON value. + * Returns the raw JSON value of [verified]. * - * 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. + * Unlike [verified], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun profilePicture(profilePicture: JsonField) = apply { - this.profilePicture = profilePicture - } + @JsonProperty("verified") @ExcludeMissing fun _verified(): JsonField = verified - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - 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() } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** 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(), + ) } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + 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 an immutable instance of [Author]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .followers() - * .username() - * .verified() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): Author = - Author( - checkRequired("id", id), - checkRequired("followers", followers), - checkRequired("username", username), - checkRequired("verified", verified), - profilePicture, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Author = apply { - if (validated) { - return@apply + @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 } - id() - followers() - username() - verified() - profilePicture() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: XTwitterScraperInvalidDataException) { - false + private val hashCode: Int by lazy { + Objects.hash(id, name, username, verified, additionalProperties) } - /** - * 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 (followers.asKnown().isPresent) 1 else 0) + - (if (username.asKnown().isPresent) 1 else 0) + - (if (verified.asKnown().isPresent) 1 else 0) + - (if (profilePicture.asKnown().isPresent) 1 else 0) + 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 Author && + return other is Tweet && id == other.id && - followers == other.followers && - username == other.username && - verified == other.verified && - profilePicture == other.profilePicture && + text == other.text && + author == other.author && + bookmarkCount == other.bookmarkCount && + createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && + 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, followers, username, verified, profilePicture, additionalProperties) + Objects.hash( + id, + text, + author, + bookmarkCount, + createdAt, + isNoteTweet, + likeCount, + quoteCount, + replyCount, + retweetCount, + viewCount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Author{id=$id, followers=$followers, username=$username, verified=$verified, profilePicture=$profilePicture, additionalProperties=$additionalProperties}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -986,16 +1064,19 @@ private constructor( return true } - return other is TweetRetrieveResponse && - tweet == other.tweet && - author == other.author && + return other is TweetListResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + tweets == other.tweets && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(tweet, author, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, tweets, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "TweetRetrieveResponse{tweet=$tweet, author=$author, additionalProperties=$additionalProperties}" + "TweetListResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, tweets=$tweets, additionalProperties=$additionalProperties}" } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParams.kt deleted file mode 100644 index 536e75b..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Look up tweet */ -class TweetRetrieveParams -private constructor( - private val tweetId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TweetRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TweetRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TweetRetrieveParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tweetRetrieveParams: TweetRetrieveParams) = apply { - tweetId = tweetRetrieveParams.tweetId - additionalHeaders = tweetRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = tweetRetrieveParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TweetRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TweetRetrieveParams = - TweetRetrieveParams(tweetId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TweetRetrieveParams && - tweetId == other.tweetId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(tweetId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TweetRetrieveParams{tweetId=$tweetId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchParams.kt index d2c791b..0535b90 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchParams.kt @@ -33,7 +33,7 @@ private constructor( /** Pagination cursor from previous response */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Deprecated — use cursor-based pagination instead */ + /** Max tweets to return (server paginates internally). Omit for single page (~20). */ fun limit(): Optional = Optional.ofNullable(limit) /** Sort order — Latest (chronological) or Top (engagement-ranked) */ @@ -99,7 +99,7 @@ private constructor( /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Deprecated — use cursor-based pagination instead */ + /** Max tweets to return (server paginates internally). Omit for single page (~20). */ fun limit(limit: Long?) = apply { this.limit = limit } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt index f40c2f2..26393b9 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class TweetSearchResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParams.kt deleted file mode 100644 index d4a2eac..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Like tweet */ -class LikeCreateParams -private constructor( - private val tweetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [LikeCreateParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LikeCreateParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(likeCreateParams: LikeCreateParams) = apply { - tweetId = likeCreateParams.tweetId - body = likeCreateParams.body.toBuilder() - additionalHeaders = likeCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = likeCreateParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [LikeCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): LikeCreateParams = - LikeCreateParams( - tweetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LikeCreateParams && - tweetId == other.tweetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tweetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "LikeCreateParams{tweetId=$tweetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponse.kt deleted file mode 100644 index ad893c0..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class LikeCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [LikeCreateResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LikeCreateResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(likeCreateResponse: LikeCreateResponse) = apply { - success = likeCreateResponse.success - additionalProperties = likeCreateResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [LikeCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LikeCreateResponse = - LikeCreateResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): LikeCreateResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LikeCreateResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LikeCreateResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParams.kt deleted file mode 100644 index 4ca8cd5..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Unlike tweet */ -class LikeDeleteParams -private constructor( - private val tweetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [LikeDeleteParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LikeDeleteParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(likeDeleteParams: LikeDeleteParams) = apply { - tweetId = likeDeleteParams.tweetId - body = likeDeleteParams.body.toBuilder() - additionalHeaders = likeDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = likeDeleteParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [LikeDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): LikeDeleteParams = - LikeDeleteParams( - tweetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LikeDeleteParams && - tweetId == other.tweetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tweetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "LikeDeleteParams{tweetId=$tweetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponse.kt deleted file mode 100644 index b690b0a..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class LikeDeleteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [LikeDeleteResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LikeDeleteResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(likeDeleteResponse: LikeDeleteResponse) = apply { - success = likeDeleteResponse.success - additionalProperties = likeDeleteResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [LikeDeleteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LikeDeleteResponse = - LikeDeleteResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): LikeDeleteResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LikeDeleteResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LikeDeleteResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParams.kt deleted file mode 100644 index 1f59da1..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Retweet */ -class RetweetCreateParams -private constructor( - private val tweetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RetweetCreateParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RetweetCreateParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(retweetCreateParams: RetweetCreateParams) = apply { - tweetId = retweetCreateParams.tweetId - body = retweetCreateParams.body.toBuilder() - additionalHeaders = retweetCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = retweetCreateParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [RetweetCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RetweetCreateParams = - RetweetCreateParams( - tweetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RetweetCreateParams && - tweetId == other.tweetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tweetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "RetweetCreateParams{tweetId=$tweetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponse.kt deleted file mode 100644 index 25c7d77..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class RetweetCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [RetweetCreateResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RetweetCreateResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(retweetCreateResponse: RetweetCreateResponse) = apply { - success = retweetCreateResponse.success - additionalProperties = retweetCreateResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [RetweetCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RetweetCreateResponse = - RetweetCreateResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RetweetCreateResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RetweetCreateResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RetweetCreateResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParams.kt deleted file mode 100644 index 9a60978..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Unretweet */ -class RetweetDeleteParams -private constructor( - private val tweetId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tweetId(): Optional = Optional.ofNullable(tweetId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [RetweetDeleteParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RetweetDeleteParams]. */ - class Builder internal constructor() { - - private var tweetId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(retweetDeleteParams: RetweetDeleteParams) = apply { - tweetId = retweetDeleteParams.tweetId - body = retweetDeleteParams.body.toBuilder() - additionalHeaders = retweetDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = retweetDeleteParams.additionalQueryParams.toBuilder() - } - - fun tweetId(tweetId: String?) = apply { this.tweetId = tweetId } - - /** Alias for calling [Builder.tweetId] with `tweetId.orElse(null)`. */ - fun tweetId(tweetId: Optional) = tweetId(tweetId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [RetweetDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RetweetDeleteParams = - RetweetDeleteParams( - tweetId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tweetId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RetweetDeleteParams && - tweetId == other.tweetId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tweetId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "RetweetDeleteParams{tweetId=$tweetId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponse.kt deleted file mode 100644 index c362cc8..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class RetweetDeleteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [RetweetDeleteResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RetweetDeleteResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(retweetDeleteResponse: RetweetDeleteResponse) = apply { - success = retweetDeleteResponse.success - additionalProperties = retweetDeleteResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [RetweetDeleteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RetweetDeleteResponse = - RetweetDeleteResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RetweetDeleteResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RetweetDeleteResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RetweetDeleteResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfile.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfile.kt index 13c30e1..f95b2aa 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfile.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfile.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects import java.util.Optional +/** X user profile with bio, follower counts, and verification status. */ class UserProfile @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponse.kt new file mode 100644 index 0000000..2d79878 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponse.kt @@ -0,0 +1,813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class UserRetrieveBatchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 [UserRetrieveBatchResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveBatchResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRetrieveBatchResponse: UserRetrieveBatchResponse) = apply { + hasNextPage = userRetrieveBatchResponse.hasNextPage + nextCursor = userRetrieveBatchResponse.nextCursor + users = userRetrieveBatchResponse.users.map { it.toMutableList() } + additionalProperties = userRetrieveBatchResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [UserRetrieveBatchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveBatchResponse = + UserRetrieveBatchResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveBatchResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is UserRetrieveBatchResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveBatchResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersParams.kt index 4d980cd..de5767f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersParams.kt @@ -21,7 +21,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for followers list */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Items per page (20-200, default 200) */ @@ -68,7 +68,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for followers list */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponse.kt new file mode 100644 index 0000000..ae26c0a --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponse.kt @@ -0,0 +1,814 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class UserRetrieveFollowersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [UserRetrieveFollowersResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveFollowersResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRetrieveFollowersResponse: UserRetrieveFollowersResponse) = apply { + hasNextPage = userRetrieveFollowersResponse.hasNextPage + nextCursor = userRetrieveFollowersResponse.nextCursor + users = userRetrieveFollowersResponse.users.map { it.toMutableList() } + additionalProperties = userRetrieveFollowersResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [UserRetrieveFollowersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveFollowersResponse = + UserRetrieveFollowersResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveFollowersResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is UserRetrieveFollowersResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveFollowersResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowParams.kt index 851e187..a481ec2 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor from previous response */ + /** Pagination cursor for followers-you-know */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -65,7 +65,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for followers-you-know */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponse.kt index 2c85958..41b4d1f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of user profiles with cursor-based navigation. */ class UserRetrieveFollowersYouKnowResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -246,6 +247,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** X user profile with bio, follower counts, and verification status. */ class User @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingParams.kt index 2d7bca9..aa24e7e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingParams.kt @@ -21,10 +21,10 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for following list */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Items per page (20-200, default 200) */ + /** Results per page (20-200, default 200) */ fun pageSize(): Optional = Optional.ofNullable(pageSize) /** Additional headers to send with the request. */ @@ -68,13 +68,13 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for following list */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Items per page (20-200, default 200) */ + /** Results per page (20-200, default 200) */ fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponse.kt new file mode 100644 index 0000000..206cf28 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponse.kt @@ -0,0 +1,814 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class UserRetrieveFollowingResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [UserRetrieveFollowingResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveFollowingResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRetrieveFollowingResponse: UserRetrieveFollowingResponse) = apply { + hasNextPage = userRetrieveFollowingResponse.hasNextPage + nextCursor = userRetrieveFollowingResponse.nextCursor + users = userRetrieveFollowingResponse.users.map { it.toMutableList() } + additionalProperties = userRetrieveFollowingResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [UserRetrieveFollowingResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveFollowingResponse = + UserRetrieveFollowingResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveFollowingResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is UserRetrieveFollowingResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveFollowingResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesParams.kt index 50772e0..23dce02 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor from previous response */ + /** Pagination cursor for liked tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -60,7 +60,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for liked tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt index 77788f2..a8b8b89 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class UserRetrieveLikesResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaParams.kt index d0e16d0..2391280 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor from previous response */ + /** Pagination cursor for media tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -60,7 +60,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for media tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt index 3444c0e..ca058f7 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class UserRetrieveMediaResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsParams.kt index e6527e6..0c71e3c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsParams.kt @@ -22,13 +22,13 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for mentions */ fun cursor(): Optional = Optional.ofNullable(cursor) - /** Unix timestamp - filter after */ + /** Unix timestamp - return mentions after this time */ fun sinceTime(): Optional = Optional.ofNullable(sinceTime) - /** Unix timestamp - filter before */ + /** Unix timestamp - return mentions before this time */ fun untilTime(): Optional = Optional.ofNullable(untilTime) /** Additional headers to send with the request. */ @@ -74,19 +74,19 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for mentions */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - /** Unix timestamp - filter after */ + /** Unix timestamp - return mentions after this time */ fun sinceTime(sinceTime: String?) = apply { this.sinceTime = sinceTime } /** Alias for calling [Builder.sinceTime] with `sinceTime.orElse(null)`. */ fun sinceTime(sinceTime: Optional) = sinceTime(sinceTime.getOrNull()) - /** Unix timestamp - filter before */ + /** Unix timestamp - return mentions before this time */ fun untilTime(untilTime: String?) = apply { this.untilTime = untilTime } /** Alias for calling [Builder.untilTime] with `untilTime.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponse.kt new file mode 100644 index 0000000..6ce434f --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponse.kt @@ -0,0 +1,1082 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of tweets with cursor-based navigation. */ +class UserRetrieveMentionsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val tweets: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, tweets, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [tweets]. + * + * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets + + @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 [UserRetrieveMentionsResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveMentionsResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var tweets: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRetrieveMentionsResponse: UserRetrieveMentionsResponse) = apply { + hasNextPage = userRetrieveMentionsResponse.hasNextPage + nextCursor = userRetrieveMentionsResponse.nextCursor + tweets = userRetrieveMentionsResponse.tweets.map { it.toMutableList() } + additionalProperties = userRetrieveMentionsResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun tweets(tweets: JsonField>) = apply { + this.tweets = tweets.map { it.toMutableList() } + } + + /** + * Adds a single [Tweet] to [tweets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTweet(tweet: Tweet) = apply { + tweets = + (tweets ?: JsonField.of(mutableListOf())).also { + checkKnown("tweets", it).add(tweet) + } + } + + 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 [UserRetrieveMentionsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .tweets() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveMentionsResponse = + UserRetrieveMentionsResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("tweets", tweets).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveMentionsResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + tweets().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Tweet returned from search results with inline author info. */ + 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 isNoteTweet: 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("isNoteTweet") + @ExcludeMissing + isNoteTweet: 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, + isNoteTweet, + 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") + + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + + /** + * @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 [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + + /** + * 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 isNoteTweet: 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 + isNoteTweet = tweet.isNoteTweet + 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 } + + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + + 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, + isNoteTweet, + 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() + isNoteTweet() + 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 (isNoteTweet.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 && + isNoteTweet == other.isNoteTweet && + 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, + isNoteTweet, + 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, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserRetrieveMentionsResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + tweets == other.tweets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, tweets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveMentionsResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, tweets=$tweets, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParams.kt deleted file mode 100644 index 36b38f9..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users - -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Look up X user */ -class UserRetrieveParams -private constructor( - private val username: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun username(): Optional = Optional.ofNullable(username) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): UserRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [UserRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserRetrieveParams]. */ - class Builder internal constructor() { - - private var username: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(userRetrieveParams: UserRetrieveParams) = apply { - username = userRetrieveParams.username - additionalHeaders = userRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = userRetrieveParams.additionalQueryParams.toBuilder() - } - - fun username(username: String?) = apply { this.username = username } - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [UserRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UserRetrieveParams = - UserRetrieveParams(username, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> username ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserRetrieveParams && - username == other.username && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(username, additionalHeaders, additionalQueryParams) - - override fun toString() = - "UserRetrieveParams{username=$username, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponse.kt deleted file mode 100644 index 6e0cbab..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponse.kt +++ /dev/null @@ -1,534 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional - -class UserRetrieveResponse -@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 [UserRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserRetrieveResponse]. */ - 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(userRetrieveResponse: UserRetrieveResponse) = apply { - id = userRetrieveResponse.id - name = userRetrieveResponse.name - username = userRetrieveResponse.username - createdAt = userRetrieveResponse.createdAt - description = userRetrieveResponse.description - followers = userRetrieveResponse.followers - following = userRetrieveResponse.following - location = userRetrieveResponse.location - profilePicture = userRetrieveResponse.profilePicture - statusesCount = userRetrieveResponse.statusesCount - verified = userRetrieveResponse.verified - additionalProperties = userRetrieveResponse.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 [UserRetrieveResponse]. - * - * 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(): UserRetrieveResponse = - UserRetrieveResponse( - 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(): UserRetrieveResponse = 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 UserRetrieveResponse && - 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() = - "UserRetrieveResponse{id=$id, name=$name, username=$username, createdAt=$createdAt, description=$description, followers=$followers, following=$following, location=$location, profilePicture=$profilePicture, statusesCount=$statusesCount, verified=$verified, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchParams.kt index 4189d9f..b2cecc0 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchParams.kt @@ -19,10 +19,10 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - /** Search query */ + /** User search query */ fun q(): String = q - /** Pagination cursor */ + /** Pagination cursor for user search */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -62,10 +62,10 @@ private constructor( additionalQueryParams = userRetrieveSearchParams.additionalQueryParams.toBuilder() } - /** Search query */ + /** User search query */ fun q(q: String) = apply { this.q = q } - /** Pagination cursor */ + /** Pagination cursor for user search */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponse.kt new file mode 100644 index 0000000..014a267 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponse.kt @@ -0,0 +1,813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class UserRetrieveSearchResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 [UserRetrieveSearchResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveSearchResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRetrieveSearchResponse: UserRetrieveSearchResponse) = apply { + hasNextPage = userRetrieveSearchResponse.hasNextPage + nextCursor = userRetrieveSearchResponse.nextCursor + users = userRetrieveSearchResponse.users.map { it.toMutableList() } + additionalProperties = userRetrieveSearchResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [UserRetrieveSearchResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveSearchResponse = + UserRetrieveSearchResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveSearchResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is UserRetrieveSearchResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveSearchResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsParams.kt index e7751f8..af8621c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsParams.kt @@ -22,7 +22,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor from previous response */ + /** Pagination cursor for user tweets */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Include parent tweet for replies */ @@ -72,7 +72,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor from previous response */ + /** Pagination cursor for user tweets */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt index 236d37f..582cd15 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of tweets with cursor-based navigation. */ class UserRetrieveTweetsResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -244,6 +245,7 @@ private constructor( (if (nextCursor.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Tweet returned from search results with inline author info. */ class Tweet @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -252,6 +254,7 @@ private constructor( private val author: JsonField, private val bookmarkCount: JsonField, private val createdAt: JsonField, + private val isNoteTweet: JsonField, private val likeCount: JsonField, private val quoteCount: JsonField, private val replyCount: JsonField, @@ -271,6 +274,9 @@ private constructor( @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("isNoteTweet") + @ExcludeMissing + isNoteTweet: JsonField = JsonMissing.of(), @JsonProperty("likeCount") @ExcludeMissing likeCount: JsonField = JsonMissing.of(), @@ -290,6 +296,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +337,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * True for Note Tweets (long-form content, up to 25,000 characters) + * + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isNoteTweet(): Optional = isNoteTweet.getOptional("isNoteTweet") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +413,15 @@ private constructor( */ @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [isNoteTweet]. + * + * Unlike [isNoteTweet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isNoteTweet") + @ExcludeMissing + fun _isNoteTweet(): JsonField = isNoteTweet + /** * Returns the raw JSON value of [likeCount]. * @@ -470,6 +494,7 @@ private constructor( private var author: JsonField = JsonMissing.of() private var bookmarkCount: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() + private var isNoteTweet: JsonField = JsonMissing.of() private var likeCount: JsonField = JsonMissing.of() private var quoteCount: JsonField = JsonMissing.of() private var replyCount: JsonField = JsonMissing.of() @@ -484,6 +509,7 @@ private constructor( author = tweet.author bookmarkCount = tweet.bookmarkCount createdAt = tweet.createdAt + isNoteTweet = tweet.isNoteTweet likeCount = tweet.likeCount quoteCount = tweet.quoteCount replyCount = tweet.replyCount @@ -549,6 +575,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** True for Note Tweets (long-form content, up to 25,000 characters) */ + fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) + + /** + * Sets [Builder.isNoteTweet] to an arbitrary JSON value. + * + * You should usually call [Builder.isNoteTweet] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isNoteTweet(isNoteTweet: JsonField) = apply { + this.isNoteTweet = isNoteTweet + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +685,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +707,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +737,7 @@ private constructor( (author.asKnown().getOrNull()?.validity() ?: 0) + (if (bookmarkCount.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isNoteTweet.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) + @@ -984,6 +1027,7 @@ private constructor( author == other.author && bookmarkCount == other.bookmarkCount && createdAt == other.createdAt && + isNoteTweet == other.isNoteTweet && likeCount == other.likeCount && quoteCount == other.quoteCount && replyCount == other.replyCount && @@ -999,6 +1043,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1056,7 @@ private constructor( 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}" + "Tweet{id=$id, text=$text, author=$author, bookmarkCount=$bookmarkCount, createdAt=$createdAt, isNoteTweet=$isNoteTweet, likeCount=$likeCount, quoteCount=$quoteCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersParams.kt index a5a9290..acf35e4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersParams.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersParams.kt @@ -20,7 +20,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id) - /** Pagination cursor */ + /** Pagination cursor for verified followers */ fun cursor(): Optional = Optional.ofNullable(cursor) /** Additional headers to send with the request. */ @@ -66,7 +66,7 @@ private constructor( /** Alias for calling [Builder.id] with `id.orElse(null)`. */ fun id(id: Optional) = id(id.getOrNull()) - /** Pagination cursor */ + /** Pagination cursor for verified followers */ fun cursor(cursor: String?) = apply { this.cursor = cursor } /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponse.kt new file mode 100644 index 0000000..4cea377 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponse.kt @@ -0,0 +1,817 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.x_twitter_scraper.api.core.ExcludeMissing +import com.x_twitter_scraper.api.core.JsonField +import com.x_twitter_scraper.api.core.JsonMissing +import com.x_twitter_scraper.api.core.JsonValue +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of user profiles with cursor-based navigation. */ +class UserRetrieveVerifiedFollowersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasNextPage: JsonField, + private val nextCursor: JsonField, + private val users: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + ) : this(hasNextPage, nextCursor, users, 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 hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") + + /** + * @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 nextCursor(): String = nextCursor.getRequired("next_cursor") + + /** + * @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") + + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + + @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 + * [UserRetrieveVerifiedFollowersResponse]. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRetrieveVerifiedFollowersResponse]. */ + class Builder internal constructor() { + + private var hasNextPage: JsonField? = null + private var nextCursor: JsonField? = null + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + userRetrieveVerifiedFollowersResponse: UserRetrieveVerifiedFollowersResponse + ) = apply { + hasNextPage = userRetrieveVerifiedFollowersResponse.hasNextPage + nextCursor = userRetrieveVerifiedFollowersResponse.nextCursor + users = userRetrieveVerifiedFollowersResponse.users.map { it.toMutableList() } + additionalProperties = + userRetrieveVerifiedFollowersResponse.additionalProperties.toMutableMap() + } + + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [User] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: User) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } + } + + 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 [UserRetrieveVerifiedFollowersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasNextPage() + * .nextCursor() + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserRetrieveVerifiedFollowersResponse = + UserRetrieveVerifiedFollowersResponse( + checkRequired("hasNextPage", hasNextPage), + checkRequired("nextCursor", nextCursor), + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRetrieveVerifiedFollowersResponse = apply { + if (validated) { + return@apply + } + + hasNextPage() + nextCursor() + users().forEach { it.validate() } + 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 (hasNextPage.asKnown().isPresent) 1 else 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** X user profile with bio, follower counts, and verification status. */ + 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 + } + + return other is UserRetrieveVerifiedFollowersResponse && + hasNextPage == other.hasNextPage && + nextCursor == other.nextCursor && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasNextPage, nextCursor, users, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRetrieveVerifiedFollowersResponse{hasNextPage=$hasNextPage, nextCursor=$nextCursor, users=$users, additionalProperties=$additionalProperties}" +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParams.kt deleted file mode 100644 index 7198188..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Follow user */ -class FollowCreateParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [FollowCreateParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FollowCreateParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(followCreateParams: FollowCreateParams) = apply { - userId = followCreateParams.userId - body = followCreateParams.body.toBuilder() - additionalHeaders = followCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = followCreateParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [FollowCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FollowCreateParams = - FollowCreateParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FollowCreateParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "FollowCreateParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponse.kt deleted file mode 100644 index cbfc3ab..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class FollowCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [FollowCreateResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FollowCreateResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(followCreateResponse: FollowCreateResponse) = apply { - success = followCreateResponse.success - additionalProperties = followCreateResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [FollowCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FollowCreateResponse = - FollowCreateResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): FollowCreateResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FollowCreateResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FollowCreateResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParams.kt deleted file mode 100644 index 66d4881..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParams.kt +++ /dev/null @@ -1,437 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonField -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.core.Params -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.http.Headers -import com.x_twitter_scraper.api.core.http.QueryParams -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Unfollow user */ -class FollowDeleteAllParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * X account (@username or account 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 account(): String = body.account() - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _account(): JsonField = body._account() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [FollowDeleteAllParams]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FollowDeleteAllParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(followDeleteAllParams: FollowDeleteAllParams) = apply { - userId = followDeleteAllParams.userId - body = followDeleteAllParams.body.toBuilder() - additionalHeaders = followDeleteAllParams.additionalHeaders.toBuilder() - additionalQueryParams = followDeleteAllParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [account] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** X account (@username or account ID) */ - fun account(account: String) = apply { body.account(account) } - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun account(account: JsonField) = apply { body.account(account) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [FollowDeleteAllParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FollowDeleteAllParams = - FollowDeleteAllParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val account: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account") @ExcludeMissing account: JsonField = JsonMissing.of() - ) : this(account, mutableMapOf()) - - /** - * X account (@username or account 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 account(): String = account.getRequired("account") - - /** - * Returns the raw JSON value of [account]. - * - * Unlike [account], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account") @ExcludeMissing fun _account(): JsonField = account - - @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 [Body]. - * - * The following fields are required: - * ```java - * .account() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var account: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - account = body.account - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** X account (@username or account ID) */ - fun account(account: String) = account(JsonField.of(account)) - - /** - * Sets [Builder.account] to an arbitrary JSON value. - * - * You should usually call [Builder.account] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun account(account: JsonField) = apply { this.account = account } - - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .account() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("account", account), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - account() - 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 (account.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - account == other.account && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(account, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{account=$account, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FollowDeleteAllParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "FollowDeleteAllParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponse.kt deleted file mode 100644 index 176ad69..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponse.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.x_twitter_scraper.api.core.ExcludeMissing -import com.x_twitter_scraper.api.core.JsonMissing -import com.x_twitter_scraper.api.core.JsonValue -import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.util.Collections -import java.util.Objects - -class FollowDeleteAllResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val success: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of() - ) : this(success, mutableMapOf()) - - /** - * Expected to always return the following: - * ```java - * JsonValue.from(true) - * ``` - * - * However, this method can be useful for debugging and logging (e.g. if the server responded - * with an unexpected value). - */ - @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success - - @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 [FollowDeleteAllResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FollowDeleteAllResponse]. */ - class Builder internal constructor() { - - private var success: JsonValue = JsonValue.from(true) - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(followDeleteAllResponse: FollowDeleteAllResponse) = apply { - success = followDeleteAllResponse.success - additionalProperties = followDeleteAllResponse.additionalProperties.toMutableMap() - } - - /** - * Sets the field to an arbitrary JSON value. - * - * It is usually unnecessary to call this method because the field defaults to the - * following: - * ```java - * JsonValue.from(true) - * ``` - * - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun success(success: JsonValue) = apply { this.success = success } - - 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 [FollowDeleteAllResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): FollowDeleteAllResponse = - FollowDeleteAllResponse(success, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): FollowDeleteAllResponse = apply { - if (validated) { - return@apply - } - - _success().let { - if (it != JsonValue.from(true)) { - throw XTwitterScraperInvalidDataException("'success' is invalid, received $it") - } - } - 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 = success.let { if (it == JsonValue.from(true)) 1 else 0 } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FollowDeleteAllResponse && - success == other.success && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FollowDeleteAllResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncImpl.kt index b18ba9a..f18a2d0 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncImpl.kt @@ -151,7 +151,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("account") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncImpl.kt index 71e0ec7..4b30a08 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncImpl.kt @@ -88,7 +88,11 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("api-keys") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -118,7 +122,11 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .baseUrl(clientOptions.baseUrl()) .addPathSegments("api-keys") .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -152,7 +160,11 @@ class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: Cli .addPathSegments("api-keys", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsync.kt index 586f492..f386c42 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsync.kt @@ -4,21 +4,13 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleAnalyzeResponse import com.x_twitter_scraper.api.models.styles.StyleCompareParams import com.x_twitter_scraper.api.models.styles.StyleCompareResponse -import com.x_twitter_scraper.api.models.styles.StyleDeleteParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceResponse import com.x_twitter_scraper.api.models.styles.StyleListParams import com.x_twitter_scraper.api.models.styles.StyleListResponse -import com.x_twitter_scraper.api.models.styles.StyleRetrieveParams -import com.x_twitter_scraper.api.models.styles.StyleRetrieveResponse -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -37,65 +29,6 @@ interface StyleServiceAsync { */ fun withOptions(modifier: Consumer): StyleServiceAsync - /** Get cached style profile */ - fun retrieve(username: String): CompletableFuture = - retrieve(username, StyleRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - ): CompletableFuture = retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: StyleRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(username, StyleRetrieveParams.none(), requestOptions) - - /** Save style profile with custom tweets */ - fun update( - username: String, - params: StyleUpdateParams, - ): CompletableFuture = update(username, params, RequestOptions.none()) - - /** @see update */ - fun update( - username: String, - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().username(username).build(), requestOptions) - - /** @see update */ - fun update(params: StyleUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** List cached style profiles */ fun list(): CompletableFuture = list(StyleListParams.none()) @@ -114,38 +47,6 @@ interface StyleServiceAsync { fun list(requestOptions: RequestOptions): CompletableFuture = list(StyleListParams.none(), requestOptions) - /** Delete a style profile */ - fun delete(username: String): CompletableFuture = - delete(username, StyleDeleteParams.none()) - - /** @see delete */ - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().username(username).build(), requestOptions) - - /** @see delete */ - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - ): CompletableFuture = delete(username, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: StyleDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(username: String, requestOptions: RequestOptions): CompletableFuture = - delete(username, StyleDeleteParams.none(), requestOptions) - /** Analyze writing style from recent tweets */ fun analyze(params: StyleAnalyzeParams): CompletableFuture = analyze(params, RequestOptions.none()) @@ -166,44 +67,6 @@ interface StyleServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Get engagement metrics for style tweets */ - fun getPerformance(username: String): CompletableFuture = - getPerformance(username, StyleGetPerformanceParams.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - getPerformance(params.toBuilder().username(username).build(), requestOptions) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - ): CompletableFuture = - getPerformance(username, params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see getPerformance */ - fun getPerformance( - params: StyleGetPerformanceParams - ): CompletableFuture = - getPerformance(params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture = - getPerformance(username, StyleGetPerformanceParams.none(), requestOptions) - /** A view of [StyleServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -216,77 +79,6 @@ interface StyleServiceAsync { modifier: Consumer ): StyleServiceAsync.WithRawResponse - /** - * Returns a raw HTTP response for `get /styles/{username}`, but is otherwise the same as - * [StyleServiceAsync.retrieve]. - */ - fun retrieve(username: String): CompletableFuture> = - retrieve(username, StyleRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - ): CompletableFuture> = - retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: StyleRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(username, StyleRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /styles/{username}`, but is otherwise the same as - * [StyleServiceAsync.update]. - */ - fun update( - username: String, - params: StyleUpdateParams, - ): CompletableFuture> = - update(username, params, RequestOptions.none()) - - /** @see update */ - fun update( - username: String, - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().username(username).build(), requestOptions) - - /** @see update */ - fun update( - params: StyleUpdateParams - ): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `get /styles`, but is otherwise the same as * [StyleServiceAsync.list]. @@ -312,44 +104,6 @@ interface StyleServiceAsync { ): CompletableFuture> = list(StyleListParams.none(), requestOptions) - /** - * Returns a raw HTTP response for `delete /styles/{username}`, but is otherwise the same as - * [StyleServiceAsync.delete]. - */ - fun delete(username: String): CompletableFuture = - delete(username, StyleDeleteParams.none()) - - /** @see delete */ - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().username(username).build(), requestOptions) - - /** @see delete */ - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - ): CompletableFuture = delete(username, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: StyleDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(username, StyleDeleteParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /styles`, but is otherwise the same as * [StyleServiceAsync.analyze]. @@ -379,48 +133,5 @@ interface StyleServiceAsync { params: StyleCompareParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /styles/{username}/performance`, but is otherwise - * the same as [StyleServiceAsync.getPerformance]. - */ - fun getPerformance( - username: String - ): CompletableFuture> = - getPerformance(username, StyleGetPerformanceParams.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - getPerformance(params.toBuilder().username(username).build(), requestOptions) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - ): CompletableFuture> = - getPerformance(username, params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see getPerformance */ - fun getPerformance( - params: StyleGetPerformanceParams - ): CompletableFuture> = - getPerformance(params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - getPerformance(username, StyleGetPerformanceParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncImpl.kt index e93b094..35276e5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncImpl.kt @@ -4,8 +4,6 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -21,18 +19,10 @@ import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleAnalyzeResponse import com.x_twitter_scraper.api.models.styles.StyleCompareParams import com.x_twitter_scraper.api.models.styles.StyleCompareResponse -import com.x_twitter_scraper.api.models.styles.StyleDeleteParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceResponse import com.x_twitter_scraper.api.models.styles.StyleListParams import com.x_twitter_scraper.api.models.styles.StyleListResponse -import com.x_twitter_scraper.api.models.styles.StyleRetrieveParams -import com.x_twitter_scraper.api.models.styles.StyleRetrieveResponse -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull /** Tweet composition, drafts, writing styles & radar */ class StyleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -47,20 +37,6 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): StyleServiceAsync = StyleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /styles/{username} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /styles/{username} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - override fun list( params: StyleListParams, requestOptions: RequestOptions, @@ -68,13 +44,6 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie // get /styles withRawResponse().list(params, requestOptions).thenApply { it.parse() } - override fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /styles/{username} - withRawResponse().delete(params, requestOptions).thenAccept {} - override fun analyze( params: StyleAnalyzeParams, requestOptions: RequestOptions, @@ -89,13 +58,6 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie // get /styles/compare withRawResponse().compare(params, requestOptions).thenApply { it.parse() } - override fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /styles/{username}/performance - withRawResponse().getPerformance(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : StyleServiceAsync.WithRawResponse { @@ -109,73 +71,6 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -206,33 +101,6 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - private val analyzeHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -293,38 +161,5 @@ class StyleServiceAsyncImpl internal constructor(private val clientOptions: Clie } } } - - private val getPerformanceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0), "performance") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { getPerformanceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/TrendServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/TrendServiceAsync.kt index 8085ed7..3cb522b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/TrendServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/TrendServiceAsync.kt @@ -25,7 +25,7 @@ interface TrendServiceAsync { */ fun withOptions(modifier: Consumer): TrendServiceAsync - /** Get trending topics */ + /** Get regional trending topics */ fun list(): CompletableFuture = list(TrendListParams.none()) /** @see list */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsync.kt index b608d63..f17ec3a 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsync.kt @@ -4,7 +4,6 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.XGetArticleParams import com.x_twitter_scraper.api.models.x.XGetArticleResponse @@ -13,6 +12,7 @@ import com.x_twitter_scraper.api.models.x.XGetHomeTimelineResponse import com.x_twitter_scraper.api.models.x.XGetNotificationsParams import com.x_twitter_scraper.api.models.x.XGetNotificationsResponse import com.x_twitter_scraper.api.models.x.XGetTrendsParams +import com.x_twitter_scraper.api.models.x.XGetTrendsResponse import com.x_twitter_scraper.api.services.async.x.AccountServiceAsync import com.x_twitter_scraper.api.services.async.x.BookmarkServiceAsync import com.x_twitter_scraper.api.services.async.x.CommunityServiceAsync @@ -147,20 +147,21 @@ interface XServiceAsync { getNotifications(XGetNotificationsParams.none(), requestOptions) /** Get trending topics */ - fun getTrends(): CompletableFuture = getTrends(XGetTrendsParams.none()) + fun getTrends(): CompletableFuture = getTrends(XGetTrendsParams.none()) /** @see getTrends */ fun getTrends( params: XGetTrendsParams = XGetTrendsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see getTrends */ - fun getTrends(params: XGetTrendsParams = XGetTrendsParams.none()): CompletableFuture = - getTrends(params, RequestOptions.none()) + fun getTrends( + params: XGetTrendsParams = XGetTrendsParams.none() + ): CompletableFuture = getTrends(params, RequestOptions.none()) /** @see getTrends */ - fun getTrends(requestOptions: RequestOptions): CompletableFuture = + fun getTrends(requestOptions: RequestOptions): CompletableFuture = getTrends(XGetTrendsParams.none(), requestOptions) /** A view of [XServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -295,21 +296,25 @@ interface XServiceAsync { * Returns a raw HTTP response for `get /x/trends`, but is otherwise the same as * [XServiceAsync.getTrends]. */ - fun getTrends(): CompletableFuture = getTrends(XGetTrendsParams.none()) + fun getTrends(): CompletableFuture> = + getTrends(XGetTrendsParams.none()) /** @see getTrends */ fun getTrends( params: XGetTrendsParams = XGetTrendsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see getTrends */ fun getTrends( params: XGetTrendsParams = XGetTrendsParams.none() - ): CompletableFuture = getTrends(params, RequestOptions.none()) + ): CompletableFuture> = + getTrends(params, RequestOptions.none()) /** @see getTrends */ - fun getTrends(requestOptions: RequestOptions): CompletableFuture = + fun getTrends( + requestOptions: RequestOptions + ): CompletableFuture> = getTrends(XGetTrendsParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncImpl.kt index fc4b5f0..096b25e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -23,6 +22,7 @@ import com.x_twitter_scraper.api.models.x.XGetHomeTimelineResponse import com.x_twitter_scraper.api.models.x.XGetNotificationsParams import com.x_twitter_scraper.api.models.x.XGetNotificationsResponse import com.x_twitter_scraper.api.models.x.XGetTrendsParams +import com.x_twitter_scraper.api.models.x.XGetTrendsResponse import com.x_twitter_scraper.api.services.async.x.AccountServiceAsync import com.x_twitter_scraper.api.services.async.x.AccountServiceAsyncImpl import com.x_twitter_scraper.api.services.async.x.BookmarkServiceAsync @@ -133,9 +133,9 @@ class XServiceAsyncImpl internal constructor(private val clientOptions: ClientOp override fun getTrends( params: XGetTrendsParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/trends - withRawResponse().getTrends(params, requestOptions).thenAccept {} + withRawResponse().getTrends(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : XServiceAsync.WithRawResponse { @@ -310,12 +310,13 @@ class XServiceAsyncImpl internal constructor(private val clientOptions: ClientOp } } - private val getTrendsHandler: Handler = emptyHandler() + private val getTrendsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun getTrends( params: XGetTrendsParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -328,7 +329,13 @@ class XServiceAsyncImpl internal constructor(private val clientOptions: ClientOp .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { getTrendsHandler.handle(it) } + response + .use { getTrendsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncImpl.kt index cc763dc..dff443b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncImpl.kt @@ -106,7 +106,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("x", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -139,7 +143,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .baseUrl(clientOptions.baseUrl()) .addPathSegments("x", "accounts", params._pathParam(0)) .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -169,7 +177,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .baseUrl(clientOptions.baseUrl()) .addPathSegments("x", "accounts") .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -203,7 +215,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("x", "accounts", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } @@ -237,7 +253,11 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl .addPathSegments("x", "accounts", params._pathParam(0), "reauth") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepareAsync(clientOptions, params, SecurityOptions.none()) + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().apiKey(true).build(), + ) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsync.kt index 81b7a08..6d50cfe 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsync.kt @@ -4,7 +4,6 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.communities.CommunityCreateParams import com.x_twitter_scraper.api.models.x.communities.CommunityCreateResponse @@ -13,8 +12,11 @@ import com.x_twitter_scraper.api.models.x.communities.CommunityDeleteResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoParams import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchResponse import com.x_twitter_scraper.api.services.async.x.communities.JoinServiceAsync import com.x_twitter_scraper.api.services.async.x.communities.TweetServiceAsync import java.util.concurrent.CompletableFuture @@ -113,7 +115,7 @@ interface CommunityServiceAsync { retrieveInfo(id, CommunityRetrieveInfoParams.none(), requestOptions) /** Get community members */ - fun retrieveMembers(id: String): CompletableFuture = + fun retrieveMembers(id: String): CompletableFuture = retrieveMembers(id, CommunityRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -121,30 +123,37 @@ interface CommunityServiceAsync { id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), - ): CompletableFuture = retrieveMembers(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveMembers */ - fun retrieveMembers(params: CommunityRetrieveMembersParams): CompletableFuture = + fun retrieveMembers( + params: CommunityRetrieveMembersParams + ): CompletableFuture = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ - fun retrieveMembers(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveMembers( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveMembers(id, CommunityRetrieveMembersParams.none(), requestOptions) /** Get community moderators */ - fun retrieveModerators(id: String): CompletableFuture = + fun retrieveModerators(id: String): CompletableFuture = retrieveModerators(id, CommunityRetrieveModeratorsParams.none()) /** @see retrieveModerators */ @@ -152,38 +161,46 @@ interface CommunityServiceAsync { id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveModerators(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveModerators */ fun retrieveModerators( id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), - ): CompletableFuture = retrieveModerators(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveModerators(id, params, RequestOptions.none()) /** @see retrieveModerators */ fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveModerators */ - fun retrieveModerators(params: CommunityRetrieveModeratorsParams): CompletableFuture = + fun retrieveModerators( + params: CommunityRetrieveModeratorsParams + ): CompletableFuture = retrieveModerators(params, RequestOptions.none()) /** @see retrieveModerators */ - fun retrieveModerators(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveModerators( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveModerators(id, CommunityRetrieveModeratorsParams.none(), requestOptions) /** Search tweets across communities */ - fun retrieveSearch(params: CommunityRetrieveSearchParams): CompletableFuture = + fun retrieveSearch( + params: CommunityRetrieveSearchParams + ): CompletableFuture = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [CommunityServiceAsync] that provides access to raw HTTP responses for each method. @@ -297,7 +314,9 @@ interface CommunityServiceAsync { * Returns a raw HTTP response for `get /x/communities/{id}/members`, but is otherwise the * same as [CommunityServiceAsync.retrieveMembers]. */ - fun retrieveMembers(id: String): CompletableFuture = + fun retrieveMembers( + id: String + ): CompletableFuture> = retrieveMembers(id, CommunityRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -305,38 +324,42 @@ interface CommunityServiceAsync { id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), - ): CompletableFuture = retrieveMembers(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveMembers */ fun retrieveMembers( params: CommunityRetrieveMembersParams - ): CompletableFuture = retrieveMembers(params, RequestOptions.none()) + ): CompletableFuture> = + retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveMembers(id, CommunityRetrieveMembersParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /x/communities/{id}/moderators`, but is otherwise * the same as [CommunityServiceAsync.retrieveModerators]. */ - fun retrieveModerators(id: String): CompletableFuture = + fun retrieveModerators( + id: String + ): CompletableFuture> = retrieveModerators(id, CommunityRetrieveModeratorsParams.none()) /** @see retrieveModerators */ @@ -344,44 +367,48 @@ interface CommunityServiceAsync { id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveModerators(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveModerators */ fun retrieveModerators( id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), - ): CompletableFuture = retrieveModerators(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveModerators(id, params, RequestOptions.none()) /** @see retrieveModerators */ fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveModerators */ fun retrieveModerators( params: CommunityRetrieveModeratorsParams - ): CompletableFuture = retrieveModerators(params, RequestOptions.none()) + ): CompletableFuture> = + retrieveModerators(params, RequestOptions.none()) /** @see retrieveModerators */ fun retrieveModerators( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveModerators(id, CommunityRetrieveModeratorsParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /x/communities/search`, but is otherwise the same as * [CommunityServiceAsync.retrieveSearch]. */ - fun retrieveSearch(params: CommunityRetrieveSearchParams): CompletableFuture = + fun retrieveSearch( + params: CommunityRetrieveSearchParams + ): CompletableFuture> = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncImpl.kt index 689f1af..0772832 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -24,8 +23,11 @@ import com.x_twitter_scraper.api.models.x.communities.CommunityDeleteResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoParams import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchResponse import com.x_twitter_scraper.api.services.async.x.communities.JoinServiceAsync import com.x_twitter_scraper.api.services.async.x.communities.JoinServiceAsyncImpl import com.x_twitter_scraper.api.services.async.x.communities.TweetServiceAsync @@ -80,23 +82,23 @@ class CommunityServiceAsyncImpl internal constructor(private val clientOptions: override fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/communities/{id}/members - withRawResponse().retrieveMembers(params, requestOptions).thenAccept {} + withRawResponse().retrieveMembers(params, requestOptions).thenApply { it.parse() } override fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/communities/{id}/moderators - withRawResponse().retrieveModerators(params, requestOptions).thenAccept {} + withRawResponse().retrieveModerators(params, requestOptions).thenApply { it.parse() } override fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/communities/search - withRawResponse().retrieveSearch(params, requestOptions).thenAccept {} + withRawResponse().retrieveSearch(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommunityServiceAsync.WithRawResponse { @@ -223,12 +225,13 @@ class CommunityServiceAsyncImpl internal constructor(private val clientOptions: } } - private val retrieveMembersHandler: Handler = emptyHandler() + private val retrieveMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -244,17 +247,24 @@ class CommunityServiceAsyncImpl internal constructor(private val clientOptions: .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveMembersHandler.handle(it) } + response + .use { retrieveMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - private val retrieveModeratorsHandler: Handler = emptyHandler() + private val retrieveModeratorsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -270,17 +280,24 @@ class CommunityServiceAsyncImpl internal constructor(private val clientOptions: .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveModeratorsHandler.handle(it) } + response + .use { retrieveModeratorsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - private val retrieveSearchHandler: Handler = emptyHandler() + private val retrieveSearchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -293,7 +310,13 @@ class CommunityServiceAsyncImpl internal constructor(private val clientOptions: .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveSearchHandler.handle(it) } + response + .use { retrieveSearchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsync.kt index dc94617..b8c2029 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsync.kt @@ -4,10 +4,13 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -27,7 +30,7 @@ interface ListServiceAsync { fun withOptions(modifier: Consumer): ListServiceAsync /** Get list followers */ - fun retrieveFollowers(id: String): CompletableFuture = + fun retrieveFollowers(id: String): CompletableFuture = retrieveFollowers(id, ListRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -35,31 +38,37 @@ interface ListServiceAsync { id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), - ): CompletableFuture = retrieveFollowers(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveFollowers */ - fun retrieveFollowers(params: ListRetrieveFollowersParams): CompletableFuture = + fun retrieveFollowers( + params: ListRetrieveFollowersParams + ): CompletableFuture = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ - fun retrieveFollowers(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveFollowers(id, ListRetrieveFollowersParams.none(), requestOptions) /** Get list members */ - fun retrieveMembers(id: String): CompletableFuture = + fun retrieveMembers(id: String): CompletableFuture = retrieveMembers(id, ListRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -67,30 +76,37 @@ interface ListServiceAsync { id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), - ): CompletableFuture = retrieveMembers(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveMembers */ - fun retrieveMembers(params: ListRetrieveMembersParams): CompletableFuture = + fun retrieveMembers( + params: ListRetrieveMembersParams + ): CompletableFuture = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ - fun retrieveMembers(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveMembers( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveMembers(id, ListRetrieveMembersParams.none(), requestOptions) /** Get list tweets */ - fun retrieveTweets(id: String): CompletableFuture = + fun retrieveTweets(id: String): CompletableFuture = retrieveTweets(id, ListRetrieveTweetsParams.none()) /** @see retrieveTweets */ @@ -98,26 +114,32 @@ interface ListServiceAsync { id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = retrieveTweets(params.toBuilder().id(id).build(), requestOptions) + ): CompletableFuture = + retrieveTweets(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveTweets */ fun retrieveTweets( id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), - ): CompletableFuture = retrieveTweets(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveTweets(id, params, RequestOptions.none()) /** @see retrieveTweets */ fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveTweets */ - fun retrieveTweets(params: ListRetrieveTweetsParams): CompletableFuture = - retrieveTweets(params, RequestOptions.none()) + fun retrieveTweets( + params: ListRetrieveTweetsParams + ): CompletableFuture = retrieveTweets(params, RequestOptions.none()) /** @see retrieveTweets */ - fun retrieveTweets(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveTweets( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveTweets(id, ListRetrieveTweetsParams.none(), requestOptions) /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -134,7 +156,9 @@ interface ListServiceAsync { * Returns a raw HTTP response for `get /x/lists/{id}/followers`, but is otherwise the same * as [ListServiceAsync.retrieveFollowers]. */ - fun retrieveFollowers(id: String): CompletableFuture = + fun retrieveFollowers( + id: String + ): CompletableFuture> = retrieveFollowers(id, ListRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -142,38 +166,42 @@ interface ListServiceAsync { id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), - ): CompletableFuture = retrieveFollowers(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveFollowers */ fun retrieveFollowers( params: ListRetrieveFollowersParams - ): CompletableFuture = retrieveFollowers(params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowers(id, ListRetrieveFollowersParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /x/lists/{id}/members`, but is otherwise the same as * [ListServiceAsync.retrieveMembers]. */ - fun retrieveMembers(id: String): CompletableFuture = + fun retrieveMembers( + id: String + ): CompletableFuture> = retrieveMembers(id, ListRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -181,37 +209,42 @@ interface ListServiceAsync { id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), - ): CompletableFuture = retrieveMembers(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveMembers */ - fun retrieveMembers(params: ListRetrieveMembersParams): CompletableFuture = + fun retrieveMembers( + params: ListRetrieveMembersParams + ): CompletableFuture> = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveMembers(id, ListRetrieveMembersParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /x/lists/{id}/tweets`, but is otherwise the same as * [ListServiceAsync.retrieveTweets]. */ - fun retrieveTweets(id: String): CompletableFuture = + fun retrieveTweets( + id: String + ): CompletableFuture> = retrieveTweets(id, ListRetrieveTweetsParams.none()) /** @see retrieveTweets */ @@ -219,30 +252,33 @@ interface ListServiceAsync { id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveTweets(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveTweets */ fun retrieveTweets( id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), - ): CompletableFuture = retrieveTweets(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveTweets(id, params, RequestOptions.none()) /** @see retrieveTweets */ fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveTweets */ - fun retrieveTweets(params: ListRetrieveTweetsParams): CompletableFuture = + fun retrieveTweets( + params: ListRetrieveTweetsParams + ): CompletableFuture> = retrieveTweets(params, RequestOptions.none()) /** @see retrieveTweets */ fun retrieveTweets( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveTweets(id, ListRetrieveTweetsParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncImpl.kt index e6a4fff..b77fb45 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncImpl.kt @@ -5,18 +5,22 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler +import com.x_twitter_scraper.api.core.handlers.jsonHandler import com.x_twitter_scraper.api.core.http.HttpMethod import com.x_twitter_scraper.api.core.http.HttpRequest import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponse.Handler +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepareAsync import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -37,23 +41,23 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/lists/{id}/followers - withRawResponse().retrieveFollowers(params, requestOptions).thenAccept {} + withRawResponse().retrieveFollowers(params, requestOptions).thenApply { it.parse() } override fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/lists/{id}/members - withRawResponse().retrieveMembers(params, requestOptions).thenAccept {} + withRawResponse().retrieveMembers(params, requestOptions).thenApply { it.parse() } override fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/lists/{id}/tweets - withRawResponse().retrieveTweets(params, requestOptions).thenAccept {} + withRawResponse().retrieveTweets(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ListServiceAsync.WithRawResponse { @@ -68,12 +72,13 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveFollowersHandler: Handler = emptyHandler() + private val retrieveFollowersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -89,17 +94,24 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveFollowersHandler.handle(it) } + response + .use { retrieveFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - private val retrieveMembersHandler: Handler = emptyHandler() + private val retrieveMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -115,17 +127,24 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveMembersHandler.handle(it) } + response + .use { retrieveMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - private val retrieveTweetsHandler: Handler = emptyHandler() + private val retrieveTweetsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -141,7 +160,13 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveTweetsHandler.handle(it) } + response + .use { retrieveTweetsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsync.kt index ef4a35a..fd9eeee 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsync.kt @@ -4,12 +4,9 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams @@ -21,8 +18,7 @@ import com.x_twitter_scraper.api.models.x.tweets.TweetGetRetweetersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadResponse import com.x_twitter_scraper.api.models.x.tweets.TweetListParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveResponse +import com.x_twitter_scraper.api.models.x.tweets.TweetListResponse import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse import com.x_twitter_scraper.api.services.async.x.tweets.LikeServiceAsync @@ -44,10 +40,8 @@ interface TweetServiceAsync { */ fun withOptions(modifier: Consumer): TweetServiceAsync - /** X write actions (tweets, likes, follows, DMs) */ fun like(): LikeServiceAsync - /** X write actions (tweets, likes, follows, DMs) */ fun retweet(): RetweetServiceAsync /** Create tweet */ @@ -60,72 +54,15 @@ interface TweetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Look up tweet */ - fun retrieve(tweetId: String): CompletableFuture = - retrieve(tweetId, TweetRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - ): CompletableFuture = retrieve(tweetId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: TweetRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(tweetId, TweetRetrieveParams.none(), requestOptions) - /** Get multiple tweets by IDs */ - fun list(params: TweetListParams): CompletableFuture = + fun list(params: TweetListParams): CompletableFuture = list(params, RequestOptions.none()) /** @see list */ fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Delete tweet */ - fun delete(tweetId: String, params: TweetDeleteParams): CompletableFuture = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: TweetDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Get users who liked a tweet */ fun getFavoriters(id: String): CompletableFuture = @@ -328,10 +265,8 @@ interface TweetServiceAsync { modifier: Consumer ): TweetServiceAsync.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun like(): LikeServiceAsync.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun retweet(): RetweetServiceAsync.WithRawResponse /** @@ -349,89 +284,18 @@ interface TweetServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `get /x/tweets/{tweetId}`, but is otherwise the same as - * [TweetServiceAsync.retrieve]. - */ - fun retrieve(tweetId: String): CompletableFuture> = - retrieve(tweetId, TweetRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - ): CompletableFuture> = - retrieve(tweetId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: TweetRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(tweetId, TweetRetrieveParams.none(), requestOptions) - /** * Returns a raw HTTP response for `get /x/tweets`, but is otherwise the same as * [TweetServiceAsync.list]. */ - fun list(params: TweetListParams): CompletableFuture = + fun list(params: TweetListParams): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}`, but is otherwise the same - * as [TweetServiceAsync.delete]. - */ - fun delete( - tweetId: String, - params: TweetDeleteParams, - ): CompletableFuture> = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete( - params: TweetDeleteParams - ): CompletableFuture> = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /x/tweets/{id}/favoriters`, but is otherwise the diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncImpl.kt index 57e04fd..41d599f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -19,8 +18,6 @@ import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepareAsync import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams @@ -32,8 +29,7 @@ import com.x_twitter_scraper.api.models.x.tweets.TweetGetRetweetersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadResponse import com.x_twitter_scraper.api.models.x.tweets.TweetListParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveResponse +import com.x_twitter_scraper.api.models.x.tweets.TweetListResponse import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse import com.x_twitter_scraper.api.services.async.x.tweets.LikeServiceAsync @@ -60,10 +56,8 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): TweetServiceAsync = TweetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** X write actions (tweets, likes, follows, DMs) */ override fun like(): LikeServiceAsync = like - /** X write actions (tweets, likes, follows, DMs) */ override fun retweet(): RetweetServiceAsync = retweet override fun create( @@ -73,26 +67,12 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie // post /x/tweets withRawResponse().create(params, requestOptions).thenApply { it.parse() } - override fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /x/tweets/{tweetId} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun list( params: TweetListParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/tweets - withRawResponse().list(params, requestOptions).thenAccept {} - - override fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /x/tweets/{tweetId} - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + withRawResponse().list(params, requestOptions).thenApply { it.parse() } override fun getFavoriters( params: TweetGetFavoritersParams, @@ -157,10 +137,8 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) - /** X write actions (tweets, likes, follows, DMs) */ override fun like(): LikeServiceAsync.WithRawResponse = like - /** X write actions (tweets, likes, follows, DMs) */ override fun retweet(): RetweetServiceAsync.WithRawResponse = retweet private val createHandler: Handler = @@ -194,45 +172,13 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = emptyHandler() + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun list( params: TweetListParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -241,40 +187,12 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { listHandler.handle(it) } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) return request .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .use { listHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsync.kt index 1a3db15..5349bf6 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsync.kt @@ -4,24 +4,27 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveResponse +import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersResponse import com.x_twitter_scraper.api.services.async.x.users.FollowServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -41,56 +44,21 @@ interface UserServiceAsync { */ fun withOptions(modifier: Consumer): UserServiceAsync - /** X write actions (tweets, likes, follows, DMs) */ fun follow(): FollowServiceAsync - /** Look up X user */ - fun retrieve(username: String): CompletableFuture = - retrieve(username, UserRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - ): CompletableFuture = retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: UserRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(username, UserRetrieveParams.none(), requestOptions) - /** Get multiple users by IDs */ - fun retrieveBatch(params: UserRetrieveBatchParams): CompletableFuture = - retrieveBatch(params, RequestOptions.none()) + fun retrieveBatch( + params: UserRetrieveBatchParams + ): CompletableFuture = retrieveBatch(params, RequestOptions.none()) /** @see retrieveBatch */ fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Get user followers */ - fun retrieveFollowers(id: String): CompletableFuture = + fun retrieveFollowers(id: String): CompletableFuture = retrieveFollowers(id, UserRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -98,27 +66,33 @@ interface UserServiceAsync { id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), - ): CompletableFuture = retrieveFollowers(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveFollowers */ - fun retrieveFollowers(params: UserRetrieveFollowersParams): CompletableFuture = + fun retrieveFollowers( + params: UserRetrieveFollowersParams + ): CompletableFuture = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ - fun retrieveFollowers(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveFollowers(id, UserRetrieveFollowersParams.none(), requestOptions) /** Get followers you know for a user */ @@ -162,7 +136,7 @@ interface UserServiceAsync { retrieveFollowersYouKnow(id, UserRetrieveFollowersYouKnowParams.none(), requestOptions) /** Get users this user follows */ - fun retrieveFollowing(id: String): CompletableFuture = + fun retrieveFollowing(id: String): CompletableFuture = retrieveFollowing(id, UserRetrieveFollowingParams.none()) /** @see retrieveFollowing */ @@ -170,27 +144,33 @@ interface UserServiceAsync { id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowing */ fun retrieveFollowing( id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), - ): CompletableFuture = retrieveFollowing(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveFollowing(id, params, RequestOptions.none()) /** @see retrieveFollowing */ fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveFollowing */ - fun retrieveFollowing(params: UserRetrieveFollowingParams): CompletableFuture = + fun retrieveFollowing( + params: UserRetrieveFollowingParams + ): CompletableFuture = retrieveFollowing(params, RequestOptions.none()) /** @see retrieveFollowing */ - fun retrieveFollowing(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveFollowing( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveFollowing(id, UserRetrieveFollowingParams.none(), requestOptions) /** Get tweets liked by a user */ @@ -268,7 +248,7 @@ interface UserServiceAsync { retrieveMedia(id, UserRetrieveMediaParams.none(), requestOptions) /** Get tweets mentioning a user */ - fun retrieveMentions(id: String): CompletableFuture = + fun retrieveMentions(id: String): CompletableFuture = retrieveMentions(id, UserRetrieveMentionsParams.none()) /** @see retrieveMentions */ @@ -276,38 +256,45 @@ interface UserServiceAsync { id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveMentions(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMentions */ fun retrieveMentions( id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), - ): CompletableFuture = retrieveMentions(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveMentions(id, params, RequestOptions.none()) /** @see retrieveMentions */ fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveMentions */ - fun retrieveMentions(params: UserRetrieveMentionsParams): CompletableFuture = + fun retrieveMentions( + params: UserRetrieveMentionsParams + ): CompletableFuture = retrieveMentions(params, RequestOptions.none()) /** @see retrieveMentions */ - fun retrieveMentions(id: String, requestOptions: RequestOptions): CompletableFuture = + fun retrieveMentions( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = retrieveMentions(id, UserRetrieveMentionsParams.none(), requestOptions) /** Search users by name or username */ - fun retrieveSearch(params: UserRetrieveSearchParams): CompletableFuture = - retrieveSearch(params, RequestOptions.none()) + fun retrieveSearch( + params: UserRetrieveSearchParams + ): CompletableFuture = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Get recent tweets by a user */ fun retrieveTweets(id: String): CompletableFuture = @@ -347,7 +334,9 @@ interface UserServiceAsync { retrieveTweets(id, UserRetrieveTweetsParams.none(), requestOptions) /** Get verified followers */ - fun retrieveVerifiedFollowers(id: String): CompletableFuture = + fun retrieveVerifiedFollowers( + id: String + ): CompletableFuture = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none()) /** @see retrieveVerifiedFollowers */ @@ -355,31 +344,33 @@ interface UserServiceAsync { id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), - ): CompletableFuture = retrieveVerifiedFollowers(id, params, RequestOptions.none()) + ): CompletableFuture = + retrieveVerifiedFollowers(id, params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams - ): CompletableFuture = retrieveVerifiedFollowers(params, RequestOptions.none()) + ): CompletableFuture = + retrieveVerifiedFollowers(params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none(), requestOptions) /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -392,68 +383,30 @@ interface UserServiceAsync { */ fun withOptions(modifier: Consumer): UserServiceAsync.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun follow(): FollowServiceAsync.WithRawResponse - /** - * Returns a raw HTTP response for `get /x/users/{username}`, but is otherwise the same as - * [UserServiceAsync.retrieve]. - */ - fun retrieve(username: String): CompletableFuture> = - retrieve(username, UserRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - ): CompletableFuture> = - retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: UserRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(username, UserRetrieveParams.none(), requestOptions) - /** * Returns a raw HTTP response for `get /x/users/batch`, but is otherwise the same as * [UserServiceAsync.retrieveBatch]. */ - fun retrieveBatch(params: UserRetrieveBatchParams): CompletableFuture = + fun retrieveBatch( + params: UserRetrieveBatchParams + ): CompletableFuture> = retrieveBatch(params, RequestOptions.none()) /** @see retrieveBatch */ fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** * Returns a raw HTTP response for `get /x/users/{id}/followers`, but is otherwise the same * as [UserServiceAsync.retrieveFollowers]. */ - fun retrieveFollowers(id: String): CompletableFuture = + fun retrieveFollowers( + id: String + ): CompletableFuture> = retrieveFollowers(id, UserRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -461,31 +414,33 @@ interface UserServiceAsync { id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), - ): CompletableFuture = retrieveFollowers(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveFollowers */ fun retrieveFollowers( params: UserRetrieveFollowersParams - ): CompletableFuture = retrieveFollowers(params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowers(id, UserRetrieveFollowersParams.none(), requestOptions) /** @@ -535,7 +490,9 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /x/users/{id}/following`, but is otherwise the same * as [UserServiceAsync.retrieveFollowing]. */ - fun retrieveFollowing(id: String): CompletableFuture = + fun retrieveFollowing( + id: String + ): CompletableFuture> = retrieveFollowing(id, UserRetrieveFollowingParams.none()) /** @see retrieveFollowing */ @@ -543,31 +500,33 @@ interface UserServiceAsync { id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowing */ fun retrieveFollowing( id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), - ): CompletableFuture = retrieveFollowing(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowing(id, params, RequestOptions.none()) /** @see retrieveFollowing */ fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveFollowing */ fun retrieveFollowing( params: UserRetrieveFollowingParams - ): CompletableFuture = retrieveFollowing(params, RequestOptions.none()) + ): CompletableFuture> = + retrieveFollowing(params, RequestOptions.none()) /** @see retrieveFollowing */ fun retrieveFollowing( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveFollowing(id, UserRetrieveFollowingParams.none(), requestOptions) /** @@ -660,7 +619,9 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /x/users/{id}/mentions`, but is otherwise the same * as [UserServiceAsync.retrieveMentions]. */ - fun retrieveMentions(id: String): CompletableFuture = + fun retrieveMentions( + id: String + ): CompletableFuture> = retrieveMentions(id, UserRetrieveMentionsParams.none()) /** @see retrieveMentions */ @@ -668,44 +629,49 @@ interface UserServiceAsync { id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveMentions(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMentions */ fun retrieveMentions( id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), - ): CompletableFuture = retrieveMentions(id, params, RequestOptions.none()) + ): CompletableFuture> = + retrieveMentions(id, params, RequestOptions.none()) /** @see retrieveMentions */ fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveMentions */ - fun retrieveMentions(params: UserRetrieveMentionsParams): CompletableFuture = + fun retrieveMentions( + params: UserRetrieveMentionsParams + ): CompletableFuture> = retrieveMentions(params, RequestOptions.none()) /** @see retrieveMentions */ fun retrieveMentions( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveMentions(id, UserRetrieveMentionsParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /x/users/search`, but is otherwise the same as * [UserServiceAsync.retrieveSearch]. */ - fun retrieveSearch(params: UserRetrieveSearchParams): CompletableFuture = + fun retrieveSearch( + params: UserRetrieveSearchParams + ): CompletableFuture> = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** * Returns a raw HTTP response for `get /x/users/{id}/tweets`, but is otherwise the same as @@ -754,7 +720,9 @@ interface UserServiceAsync { * Returns a raw HTTP response for `get /x/users/{id}/verified-followers`, but is otherwise * the same as [UserServiceAsync.retrieveVerifiedFollowers]. */ - fun retrieveVerifiedFollowers(id: String): CompletableFuture = + fun retrieveVerifiedFollowers( + id: String + ): CompletableFuture> = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none()) /** @see retrieveVerifiedFollowers */ @@ -763,33 +731,33 @@ interface UserServiceAsync { params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), - ): CompletableFuture = + ): CompletableFuture> = retrieveVerifiedFollowers(id, params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams - ): CompletableFuture = + ): CompletableFuture> = retrieveVerifiedFollowers(params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( id: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture> = retrieveVerifiedFollowers( id, UserRetrieveVerifiedFollowersParams.none(), diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncImpl.kt index 052b8bc..84c2f9f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -17,21 +16,25 @@ import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepareAsync import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveResponse +import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersResponse import com.x_twitter_scraper.api.services.async.x.users.FollowServiceAsync import com.x_twitter_scraper.api.services.async.x.users.FollowServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -53,29 +56,21 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): UserServiceAsync = UserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** X write actions (tweets, likes, follows, DMs) */ override fun follow(): FollowServiceAsync = follow - override fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /x/users/{username} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - override fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/batch - withRawResponse().retrieveBatch(params, requestOptions).thenAccept {} + withRawResponse().retrieveBatch(params, requestOptions).thenApply { it.parse() } override fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/{id}/followers - withRawResponse().retrieveFollowers(params, requestOptions).thenAccept {} + withRawResponse().retrieveFollowers(params, requestOptions).thenApply { it.parse() } override fun retrieveFollowersYouKnow( params: UserRetrieveFollowersYouKnowParams, @@ -87,9 +82,9 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/{id}/following - withRawResponse().retrieveFollowing(params, requestOptions).thenAccept {} + withRawResponse().retrieveFollowing(params, requestOptions).thenApply { it.parse() } override fun retrieveLikes( params: UserRetrieveLikesParams, @@ -108,16 +103,16 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/{id}/mentions - withRawResponse().retrieveMentions(params, requestOptions).thenAccept {} + withRawResponse().retrieveMentions(params, requestOptions).thenApply { it.parse() } override fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/search - withRawResponse().retrieveSearch(params, requestOptions).thenAccept {} + withRawResponse().retrieveSearch(params, requestOptions).thenApply { it.parse() } override fun retrieveTweets( params: UserRetrieveTweetsParams, @@ -129,9 +124,9 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/users/{id}/verified-followers - withRawResponse().retrieveVerifiedFollowers(params, requestOptions).thenAccept {} + withRawResponse().retrieveVerifiedFollowers(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UserServiceAsync.WithRawResponse { @@ -150,24 +145,20 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - /** X write actions (tweets, likes, follows, DMs) */ override fun follow(): FollowServiceAsync.WithRawResponse = follow - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveBatchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun retrieve( - params: UserRetrieveParams, + override fun retrieveBatch( + params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0)) + .addPathSegments("x", "users", "batch") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -176,7 +167,7 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { retrieveHandler.handle(it) } + .use { retrieveBatchHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -186,35 +177,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val retrieveBatchHandler: Handler = emptyHandler() - - override fun retrieveBatch( - params: UserRetrieveBatchParams, - requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", "batch") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { retrieveBatchHandler.handle(it) } - } - } - } - - private val retrieveFollowersHandler: Handler = emptyHandler() + private val retrieveFollowersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -230,7 +199,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveFollowersHandler.handle(it) } + response + .use { retrieveFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } @@ -268,12 +243,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val retrieveFollowingHandler: Handler = emptyHandler() + private val retrieveFollowingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -289,7 +265,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveFollowingHandler.handle(it) } + response + .use { retrieveFollowingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } @@ -360,12 +342,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val retrieveMentionsHandler: Handler = emptyHandler() + private val retrieveMentionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -381,17 +364,24 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveMentionsHandler.handle(it) } + response + .use { retrieveMentionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - private val retrieveSearchHandler: Handler = emptyHandler() + private val retrieveSearchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -404,7 +394,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveSearchHandler.handle(it) } + response + .use { retrieveSearchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } @@ -442,12 +438,14 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val retrieveVerifiedFollowersHandler: Handler = emptyHandler() + private val retrieveVerifiedFollowersHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -463,7 +461,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveVerifiedFollowersHandler.handle(it) } + response + .use { retrieveVerifiedFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsync.kt index 16d7781..e01adb8 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsync.kt @@ -4,8 +4,9 @@ package com.x_twitter_scraper.api.services.async.x.communities import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListParams +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -25,14 +26,14 @@ interface TweetServiceAsync { fun withOptions(modifier: Consumer): TweetServiceAsync /** Search tweets across all communities */ - fun list(params: TweetListParams): CompletableFuture = + fun list(params: TweetListParams): CompletableFuture = list(params, RequestOptions.none()) /** @see list */ fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** A view of [TweetServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -50,13 +51,13 @@ interface TweetServiceAsync { * Returns a raw HTTP response for `get /x/communities/tweets`, but is otherwise the same as * [TweetServiceAsync.list]. */ - fun list(params: TweetListParams): CompletableFuture = + fun list(params: TweetListParams): CompletableFuture> = list(params, RequestOptions.none()) /** @see list */ fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture> } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncImpl.kt index 5d40174..f0621a4 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncImpl.kt @@ -4,16 +4,18 @@ package com.x_twitter_scraper.api.services.async.x.communities import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler +import com.x_twitter_scraper.api.core.handlers.jsonHandler import com.x_twitter_scraper.api.core.http.HttpMethod import com.x_twitter_scraper.api.core.http.HttpRequest import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponse.Handler +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepareAsync import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListParams +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -33,9 +35,9 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun list( params: TweetListParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/communities/tweets - withRawResponse().list(params, requestOptions).thenAccept {} + withRawResponse().list(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TweetServiceAsync.WithRawResponse { @@ -50,12 +52,13 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler = emptyHandler() + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun list( params: TweetListParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -68,7 +71,13 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { listHandler.handle(it) } + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsync.kt index 13c97e5..617f946 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsync.kt @@ -3,16 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface LikeServiceAsync { /** @@ -27,50 +19,6 @@ interface LikeServiceAsync { */ fun withOptions(modifier: Consumer): LikeServiceAsync - /** Like tweet */ - fun create(tweetId: String, params: LikeCreateParams): CompletableFuture = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create(params: LikeCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Unlike tweet */ - fun delete(tweetId: String, params: LikeDeleteParams): CompletableFuture = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: LikeDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** A view of [LikeServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -80,65 +28,5 @@ interface LikeServiceAsync { * The original service is not modified. */ fun withOptions(modifier: Consumer): LikeServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/tweets/{tweetId}/like`, but is otherwise the - * same as [LikeServiceAsync.create]. - */ - fun create( - tweetId: String, - params: LikeCreateParams, - ): CompletableFuture> = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create( - params: LikeCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}/like`, but is otherwise the - * same as [LikeServiceAsync.delete]. - */ - fun delete( - tweetId: String, - params: LikeDeleteParams, - ): CompletableFuture> = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete( - params: LikeDeleteParams - ): CompletableFuture> = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncImpl.kt index b4213e6..e5a1a87 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncImpl.kt @@ -3,28 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepareAsync -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class LikeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LikeServiceAsync { @@ -37,99 +17,14 @@ class LikeServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): LikeServiceAsync = LikeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: LikeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /x/tweets/{tweetId}/like - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /x/tweets/{tweetId}/like - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LikeServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): LikeServiceAsync.WithRawResponse = LikeServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: LikeCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "like") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "like") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsync.kt index 1027f92..0d0b146 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsync.kt @@ -3,16 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface RetweetServiceAsync { /** @@ -27,54 +19,6 @@ interface RetweetServiceAsync { */ fun withOptions(modifier: Consumer): RetweetServiceAsync - /** Retweet */ - fun create( - tweetId: String, - params: RetweetCreateParams, - ): CompletableFuture = create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create(params: RetweetCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Unretweet */ - fun delete( - tweetId: String, - params: RetweetDeleteParams, - ): CompletableFuture = delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: RetweetDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * A view of [RetweetServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -88,65 +32,5 @@ interface RetweetServiceAsync { fun withOptions( modifier: Consumer ): RetweetServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/tweets/{tweetId}/retweet`, but is otherwise the - * same as [RetweetServiceAsync.create]. - */ - fun create( - tweetId: String, - params: RetweetCreateParams, - ): CompletableFuture> = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create( - params: RetweetCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}/retweet`, but is otherwise - * the same as [RetweetServiceAsync.delete]. - */ - fun delete( - tweetId: String, - params: RetweetDeleteParams, - ): CompletableFuture> = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete( - params: RetweetDeleteParams - ): CompletableFuture> = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncImpl.kt index 0885ab0..b1b8dec 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncImpl.kt @@ -3,28 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepareAsync -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class RetweetServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RetweetServiceAsync { @@ -37,99 +17,14 @@ class RetweetServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withOptions(modifier: Consumer): RetweetServiceAsync = RetweetServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /x/tweets/{tweetId}/retweet - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /x/tweets/{tweetId}/retweet - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RetweetServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): RetweetServiceAsync.WithRawResponse = RetweetServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "retweet") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "retweet") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsync.kt index 5befb54..f750409 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsync.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsync.kt @@ -3,16 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.users import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateResponse -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface FollowServiceAsync { /** @@ -27,54 +19,6 @@ interface FollowServiceAsync { */ fun withOptions(modifier: Consumer): FollowServiceAsync - /** Follow user */ - fun create( - userId: String, - params: FollowCreateParams, - ): CompletableFuture = create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create(params: FollowCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Unfollow user */ - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - ): CompletableFuture = deleteAll(userId, params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - deleteAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see deleteAll */ - fun deleteAll(params: FollowDeleteAllParams): CompletableFuture = - deleteAll(params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * A view of [FollowServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -88,65 +32,5 @@ interface FollowServiceAsync { fun withOptions( modifier: Consumer ): FollowServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/users/{userId}/follow`, but is otherwise the - * same as [FollowServiceAsync.create]. - */ - fun create( - userId: String, - params: FollowCreateParams, - ): CompletableFuture> = - create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create( - params: FollowCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `delete /x/users/{userId}/follow`, but is otherwise the - * same as [FollowServiceAsync.deleteAll]. - */ - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - ): CompletableFuture> = - deleteAll(userId, params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - deleteAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see deleteAll */ - fun deleteAll( - params: FollowDeleteAllParams - ): CompletableFuture> = - deleteAll(params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncImpl.kt index 50ecbda..40dee5d 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncImpl.kt @@ -3,28 +3,8 @@ package com.x_twitter_scraper.api.services.async.x.users import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepareAsync -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateResponse -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllResponse -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class FollowServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : FollowServiceAsync { @@ -37,99 +17,14 @@ class FollowServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): FollowServiceAsync = FollowServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: FollowCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /x/users/{userId}/follow - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /x/users/{userId}/follow - withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FollowServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): FollowServiceAsync.WithRawResponse = FollowServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: FollowCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0), "follow") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteAllHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0), "follow") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { deleteAllHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceImpl.kt index 6d08094..1b9c9e5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceImpl.kt @@ -140,7 +140,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("account") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceImpl.kt index e3f79ce..4ac35de 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceImpl.kt @@ -87,7 +87,7 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("api-keys") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -114,7 +114,7 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .baseUrl(clientOptions.baseUrl()) .addPathSegments("api-keys") .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -145,7 +145,7 @@ class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOp .addPathSegments("api-keys", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleService.kt index d0c0c38..9b84523 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleService.kt @@ -5,21 +5,13 @@ package com.x_twitter_scraper.api.services.blocking import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleAnalyzeResponse import com.x_twitter_scraper.api.models.styles.StyleCompareParams import com.x_twitter_scraper.api.models.styles.StyleCompareResponse -import com.x_twitter_scraper.api.models.styles.StyleDeleteParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceResponse import com.x_twitter_scraper.api.models.styles.StyleListParams import com.x_twitter_scraper.api.models.styles.StyleListResponse -import com.x_twitter_scraper.api.models.styles.StyleRetrieveParams -import com.x_twitter_scraper.api.models.styles.StyleRetrieveResponse -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateResponse import java.util.function.Consumer /** Tweet composition, drafts, writing styles & radar */ @@ -37,59 +29,6 @@ interface StyleService { */ fun withOptions(modifier: Consumer): StyleService - /** Get cached style profile */ - fun retrieve(username: String): StyleRetrieveResponse = - retrieve(username, StyleRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleRetrieveResponse = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - ): StyleRetrieveResponse = retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: StyleRetrieveParams): StyleRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(username: String, requestOptions: RequestOptions): StyleRetrieveResponse = - retrieve(username, StyleRetrieveParams.none(), requestOptions) - - /** Save style profile with custom tweets */ - fun update(username: String, params: StyleUpdateParams): StyleUpdateResponse = - update(username, params, RequestOptions.none()) - - /** @see update */ - fun update( - username: String, - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleUpdateResponse = update(params.toBuilder().username(username).build(), requestOptions) - - /** @see update */ - fun update(params: StyleUpdateParams): StyleUpdateResponse = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleUpdateResponse - /** List cached style profiles */ fun list(): StyleListResponse = list(StyleListParams.none()) @@ -107,30 +46,6 @@ interface StyleService { fun list(requestOptions: RequestOptions): StyleListResponse = list(StyleListParams.none(), requestOptions) - /** Delete a style profile */ - fun delete(username: String) = delete(username, StyleDeleteParams.none()) - - /** @see delete */ - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().username(username).build(), requestOptions) - - /** @see delete */ - fun delete(username: String, params: StyleDeleteParams = StyleDeleteParams.none()) = - delete(username, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: StyleDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: StyleDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(username: String, requestOptions: RequestOptions) = - delete(username, StyleDeleteParams.none(), requestOptions) - /** Analyze writing style from recent tweets */ fun analyze(params: StyleAnalyzeParams): StyleAnalyzeResponse = analyze(params, RequestOptions.none()) @@ -151,41 +66,6 @@ interface StyleService { requestOptions: RequestOptions = RequestOptions.none(), ): StyleCompareResponse - /** Get engagement metrics for style tweets */ - fun getPerformance(username: String): StyleGetPerformanceResponse = - getPerformance(username, StyleGetPerformanceParams.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleGetPerformanceResponse = - getPerformance(params.toBuilder().username(username).build(), requestOptions) - - /** @see getPerformance */ - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - ): StyleGetPerformanceResponse = getPerformance(username, params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): StyleGetPerformanceResponse - - /** @see getPerformance */ - fun getPerformance(params: StyleGetPerformanceParams): StyleGetPerformanceResponse = - getPerformance(params, RequestOptions.none()) - - /** @see getPerformance */ - fun getPerformance( - username: String, - requestOptions: RequestOptions, - ): StyleGetPerformanceResponse = - getPerformance(username, StyleGetPerformanceParams.none(), requestOptions) - /** A view of [StyleService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -196,82 +76,6 @@ interface StyleService { */ fun withOptions(modifier: Consumer): StyleService.WithRawResponse - /** - * Returns a raw HTTP response for `get /styles/{username}`, but is otherwise the same as - * [StyleService.retrieve]. - */ - @MustBeClosed - fun retrieve(username: String): HttpResponseFor = - retrieve(username, StyleRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - params: StyleRetrieveParams = StyleRetrieveParams.none(), - ): HttpResponseFor = - retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: StyleRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(username, StyleRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /styles/{username}`, but is otherwise the same as - * [StyleService.update]. - */ - @MustBeClosed - fun update( - username: String, - params: StyleUpdateParams, - ): HttpResponseFor = update(username, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - username: String, - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().username(username).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: StyleUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - /** * Returns a raw HTTP response for `get /styles`, but is otherwise the same as * [StyleService.list]. @@ -296,44 +100,6 @@ interface StyleService { fun list(requestOptions: RequestOptions): HttpResponseFor = list(StyleListParams.none(), requestOptions) - /** - * Returns a raw HTTP response for `delete /styles/{username}`, but is otherwise the same as - * [StyleService.delete]. - */ - @MustBeClosed - fun delete(username: String): HttpResponse = delete(username, StyleDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().username(username).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - username: String, - params: StyleDeleteParams = StyleDeleteParams.none(), - ): HttpResponse = delete(username, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: StyleDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(username: String, requestOptions: RequestOptions): HttpResponse = - delete(username, StyleDeleteParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /styles`, but is otherwise the same as * [StyleService.analyze]. @@ -363,52 +129,5 @@ interface StyleService { params: StyleCompareParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /styles/{username}/performance`, but is otherwise - * the same as [StyleService.getPerformance]. - */ - @MustBeClosed - fun getPerformance(username: String): HttpResponseFor = - getPerformance(username, StyleGetPerformanceParams.none()) - - /** @see getPerformance */ - @MustBeClosed - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - getPerformance(params.toBuilder().username(username).build(), requestOptions) - - /** @see getPerformance */ - @MustBeClosed - fun getPerformance( - username: String, - params: StyleGetPerformanceParams = StyleGetPerformanceParams.none(), - ): HttpResponseFor = - getPerformance(username, params, RequestOptions.none()) - - /** @see getPerformance */ - @MustBeClosed - fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see getPerformance */ - @MustBeClosed - fun getPerformance( - params: StyleGetPerformanceParams - ): HttpResponseFor = - getPerformance(params, RequestOptions.none()) - - /** @see getPerformance */ - @MustBeClosed - fun getPerformance( - username: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - getPerformance(username, StyleGetPerformanceParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceImpl.kt index 8239f05..efed212 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceImpl.kt @@ -4,8 +4,6 @@ package com.x_twitter_scraper.api.services.blocking import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -21,17 +19,9 @@ import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleAnalyzeResponse import com.x_twitter_scraper.api.models.styles.StyleCompareParams import com.x_twitter_scraper.api.models.styles.StyleCompareResponse -import com.x_twitter_scraper.api.models.styles.StyleDeleteParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceParams -import com.x_twitter_scraper.api.models.styles.StyleGetPerformanceResponse import com.x_twitter_scraper.api.models.styles.StyleListParams import com.x_twitter_scraper.api.models.styles.StyleListResponse -import com.x_twitter_scraper.api.models.styles.StyleRetrieveParams -import com.x_twitter_scraper.api.models.styles.StyleRetrieveResponse -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateResponse import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull /** Tweet composition, drafts, writing styles & radar */ class StyleServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,29 +36,10 @@ class StyleServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): StyleService = StyleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions, - ): StyleRetrieveResponse = - // get /styles/{username} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions, - ): StyleUpdateResponse = - // put /styles/{username} - withRawResponse().update(params, requestOptions).parse() - override fun list(params: StyleListParams, requestOptions: RequestOptions): StyleListResponse = // get /styles withRawResponse().list(params, requestOptions).parse() - override fun delete(params: StyleDeleteParams, requestOptions: RequestOptions) { - // delete /styles/{username} - withRawResponse().delete(params, requestOptions) - } - override fun analyze( params: StyleAnalyzeParams, requestOptions: RequestOptions, @@ -83,13 +54,6 @@ class StyleServiceImpl internal constructor(private val clientOptions: ClientOpt // get /styles/compare withRawResponse().compare(params, requestOptions).parse() - override fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions, - ): StyleGetPerformanceResponse = - // get /styles/{username}/performance - withRawResponse().getPerformance(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : StyleService.WithRawResponse { @@ -103,67 +67,6 @@ class StyleServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: StyleRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: StyleUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -191,30 +94,6 @@ class StyleServiceImpl internal constructor(private val clientOptions: ClientOpt } } - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: StyleDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - private val analyzeHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -269,35 +148,5 @@ class StyleServiceImpl internal constructor(private val clientOptions: ClientOpt } } } - - private val getPerformanceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getPerformance( - params: StyleGetPerformanceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("styles", params._pathParam(0), "performance") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { getPerformanceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/TrendService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/TrendService.kt index ad4054f..fe2b59e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/TrendService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/TrendService.kt @@ -25,7 +25,7 @@ interface TrendService { */ fun withOptions(modifier: Consumer): TrendService - /** Get trending topics */ + /** Get regional trending topics */ fun list(): TrendListResponse = list(TrendListParams.none()) /** @see list */ diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XService.kt index 6fe7efa..e5e4e6c 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XService.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.XGetArticleParams import com.x_twitter_scraper.api.models.x.XGetArticleResponse @@ -14,6 +13,7 @@ import com.x_twitter_scraper.api.models.x.XGetHomeTimelineResponse import com.x_twitter_scraper.api.models.x.XGetNotificationsParams import com.x_twitter_scraper.api.models.x.XGetNotificationsResponse import com.x_twitter_scraper.api.models.x.XGetTrendsParams +import com.x_twitter_scraper.api.models.x.XGetTrendsResponse import com.x_twitter_scraper.api.services.blocking.x.AccountService import com.x_twitter_scraper.api.services.blocking.x.BookmarkService import com.x_twitter_scraper.api.services.blocking.x.CommunityService @@ -137,20 +137,20 @@ interface XService { getNotifications(XGetNotificationsParams.none(), requestOptions) /** Get trending topics */ - fun getTrends() = getTrends(XGetTrendsParams.none()) + fun getTrends(): XGetTrendsResponse = getTrends(XGetTrendsParams.none()) /** @see getTrends */ fun getTrends( params: XGetTrendsParams = XGetTrendsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) + ): XGetTrendsResponse /** @see getTrends */ - fun getTrends(params: XGetTrendsParams = XGetTrendsParams.none()) = + fun getTrends(params: XGetTrendsParams = XGetTrendsParams.none()): XGetTrendsResponse = getTrends(params, RequestOptions.none()) /** @see getTrends */ - fun getTrends(requestOptions: RequestOptions) = + fun getTrends(requestOptions: RequestOptions): XGetTrendsResponse = getTrends(XGetTrendsParams.none(), requestOptions) /** A view of [XService] that provides access to raw HTTP responses for each method. */ @@ -296,23 +296,25 @@ interface XService { * Returns a raw HTTP response for `get /x/trends`, but is otherwise the same as * [XService.getTrends]. */ - @MustBeClosed fun getTrends(): HttpResponse = getTrends(XGetTrendsParams.none()) + @MustBeClosed + fun getTrends(): HttpResponseFor = getTrends(XGetTrendsParams.none()) /** @see getTrends */ @MustBeClosed fun getTrends( params: XGetTrendsParams = XGetTrendsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see getTrends */ @MustBeClosed - fun getTrends(params: XGetTrendsParams = XGetTrendsParams.none()): HttpResponse = - getTrends(params, RequestOptions.none()) + fun getTrends( + params: XGetTrendsParams = XGetTrendsParams.none() + ): HttpResponseFor = getTrends(params, RequestOptions.none()) /** @see getTrends */ @MustBeClosed - fun getTrends(requestOptions: RequestOptions): HttpResponse = + fun getTrends(requestOptions: RequestOptions): HttpResponseFor = getTrends(XGetTrendsParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceImpl.kt index e6c77e5..e5dd816 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -23,6 +22,7 @@ import com.x_twitter_scraper.api.models.x.XGetHomeTimelineResponse import com.x_twitter_scraper.api.models.x.XGetNotificationsParams import com.x_twitter_scraper.api.models.x.XGetNotificationsResponse import com.x_twitter_scraper.api.models.x.XGetTrendsParams +import com.x_twitter_scraper.api.models.x.XGetTrendsResponse import com.x_twitter_scraper.api.services.blocking.x.AccountService import com.x_twitter_scraper.api.services.blocking.x.AccountServiceImpl import com.x_twitter_scraper.api.services.blocking.x.BookmarkService @@ -126,10 +126,12 @@ class XServiceImpl internal constructor(private val clientOptions: ClientOptions // get /x/notifications withRawResponse().getNotifications(params, requestOptions).parse() - override fun getTrends(params: XGetTrendsParams, requestOptions: RequestOptions) { + override fun getTrends( + params: XGetTrendsParams, + requestOptions: RequestOptions, + ): XGetTrendsResponse = // get /x/trends - withRawResponse().getTrends(params, requestOptions) - } + withRawResponse().getTrends(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : XService.WithRawResponse { @@ -295,12 +297,13 @@ class XServiceImpl internal constructor(private val clientOptions: ClientOptions } } - private val getTrendsHandler: Handler = emptyHandler() + private val getTrendsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun getTrends( params: XGetTrendsParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -311,7 +314,13 @@ class XServiceImpl internal constructor(private val clientOptions: ClientOptions val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { getTrendsHandler.handle(it) } + response + .use { getTrendsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceImpl.kt index 75f3296..9ec6a7f 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceImpl.kt @@ -105,7 +105,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("x", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -135,7 +135,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .baseUrl(clientOptions.baseUrl()) .addPathSegments("x", "accounts", params._pathParam(0)) .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -162,7 +162,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .baseUrl(clientOptions.baseUrl()) .addPathSegments("x", "accounts") .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -193,7 +193,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("x", "accounts", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { @@ -224,7 +224,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO .addPathSegments("x", "accounts", params._pathParam(0), "reauth") .body(json(clientOptions.jsonMapper, params._body())) .build() - .prepare(clientOptions, params, SecurityOptions.none()) + .prepare(clientOptions, params, SecurityOptions.builder().apiKey(true).build()) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityService.kt index 4f2a8be..aaa6b0e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityService.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking.x import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.communities.CommunityCreateParams import com.x_twitter_scraper.api.models.x.communities.CommunityCreateResponse @@ -14,8 +13,11 @@ import com.x_twitter_scraper.api.models.x.communities.CommunityDeleteResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoParams import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchResponse import com.x_twitter_scraper.api.services.blocking.x.communities.JoinService import com.x_twitter_scraper.api.services.blocking.x.communities.TweetService import java.util.function.Consumer @@ -104,37 +106,42 @@ interface CommunityService { retrieveInfo(id, CommunityRetrieveInfoParams.none(), requestOptions) /** Get community members */ - fun retrieveMembers(id: String) = retrieveMembers(id, CommunityRetrieveMembersParams.none()) + fun retrieveMembers(id: String): CommunityRetrieveMembersResponse = + retrieveMembers(id, CommunityRetrieveMembersParams.none()) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): CommunityRetrieveMembersResponse = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), - ) = retrieveMembers(id, params, RequestOptions.none()) + ): CommunityRetrieveMembersResponse = retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): CommunityRetrieveMembersResponse /** @see retrieveMembers */ - fun retrieveMembers(params: CommunityRetrieveMembersParams) = + fun retrieveMembers(params: CommunityRetrieveMembersParams): CommunityRetrieveMembersResponse = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ - fun retrieveMembers(id: String, requestOptions: RequestOptions) = + fun retrieveMembers( + id: String, + requestOptions: RequestOptions, + ): CommunityRetrieveMembersResponse = retrieveMembers(id, CommunityRetrieveMembersParams.none(), requestOptions) /** Get community moderators */ - fun retrieveModerators(id: String) = + fun retrieveModerators(id: String): CommunityRetrieveModeratorsResponse = retrieveModerators(id, CommunityRetrieveModeratorsParams.none()) /** @see retrieveModerators */ @@ -142,37 +149,42 @@ interface CommunityService { id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveModerators(params.toBuilder().id(id).build(), requestOptions) + ): CommunityRetrieveModeratorsResponse = + retrieveModerators(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveModerators */ fun retrieveModerators( id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), - ) = retrieveModerators(id, params, RequestOptions.none()) + ): CommunityRetrieveModeratorsResponse = retrieveModerators(id, params, RequestOptions.none()) /** @see retrieveModerators */ fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): CommunityRetrieveModeratorsResponse /** @see retrieveModerators */ - fun retrieveModerators(params: CommunityRetrieveModeratorsParams) = - retrieveModerators(params, RequestOptions.none()) + fun retrieveModerators( + params: CommunityRetrieveModeratorsParams + ): CommunityRetrieveModeratorsResponse = retrieveModerators(params, RequestOptions.none()) /** @see retrieveModerators */ - fun retrieveModerators(id: String, requestOptions: RequestOptions) = + fun retrieveModerators( + id: String, + requestOptions: RequestOptions, + ): CommunityRetrieveModeratorsResponse = retrieveModerators(id, CommunityRetrieveModeratorsParams.none(), requestOptions) /** Search tweets across communities */ - fun retrieveSearch(params: CommunityRetrieveSearchParams) = + fun retrieveSearch(params: CommunityRetrieveSearchParams): CommunityRetrieveSearchResponse = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): CommunityRetrieveSearchResponse /** A view of [CommunityService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -288,7 +300,7 @@ interface CommunityService { * same as [CommunityService.retrieveMembers]. */ @MustBeClosed - fun retrieveMembers(id: String): HttpResponse = + fun retrieveMembers(id: String): HttpResponseFor = retrieveMembers(id, CommunityRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -297,30 +309,37 @@ interface CommunityService { id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ @MustBeClosed fun retrieveMembers( id: String, params: CommunityRetrieveMembersParams = CommunityRetrieveMembersParams.none(), - ): HttpResponse = retrieveMembers(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ @MustBeClosed fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveMembers */ @MustBeClosed - fun retrieveMembers(params: CommunityRetrieveMembersParams): HttpResponse = + fun retrieveMembers( + params: CommunityRetrieveMembersParams + ): HttpResponseFor = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ @MustBeClosed - fun retrieveMembers(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveMembers( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveMembers(id, CommunityRetrieveMembersParams.none(), requestOptions) /** @@ -328,7 +347,7 @@ interface CommunityService { * the same as [CommunityService.retrieveModerators]. */ @MustBeClosed - fun retrieveModerators(id: String): HttpResponse = + fun retrieveModerators(id: String): HttpResponseFor = retrieveModerators(id, CommunityRetrieveModeratorsParams.none()) /** @see retrieveModerators */ @@ -337,30 +356,37 @@ interface CommunityService { id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveModerators(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveModerators(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveModerators */ @MustBeClosed fun retrieveModerators( id: String, params: CommunityRetrieveModeratorsParams = CommunityRetrieveModeratorsParams.none(), - ): HttpResponse = retrieveModerators(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveModerators(id, params, RequestOptions.none()) /** @see retrieveModerators */ @MustBeClosed fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveModerators */ @MustBeClosed - fun retrieveModerators(params: CommunityRetrieveModeratorsParams): HttpResponse = + fun retrieveModerators( + params: CommunityRetrieveModeratorsParams + ): HttpResponseFor = retrieveModerators(params, RequestOptions.none()) /** @see retrieveModerators */ @MustBeClosed - fun retrieveModerators(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveModerators( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveModerators(id, CommunityRetrieveModeratorsParams.none(), requestOptions) /** @@ -368,7 +394,9 @@ interface CommunityService { * [CommunityService.retrieveSearch]. */ @MustBeClosed - fun retrieveSearch(params: CommunityRetrieveSearchParams): HttpResponse = + fun retrieveSearch( + params: CommunityRetrieveSearchParams + ): HttpResponseFor = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ @@ -376,6 +404,6 @@ interface CommunityService { fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceImpl.kt index e92dedc..8c27656 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -24,8 +23,11 @@ import com.x_twitter_scraper.api.models.x.communities.CommunityDeleteResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoParams import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveInfoResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveModeratorsResponse import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.communities.CommunityRetrieveSearchResponse import com.x_twitter_scraper.api.services.blocking.x.communities.JoinService import com.x_twitter_scraper.api.services.blocking.x.communities.JoinServiceImpl import com.x_twitter_scraper.api.services.blocking.x.communities.TweetService @@ -79,26 +81,23 @@ class CommunityServiceImpl internal constructor(private val clientOptions: Clien override fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions, - ) { + ): CommunityRetrieveMembersResponse = // get /x/communities/{id}/members - withRawResponse().retrieveMembers(params, requestOptions) - } + withRawResponse().retrieveMembers(params, requestOptions).parse() override fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions, - ) { + ): CommunityRetrieveModeratorsResponse = // get /x/communities/{id}/moderators - withRawResponse().retrieveModerators(params, requestOptions) - } + withRawResponse().retrieveModerators(params, requestOptions).parse() override fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions, - ) { + ): CommunityRetrieveSearchResponse = // get /x/communities/search - withRawResponse().retrieveSearch(params, requestOptions) - } + withRawResponse().retrieveSearch(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommunityService.WithRawResponse { @@ -216,12 +215,13 @@ class CommunityServiceImpl internal constructor(private val clientOptions: Clien } } - private val retrieveMembersHandler: Handler = emptyHandler() + private val retrieveMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMembers( params: CommunityRetrieveMembersParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -235,16 +235,23 @@ class CommunityServiceImpl internal constructor(private val clientOptions: Clien val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveMembersHandler.handle(it) } + response + .use { retrieveMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - private val retrieveModeratorsHandler: Handler = emptyHandler() + private val retrieveModeratorsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveModerators( params: CommunityRetrieveModeratorsParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -258,16 +265,23 @@ class CommunityServiceImpl internal constructor(private val clientOptions: Clien val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveModeratorsHandler.handle(it) } + response + .use { retrieveModeratorsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - private val retrieveSearchHandler: Handler = emptyHandler() + private val retrieveSearchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveSearch( params: CommunityRetrieveSearchParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -278,7 +292,13 @@ class CommunityServiceImpl internal constructor(private val clientOptions: Clien val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveSearchHandler.handle(it) } + response + .use { retrieveSearchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListService.kt index 46d6a2f..da13bda 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListService.kt @@ -5,10 +5,13 @@ package com.x_twitter_scraper.api.services.blocking.x import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsResponse import java.util.function.Consumer /** X data lookups (subscription required) */ @@ -27,93 +30,102 @@ interface ListService { fun withOptions(modifier: Consumer): ListService /** Get list followers */ - fun retrieveFollowers(id: String) = retrieveFollowers(id, ListRetrieveFollowersParams.none()) + fun retrieveFollowers(id: String): ListRetrieveFollowersResponse = + retrieveFollowers(id, ListRetrieveFollowersParams.none()) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) + ): ListRetrieveFollowersResponse = + retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), - ) = retrieveFollowers(id, params, RequestOptions.none()) + ): ListRetrieveFollowersResponse = retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): ListRetrieveFollowersResponse /** @see retrieveFollowers */ - fun retrieveFollowers(params: ListRetrieveFollowersParams) = + fun retrieveFollowers(params: ListRetrieveFollowersParams): ListRetrieveFollowersResponse = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ - fun retrieveFollowers(id: String, requestOptions: RequestOptions) = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): ListRetrieveFollowersResponse = retrieveFollowers(id, ListRetrieveFollowersParams.none(), requestOptions) /** Get list members */ - fun retrieveMembers(id: String) = retrieveMembers(id, ListRetrieveMembersParams.none()) + fun retrieveMembers(id: String): ListRetrieveMembersResponse = + retrieveMembers(id, ListRetrieveMembersParams.none()) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): ListRetrieveMembersResponse = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ fun retrieveMembers( id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), - ) = retrieveMembers(id, params, RequestOptions.none()) + ): ListRetrieveMembersResponse = retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): ListRetrieveMembersResponse /** @see retrieveMembers */ - fun retrieveMembers(params: ListRetrieveMembersParams) = + fun retrieveMembers(params: ListRetrieveMembersParams): ListRetrieveMembersResponse = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ - fun retrieveMembers(id: String, requestOptions: RequestOptions) = + fun retrieveMembers(id: String, requestOptions: RequestOptions): ListRetrieveMembersResponse = retrieveMembers(id, ListRetrieveMembersParams.none(), requestOptions) /** Get list tweets */ - fun retrieveTweets(id: String) = retrieveTweets(id, ListRetrieveTweetsParams.none()) + fun retrieveTweets(id: String): ListRetrieveTweetsResponse = + retrieveTweets(id, ListRetrieveTweetsParams.none()) /** @see retrieveTweets */ fun retrieveTweets( id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveTweets(params.toBuilder().id(id).build(), requestOptions) + ): ListRetrieveTweetsResponse = + retrieveTweets(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveTweets */ fun retrieveTweets( id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), - ) = retrieveTweets(id, params, RequestOptions.none()) + ): ListRetrieveTweetsResponse = retrieveTweets(id, params, RequestOptions.none()) /** @see retrieveTweets */ fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): ListRetrieveTweetsResponse /** @see retrieveTweets */ - fun retrieveTweets(params: ListRetrieveTweetsParams) = + fun retrieveTweets(params: ListRetrieveTweetsParams): ListRetrieveTweetsResponse = retrieveTweets(params, RequestOptions.none()) /** @see retrieveTweets */ - fun retrieveTweets(id: String, requestOptions: RequestOptions) = + fun retrieveTweets(id: String, requestOptions: RequestOptions): ListRetrieveTweetsResponse = retrieveTweets(id, ListRetrieveTweetsParams.none(), requestOptions) /** A view of [ListService] that provides access to raw HTTP responses for each method. */ @@ -131,7 +143,7 @@ interface ListService { * as [ListService.retrieveFollowers]. */ @MustBeClosed - fun retrieveFollowers(id: String): HttpResponse = + fun retrieveFollowers(id: String): HttpResponseFor = retrieveFollowers(id, ListRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -140,30 +152,37 @@ interface ListService { id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ @MustBeClosed fun retrieveFollowers( id: String, params: ListRetrieveFollowersParams = ListRetrieveFollowersParams.none(), - ): HttpResponse = retrieveFollowers(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ @MustBeClosed fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveFollowers */ @MustBeClosed - fun retrieveFollowers(params: ListRetrieveFollowersParams): HttpResponse = + fun retrieveFollowers( + params: ListRetrieveFollowersParams + ): HttpResponseFor = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ @MustBeClosed - fun retrieveFollowers(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveFollowers(id, ListRetrieveFollowersParams.none(), requestOptions) /** @@ -171,7 +190,7 @@ interface ListService { * [ListService.retrieveMembers]. */ @MustBeClosed - fun retrieveMembers(id: String): HttpResponse = + fun retrieveMembers(id: String): HttpResponseFor = retrieveMembers(id, ListRetrieveMembersParams.none()) /** @see retrieveMembers */ @@ -180,30 +199,37 @@ interface ListService { id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveMembers(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveMembers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMembers */ @MustBeClosed fun retrieveMembers( id: String, params: ListRetrieveMembersParams = ListRetrieveMembersParams.none(), - ): HttpResponse = retrieveMembers(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveMembers(id, params, RequestOptions.none()) /** @see retrieveMembers */ @MustBeClosed fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveMembers */ @MustBeClosed - fun retrieveMembers(params: ListRetrieveMembersParams): HttpResponse = + fun retrieveMembers( + params: ListRetrieveMembersParams + ): HttpResponseFor = retrieveMembers(params, RequestOptions.none()) /** @see retrieveMembers */ @MustBeClosed - fun retrieveMembers(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveMembers( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveMembers(id, ListRetrieveMembersParams.none(), requestOptions) /** @@ -211,7 +237,7 @@ interface ListService { * [ListService.retrieveTweets]. */ @MustBeClosed - fun retrieveTweets(id: String): HttpResponse = + fun retrieveTweets(id: String): HttpResponseFor = retrieveTweets(id, ListRetrieveTweetsParams.none()) /** @see retrieveTweets */ @@ -220,30 +246,37 @@ interface ListService { id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveTweets(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveTweets(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveTweets */ @MustBeClosed fun retrieveTweets( id: String, params: ListRetrieveTweetsParams = ListRetrieveTweetsParams.none(), - ): HttpResponse = retrieveTweets(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveTweets(id, params, RequestOptions.none()) /** @see retrieveTweets */ @MustBeClosed fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveTweets */ @MustBeClosed - fun retrieveTweets(params: ListRetrieveTweetsParams): HttpResponse = + fun retrieveTweets( + params: ListRetrieveTweetsParams + ): HttpResponseFor = retrieveTweets(params, RequestOptions.none()) /** @see retrieveTweets */ @MustBeClosed - fun retrieveTweets(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveTweets( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveTweets(id, ListRetrieveTweetsParams.none(), requestOptions) } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceImpl.kt index 2421b11..3f047fe 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceImpl.kt @@ -5,18 +5,22 @@ package com.x_twitter_scraper.api.services.blocking.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler +import com.x_twitter_scraper.api.core.handlers.jsonHandler import com.x_twitter_scraper.api.core.http.HttpMethod import com.x_twitter_scraper.api.core.http.HttpRequest import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponse.Handler +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepare import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveMembersResponse import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsParams +import com.x_twitter_scraper.api.models.x.lists.ListRetrieveTweetsResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -35,23 +39,23 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti override fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions, - ) { + ): ListRetrieveFollowersResponse = // get /x/lists/{id}/followers - withRawResponse().retrieveFollowers(params, requestOptions) - } + withRawResponse().retrieveFollowers(params, requestOptions).parse() override fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions, - ) { + ): ListRetrieveMembersResponse = // get /x/lists/{id}/members - withRawResponse().retrieveMembers(params, requestOptions) - } + withRawResponse().retrieveMembers(params, requestOptions).parse() - override fun retrieveTweets(params: ListRetrieveTweetsParams, requestOptions: RequestOptions) { + override fun retrieveTweets( + params: ListRetrieveTweetsParams, + requestOptions: RequestOptions, + ): ListRetrieveTweetsResponse = // get /x/lists/{id}/tweets - withRawResponse().retrieveTweets(params, requestOptions) - } + withRawResponse().retrieveTweets(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ListService.WithRawResponse { @@ -66,12 +70,13 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveFollowersHandler: Handler = emptyHandler() + private val retrieveFollowersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowers( params: ListRetrieveFollowersParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -85,16 +90,23 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveFollowersHandler.handle(it) } + response + .use { retrieveFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - private val retrieveMembersHandler: Handler = emptyHandler() + private val retrieveMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMembers( params: ListRetrieveMembersParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -108,16 +120,23 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveMembersHandler.handle(it) } + response + .use { retrieveMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - private val retrieveTweetsHandler: Handler = emptyHandler() + private val retrieveTweetsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveTweets( params: ListRetrieveTweetsParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -131,7 +150,13 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveTweetsHandler.handle(it) } + response + .use { retrieveTweetsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetService.kt index 6ef7d9f..400835b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetService.kt @@ -5,12 +5,9 @@ package com.x_twitter_scraper.api.services.blocking.x import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams @@ -22,8 +19,7 @@ import com.x_twitter_scraper.api.models.x.tweets.TweetGetRetweetersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadResponse import com.x_twitter_scraper.api.models.x.tweets.TweetListParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveResponse +import com.x_twitter_scraper.api.models.x.tweets.TweetListResponse import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse import com.x_twitter_scraper.api.services.blocking.x.tweets.LikeService @@ -44,10 +40,8 @@ interface TweetService { */ fun withOptions(modifier: Consumer): TweetService - /** X write actions (tweets, likes, follows, DMs) */ fun like(): LikeService - /** X write actions (tweets, likes, follows, DMs) */ fun retweet(): RetweetService /** Create tweet */ @@ -60,63 +54,14 @@ interface TweetService { requestOptions: RequestOptions = RequestOptions.none(), ): TweetCreateResponse - /** Look up tweet */ - fun retrieve(tweetId: String): TweetRetrieveResponse = - retrieve(tweetId, TweetRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): TweetRetrieveResponse = retrieve(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - ): TweetRetrieveResponse = retrieve(tweetId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TweetRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: TweetRetrieveParams): TweetRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(tweetId: String, requestOptions: RequestOptions): TweetRetrieveResponse = - retrieve(tweetId, TweetRetrieveParams.none(), requestOptions) - /** Get multiple tweets by IDs */ - fun list(params: TweetListParams) = list(params, RequestOptions.none()) + fun list(params: TweetListParams): TweetListResponse = list(params, RequestOptions.none()) /** @see list */ - fun list(params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Delete tweet */ - fun delete(tweetId: String, params: TweetDeleteParams): TweetDeleteResponse = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: TweetDeleteParams, + fun list( + params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): TweetDeleteResponse = delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: TweetDeleteParams): TweetDeleteResponse = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TweetDeleteResponse + ): TweetListResponse /** Get users who liked a tweet */ fun getFavoriters(id: String): TweetGetFavoritersResponse = @@ -291,10 +236,8 @@ interface TweetService { */ fun withOptions(modifier: Consumer): TweetService.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun like(): LikeService.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun retweet(): RetweetService.WithRawResponse /** @@ -312,94 +255,20 @@ interface TweetService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `get /x/tweets/{tweetId}`, but is otherwise the same as - * [TweetService.retrieve]. - */ - @MustBeClosed - fun retrieve(tweetId: String): HttpResponseFor = - retrieve(tweetId, TweetRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - tweetId: String, - params: TweetRetrieveParams = TweetRetrieveParams.none(), - ): HttpResponseFor = retrieve(tweetId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: TweetRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - tweetId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(tweetId, TweetRetrieveParams.none(), requestOptions) - /** * Returns a raw HTTP response for `get /x/tweets`, but is otherwise the same as * [TweetService.list]. */ @MustBeClosed - fun list(params: TweetListParams): HttpResponse = list(params, RequestOptions.none()) + fun list(params: TweetListParams): HttpResponseFor = + list(params, RequestOptions.none()) /** @see list */ @MustBeClosed fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}`, but is otherwise the same - * as [TweetService.delete]. - */ - @MustBeClosed - fun delete( - tweetId: String, - params: TweetDeleteParams, - ): HttpResponseFor = delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - tweetId: String, - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: TweetDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /x/tweets/{id}/favoriters`, but is otherwise the diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceImpl.kt index 63c6594..2c6b9b0 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -19,8 +18,6 @@ import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepare import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams @@ -32,8 +29,7 @@ import com.x_twitter_scraper.api.models.x.tweets.TweetGetRetweetersResponse import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetThreadResponse import com.x_twitter_scraper.api.models.x.tweets.TweetListParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveParams -import com.x_twitter_scraper.api.models.x.tweets.TweetRetrieveResponse +import com.x_twitter_scraper.api.models.x.tweets.TweetListResponse import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse import com.x_twitter_scraper.api.services.blocking.x.tweets.LikeService @@ -59,10 +55,8 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): TweetService = TweetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** X write actions (tweets, likes, follows, DMs) */ override fun like(): LikeService = like - /** X write actions (tweets, likes, follows, DMs) */ override fun retweet(): RetweetService = retweet override fun create( @@ -72,24 +66,9 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt // post /x/tweets withRawResponse().create(params, requestOptions).parse() - override fun retrieve( - params: TweetRetrieveParams, - requestOptions: RequestOptions, - ): TweetRetrieveResponse = - // get /x/tweets/{tweetId} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun list(params: TweetListParams, requestOptions: RequestOptions) { + override fun list(params: TweetListParams, requestOptions: RequestOptions): TweetListResponse = // get /x/tweets - withRawResponse().list(params, requestOptions) - } - - override fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions, - ): TweetDeleteResponse = - // delete /x/tweets/{tweetId} - withRawResponse().delete(params, requestOptions).parse() + withRawResponse().list(params, requestOptions).parse() override fun getFavoriters( params: TweetGetFavoritersParams, @@ -154,10 +133,8 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) - /** X write actions (tweets, likes, follows, DMs) */ override fun like(): LikeService.WithRawResponse = like - /** X write actions (tweets, likes, follows, DMs) */ override fun retweet(): RetweetService.WithRawResponse = retweet private val createHandler: Handler = @@ -188,39 +165,13 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun retrieve( - params: TweetRetrieveParams, + override fun list( + params: TweetListParams, requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = emptyHandler() - - override fun list(params: TweetListParams, requestOptions: RequestOptions): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -230,34 +181,9 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { listHandler.handle(it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { deleteHandler.handle(it) } + .use { listHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserService.kt index 6753f00..45f7229 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserService.kt @@ -5,24 +5,27 @@ package com.x_twitter_scraper.api.services.blocking.x import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveResponse +import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersResponse import com.x_twitter_scraper.api.services.blocking.x.users.FollowService import java.util.function.Consumer @@ -41,79 +44,51 @@ interface UserService { */ fun withOptions(modifier: Consumer): UserService - /** X write actions (tweets, likes, follows, DMs) */ fun follow(): FollowService - /** Look up X user */ - fun retrieve(username: String): UserRetrieveResponse = - retrieve(username, UserRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UserRetrieveResponse = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - ): UserRetrieveResponse = retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): UserRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: UserRetrieveParams): UserRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(username: String, requestOptions: RequestOptions): UserRetrieveResponse = - retrieve(username, UserRetrieveParams.none(), requestOptions) - /** Get multiple users by IDs */ - fun retrieveBatch(params: UserRetrieveBatchParams) = + fun retrieveBatch(params: UserRetrieveBatchParams): UserRetrieveBatchResponse = retrieveBatch(params, RequestOptions.none()) /** @see retrieveBatch */ fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveBatchResponse /** Get user followers */ - fun retrieveFollowers(id: String) = retrieveFollowers(id, UserRetrieveFollowersParams.none()) + fun retrieveFollowers(id: String): UserRetrieveFollowersResponse = + retrieveFollowers(id, UserRetrieveFollowersParams.none()) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) + ): UserRetrieveFollowersResponse = + retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ fun retrieveFollowers( id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), - ) = retrieveFollowers(id, params, RequestOptions.none()) + ): UserRetrieveFollowersResponse = retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveFollowersResponse /** @see retrieveFollowers */ - fun retrieveFollowers(params: UserRetrieveFollowersParams) = + fun retrieveFollowers(params: UserRetrieveFollowersParams): UserRetrieveFollowersResponse = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ - fun retrieveFollowers(id: String, requestOptions: RequestOptions) = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): UserRetrieveFollowersResponse = retrieveFollowers(id, UserRetrieveFollowersParams.none(), requestOptions) /** Get followers you know for a user */ @@ -155,33 +130,38 @@ interface UserService { retrieveFollowersYouKnow(id, UserRetrieveFollowersYouKnowParams.none(), requestOptions) /** Get users this user follows */ - fun retrieveFollowing(id: String) = retrieveFollowing(id, UserRetrieveFollowingParams.none()) + fun retrieveFollowing(id: String): UserRetrieveFollowingResponse = + retrieveFollowing(id, UserRetrieveFollowingParams.none()) /** @see retrieveFollowing */ fun retrieveFollowing( id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) + ): UserRetrieveFollowingResponse = + retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowing */ fun retrieveFollowing( id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), - ) = retrieveFollowing(id, params, RequestOptions.none()) + ): UserRetrieveFollowingResponse = retrieveFollowing(id, params, RequestOptions.none()) /** @see retrieveFollowing */ fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveFollowingResponse /** @see retrieveFollowing */ - fun retrieveFollowing(params: UserRetrieveFollowingParams) = + fun retrieveFollowing(params: UserRetrieveFollowingParams): UserRetrieveFollowingResponse = retrieveFollowing(params, RequestOptions.none()) /** @see retrieveFollowing */ - fun retrieveFollowing(id: String, requestOptions: RequestOptions) = + fun retrieveFollowing( + id: String, + requestOptions: RequestOptions, + ): UserRetrieveFollowingResponse = retrieveFollowing(id, UserRetrieveFollowingParams.none(), requestOptions) /** Get tweets liked by a user */ @@ -247,44 +227,46 @@ interface UserService { retrieveMedia(id, UserRetrieveMediaParams.none(), requestOptions) /** Get tweets mentioning a user */ - fun retrieveMentions(id: String) = retrieveMentions(id, UserRetrieveMentionsParams.none()) + fun retrieveMentions(id: String): UserRetrieveMentionsResponse = + retrieveMentions(id, UserRetrieveMentionsParams.none()) /** @see retrieveMentions */ fun retrieveMentions( id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveMentions(params.toBuilder().id(id).build(), requestOptions) + ): UserRetrieveMentionsResponse = + retrieveMentions(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMentions */ fun retrieveMentions( id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), - ) = retrieveMentions(id, params, RequestOptions.none()) + ): UserRetrieveMentionsResponse = retrieveMentions(id, params, RequestOptions.none()) /** @see retrieveMentions */ fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveMentionsResponse /** @see retrieveMentions */ - fun retrieveMentions(params: UserRetrieveMentionsParams) = + fun retrieveMentions(params: UserRetrieveMentionsParams): UserRetrieveMentionsResponse = retrieveMentions(params, RequestOptions.none()) /** @see retrieveMentions */ - fun retrieveMentions(id: String, requestOptions: RequestOptions) = + fun retrieveMentions(id: String, requestOptions: RequestOptions): UserRetrieveMentionsResponse = retrieveMentions(id, UserRetrieveMentionsParams.none(), requestOptions) /** Search users by name or username */ - fun retrieveSearch(params: UserRetrieveSearchParams) = + fun retrieveSearch(params: UserRetrieveSearchParams): UserRetrieveSearchResponse = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveSearchResponse /** Get recent tweets by a user */ fun retrieveTweets(id: String): UserRetrieveTweetsResponse = @@ -319,7 +301,7 @@ interface UserService { retrieveTweets(id, UserRetrieveTweetsParams.none(), requestOptions) /** Get verified followers */ - fun retrieveVerifiedFollowers(id: String) = + fun retrieveVerifiedFollowers(id: String): UserRetrieveVerifiedFollowersResponse = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none()) /** @see retrieveVerifiedFollowers */ @@ -327,26 +309,33 @@ interface UserService { id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ) = retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) + ): UserRetrieveVerifiedFollowersResponse = + retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), - ) = retrieveVerifiedFollowers(id, params, RequestOptions.none()) + ): UserRetrieveVerifiedFollowersResponse = + retrieveVerifiedFollowers(id, params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ) + ): UserRetrieveVerifiedFollowersResponse /** @see retrieveVerifiedFollowers */ - fun retrieveVerifiedFollowers(params: UserRetrieveVerifiedFollowersParams) = + fun retrieveVerifiedFollowers( + params: UserRetrieveVerifiedFollowersParams + ): UserRetrieveVerifiedFollowersResponse = retrieveVerifiedFollowers(params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ - fun retrieveVerifiedFollowers(id: String, requestOptions: RequestOptions) = + fun retrieveVerifiedFollowers( + id: String, + requestOptions: RequestOptions, + ): UserRetrieveVerifiedFollowersResponse = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none(), requestOptions) /** A view of [UserService] that provides access to raw HTTP responses for each method. */ @@ -359,74 +348,30 @@ interface UserService { */ fun withOptions(modifier: Consumer): UserService.WithRawResponse - /** X write actions (tweets, likes, follows, DMs) */ fun follow(): FollowService.WithRawResponse - /** - * Returns a raw HTTP response for `get /x/users/{username}`, but is otherwise the same as - * [UserService.retrieve]. - */ - @MustBeClosed - fun retrieve(username: String): HttpResponseFor = - retrieve(username, UserRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().username(username).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - params: UserRetrieveParams = UserRetrieveParams.none(), - ): HttpResponseFor = retrieve(username, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: UserRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - username: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(username, UserRetrieveParams.none(), requestOptions) - /** * Returns a raw HTTP response for `get /x/users/batch`, but is otherwise the same as * [UserService.retrieveBatch]. */ @MustBeClosed - fun retrieveBatch(params: UserRetrieveBatchParams): HttpResponse = - retrieveBatch(params, RequestOptions.none()) + fun retrieveBatch( + params: UserRetrieveBatchParams + ): HttpResponseFor = retrieveBatch(params, RequestOptions.none()) /** @see retrieveBatch */ @MustBeClosed fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** * Returns a raw HTTP response for `get /x/users/{id}/followers`, but is otherwise the same * as [UserService.retrieveFollowers]. */ @MustBeClosed - fun retrieveFollowers(id: String): HttpResponse = + fun retrieveFollowers(id: String): HttpResponseFor = retrieveFollowers(id, UserRetrieveFollowersParams.none()) /** @see retrieveFollowers */ @@ -435,30 +380,37 @@ interface UserService { id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowers */ @MustBeClosed fun retrieveFollowers( id: String, params: UserRetrieveFollowersParams = UserRetrieveFollowersParams.none(), - ): HttpResponse = retrieveFollowers(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveFollowers(id, params, RequestOptions.none()) /** @see retrieveFollowers */ @MustBeClosed fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveFollowers */ @MustBeClosed - fun retrieveFollowers(params: UserRetrieveFollowersParams): HttpResponse = + fun retrieveFollowers( + params: UserRetrieveFollowersParams + ): HttpResponseFor = retrieveFollowers(params, RequestOptions.none()) /** @see retrieveFollowers */ @MustBeClosed - fun retrieveFollowers(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveFollowers( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveFollowers(id, UserRetrieveFollowersParams.none(), requestOptions) /** @@ -515,7 +467,7 @@ interface UserService { * as [UserService.retrieveFollowing]. */ @MustBeClosed - fun retrieveFollowing(id: String): HttpResponse = + fun retrieveFollowing(id: String): HttpResponseFor = retrieveFollowing(id, UserRetrieveFollowingParams.none()) /** @see retrieveFollowing */ @@ -524,30 +476,37 @@ interface UserService { id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveFollowing(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveFollowing */ @MustBeClosed fun retrieveFollowing( id: String, params: UserRetrieveFollowingParams = UserRetrieveFollowingParams.none(), - ): HttpResponse = retrieveFollowing(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveFollowing(id, params, RequestOptions.none()) /** @see retrieveFollowing */ @MustBeClosed fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveFollowing */ @MustBeClosed - fun retrieveFollowing(params: UserRetrieveFollowingParams): HttpResponse = + fun retrieveFollowing( + params: UserRetrieveFollowingParams + ): HttpResponseFor = retrieveFollowing(params, RequestOptions.none()) /** @see retrieveFollowing */ @MustBeClosed - fun retrieveFollowing(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveFollowing( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveFollowing(id, UserRetrieveFollowingParams.none(), requestOptions) /** @@ -647,7 +606,7 @@ interface UserService { * as [UserService.retrieveMentions]. */ @MustBeClosed - fun retrieveMentions(id: String): HttpResponse = + fun retrieveMentions(id: String): HttpResponseFor = retrieveMentions(id, UserRetrieveMentionsParams.none()) /** @see retrieveMentions */ @@ -656,30 +615,37 @@ interface UserService { id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = retrieveMentions(params.toBuilder().id(id).build(), requestOptions) + ): HttpResponseFor = + retrieveMentions(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveMentions */ @MustBeClosed fun retrieveMentions( id: String, params: UserRetrieveMentionsParams = UserRetrieveMentionsParams.none(), - ): HttpResponse = retrieveMentions(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveMentions(id, params, RequestOptions.none()) /** @see retrieveMentions */ @MustBeClosed fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveMentions */ @MustBeClosed - fun retrieveMentions(params: UserRetrieveMentionsParams): HttpResponse = + fun retrieveMentions( + params: UserRetrieveMentionsParams + ): HttpResponseFor = retrieveMentions(params, RequestOptions.none()) /** @see retrieveMentions */ @MustBeClosed - fun retrieveMentions(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveMentions( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveMentions(id, UserRetrieveMentionsParams.none(), requestOptions) /** @@ -687,7 +653,9 @@ interface UserService { * [UserService.retrieveSearch]. */ @MustBeClosed - fun retrieveSearch(params: UserRetrieveSearchParams): HttpResponse = + fun retrieveSearch( + params: UserRetrieveSearchParams + ): HttpResponseFor = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ @@ -695,7 +663,7 @@ interface UserService { fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** * Returns a raw HTTP response for `get /x/users/{id}/tweets`, but is otherwise the same as @@ -749,7 +717,9 @@ interface UserService { * the same as [UserService.retrieveVerifiedFollowers]. */ @MustBeClosed - fun retrieveVerifiedFollowers(id: String): HttpResponse = + fun retrieveVerifiedFollowers( + id: String + ): HttpResponseFor = retrieveVerifiedFollowers(id, UserRetrieveVerifiedFollowersParams.none()) /** @see retrieveVerifiedFollowers */ @@ -759,7 +729,7 @@ interface UserService { params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = + ): HttpResponseFor = retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveVerifiedFollowers */ @@ -767,23 +737,29 @@ interface UserService { fun retrieveVerifiedFollowers( id: String, params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), - ): HttpResponse = retrieveVerifiedFollowers(id, params, RequestOptions.none()) + ): HttpResponseFor = + retrieveVerifiedFollowers(id, params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ @MustBeClosed fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor /** @see retrieveVerifiedFollowers */ @MustBeClosed - fun retrieveVerifiedFollowers(params: UserRetrieveVerifiedFollowersParams): HttpResponse = + fun retrieveVerifiedFollowers( + params: UserRetrieveVerifiedFollowersParams + ): HttpResponseFor = retrieveVerifiedFollowers(params, RequestOptions.none()) /** @see retrieveVerifiedFollowers */ @MustBeClosed - fun retrieveVerifiedFollowers(id: String, requestOptions: RequestOptions): HttpResponse = + fun retrieveVerifiedFollowers( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = retrieveVerifiedFollowers( id, UserRetrieveVerifiedFollowersParams.none(), diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceImpl.kt index 9357c30..d280bb5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceImpl.kt @@ -5,7 +5,6 @@ package com.x_twitter_scraper.api.services.blocking.x import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler import com.x_twitter_scraper.api.core.handlers.jsonHandler @@ -17,21 +16,25 @@ import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepare import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveBatchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowersYouKnowResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveFollowingResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveLikesResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveMediaResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveParams -import com.x_twitter_scraper.api.models.x.users.UserRetrieveResponse +import com.x_twitter_scraper.api.models.x.users.UserRetrieveMentionsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveSearchResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersParams +import com.x_twitter_scraper.api.models.x.users.UserRetrieveVerifiedFollowersResponse import com.x_twitter_scraper.api.services.blocking.x.users.FollowService import com.x_twitter_scraper.api.services.blocking.x.users.FollowServiceImpl import java.util.function.Consumer @@ -51,28 +54,21 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): UserService = UserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - /** X write actions (tweets, likes, follows, DMs) */ override fun follow(): FollowService = follow - override fun retrieve( - params: UserRetrieveParams, + override fun retrieveBatch( + params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): UserRetrieveResponse = - // get /x/users/{username} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun retrieveBatch(params: UserRetrieveBatchParams, requestOptions: RequestOptions) { + ): UserRetrieveBatchResponse = // get /x/users/batch - withRawResponse().retrieveBatch(params, requestOptions) - } + withRawResponse().retrieveBatch(params, requestOptions).parse() override fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions, - ) { + ): UserRetrieveFollowersResponse = // get /x/users/{id}/followers - withRawResponse().retrieveFollowers(params, requestOptions) - } + withRawResponse().retrieveFollowers(params, requestOptions).parse() override fun retrieveFollowersYouKnow( params: UserRetrieveFollowersYouKnowParams, @@ -84,10 +80,9 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions, - ) { + ): UserRetrieveFollowingResponse = // get /x/users/{id}/following - withRawResponse().retrieveFollowing(params, requestOptions) - } + withRawResponse().retrieveFollowing(params, requestOptions).parse() override fun retrieveLikes( params: UserRetrieveLikesParams, @@ -106,15 +101,16 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions, - ) { + ): UserRetrieveMentionsResponse = // get /x/users/{id}/mentions - withRawResponse().retrieveMentions(params, requestOptions) - } + withRawResponse().retrieveMentions(params, requestOptions).parse() - override fun retrieveSearch(params: UserRetrieveSearchParams, requestOptions: RequestOptions) { + override fun retrieveSearch( + params: UserRetrieveSearchParams, + requestOptions: RequestOptions, + ): UserRetrieveSearchResponse = // get /x/users/search - withRawResponse().retrieveSearch(params, requestOptions) - } + withRawResponse().retrieveSearch(params, requestOptions).parse() override fun retrieveTweets( params: UserRetrieveTweetsParams, @@ -126,10 +122,9 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions, - ) { + ): UserRetrieveVerifiedFollowersResponse = // get /x/users/{id}/verified-followers - withRawResponse().retrieveVerifiedFollowers(params, requestOptions) - } + withRawResponse().retrieveVerifiedFollowers(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : UserService.WithRawResponse { @@ -148,31 +143,27 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - /** X write actions (tweets, likes, follows, DMs) */ override fun follow(): FollowService.WithRawResponse = follow - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveBatchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun retrieve( - params: UserRetrieveParams, + override fun retrieveBatch( + params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("username", params.username().getOrNull()) + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0)) + .addPathSegments("x", "users", "batch") .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { retrieveHandler.handle(it) } + .use { retrieveBatchHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -181,32 +172,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val retrieveBatchHandler: Handler = emptyHandler() - - override fun retrieveBatch( - params: UserRetrieveBatchParams, - requestOptions: RequestOptions, - ): HttpResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", "batch") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { retrieveBatchHandler.handle(it) } - } - } - - private val retrieveFollowersHandler: Handler = emptyHandler() + private val retrieveFollowersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowers( params: UserRetrieveFollowersParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -220,7 +192,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveFollowersHandler.handle(it) } + response + .use { retrieveFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } @@ -254,12 +232,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val retrieveFollowingHandler: Handler = emptyHandler() + private val retrieveFollowingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveFollowing( params: UserRetrieveFollowingParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -273,7 +252,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveFollowingHandler.handle(it) } + response + .use { retrieveFollowingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } @@ -337,12 +322,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val retrieveMentionsHandler: Handler = emptyHandler() + private val retrieveMentionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveMentions( params: UserRetrieveMentionsParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -356,16 +342,23 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveMentionsHandler.handle(it) } + response + .use { retrieveMentionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - private val retrieveSearchHandler: Handler = emptyHandler() + private val retrieveSearchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveSearch( params: UserRetrieveSearchParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -376,7 +369,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveSearchHandler.handle(it) } + response + .use { retrieveSearchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } @@ -410,12 +409,14 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val retrieveVerifiedFollowersHandler: Handler = emptyHandler() + private val retrieveVerifiedFollowersHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveVerifiedFollowers( params: UserRetrieveVerifiedFollowersParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("id", params.id().getOrNull()) @@ -429,7 +430,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { retrieveVerifiedFollowersHandler.handle(it) } + response + .use { retrieveVerifiedFollowersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetService.kt index f4810c2..2934bc5 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetService.kt @@ -5,8 +5,9 @@ package com.x_twitter_scraper.api.services.blocking.x.communities import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponse +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListParams +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListResponse import java.util.function.Consumer /** X data lookups (subscription required) */ @@ -25,10 +26,13 @@ interface TweetService { fun withOptions(modifier: Consumer): TweetService /** Search tweets across all communities */ - fun list(params: TweetListParams) = list(params, RequestOptions.none()) + fun list(params: TweetListParams): TweetListResponse = list(params, RequestOptions.none()) /** @see list */ - fun list(params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none()) + fun list( + params: TweetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TweetListResponse /** A view of [TweetService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -45,13 +49,14 @@ interface TweetService { * [TweetService.list]. */ @MustBeClosed - fun list(params: TweetListParams): HttpResponse = list(params, RequestOptions.none()) + fun list(params: TweetListParams): HttpResponseFor = + list(params, RequestOptions.none()) /** @see list */ @MustBeClosed fun list( params: TweetListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse + ): HttpResponseFor } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceImpl.kt index 4e52502..587e610 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceImpl.kt @@ -4,16 +4,18 @@ package com.x_twitter_scraper.api.services.blocking.x.communities import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.handlers.emptyHandler import com.x_twitter_scraper.api.core.handlers.errorBodyHandler import com.x_twitter_scraper.api.core.handlers.errorHandler +import com.x_twitter_scraper.api.core.handlers.jsonHandler import com.x_twitter_scraper.api.core.http.HttpMethod import com.x_twitter_scraper.api.core.http.HttpRequest import com.x_twitter_scraper.api.core.http.HttpResponse import com.x_twitter_scraper.api.core.http.HttpResponse.Handler +import com.x_twitter_scraper.api.core.http.HttpResponseFor import com.x_twitter_scraper.api.core.http.parseable import com.x_twitter_scraper.api.core.prepare import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListParams +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListResponse import java.util.function.Consumer /** X data lookups (subscription required) */ @@ -29,10 +31,9 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): TweetService = TweetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun list(params: TweetListParams, requestOptions: RequestOptions) { + override fun list(params: TweetListParams, requestOptions: RequestOptions): TweetListResponse = // get /x/communities/tweets - withRawResponse().list(params, requestOptions) - } + withRawResponse().list(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TweetService.WithRawResponse { @@ -47,9 +48,13 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler = emptyHandler() + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun list(params: TweetListParams, requestOptions: RequestOptions): HttpResponse { + override fun list( + params: TweetListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -60,7 +65,13 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response.use { listHandler.handle(it) } + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeService.kt index 5ad5719..3c39ee0 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeService.kt @@ -2,17 +2,9 @@ package com.x_twitter_scraper.api.services.blocking.x.tweets -import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteResponse import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface LikeService { /** @@ -27,46 +19,6 @@ interface LikeService { */ fun withOptions(modifier: Consumer): LikeService - /** Like tweet */ - fun create(tweetId: String, params: LikeCreateParams): LikeCreateResponse = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): LikeCreateResponse = create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create(params: LikeCreateParams): LikeCreateResponse = create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): LikeCreateResponse - - /** Unlike tweet */ - fun delete(tweetId: String, params: LikeDeleteParams): LikeDeleteResponse = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): LikeDeleteResponse = delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: LikeDeleteParams): LikeDeleteResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): LikeDeleteResponse - /** A view of [LikeService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -76,63 +28,5 @@ interface LikeService { * The original service is not modified. */ fun withOptions(modifier: Consumer): LikeService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/tweets/{tweetId}/like`, but is otherwise the - * same as [LikeService.create]. - */ - @MustBeClosed - fun create(tweetId: String, params: LikeCreateParams): HttpResponseFor = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - tweetId: String, - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - @MustBeClosed - fun create(params: LikeCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: LikeCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}/like`, but is otherwise the - * same as [LikeService.delete]. - */ - @MustBeClosed - fun delete(tweetId: String, params: LikeDeleteParams): HttpResponseFor = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - tweetId: String, - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: LikeDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceImpl.kt index 84095df..4390064 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceImpl.kt @@ -3,27 +3,8 @@ package com.x_twitter_scraper.api.services.blocking.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepare -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteResponse import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class LikeServiceImpl internal constructor(private val clientOptions: ClientOptions) : LikeService { private val withRawResponse: LikeService.WithRawResponse by lazy { @@ -35,93 +16,14 @@ class LikeServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): LikeService = LikeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: LikeCreateParams, - requestOptions: RequestOptions, - ): LikeCreateResponse = - // post /x/tweets/{tweetId}/like - withRawResponse().create(params, requestOptions).parse() - - override fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions, - ): LikeDeleteResponse = - // delete /x/tweets/{tweetId}/like - withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : LikeService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): LikeService.WithRawResponse = LikeServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: LikeCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "like") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: LikeDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "like") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetService.kt index ba2e3f9..4626a84 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetService.kt @@ -2,17 +2,9 @@ package com.x_twitter_scraper.api.services.blocking.x.tweets -import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteResponse import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface RetweetService { /** @@ -27,48 +19,6 @@ interface RetweetService { */ fun withOptions(modifier: Consumer): RetweetService - /** Retweet */ - fun create(tweetId: String, params: RetweetCreateParams): RetweetCreateResponse = - create(tweetId, params, RequestOptions.none()) - - /** @see create */ - fun create( - tweetId: String, - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): RetweetCreateResponse = create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - fun create(params: RetweetCreateParams): RetweetCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): RetweetCreateResponse - - /** Unretweet */ - fun delete(tweetId: String, params: RetweetDeleteParams): RetweetDeleteResponse = - delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tweetId: String, - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): RetweetDeleteResponse = delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - fun delete(params: RetweetDeleteParams): RetweetDeleteResponse = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): RetweetDeleteResponse - /** A view of [RetweetService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -78,67 +28,5 @@ interface RetweetService { * The original service is not modified. */ fun withOptions(modifier: Consumer): RetweetService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/tweets/{tweetId}/retweet`, but is otherwise the - * same as [RetweetService.create]. - */ - @MustBeClosed - fun create( - tweetId: String, - params: RetweetCreateParams, - ): HttpResponseFor = create(tweetId, params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - tweetId: String, - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - create(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see create */ - @MustBeClosed - fun create(params: RetweetCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `delete /x/tweets/{tweetId}/retweet`, but is otherwise - * the same as [RetweetService.delete]. - */ - @MustBeClosed - fun delete( - tweetId: String, - params: RetweetDeleteParams, - ): HttpResponseFor = delete(tweetId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - tweetId: String, - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - delete(params.toBuilder().tweetId(tweetId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: RetweetDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceImpl.kt index 8141286..56af3ed 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceImpl.kt @@ -3,27 +3,8 @@ package com.x_twitter_scraper.api.services.blocking.x.tweets import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepare -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateResponse -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteResponse import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class RetweetServiceImpl internal constructor(private val clientOptions: ClientOptions) : RetweetService { @@ -36,93 +17,14 @@ class RetweetServiceImpl internal constructor(private val clientOptions: ClientO override fun withOptions(modifier: Consumer): RetweetService = RetweetServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions, - ): RetweetCreateResponse = - // post /x/tweets/{tweetId}/retweet - withRawResponse().create(params, requestOptions).parse() - - override fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions, - ): RetweetDeleteResponse = - // delete /x/tweets/{tweetId}/retweet - withRawResponse().delete(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RetweetService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): RetweetService.WithRawResponse = RetweetServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: RetweetCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "retweet") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: RetweetDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tweetId", params.tweetId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "tweets", params._pathParam(0), "retweet") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowService.kt index 06f7be6..04ac972 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowService.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowService.kt @@ -2,17 +2,9 @@ package com.x_twitter_scraper.api.services.blocking.x.users -import com.google.errorprone.annotations.MustBeClosed import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateResponse -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllResponse import java.util.function.Consumer -/** X write actions (tweets, likes, follows, DMs) */ interface FollowService { /** @@ -27,49 +19,6 @@ interface FollowService { */ fun withOptions(modifier: Consumer): FollowService - /** Follow user */ - fun create(userId: String, params: FollowCreateParams): FollowCreateResponse = - create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FollowCreateResponse = create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create(params: FollowCreateParams): FollowCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FollowCreateResponse - - /** Unfollow user */ - fun deleteAll(userId: String, params: FollowDeleteAllParams): FollowDeleteAllResponse = - deleteAll(userId, params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FollowDeleteAllResponse = - deleteAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see deleteAll */ - fun deleteAll(params: FollowDeleteAllParams): FollowDeleteAllResponse = - deleteAll(params, RequestOptions.none()) - - /** @see deleteAll */ - fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): FollowDeleteAllResponse - /** A view of [FollowService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -79,68 +28,5 @@ interface FollowService { * The original service is not modified. */ fun withOptions(modifier: Consumer): FollowService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /x/users/{userId}/follow`, but is otherwise the - * same as [FollowService.create]. - */ - @MustBeClosed - fun create( - userId: String, - params: FollowCreateParams, - ): HttpResponseFor = create(userId, params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - userId: String, - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - @MustBeClosed - fun create(params: FollowCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: FollowCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `delete /x/users/{userId}/follow`, but is otherwise the - * same as [FollowService.deleteAll]. - */ - @MustBeClosed - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - ): HttpResponseFor = - deleteAll(userId, params, RequestOptions.none()) - - /** @see deleteAll */ - @MustBeClosed - fun deleteAll( - userId: String, - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - deleteAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see deleteAll */ - @MustBeClosed - fun deleteAll(params: FollowDeleteAllParams): HttpResponseFor = - deleteAll(params, RequestOptions.none()) - - /** @see deleteAll */ - @MustBeClosed - fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceImpl.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceImpl.kt index 48e1435..40cd15b 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceImpl.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceImpl.kt @@ -3,27 +3,8 @@ package com.x_twitter_scraper.api.services.blocking.x.users import com.x_twitter_scraper.api.core.ClientOptions -import com.x_twitter_scraper.api.core.RequestOptions -import com.x_twitter_scraper.api.core.checkRequired -import com.x_twitter_scraper.api.core.handlers.errorBodyHandler -import com.x_twitter_scraper.api.core.handlers.errorHandler -import com.x_twitter_scraper.api.core.handlers.jsonHandler -import com.x_twitter_scraper.api.core.http.HttpMethod -import com.x_twitter_scraper.api.core.http.HttpRequest -import com.x_twitter_scraper.api.core.http.HttpResponse -import com.x_twitter_scraper.api.core.http.HttpResponse.Handler -import com.x_twitter_scraper.api.core.http.HttpResponseFor -import com.x_twitter_scraper.api.core.http.json -import com.x_twitter_scraper.api.core.http.parseable -import com.x_twitter_scraper.api.core.prepare -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateResponse -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllResponse import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull -/** X write actions (tweets, likes, follows, DMs) */ class FollowServiceImpl internal constructor(private val clientOptions: ClientOptions) : FollowService { @@ -36,93 +17,14 @@ class FollowServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): FollowService = FollowServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun create( - params: FollowCreateParams, - requestOptions: RequestOptions, - ): FollowCreateResponse = - // post /x/users/{userId}/follow - withRawResponse().create(params, requestOptions).parse() - - override fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions, - ): FollowDeleteAllResponse = - // delete /x/users/{userId}/follow - withRawResponse().deleteAll(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : FollowService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - override fun withOptions( modifier: Consumer ): FollowService.WithRawResponse = FollowServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: FollowCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0), "follow") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteAllHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun deleteAll( - params: FollowDeleteAllParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("x", "users", params._pathParam(0), "follow") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { deleteAllHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/ErrorTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/ErrorTest.kt index e31aa49..72fa3eb 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/ErrorTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/ErrorTest.kt @@ -11,15 +11,15 @@ internal class ErrorTest { @Test fun create() { - val error = Error.builder().error(Error.InnerError.INTERNAL_ERROR).build() + val error = Error.builder().error(Error.InnerError.INVALID_INPUT).build() - assertThat(error.error()).isEqualTo(Error.InnerError.INTERNAL_ERROR) + assertThat(error.error()).isEqualTo(Error.InnerError.INVALID_INPUT) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val error = Error.builder().error(Error.InnerError.INTERNAL_ERROR).build() + val error = Error.builder().error(Error.InnerError.INVALID_INPUT).build() val roundtrippedError = jsonMapper.readValue(jsonMapper.writeValueAsString(error), jacksonTypeRef()) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedTweetsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedTweetsTest.kt index 92fc50f..37604f5 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedTweetsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedTweetsTest.kt @@ -14,52 +14,54 @@ internal class PaginatedTweetsTest { val paginatedTweets = PaginatedTweets.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( PaginatedTweets.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( PaginatedTweets.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(paginatedTweets.hasNextPage()).isEqualTo(true) - assertThat(paginatedTweets.nextCursor()).isEqualTo("next_cursor") + assertThat(paginatedTweets.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(paginatedTweets.tweets()) .containsExactly( PaginatedTweets.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( PaginatedTweets.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class PaginatedTweetsTest { val paginatedTweets = PaginatedTweets.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( PaginatedTweets.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( PaginatedTweets.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedUsersTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedUsersTest.kt index c3296b8..60386f0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedUsersTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/PaginatedUsersTest.kt @@ -14,39 +14,39 @@ internal class PaginatedUsersTest { val paginatedUsers = PaginatedUsers.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( PaginatedUsers.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) .build() assertThat(paginatedUsers.hasNextPage()).isEqualTo(true) - assertThat(paginatedUsers.nextCursor()).isEqualTo("next_cursor") + assertThat(paginatedUsers.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(paginatedUsers.users()) .containsExactly( PaginatedUsers.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) @@ -58,19 +58,19 @@ internal class PaginatedUsersTest { val paginatedUsers = PaginatedUsers.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( PaginatedUsers.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountRetrieveResponseTest.kt index 88dd5cd..16782c2 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountRetrieveResponseTest.kt @@ -14,27 +14,27 @@ internal class AccountRetrieveResponseTest { fun create() { val accountRetrieveResponse = AccountRetrieveResponse.builder() - .monitorsAllowed(0L) - .monitorsUsed(0L) + .monitorsAllowed(10L) + .monitorsUsed(3L) .plan(AccountRetrieveResponse.Plan.ACTIVE) .currentPeriod( AccountRetrieveResponse.CurrentPeriod.builder() - .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .usagePercent(0.0) + .end(OffsetDateTime.parse("2025-02-01T00:00:00Z")) + .start(OffsetDateTime.parse("2025-01-01T00:00:00Z")) + .usagePercent(42.5) .build() ) .build() - assertThat(accountRetrieveResponse.monitorsAllowed()).isEqualTo(0L) - assertThat(accountRetrieveResponse.monitorsUsed()).isEqualTo(0L) + assertThat(accountRetrieveResponse.monitorsAllowed()).isEqualTo(10L) + assertThat(accountRetrieveResponse.monitorsUsed()).isEqualTo(3L) assertThat(accountRetrieveResponse.plan()).isEqualTo(AccountRetrieveResponse.Plan.ACTIVE) assertThat(accountRetrieveResponse.currentPeriod()) .contains( AccountRetrieveResponse.CurrentPeriod.builder() - .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .usagePercent(0.0) + .end(OffsetDateTime.parse("2025-02-01T00:00:00Z")) + .start(OffsetDateTime.parse("2025-01-01T00:00:00Z")) + .usagePercent(42.5) .build() ) } @@ -44,14 +44,14 @@ internal class AccountRetrieveResponseTest { val jsonMapper = jsonMapper() val accountRetrieveResponse = AccountRetrieveResponse.builder() - .monitorsAllowed(0L) - .monitorsUsed(0L) + .monitorsAllowed(10L) + .monitorsUsed(3L) .plan(AccountRetrieveResponse.Plan.ACTIVE) .currentPeriod( AccountRetrieveResponse.CurrentPeriod.builder() - .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .usagePercent(0.0) + .end(OffsetDateTime.parse("2025-02-01T00:00:00Z")) + .start(OffsetDateTime.parse("2025-01-01T00:00:00Z")) + .usagePercent(42.5) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameParamsTest.kt index f0d6108..11889d0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameParamsTest.kt @@ -9,15 +9,15 @@ internal class AccountSetXUsernameParamsTest { @Test fun create() { - AccountSetXUsernameParams.builder().username("username").build() + AccountSetXUsernameParams.builder().username("elonmusk").build() } @Test fun body() { - val params = AccountSetXUsernameParams.builder().username("username").build() + val params = AccountSetXUsernameParams.builder().username("elonmusk").build() val body = params._body() - assertThat(body.username()).isEqualTo("username") + assertThat(body.username()).isEqualTo("elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameResponseTest.kt index fbe3e92..f9025e5 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/account/AccountSetXUsernameResponseTest.kt @@ -12,16 +12,16 @@ internal class AccountSetXUsernameResponseTest { @Test fun create() { val accountSetXUsernameResponse = - AccountSetXUsernameResponse.builder().xUsername("xUsername").build() + AccountSetXUsernameResponse.builder().xUsername("elonmusk").build() - assertThat(accountSetXUsernameResponse.xUsername()).isEqualTo("xUsername") + assertThat(accountSetXUsernameResponse.xUsername()).isEqualTo("elonmusk") } @Test fun roundtrip() { val jsonMapper = jsonMapper() val accountSetXUsernameResponse = - AccountSetXUsernameResponse.builder().xUsername("xUsername").build() + AccountSetXUsernameResponse.builder().xUsername("elonmusk").build() val roundtrippedAccountSetXUsernameResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateParamsTest.kt index c68655e..937150f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateParamsTest.kt @@ -9,16 +9,16 @@ internal class ApiKeyCreateParamsTest { @Test fun create() { - ApiKeyCreateParams.builder().name("name").build() + ApiKeyCreateParams.builder().name("My API Key").build() } @Test fun body() { - val params = ApiKeyCreateParams.builder().name("name").build() + val params = ApiKeyCreateParams.builder().name("My API Key").build() val body = params._body() - assertThat(body.name()).contains("name") + assertThat(body.name()).contains("My API Key") } @Test diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateResponseTest.kt index a76ab02..d779862 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyCreateResponseTest.kt @@ -14,19 +14,19 @@ internal class ApiKeyCreateResponseTest { fun create() { val apiKeyCreateResponse = ApiKeyCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .fullKey("fullKey") - .name("name") - .prefix("prefix") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .fullKey("xq_live_abc123def456") + .name("My API Key") + .prefix("xq_live_abc1") .build() - assertThat(apiKeyCreateResponse.id()).isEqualTo("id") + assertThat(apiKeyCreateResponse.id()).isEqualTo("42") assertThat(apiKeyCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKeyCreateResponse.fullKey()).isEqualTo("fullKey") - assertThat(apiKeyCreateResponse.name()).isEqualTo("name") - assertThat(apiKeyCreateResponse.prefix()).isEqualTo("prefix") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(apiKeyCreateResponse.fullKey()).isEqualTo("xq_live_abc123def456") + assertThat(apiKeyCreateResponse.name()).isEqualTo("My API Key") + assertThat(apiKeyCreateResponse.prefix()).isEqualTo("xq_live_abc1") } @Test @@ -34,11 +34,11 @@ internal class ApiKeyCreateResponseTest { val jsonMapper = jsonMapper() val apiKeyCreateResponse = ApiKeyCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .fullKey("fullKey") - .name("name") - .prefix("prefix") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .fullKey("xq_live_abc123def456") + .name("My API Key") + .prefix("xq_live_abc1") .build() val roundtrippedApiKeyCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateParamsTest.kt index f64ba9a..81874f5 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateParamsTest.kt @@ -11,16 +11,16 @@ internal class ComposeCreateParamsTest { fun create() { ComposeCreateParams.builder() .step(ComposeCreateParams.Step.COMPOSE) - .additionalContext("additionalContext") - .callToAction("callToAction") - .draft("draft") + .additionalContext("https://x.com/elonmusk/status/1234567890") + .callToAction("Follow for more") + .draft("AI is changing everything. Here's why.") .goal(ComposeCreateParams.Goal.ENGAGEMENT) - .hasLink(true) - .hasMedia(true) - .mediaType(ComposeCreateParams.MediaType.PHOTO) - .styleUsername("styleUsername") - .tone("tone") - .topic("topic") + .hasLink(false) + .hasMedia(false) + .mediaType(ComposeCreateParams.MediaType.NONE) + .styleUsername("elonmusk") + .tone("professional") + .topic("AI trends in 2025") .build() } @@ -29,31 +29,31 @@ internal class ComposeCreateParamsTest { val params = ComposeCreateParams.builder() .step(ComposeCreateParams.Step.COMPOSE) - .additionalContext("additionalContext") - .callToAction("callToAction") - .draft("draft") + .additionalContext("https://x.com/elonmusk/status/1234567890") + .callToAction("Follow for more") + .draft("AI is changing everything. Here's why.") .goal(ComposeCreateParams.Goal.ENGAGEMENT) - .hasLink(true) - .hasMedia(true) - .mediaType(ComposeCreateParams.MediaType.PHOTO) - .styleUsername("styleUsername") - .tone("tone") - .topic("topic") + .hasLink(false) + .hasMedia(false) + .mediaType(ComposeCreateParams.MediaType.NONE) + .styleUsername("elonmusk") + .tone("professional") + .topic("AI trends in 2025") .build() val body = params._body() assertThat(body.step()).isEqualTo(ComposeCreateParams.Step.COMPOSE) - assertThat(body.additionalContext()).contains("additionalContext") - assertThat(body.callToAction()).contains("callToAction") - assertThat(body.draft()).contains("draft") + assertThat(body.additionalContext()).contains("https://x.com/elonmusk/status/1234567890") + assertThat(body.callToAction()).contains("Follow for more") + assertThat(body.draft()).contains("AI is changing everything. Here's why.") assertThat(body.goal()).contains(ComposeCreateParams.Goal.ENGAGEMENT) - assertThat(body.hasLink()).contains(true) - assertThat(body.hasMedia()).contains(true) - assertThat(body.mediaType()).contains(ComposeCreateParams.MediaType.PHOTO) - assertThat(body.styleUsername()).contains("styleUsername") - assertThat(body.tone()).contains("tone") - assertThat(body.topic()).contains("topic") + assertThat(body.hasLink()).contains(false) + assertThat(body.hasMedia()).contains(false) + assertThat(body.mediaType()).contains(ComposeCreateParams.MediaType.NONE) + assertThat(body.styleUsername()).contains("elonmusk") + assertThat(body.tone()).contains("professional") + assertThat(body.topic()).contains("AI trends in 2025") } @Test diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponseTest.kt index e3939cd..b32f720 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/compose/ComposeCreateResponseTest.kt @@ -3,8 +3,8 @@ package com.x_twitter_scraper.api.models.compose import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,8 +14,20 @@ internal class ComposeCreateResponseTest { fun create() { val composeCreateResponse = ComposeCreateResponse.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .feedback("Strong hook. Consider adding a call to action.") + .score(78.0) + .addSuggestion("Add a thread hook") + .addSuggestion("Include a relevant hashtag") + .text("AI is reshaping every industry. Here are 5 trends to watch in 2025.") .build() + + assertThat(composeCreateResponse.feedback()) + .contains("Strong hook. Consider adding a call to action.") + assertThat(composeCreateResponse.score()).contains(78.0) + assertThat(composeCreateResponse.suggestions().getOrNull()) + .containsExactly("Add a thread hook", "Include a relevant hashtag") + assertThat(composeCreateResponse.text()) + .contains("AI is reshaping every industry. Here are 5 trends to watch in 2025.") } @Test @@ -23,7 +35,11 @@ internal class ComposeCreateResponseTest { val jsonMapper = jsonMapper() val composeCreateResponse = ComposeCreateResponse.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .feedback("Strong hook. Consider adding a call to action.") + .score(78.0) + .addSuggestion("Add a thread hook") + .addSuggestion("Include a relevant hashtag") + .text("AI is reshaping every industry. Here are 5 trends to watch in 2025.") .build() val roundtrippedComposeCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditRetrieveBalanceResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditRetrieveBalanceResponseTest.kt index 7c7ea65..9fbbfc9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditRetrieveBalanceResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditRetrieveBalanceResponseTest.kt @@ -13,16 +13,16 @@ internal class CreditRetrieveBalanceResponseTest { fun create() { val creditRetrieveBalanceResponse = CreditRetrieveBalanceResponse.builder() - .autoTopupEnabled(true) - .balance(0L) - .lifetimePurchased(0L) - .lifetimeUsed(0L) + .autoTopupEnabled(false) + .balance(50000L) + .lifetimePurchased(200000L) + .lifetimeUsed(150000L) .build() - assertThat(creditRetrieveBalanceResponse.autoTopupEnabled()).isEqualTo(true) - assertThat(creditRetrieveBalanceResponse.balance()).isEqualTo(0L) - assertThat(creditRetrieveBalanceResponse.lifetimePurchased()).isEqualTo(0L) - assertThat(creditRetrieveBalanceResponse.lifetimeUsed()).isEqualTo(0L) + assertThat(creditRetrieveBalanceResponse.autoTopupEnabled()).isEqualTo(false) + assertThat(creditRetrieveBalanceResponse.balance()).isEqualTo(50000L) + assertThat(creditRetrieveBalanceResponse.lifetimePurchased()).isEqualTo(200000L) + assertThat(creditRetrieveBalanceResponse.lifetimeUsed()).isEqualTo(150000L) } @Test @@ -30,10 +30,10 @@ internal class CreditRetrieveBalanceResponseTest { val jsonMapper = jsonMapper() val creditRetrieveBalanceResponse = CreditRetrieveBalanceResponse.builder() - .autoTopupEnabled(true) - .balance(0L) - .lifetimePurchased(0L) - .lifetimeUsed(0L) + .autoTopupEnabled(false) + .balance(50000L) + .lifetimePurchased(200000L) + .lifetimeUsed(150000L) .build() val roundtrippedCreditRetrieveBalanceResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditTopupBalanceParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditTopupBalanceParamsTest.kt index 25216a8..2be968d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditTopupBalanceParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/credits/CreditTopupBalanceParamsTest.kt @@ -9,15 +9,15 @@ internal class CreditTopupBalanceParamsTest { @Test fun create() { - CreditTopupBalanceParams.builder().amount(0L).build() + CreditTopupBalanceParams.builder().amount(10000L).build() } @Test fun body() { - val params = CreditTopupBalanceParams.builder().amount(0L).build() + val params = CreditTopupBalanceParams.builder().amount(10000L).build() val body = params._body() - assertThat(body.amount()).isEqualTo(0L) + assertThat(body.amount()).isEqualTo(10000L) } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateParamsTest.kt index 4ff6b1a..1235f5b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateParamsTest.kt @@ -10,9 +10,9 @@ internal class DraftCreateParamsTest { @Test fun create() { DraftCreateParams.builder() - .text("text") + .text("AI is the future of productivity") .goal(DraftCreateParams.Goal.ENGAGEMENT) - .topic("topic") + .topic("AI trends") .build() } @@ -20,24 +20,24 @@ internal class DraftCreateParamsTest { fun body() { val params = DraftCreateParams.builder() - .text("text") + .text("AI is the future of productivity") .goal(DraftCreateParams.Goal.ENGAGEMENT) - .topic("topic") + .topic("AI trends") .build() val body = params._body() - assertThat(body.text()).isEqualTo("text") + assertThat(body.text()).isEqualTo("AI is the future of productivity") assertThat(body.goal()).contains(DraftCreateParams.Goal.ENGAGEMENT) - assertThat(body.topic()).contains("topic") + assertThat(body.topic()).contains("AI trends") } @Test fun bodyWithoutOptionalFields() { - val params = DraftCreateParams.builder().text("text").build() + val params = DraftCreateParams.builder().text("AI is the future of productivity").build() val body = params._body() - assertThat(body.text()).isEqualTo("text") + assertThat(body.text()).isEqualTo("AI is the future of productivity") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponseTest.kt index 6bb64a3..84d99be 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponseTest.kt @@ -14,22 +14,22 @@ internal class DraftCreateResponseTest { fun create() { val draftCreateResponse = DraftCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() - assertThat(draftCreateResponse.id()).isEqualTo("id") + assertThat(draftCreateResponse.id()).isEqualTo("42") assertThat(draftCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftCreateResponse.text()).isEqualTo("text") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(draftCreateResponse.text()).isEqualTo("Draft tweet about AI trends") assertThat(draftCreateResponse.updatedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftCreateResponse.goal()).contains("goal") - assertThat(draftCreateResponse.topic()).contains("topic") + .isEqualTo(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + assertThat(draftCreateResponse.goal()).contains("Engagement") + assertThat(draftCreateResponse.topic()).contains("Technology") } @Test @@ -37,12 +37,12 @@ internal class DraftCreateResponseTest { val jsonMapper = jsonMapper() val draftCreateResponse = DraftCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() val roundtrippedDraftCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetailTest.kt index ab676f6..83ae8ed 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetailTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftDetailTest.kt @@ -14,22 +14,20 @@ internal class DraftDetailTest { fun create() { val draftDetail = DraftDetail.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() - assertThat(draftDetail.id()).isEqualTo("id") - assertThat(draftDetail.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftDetail.text()).isEqualTo("text") - assertThat(draftDetail.updatedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftDetail.goal()).contains("goal") - assertThat(draftDetail.topic()).contains("topic") + assertThat(draftDetail.id()).isEqualTo("42") + assertThat(draftDetail.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(draftDetail.text()).isEqualTo("Draft tweet about AI trends") + assertThat(draftDetail.updatedAt()).isEqualTo(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + assertThat(draftDetail.goal()).contains("Engagement") + assertThat(draftDetail.topic()).contains("Technology") } @Test @@ -37,12 +35,12 @@ internal class DraftDetailTest { val jsonMapper = jsonMapper() val draftDetail = DraftDetail.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() val roundtrippedDraftDetail = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponseTest.kt index ca99ba1..68fd62d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftListResponseTest.kt @@ -16,29 +16,29 @@ internal class DraftListResponseTest { DraftListResponse.builder() .addDraft( DraftListResponse.Draft.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .goal("Engagement") + .topic("Technology") .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() assertThat(draftListResponse.drafts()) .containsExactly( DraftListResponse.Draft.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .goal("Engagement") + .topic("Technology") .build() ) - assertThat(draftListResponse.hasMore()).isEqualTo(true) - assertThat(draftListResponse.nextCursor()).contains("nextCursor") + assertThat(draftListResponse.hasMore()).isEqualTo(false) + assertThat(draftListResponse.nextCursor()).contains("abc123") } @Test @@ -48,15 +48,15 @@ internal class DraftListResponseTest { DraftListResponse.builder() .addDraft( DraftListResponse.Draft.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .goal("Engagement") + .topic("Technology") .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() val roundtrippedDraftListResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponseTest.kt index b2b2bac..3fd3277 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponseTest.kt @@ -14,22 +14,22 @@ internal class DraftRetrieveResponseTest { fun create() { val draftRetrieveResponse = DraftRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() - assertThat(draftRetrieveResponse.id()).isEqualTo("id") + assertThat(draftRetrieveResponse.id()).isEqualTo("42") assertThat(draftRetrieveResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftRetrieveResponse.text()).isEqualTo("text") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(draftRetrieveResponse.text()).isEqualTo("Draft tweet about AI trends") assertThat(draftRetrieveResponse.updatedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draftRetrieveResponse.goal()).contains("goal") - assertThat(draftRetrieveResponse.topic()).contains("topic") + .isEqualTo(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + assertThat(draftRetrieveResponse.goal()).contains("Engagement") + assertThat(draftRetrieveResponse.topic()).contains("Technology") } @Test @@ -37,12 +37,12 @@ internal class DraftRetrieveResponseTest { val jsonMapper = jsonMapper() val draftRetrieveResponse = DraftRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) + .goal("Engagement") + .topic("Technology") .build() val roundtrippedDraftRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftTest.kt index 1060ecf..000cad3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftTest.kt @@ -14,18 +14,18 @@ internal class DraftTest { fun create() { val draft = Draft.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .goal("Engagement") + .topic("Technology") .build() - assertThat(draft.id()).isEqualTo("id") - assertThat(draft.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(draft.text()).isEqualTo("text") - assertThat(draft.goal()).contains("goal") - assertThat(draft.topic()).contains("topic") + assertThat(draft.id()).isEqualTo("42") + assertThat(draft.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(draft.text()).isEqualTo("Draft tweet about AI trends") + assertThat(draft.goal()).contains("Engagement") + assertThat(draft.topic()).contains("Technology") } @Test @@ -33,11 +33,11 @@ internal class DraftTest { val jsonMapper = jsonMapper() val draft = Draft.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .text("text") - .goal("goal") - .topic("topic") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .text("Draft tweet about AI trends") + .goal("Engagement") + .topic("Technology") .build() val roundtrippedDraft = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetailTest.kt index e6c6caa..86e9855 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetailTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawDetailTest.kt @@ -14,7 +14,7 @@ internal class DrawDetailTest { fun create() { val drawDetail = DrawDetail.builder() - .id("id") + .id("https://example.com/webhook") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .totalEntries(0L) @@ -30,7 +30,7 @@ internal class DrawDetailTest { .drawnAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - assertThat(drawDetail.id()).isEqualTo("id") + assertThat(drawDetail.id()).isEqualTo("https://example.com/webhook") assertThat(drawDetail.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(drawDetail.status()).isEqualTo("status") @@ -52,7 +52,7 @@ internal class DrawDetailTest { val jsonMapper = jsonMapper() val drawDetail = DrawDetail.builder() - .id("id") + .id("https://example.com/webhook") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .totalEntries(0L) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponseTest.kt index ec00f6a..149d856 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawListResponseTest.kt @@ -25,8 +25,8 @@ internal class DrawListResponseTest { .drawnAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() assertThat(drawListResponse.draws()) @@ -41,8 +41,8 @@ internal class DrawListResponseTest { .drawnAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(drawListResponse.hasMore()).isEqualTo(true) - assertThat(drawListResponse.nextCursor()).contains("nextCursor") + assertThat(drawListResponse.hasMore()).isEqualTo(false) + assertThat(drawListResponse.nextCursor()).contains("abc123") } @Test @@ -61,8 +61,8 @@ internal class DrawListResponseTest { .drawnAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() val roundtrippedDrawListResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponseTest.kt index f1607dc..607ee4c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponseTest.kt @@ -16,7 +16,7 @@ internal class DrawRetrieveResponseTest { DrawRetrieveResponse.builder() .draw( DrawRetrieveResponse.Draw.builder() - .id("id") + .id("https://example.com/webhook") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .totalEntries(0L) @@ -45,7 +45,7 @@ internal class DrawRetrieveResponseTest { assertThat(drawRetrieveResponse.draw()) .isEqualTo( DrawRetrieveResponse.Draw.builder() - .id("id") + .id("https://example.com/webhook") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .totalEntries(0L) @@ -79,7 +79,7 @@ internal class DrawRetrieveResponseTest { DrawRetrieveResponse.builder() .draw( DrawRetrieveResponse.Draw.builder() - .id("id") + .id("https://example.com/webhook") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status("status") .totalEntries(0L) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunParamsTest.kt index ed330f4..d5050eb 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunParamsTest.kt @@ -11,18 +11,18 @@ internal class DrawRunParamsTest { @Test fun create() { DrawRunParams.builder() - .tweetUrl("https://example.com") - .backupCount(0L) - .filterAccountAgeDays(0L) - .filterLanguage("filterLanguage") - .filterMinFollowers(0L) - .mustFollowUsername("mustFollowUsername") + .tweetUrl("https://x.com/elonmusk/status/1234567890") + .backupCount(2L) + .filterAccountAgeDays(30L) + .filterLanguage("en") + .filterMinFollowers(50L) + .mustFollowUsername("elonmusk") .mustRetweet(true) - .addRequiredHashtag("string") - .addRequiredKeyword("string") - .addRequiredMention("string") + .addRequiredHashtag("#giveaway") + .addRequiredKeyword("entered") + .addRequiredMention("@elonmusk") .uniqueAuthorsOnly(true) - .winnerCount(0L) + .winnerCount(3L) .build() } @@ -30,42 +30,43 @@ internal class DrawRunParamsTest { fun body() { val params = DrawRunParams.builder() - .tweetUrl("https://example.com") - .backupCount(0L) - .filterAccountAgeDays(0L) - .filterLanguage("filterLanguage") - .filterMinFollowers(0L) - .mustFollowUsername("mustFollowUsername") + .tweetUrl("https://x.com/elonmusk/status/1234567890") + .backupCount(2L) + .filterAccountAgeDays(30L) + .filterLanguage("en") + .filterMinFollowers(50L) + .mustFollowUsername("elonmusk") .mustRetweet(true) - .addRequiredHashtag("string") - .addRequiredKeyword("string") - .addRequiredMention("string") + .addRequiredHashtag("#giveaway") + .addRequiredKeyword("entered") + .addRequiredMention("@elonmusk") .uniqueAuthorsOnly(true) - .winnerCount(0L) + .winnerCount(3L) .build() val body = params._body() - assertThat(body.tweetUrl()).isEqualTo("https://example.com") - assertThat(body.backupCount()).contains(0L) - assertThat(body.filterAccountAgeDays()).contains(0L) - assertThat(body.filterLanguage()).contains("filterLanguage") - assertThat(body.filterMinFollowers()).contains(0L) - assertThat(body.mustFollowUsername()).contains("mustFollowUsername") + assertThat(body.tweetUrl()).isEqualTo("https://x.com/elonmusk/status/1234567890") + assertThat(body.backupCount()).contains(2L) + assertThat(body.filterAccountAgeDays()).contains(30L) + assertThat(body.filterLanguage()).contains("en") + assertThat(body.filterMinFollowers()).contains(50L) + assertThat(body.mustFollowUsername()).contains("elonmusk") assertThat(body.mustRetweet()).contains(true) - assertThat(body.requiredHashtags().getOrNull()).containsExactly("string") - assertThat(body.requiredKeywords().getOrNull()).containsExactly("string") - assertThat(body.requiredMentions().getOrNull()).containsExactly("string") + assertThat(body.requiredHashtags().getOrNull()).containsExactly("#giveaway") + assertThat(body.requiredKeywords().getOrNull()).containsExactly("entered") + assertThat(body.requiredMentions().getOrNull()).containsExactly("@elonmusk") assertThat(body.uniqueAuthorsOnly()).contains(true) - assertThat(body.winnerCount()).contains(0L) + assertThat(body.winnerCount()).contains(3L) } @Test fun bodyWithoutOptionalFields() { - val params = DrawRunParams.builder().tweetUrl("https://example.com").build() + val params = + DrawRunParams.builder().tweetUrl("https://x.com/elonmusk/status/1234567890").build() val body = params._body() - assertThat(body.tweetUrl()).isEqualTo("https://example.com") + assertThat(body.tweetUrl()).isEqualTo("https://x.com/elonmusk/status/1234567890") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponseTest.kt index 050dc2e..633f1ac 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponseTest.kt @@ -13,10 +13,10 @@ internal class DrawRunResponseTest { fun create() { val drawRunResponse = DrawRunResponse.builder() - .id("id") - .totalEntries(0L) - .tweetId("tweetId") - .validEntries(0L) + .id("42") + .totalEntries(250L) + .tweetId("1234567890") + .validEntries(200L) .addWinner( DrawRunResponse.Winner.builder() .authorUsername("authorUsername") @@ -27,10 +27,10 @@ internal class DrawRunResponseTest { ) .build() - assertThat(drawRunResponse.id()).isEqualTo("id") - assertThat(drawRunResponse.totalEntries()).isEqualTo(0L) - assertThat(drawRunResponse.tweetId()).isEqualTo("tweetId") - assertThat(drawRunResponse.validEntries()).isEqualTo(0L) + assertThat(drawRunResponse.id()).isEqualTo("42") + assertThat(drawRunResponse.totalEntries()).isEqualTo(250L) + assertThat(drawRunResponse.tweetId()).isEqualTo("1234567890") + assertThat(drawRunResponse.validEntries()).isEqualTo(200L) assertThat(drawRunResponse.winners()) .containsExactly( DrawRunResponse.Winner.builder() @@ -47,10 +47,10 @@ internal class DrawRunResponseTest { val jsonMapper = jsonMapper() val drawRunResponse = DrawRunResponse.builder() - .id("id") - .totalEntries(0L) - .tweetId("tweetId") - .validEntries(0L) + .id("42") + .totalEntries(250L) + .tweetId("1234567890") + .validEntries(200L) .addWinner( DrawRunResponse.Winner.builder() .authorUsername("authorUsername") diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventDetailTest.kt index b2e1800..8df9c5d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventDetailTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventDetailTest.kt @@ -15,32 +15,31 @@ internal class EventDetailTest { fun create() { val eventDetail = EventDetail.builder() - .id("id") + .id("42") .data( EventDetail.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - .monitorId("monitorId") - .occurredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .monitorId("10") + .occurredAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .type(EventDetail.Type.TWEET_NEW) - .username("username") - .xEventId("xEventId") + .username("elonmusk") + .xEventId("1234567890") .build() - assertThat(eventDetail.id()).isEqualTo("id") + assertThat(eventDetail.id()).isEqualTo("42") assertThat(eventDetail.data()) .isEqualTo( EventDetail.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - assertThat(eventDetail.monitorId()).isEqualTo("monitorId") - assertThat(eventDetail.occurredAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(eventDetail.monitorId()).isEqualTo("10") + assertThat(eventDetail.occurredAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(eventDetail.type()).isEqualTo(EventDetail.Type.TWEET_NEW) - assertThat(eventDetail.username()).isEqualTo("username") - assertThat(eventDetail.xEventId()).contains("xEventId") + assertThat(eventDetail.username()).isEqualTo("elonmusk") + assertThat(eventDetail.xEventId()).contains("1234567890") } @Test @@ -48,17 +47,17 @@ internal class EventDetailTest { val jsonMapper = jsonMapper() val eventDetail = EventDetail.builder() - .id("id") + .id("42") .data( EventDetail.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - .monitorId("monitorId") - .occurredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .monitorId("10") + .occurredAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .type(EventDetail.Type.TWEET_NEW) - .username("username") - .xEventId("xEventId") + .username("elonmusk") + .xEventId("1234567890") .build() val roundtrippedEventDetail = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventListResponseTest.kt index c6c1c23..8b5cacd 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventListResponseTest.kt @@ -29,8 +29,8 @@ internal class EventListResponseTest { .username("username") .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() assertThat(eventListResponse.events()) @@ -48,8 +48,8 @@ internal class EventListResponseTest { .username("username") .build() ) - assertThat(eventListResponse.hasMore()).isEqualTo(true) - assertThat(eventListResponse.nextCursor()).contains("nextCursor") + assertThat(eventListResponse.hasMore()).isEqualTo(false) + assertThat(eventListResponse.nextCursor()).contains("abc123") } @Test @@ -71,8 +71,8 @@ internal class EventListResponseTest { .username("username") .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() val roundtrippedEventListResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponseTest.kt index b472f2f..3c109b9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponseTest.kt @@ -15,32 +15,32 @@ internal class EventRetrieveResponseTest { fun create() { val eventRetrieveResponse = EventRetrieveResponse.builder() - .id("id") + .id("42") .data( EventRetrieveResponse.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - .monitorId("monitorId") - .occurredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .monitorId("10") + .occurredAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .type(EventRetrieveResponse.Type.TWEET_NEW) - .username("username") - .xEventId("xEventId") + .username("elonmusk") + .xEventId("1234567890") .build() - assertThat(eventRetrieveResponse.id()).isEqualTo("id") + assertThat(eventRetrieveResponse.id()).isEqualTo("42") assertThat(eventRetrieveResponse.data()) .isEqualTo( EventRetrieveResponse.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - assertThat(eventRetrieveResponse.monitorId()).isEqualTo("monitorId") + assertThat(eventRetrieveResponse.monitorId()).isEqualTo("10") assertThat(eventRetrieveResponse.occurredAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(eventRetrieveResponse.type()).isEqualTo(EventRetrieveResponse.Type.TWEET_NEW) - assertThat(eventRetrieveResponse.username()).isEqualTo("username") - assertThat(eventRetrieveResponse.xEventId()).contains("xEventId") + assertThat(eventRetrieveResponse.username()).isEqualTo("elonmusk") + assertThat(eventRetrieveResponse.xEventId()).contains("1234567890") } @Test @@ -48,17 +48,17 @@ internal class EventRetrieveResponseTest { val jsonMapper = jsonMapper() val eventRetrieveResponse = EventRetrieveResponse.builder() - .id("id") + .id("42") .data( EventRetrieveResponse.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("tweetId", JsonValue.from("bar")) .build() ) - .monitorId("monitorId") - .occurredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .monitorId("10") + .occurredAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .type(EventRetrieveResponse.Type.TWEET_NEW) - .username("username") - .xEventId("xEventId") + .username("elonmusk") + .xEventId("1234567890") .build() val roundtrippedEventRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParamsTest.kt index 345a0dd..517b960 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostParamsTest.kt @@ -10,16 +10,16 @@ internal class ExtractionEstimateCostParamsTest { @Test fun create() { ExtractionEstimateCostParams.builder() - .toolType(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() } @@ -27,43 +27,43 @@ internal class ExtractionEstimateCostParamsTest { fun body() { val params = ExtractionEstimateCostParams.builder() - .toolType(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() val body = params._body() assertThat(body.toolType()) - .isEqualTo(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) - assertThat(body.advancedQuery()).contains("advancedQuery") - assertThat(body.exactPhrase()).contains("exactPhrase") - assertThat(body.excludeWords()).contains("excludeWords") - assertThat(body.searchQuery()).contains("searchQuery") - assertThat(body.targetCommunityId()).contains("targetCommunityId") - assertThat(body.targetListId()).contains("targetListId") - assertThat(body.targetSpaceId()).contains("targetSpaceId") - assertThat(body.targetTweetId()).contains("targetTweetId") - assertThat(body.targetUsername()).contains("targetUsername") + .isEqualTo(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) + assertThat(body.advancedQuery()).contains("min_faves:100") + assertThat(body.exactPhrase()).contains("artificial intelligence") + assertThat(body.excludeWords()).contains("spam") + assertThat(body.searchQuery()).contains("AI trends 2025") + assertThat(body.targetCommunityId()).contains("1500000000000000000") + assertThat(body.targetListId()).contains("1234567890") + assertThat(body.targetSpaceId()).contains("1vOGwMdBqpwGB") + assertThat(body.targetTweetId()).contains("1234567890") + assertThat(body.targetUsername()).contains("elonmusk") } @Test fun bodyWithoutOptionalFields() { val params = ExtractionEstimateCostParams.builder() - .toolType(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) .build() val body = params._body() assertThat(body.toolType()) - .isEqualTo(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) + .isEqualTo(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostResponseTest.kt index 8c0d95e..917e197 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionEstimateCostResponseTest.kt @@ -14,17 +14,17 @@ internal class ExtractionEstimateCostResponseTest { val extractionEstimateCostResponse = ExtractionEstimateCostResponse.builder() .allowed(true) - .estimatedResults(0L) - .projectedPercent(0.0) - .source("source") - .usagePercent(0.0) + .estimatedResults(500L) + .projectedPercent(30.0) + .source("api_count") + .usagePercent(25.0) .build() assertThat(extractionEstimateCostResponse.allowed()).isEqualTo(true) - assertThat(extractionEstimateCostResponse.estimatedResults()).isEqualTo(0L) - assertThat(extractionEstimateCostResponse.projectedPercent()).isEqualTo(0.0) - assertThat(extractionEstimateCostResponse.source()).isEqualTo("source") - assertThat(extractionEstimateCostResponse.usagePercent()).isEqualTo(0.0) + assertThat(extractionEstimateCostResponse.estimatedResults()).isEqualTo(500L) + assertThat(extractionEstimateCostResponse.projectedPercent()).isEqualTo(30.0) + assertThat(extractionEstimateCostResponse.source()).isEqualTo("api_count") + assertThat(extractionEstimateCostResponse.usagePercent()).isEqualTo(25.0) } @Test @@ -33,10 +33,10 @@ internal class ExtractionEstimateCostResponseTest { val extractionEstimateCostResponse = ExtractionEstimateCostResponse.builder() .allowed(true) - .estimatedResults(0L) - .projectedPercent(0.0) - .source("source") - .usagePercent(0.0) + .estimatedResults(500L) + .projectedPercent(30.0) + .source("api_count") + .usagePercent(25.0) .build() val roundtrippedExtractionEstimateCostResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJobTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJobTest.kt index fbf8889..cf9666b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJobTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionJobTest.kt @@ -17,7 +17,7 @@ internal class ExtractionJobTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(ExtractionJob.Status.RUNNING) - .toolType(ExtractionJob.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionJob.ToolType.FOLLOWER_EXPLORER) .totalResults(0L) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -26,7 +26,7 @@ internal class ExtractionJobTest { assertThat(extractionJob.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(extractionJob.status()).isEqualTo(ExtractionJob.Status.RUNNING) - assertThat(extractionJob.toolType()).isEqualTo(ExtractionJob.ToolType.ARTICLE_EXTRACTOR) + assertThat(extractionJob.toolType()).isEqualTo(ExtractionJob.ToolType.FOLLOWER_EXPLORER) assertThat(extractionJob.totalResults()).isEqualTo(0L) assertThat(extractionJob.completedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -40,7 +40,7 @@ internal class ExtractionJobTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(ExtractionJob.Status.RUNNING) - .toolType(ExtractionJob.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionJob.ToolType.FOLLOWER_EXPLORER) .totalResults(0L) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParamsTest.kt index 4c93f25..23e1f67 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListParamsTest.kt @@ -14,7 +14,7 @@ internal class ExtractionListParamsTest { .after("after") .limit(1L) .status(ExtractionListParams.Status.RUNNING) - .toolType(ExtractionListParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListParams.ToolType.FOLLOWER_EXPLORER) .build() } @@ -25,7 +25,7 @@ internal class ExtractionListParamsTest { .after("after") .limit(1L) .status(ExtractionListParams.Status.RUNNING) - .toolType(ExtractionListParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListParams.ToolType.FOLLOWER_EXPLORER) .build() val queryParams = params._queryParams() @@ -36,7 +36,7 @@ internal class ExtractionListParamsTest { .put("after", "after") .put("limit", "1") .put("status", "running") - .put("toolType", "article_extractor") + .put("toolType", "follower_explorer") .build() ) } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponseTest.kt index 222949f..651f131 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionListResponseTest.kt @@ -19,13 +19,13 @@ internal class ExtractionListResponseTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(ExtractionListResponse.Extraction.Status.RUNNING) - .toolType(ExtractionListResponse.Extraction.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListResponse.Extraction.ToolType.FOLLOWER_EXPLORER) .totalResults(0L) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() assertThat(extractionListResponse.extractions()) @@ -34,13 +34,13 @@ internal class ExtractionListResponseTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(ExtractionListResponse.Extraction.Status.RUNNING) - .toolType(ExtractionListResponse.Extraction.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListResponse.Extraction.ToolType.FOLLOWER_EXPLORER) .totalResults(0L) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(extractionListResponse.hasMore()).isEqualTo(true) - assertThat(extractionListResponse.nextCursor()).contains("nextCursor") + assertThat(extractionListResponse.hasMore()).isEqualTo(false) + assertThat(extractionListResponse.nextCursor()).contains("abc123") } @Test @@ -53,13 +53,13 @@ internal class ExtractionListResponseTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(ExtractionListResponse.Extraction.Status.RUNNING) - .toolType(ExtractionListResponse.Extraction.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListResponse.Extraction.ToolType.FOLLOWER_EXPLORER) .totalResults(0L) .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - .hasMore(true) - .nextCursor("nextCursor") + .hasMore(false) + .nextCursor("abc123") .build() val roundtrippedExtractionListResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponseTest.kt index 76004ee..7f2a0f4 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRetrieveResponseTest.kt @@ -14,10 +14,12 @@ internal class ExtractionRetrieveResponseTest { fun create() { val extractionRetrieveResponse = ExtractionRetrieveResponse.builder() - .hasMore(true) + .hasMore(false) .job( ExtractionRetrieveResponse.Job.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("id", JsonValue.from("bar")) + .putAdditionalProperty("toolType", JsonValue.from("bar")) + .putAdditionalProperty("status", JsonValue.from("bar")) .build() ) .addResult( @@ -25,14 +27,16 @@ internal class ExtractionRetrieveResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .nextCursor("nextCursor") + .nextCursor("abc123") .build() - assertThat(extractionRetrieveResponse.hasMore()).isEqualTo(true) + assertThat(extractionRetrieveResponse.hasMore()).isEqualTo(false) assertThat(extractionRetrieveResponse.job()) .isEqualTo( ExtractionRetrieveResponse.Job.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("id", JsonValue.from("bar")) + .putAdditionalProperty("toolType", JsonValue.from("bar")) + .putAdditionalProperty("status", JsonValue.from("bar")) .build() ) assertThat(extractionRetrieveResponse.results()) @@ -41,7 +45,7 @@ internal class ExtractionRetrieveResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - assertThat(extractionRetrieveResponse.nextCursor()).contains("nextCursor") + assertThat(extractionRetrieveResponse.nextCursor()).contains("abc123") } @Test @@ -49,10 +53,12 @@ internal class ExtractionRetrieveResponseTest { val jsonMapper = jsonMapper() val extractionRetrieveResponse = ExtractionRetrieveResponse.builder() - .hasMore(true) + .hasMore(false) .job( ExtractionRetrieveResponse.Job.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("id", JsonValue.from("bar")) + .putAdditionalProperty("toolType", JsonValue.from("bar")) + .putAdditionalProperty("status", JsonValue.from("bar")) .build() ) .addResult( @@ -60,7 +66,7 @@ internal class ExtractionRetrieveResponseTest { .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .nextCursor("nextCursor") + .nextCursor("abc123") .build() val roundtrippedExtractionRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParamsTest.kt index f60223b..484347e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunParamsTest.kt @@ -10,16 +10,16 @@ internal class ExtractionRunParamsTest { @Test fun create() { ExtractionRunParams.builder() - .toolType(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() } @@ -27,41 +27,41 @@ internal class ExtractionRunParamsTest { fun body() { val params = ExtractionRunParams.builder() - .toolType(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() val body = params._body() - assertThat(body.toolType()).isEqualTo(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) - assertThat(body.advancedQuery()).contains("advancedQuery") - assertThat(body.exactPhrase()).contains("exactPhrase") - assertThat(body.excludeWords()).contains("excludeWords") - assertThat(body.searchQuery()).contains("searchQuery") - assertThat(body.targetCommunityId()).contains("targetCommunityId") - assertThat(body.targetListId()).contains("targetListId") - assertThat(body.targetSpaceId()).contains("targetSpaceId") - assertThat(body.targetTweetId()).contains("targetTweetId") - assertThat(body.targetUsername()).contains("targetUsername") + assertThat(body.toolType()).isEqualTo(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) + assertThat(body.advancedQuery()).contains("min_faves:100") + assertThat(body.exactPhrase()).contains("artificial intelligence") + assertThat(body.excludeWords()).contains("spam") + assertThat(body.searchQuery()).contains("AI trends 2025") + assertThat(body.targetCommunityId()).contains("1500000000000000000") + assertThat(body.targetListId()).contains("1234567890") + assertThat(body.targetSpaceId()).contains("1vOGwMdBqpwGB") + assertThat(body.targetTweetId()).contains("1234567890") + assertThat(body.targetUsername()).contains("elonmusk") } @Test fun bodyWithoutOptionalFields() { val params = ExtractionRunParams.builder() - .toolType(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) .build() val body = params._body() - assertThat(body.toolType()).isEqualTo(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) + assertThat(body.toolType()).isEqualTo(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponseTest.kt index 337f708..0e67ef9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/extractions/ExtractionRunResponseTest.kt @@ -13,15 +13,15 @@ internal class ExtractionRunResponseTest { fun create() { val extractionRunResponse = ExtractionRunResponse.builder() - .id("id") + .id("a1b2c3d4-e5f6-7890-abcd-ef1234567890") .status(ExtractionRunResponse.Status.RUNNING) - .toolType(ExtractionRunResponse.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionRunResponse.ToolType.FOLLOWER_EXPLORER) .build() - assertThat(extractionRunResponse.id()).isEqualTo("id") + assertThat(extractionRunResponse.id()).isEqualTo("a1b2c3d4-e5f6-7890-abcd-ef1234567890") assertThat(extractionRunResponse.status()).isEqualTo(ExtractionRunResponse.Status.RUNNING) assertThat(extractionRunResponse.toolType()) - .isEqualTo(ExtractionRunResponse.ToolType.ARTICLE_EXTRACTOR) + .isEqualTo(ExtractionRunResponse.ToolType.FOLLOWER_EXPLORER) } @Test @@ -29,9 +29,9 @@ internal class ExtractionRunResponseTest { val jsonMapper = jsonMapper() val extractionRunResponse = ExtractionRunResponse.builder() - .id("id") + .id("a1b2c3d4-e5f6-7890-abcd-ef1234567890") .status(ExtractionRunResponse.Status.RUNNING) - .toolType(ExtractionRunResponse.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionRunResponse.ToolType.FOLLOWER_EXPLORER) .build() val roundtrippedExtractionRunResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParamsTest.kt index 8d83981..d49d525 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParamsTest.kt @@ -10,9 +10,10 @@ internal class IntegrationCreateParamsTest { @Test fun create() { IntegrationCreateParams.builder() - .config(IntegrationCreateParams.Config.builder().chatId("chatId").build()) + .config(IntegrationCreateParams.Config.builder().chatId("-1001234567890").build()) .addEventType(IntegrationCreateParams.EventType.TWEET_NEW) - .name("name") + .addEventType(IntegrationCreateParams.EventType.FOLLOWER_GAINED) + .name("My Telegram Bot") .type(IntegrationCreateParams.Type.TELEGRAM) .build() } @@ -21,18 +22,23 @@ internal class IntegrationCreateParamsTest { fun body() { val params = IntegrationCreateParams.builder() - .config(IntegrationCreateParams.Config.builder().chatId("chatId").build()) + .config(IntegrationCreateParams.Config.builder().chatId("-1001234567890").build()) .addEventType(IntegrationCreateParams.EventType.TWEET_NEW) - .name("name") + .addEventType(IntegrationCreateParams.EventType.FOLLOWER_GAINED) + .name("My Telegram Bot") .type(IntegrationCreateParams.Type.TELEGRAM) .build() val body = params._body() assertThat(body.config()) - .isEqualTo(IntegrationCreateParams.Config.builder().chatId("chatId").build()) - assertThat(body.eventTypes()).containsExactly(IntegrationCreateParams.EventType.TWEET_NEW) - assertThat(body.name()).isEqualTo("name") + .isEqualTo(IntegrationCreateParams.Config.builder().chatId("-1001234567890").build()) + assertThat(body.eventTypes()) + .containsExactly( + IntegrationCreateParams.EventType.TWEET_NEW, + IntegrationCreateParams.EventType.FOLLOWER_GAINED, + ) + assertThat(body.name()).isEqualTo("My Telegram Bot") assertThat(body.type()).isEqualTo(IntegrationCreateParams.Type.TELEGRAM) } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponseTest.kt index af0e85b..4a9a18b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponseTest.kt @@ -15,51 +15,56 @@ internal class IntegrationCreateResponseTest { fun create() { val integrationCreateResponse = IntegrationCreateResponse.builder() - .id("id") + .id("42") .config( IntegrationCreateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationCreateResponse.EventType.TWEET_NEW) + .addEventType(IntegrationCreateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationCreateResponse.Type.TELEGRAM) .filters( IntegrationCreateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() - assertThat(integrationCreateResponse.id()).isEqualTo("id") + assertThat(integrationCreateResponse.id()).isEqualTo("42") assertThat(integrationCreateResponse.config()) .isEqualTo( IntegrationCreateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) assertThat(integrationCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(integrationCreateResponse.eventTypes()) - .containsExactly(IntegrationCreateResponse.EventType.TWEET_NEW) + .containsExactly( + IntegrationCreateResponse.EventType.TWEET_NEW, + IntegrationCreateResponse.EventType.FOLLOWER_GAINED, + ) assertThat(integrationCreateResponse.isActive()).isEqualTo(true) - assertThat(integrationCreateResponse.name()).isEqualTo("name") + assertThat(integrationCreateResponse.name()).isEqualTo("My Telegram Bot") assertThat(integrationCreateResponse.type()) .isEqualTo(IntegrationCreateResponse.Type.TELEGRAM) assertThat(integrationCreateResponse.filters()) .contains( IntegrationCreateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - assertThat(integrationCreateResponse.messageTemplate()).contains("messageTemplate") + assertThat(integrationCreateResponse.messageTemplate()) + .contains("New event: {{event.type}}") assertThat(integrationCreateResponse.scopeAllMonitors()).contains(true) - assertThat(integrationCreateResponse.silentPush()).contains(true) + assertThat(integrationCreateResponse.silentPush()).contains(false) } @Test @@ -67,25 +72,26 @@ internal class IntegrationCreateResponseTest { val jsonMapper = jsonMapper() val integrationCreateResponse = IntegrationCreateResponse.builder() - .id("id") + .id("42") .config( IntegrationCreateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationCreateResponse.EventType.TWEET_NEW) + .addEventType(IntegrationCreateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationCreateResponse.Type.TELEGRAM) .filters( IntegrationCreateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() val roundtrippedIntegrationCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDeliveryTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDeliveryTest.kt index 03a8da1..7a5e422 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDeliveryTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationDeliveryTest.kt @@ -14,30 +14,30 @@ internal class IntegrationDeliveryTest { fun create() { val integrationDelivery = IntegrationDelivery.builder() - .id("id") - .attempts(0L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType("eventType") - .status("status") - .deliveredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .lastError("lastError") - .lastStatusCode(0L) - .sourceId("sourceId") - .sourceType("sourceType") + .id("42") + .attempts(1L) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .eventType("tweet.new") + .status("delivered") + .deliveredAt(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + .lastError("") + .lastStatusCode(200L) + .sourceId("100") + .sourceType("monitor") .build() - assertThat(integrationDelivery.id()).isEqualTo("id") - assertThat(integrationDelivery.attempts()).isEqualTo(0L) + assertThat(integrationDelivery.id()).isEqualTo("42") + assertThat(integrationDelivery.attempts()).isEqualTo(1L) assertThat(integrationDelivery.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(integrationDelivery.eventType()).isEqualTo("eventType") - assertThat(integrationDelivery.status()).isEqualTo("status") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(integrationDelivery.eventType()).isEqualTo("tweet.new") + assertThat(integrationDelivery.status()).isEqualTo("delivered") assertThat(integrationDelivery.deliveredAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(integrationDelivery.lastError()).contains("lastError") - assertThat(integrationDelivery.lastStatusCode()).contains(0L) - assertThat(integrationDelivery.sourceId()).contains("sourceId") - assertThat(integrationDelivery.sourceType()).contains("sourceType") + .contains(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + assertThat(integrationDelivery.lastError()).contains("") + assertThat(integrationDelivery.lastStatusCode()).contains(200L) + assertThat(integrationDelivery.sourceId()).contains("100") + assertThat(integrationDelivery.sourceType()).contains("monitor") } @Test @@ -45,16 +45,16 @@ internal class IntegrationDeliveryTest { val jsonMapper = jsonMapper() val integrationDelivery = IntegrationDelivery.builder() - .id("id") - .attempts(0L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType("eventType") - .status("status") - .deliveredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .lastError("lastError") - .lastStatusCode(0L) - .sourceId("sourceId") - .sourceType("sourceType") + .id("42") + .attempts(1L) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .eventType("tweet.new") + .status("delivered") + .deliveredAt(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + .lastError("") + .lastStatusCode(200L) + .sourceId("100") + .sourceType("monitor") .build() val roundtrippedIntegrationDelivery = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponseTest.kt index 4ef11db..b4e170d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListDeliveriesResponseTest.kt @@ -16,16 +16,16 @@ internal class IntegrationListDeliveriesResponseTest { IntegrationListDeliveriesResponse.builder() .addDelivery( IntegrationListDeliveriesResponse.Delivery.builder() - .id("id") - .attempts(0L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType("eventType") - .status("status") - .deliveredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .lastError("lastError") - .lastStatusCode(0L) - .sourceId("sourceId") - .sourceType("sourceType") + .id("42") + .attempts(1L) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .eventType("tweet.new") + .status("delivered") + .deliveredAt(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + .lastError("") + .lastStatusCode(200L) + .sourceId("100") + .sourceType("monitor") .build() ) .build() @@ -33,16 +33,16 @@ internal class IntegrationListDeliveriesResponseTest { assertThat(integrationListDeliveriesResponse.deliveries()) .containsExactly( IntegrationListDeliveriesResponse.Delivery.builder() - .id("id") - .attempts(0L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType("eventType") - .status("status") - .deliveredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .lastError("lastError") - .lastStatusCode(0L) - .sourceId("sourceId") - .sourceType("sourceType") + .id("42") + .attempts(1L) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .eventType("tweet.new") + .status("delivered") + .deliveredAt(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + .lastError("") + .lastStatusCode(200L) + .sourceId("100") + .sourceType("monitor") .build() ) } @@ -54,16 +54,16 @@ internal class IntegrationListDeliveriesResponseTest { IntegrationListDeliveriesResponse.builder() .addDelivery( IntegrationListDeliveriesResponse.Delivery.builder() - .id("id") - .attempts(0L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .eventType("eventType") - .status("status") - .deliveredAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .lastError("lastError") - .lastStatusCode(0L) - .sourceId("sourceId") - .sourceType("sourceType") + .id("42") + .attempts(1L) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .eventType("tweet.new") + .status("delivered") + .deliveredAt(OffsetDateTime.parse("2025-01-15T12:00:01Z")) + .lastError("") + .lastStatusCode(200L) + .sourceId("100") + .sourceType("monitor") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponseTest.kt index e804652..a864bc0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponseTest.kt @@ -17,25 +17,26 @@ internal class IntegrationListResponseTest { IntegrationListResponse.builder() .addIntegration( IntegrationListResponse.Integration.builder() - .id("id") + .id("42") .config( IntegrationListResponse.Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationListResponse.Integration.EventType.TWEET_NEW) + .addEventType(IntegrationListResponse.Integration.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationListResponse.Integration.Type.TELEGRAM) .filters( IntegrationListResponse.Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() ) .build() @@ -43,25 +44,26 @@ internal class IntegrationListResponseTest { assertThat(integrationListResponse.integrations()) .containsExactly( IntegrationListResponse.Integration.builder() - .id("id") + .id("42") .config( IntegrationListResponse.Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationListResponse.Integration.EventType.TWEET_NEW) + .addEventType(IntegrationListResponse.Integration.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationListResponse.Integration.Type.TELEGRAM) .filters( IntegrationListResponse.Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() ) } @@ -73,25 +75,26 @@ internal class IntegrationListResponseTest { IntegrationListResponse.builder() .addIntegration( IntegrationListResponse.Integration.builder() - .id("id") + .id("42") .config( IntegrationListResponse.Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationListResponse.Integration.EventType.TWEET_NEW) + .addEventType(IntegrationListResponse.Integration.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationListResponse.Integration.Type.TELEGRAM) .filters( IntegrationListResponse.Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponseTest.kt index 26621e8..345ae91 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponseTest.kt @@ -15,51 +15,56 @@ internal class IntegrationRetrieveResponseTest { fun create() { val integrationRetrieveResponse = IntegrationRetrieveResponse.builder() - .id("id") + .id("42") .config( IntegrationRetrieveResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationRetrieveResponse.EventType.TWEET_NEW) + .addEventType(IntegrationRetrieveResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationRetrieveResponse.Type.TELEGRAM) .filters( IntegrationRetrieveResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() - assertThat(integrationRetrieveResponse.id()).isEqualTo("id") + assertThat(integrationRetrieveResponse.id()).isEqualTo("42") assertThat(integrationRetrieveResponse.config()) .isEqualTo( IntegrationRetrieveResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) assertThat(integrationRetrieveResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(integrationRetrieveResponse.eventTypes()) - .containsExactly(IntegrationRetrieveResponse.EventType.TWEET_NEW) + .containsExactly( + IntegrationRetrieveResponse.EventType.TWEET_NEW, + IntegrationRetrieveResponse.EventType.FOLLOWER_GAINED, + ) assertThat(integrationRetrieveResponse.isActive()).isEqualTo(true) - assertThat(integrationRetrieveResponse.name()).isEqualTo("name") + assertThat(integrationRetrieveResponse.name()).isEqualTo("My Telegram Bot") assertThat(integrationRetrieveResponse.type()) .isEqualTo(IntegrationRetrieveResponse.Type.TELEGRAM) assertThat(integrationRetrieveResponse.filters()) .contains( IntegrationRetrieveResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - assertThat(integrationRetrieveResponse.messageTemplate()).contains("messageTemplate") + assertThat(integrationRetrieveResponse.messageTemplate()) + .contains("New event: {{event.type}}") assertThat(integrationRetrieveResponse.scopeAllMonitors()).contains(true) - assertThat(integrationRetrieveResponse.silentPush()).contains(true) + assertThat(integrationRetrieveResponse.silentPush()).contains(false) } @Test @@ -67,25 +72,26 @@ internal class IntegrationRetrieveResponseTest { val jsonMapper = jsonMapper() val integrationRetrieveResponse = IntegrationRetrieveResponse.builder() - .id("id") + .id("42") .config( IntegrationRetrieveResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationRetrieveResponse.EventType.TWEET_NEW) + .addEventType(IntegrationRetrieveResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationRetrieveResponse.Type.TELEGRAM) .filters( IntegrationRetrieveResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() val roundtrippedIntegrationRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationTest.kt index 6d61ea1..1202107 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationTest.kt @@ -15,49 +15,50 @@ internal class IntegrationTest { fun create() { val integration = Integration.builder() - .id("id") + .id("42") .config( Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Integration.EventType.TWEET_NEW) + .addEventType(Integration.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(Integration.Type.TELEGRAM) .filters( Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() - assertThat(integration.id()).isEqualTo("id") + assertThat(integration.id()).isEqualTo("42") assertThat(integration.config()) .isEqualTo( Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - assertThat(integration.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(integration.eventTypes()).containsExactly(Integration.EventType.TWEET_NEW) + assertThat(integration.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(integration.eventTypes()) + .containsExactly(Integration.EventType.TWEET_NEW, Integration.EventType.FOLLOWER_GAINED) assertThat(integration.isActive()).isEqualTo(true) - assertThat(integration.name()).isEqualTo("name") + assertThat(integration.name()).isEqualTo("My Telegram Bot") assertThat(integration.type()).isEqualTo(Integration.Type.TELEGRAM) assertThat(integration.filters()) .contains( Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - assertThat(integration.messageTemplate()).contains("messageTemplate") + assertThat(integration.messageTemplate()).contains("New event: {{event.type}}") assertThat(integration.scopeAllMonitors()).contains(true) - assertThat(integration.silentPush()).contains(true) + assertThat(integration.silentPush()).contains(false) } @Test @@ -65,25 +66,26 @@ internal class IntegrationTest { val jsonMapper = jsonMapper() val integration = Integration.builder() - .id("id") + .id("42") .config( Integration.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Integration.EventType.TWEET_NEW) + .addEventType(Integration.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(Integration.Type.TELEGRAM) .filters( Integration.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() val roundtrippedIntegration = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParamsTest.kt index dbce7af..b31c7fa 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateParamsTest.kt @@ -2,7 +2,6 @@ package com.x_twitter_scraper.api.models.integrations -import com.x_twitter_scraper.api.core.JsonValue import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,20 +13,13 @@ internal class IntegrationUpdateParamsTest { IntegrationUpdateParams.builder() .id("id") .addEventType(IntegrationUpdateParams.EventType.TWEET_NEW) - .filters( - IntegrationUpdateParams.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .addEventType(IntegrationUpdateParams.EventType.FOLLOWER_GAINED) + .filters(IntegrationUpdateParams.Filters.builder().build()) .isActive(true) - .messageTemplate( - IntegrationUpdateParams.MessageTemplate.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") + .messageTemplate(IntegrationUpdateParams.MessageTemplate.builder().build()) + .name("My Telegram Bot") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() } @@ -46,42 +38,29 @@ internal class IntegrationUpdateParamsTest { IntegrationUpdateParams.builder() .id("id") .addEventType(IntegrationUpdateParams.EventType.TWEET_NEW) - .filters( - IntegrationUpdateParams.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .addEventType(IntegrationUpdateParams.EventType.FOLLOWER_GAINED) + .filters(IntegrationUpdateParams.Filters.builder().build()) .isActive(true) - .messageTemplate( - IntegrationUpdateParams.MessageTemplate.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") + .messageTemplate(IntegrationUpdateParams.MessageTemplate.builder().build()) + .name("My Telegram Bot") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() val body = params._body() assertThat(body.eventTypes().getOrNull()) - .containsExactly(IntegrationUpdateParams.EventType.TWEET_NEW) - assertThat(body.filters()) - .contains( - IntegrationUpdateParams.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() + .containsExactly( + IntegrationUpdateParams.EventType.TWEET_NEW, + IntegrationUpdateParams.EventType.FOLLOWER_GAINED, ) + assertThat(body.filters()).contains(IntegrationUpdateParams.Filters.builder().build()) assertThat(body.isActive()).contains(true) assertThat(body.messageTemplate()) - .contains( - IntegrationUpdateParams.MessageTemplate.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.name()).contains("name") + .contains(IntegrationUpdateParams.MessageTemplate.builder().build()) + assertThat(body.name()).contains("My Telegram Bot") assertThat(body.scopeAllMonitors()).contains(true) - assertThat(body.silentPush()).contains(true) + assertThat(body.silentPush()).contains(false) } @Test diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponseTest.kt index 2516a6e..ecad87f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponseTest.kt @@ -15,51 +15,56 @@ internal class IntegrationUpdateResponseTest { fun create() { val integrationUpdateResponse = IntegrationUpdateResponse.builder() - .id("id") + .id("42") .config( IntegrationUpdateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationUpdateResponse.EventType.TWEET_NEW) + .addEventType(IntegrationUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationUpdateResponse.Type.TELEGRAM) .filters( IntegrationUpdateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() - assertThat(integrationUpdateResponse.id()).isEqualTo("id") + assertThat(integrationUpdateResponse.id()).isEqualTo("42") assertThat(integrationUpdateResponse.config()) .isEqualTo( IntegrationUpdateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) assertThat(integrationUpdateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(integrationUpdateResponse.eventTypes()) - .containsExactly(IntegrationUpdateResponse.EventType.TWEET_NEW) + .containsExactly( + IntegrationUpdateResponse.EventType.TWEET_NEW, + IntegrationUpdateResponse.EventType.FOLLOWER_GAINED, + ) assertThat(integrationUpdateResponse.isActive()).isEqualTo(true) - assertThat(integrationUpdateResponse.name()).isEqualTo("name") + assertThat(integrationUpdateResponse.name()).isEqualTo("My Telegram Bot") assertThat(integrationUpdateResponse.type()) .isEqualTo(IntegrationUpdateResponse.Type.TELEGRAM) assertThat(integrationUpdateResponse.filters()) .contains( IntegrationUpdateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - assertThat(integrationUpdateResponse.messageTemplate()).contains("messageTemplate") + assertThat(integrationUpdateResponse.messageTemplate()) + .contains("New event: {{event.type}}") assertThat(integrationUpdateResponse.scopeAllMonitors()).contains(true) - assertThat(integrationUpdateResponse.silentPush()).contains(true) + assertThat(integrationUpdateResponse.silentPush()).contains(false) } @Test @@ -67,25 +72,26 @@ internal class IntegrationUpdateResponseTest { val jsonMapper = jsonMapper() val integrationUpdateResponse = IntegrationUpdateResponse.builder() - .id("id") + .id("42") .config( IntegrationUpdateResponse.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("chatId", JsonValue.from("bar")) .build() ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(IntegrationUpdateResponse.EventType.TWEET_NEW) + .addEventType(IntegrationUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .name("name") + .name("My Telegram Bot") .type(IntegrationUpdateResponse.Type.TELEGRAM) .filters( IntegrationUpdateResponse.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("minFollowers", JsonValue.from("bar")) .build() ) - .messageTemplate("messageTemplate") + .messageTemplate("New event: {{event.type}}") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() val roundtrippedIntegrationUpdateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParamsTest.kt index 8d2a61d..4af7054 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParamsTest.kt @@ -11,7 +11,8 @@ internal class MonitorCreateParamsTest { fun create() { MonitorCreateParams.builder() .addEventType(MonitorCreateParams.EventType.TWEET_NEW) - .username("username") + .addEventType(MonitorCreateParams.EventType.FOLLOWER_GAINED) + .username("elonmusk") .build() } @@ -20,12 +21,17 @@ internal class MonitorCreateParamsTest { val params = MonitorCreateParams.builder() .addEventType(MonitorCreateParams.EventType.TWEET_NEW) - .username("username") + .addEventType(MonitorCreateParams.EventType.FOLLOWER_GAINED) + .username("elonmusk") .build() val body = params._body() - assertThat(body.eventTypes()).containsExactly(MonitorCreateParams.EventType.TWEET_NEW) - assertThat(body.username()).isEqualTo("username") + assertThat(body.eventTypes()) + .containsExactly( + MonitorCreateParams.EventType.TWEET_NEW, + MonitorCreateParams.EventType.FOLLOWER_GAINED, + ) + assertThat(body.username()).isEqualTo("elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponseTest.kt index 9a0bc41..9df79c0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponseTest.kt @@ -14,20 +14,24 @@ internal class MonitorCreateResponseTest { fun create() { val monitorCreateResponse = MonitorCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorCreateResponse.EventType.TWEET_NEW) - .username("username") - .xUserId("xUserId") + .addEventType(MonitorCreateResponse.EventType.FOLLOWER_GAINED) + .username("elonmusk") + .xUserId("1234567890") .build() - assertThat(monitorCreateResponse.id()).isEqualTo("id") + assertThat(monitorCreateResponse.id()).isEqualTo("42") assertThat(monitorCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(monitorCreateResponse.eventTypes()) - .containsExactly(MonitorCreateResponse.EventType.TWEET_NEW) - assertThat(monitorCreateResponse.username()).isEqualTo("username") - assertThat(monitorCreateResponse.xUserId()).isEqualTo("xUserId") + .containsExactly( + MonitorCreateResponse.EventType.TWEET_NEW, + MonitorCreateResponse.EventType.FOLLOWER_GAINED, + ) + assertThat(monitorCreateResponse.username()).isEqualTo("elonmusk") + assertThat(monitorCreateResponse.xUserId()).isEqualTo("1234567890") } @Test @@ -35,11 +39,12 @@ internal class MonitorCreateResponseTest { val jsonMapper = jsonMapper() val monitorCreateResponse = MonitorCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorCreateResponse.EventType.TWEET_NEW) - .username("username") - .xUserId("xUserId") + .addEventType(MonitorCreateResponse.EventType.FOLLOWER_GAINED) + .username("elonmusk") + .xUserId("1234567890") .build() val roundtrippedMonitorCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponseTest.kt index d652438..38466f4 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponseTest.kt @@ -16,12 +16,13 @@ internal class MonitorListResponseTest { MonitorListResponse.builder() .addMonitor( MonitorListResponse.Monitor.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorListResponse.Monitor.EventType.TWEET_NEW) + .addEventType(MonitorListResponse.Monitor.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() ) .total(0L) @@ -30,12 +31,13 @@ internal class MonitorListResponseTest { assertThat(monitorListResponse.monitors()) .containsExactly( MonitorListResponse.Monitor.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorListResponse.Monitor.EventType.TWEET_NEW) + .addEventType(MonitorListResponse.Monitor.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() ) assertThat(monitorListResponse.total()).isEqualTo(0L) @@ -48,12 +50,13 @@ internal class MonitorListResponseTest { MonitorListResponse.builder() .addMonitor( MonitorListResponse.Monitor.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorListResponse.Monitor.EventType.TWEET_NEW) + .addEventType(MonitorListResponse.Monitor.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() ) .total(0L) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponseTest.kt index 2504c7f..670a643 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponseTest.kt @@ -14,22 +14,26 @@ internal class MonitorRetrieveResponseTest { fun create() { val monitorRetrieveResponse = MonitorRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorRetrieveResponse.EventType.TWEET_NEW) + .addEventType(MonitorRetrieveResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() - assertThat(monitorRetrieveResponse.id()).isEqualTo("id") + assertThat(monitorRetrieveResponse.id()).isEqualTo("42") assertThat(monitorRetrieveResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(monitorRetrieveResponse.eventTypes()) - .containsExactly(MonitorRetrieveResponse.EventType.TWEET_NEW) + .containsExactly( + MonitorRetrieveResponse.EventType.TWEET_NEW, + MonitorRetrieveResponse.EventType.FOLLOWER_GAINED, + ) assertThat(monitorRetrieveResponse.isActive()).isEqualTo(true) - assertThat(monitorRetrieveResponse.username()).isEqualTo("username") - assertThat(monitorRetrieveResponse.xUserId()).isEqualTo("xUserId") + assertThat(monitorRetrieveResponse.username()).isEqualTo("elonmusk") + assertThat(monitorRetrieveResponse.xUserId()).isEqualTo("9876543210") } @Test @@ -37,12 +41,13 @@ internal class MonitorRetrieveResponseTest { val jsonMapper = jsonMapper() val monitorRetrieveResponse = MonitorRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorRetrieveResponse.EventType.TWEET_NEW) + .addEventType(MonitorRetrieveResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() val roundtrippedMonitorRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorTest.kt index 21b43a9..fb066e6 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorTest.kt @@ -14,20 +14,22 @@ internal class MonitorTest { fun create() { val monitor = Monitor.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Monitor.EventType.TWEET_NEW) + .addEventType(Monitor.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() - assertThat(monitor.id()).isEqualTo("id") - assertThat(monitor.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(monitor.eventTypes()).containsExactly(Monitor.EventType.TWEET_NEW) + assertThat(monitor.id()).isEqualTo("42") + assertThat(monitor.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(monitor.eventTypes()) + .containsExactly(Monitor.EventType.TWEET_NEW, Monitor.EventType.FOLLOWER_GAINED) assertThat(monitor.isActive()).isEqualTo(true) - assertThat(monitor.username()).isEqualTo("username") - assertThat(monitor.xUserId()).isEqualTo("xUserId") + assertThat(monitor.username()).isEqualTo("elonmusk") + assertThat(monitor.xUserId()).isEqualTo("9876543210") } @Test @@ -35,12 +37,13 @@ internal class MonitorTest { val jsonMapper = jsonMapper() val monitor = Monitor.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Monitor.EventType.TWEET_NEW) + .addEventType(Monitor.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() val roundtrippedMonitor = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponseTest.kt index e601410..ace2d7d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponseTest.kt @@ -14,22 +14,26 @@ internal class MonitorUpdateResponseTest { fun create() { val monitorUpdateResponse = MonitorUpdateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorUpdateResponse.EventType.TWEET_NEW) + .addEventType(MonitorUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() - assertThat(monitorUpdateResponse.id()).isEqualTo("id") + assertThat(monitorUpdateResponse.id()).isEqualTo("42") assertThat(monitorUpdateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(monitorUpdateResponse.eventTypes()) - .containsExactly(MonitorUpdateResponse.EventType.TWEET_NEW) + .containsExactly( + MonitorUpdateResponse.EventType.TWEET_NEW, + MonitorUpdateResponse.EventType.FOLLOWER_GAINED, + ) assertThat(monitorUpdateResponse.isActive()).isEqualTo(true) - assertThat(monitorUpdateResponse.username()).isEqualTo("username") - assertThat(monitorUpdateResponse.xUserId()).isEqualTo("xUserId") + assertThat(monitorUpdateResponse.username()).isEqualTo("elonmusk") + assertThat(monitorUpdateResponse.xUserId()).isEqualTo("9876543210") } @Test @@ -37,12 +41,13 @@ internal class MonitorUpdateResponseTest { val jsonMapper = jsonMapper() val monitorUpdateResponse = MonitorUpdateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(MonitorUpdateResponse.EventType.TWEET_NEW) + .addEventType(MonitorUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .username("username") - .xUserId("xUserId") + .username("elonmusk") + .xUserId("9876543210") .build() val roundtrippedMonitorUpdateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarItemTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarItemTest.kt index 8fbf0cd..3587855 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarItemTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarItemTest.kt @@ -14,27 +14,26 @@ internal class RadarItemTest { fun create() { val radarItem = RadarItem.builder() - .category("category") - .publishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .region("region") - .score(0.0) - .source("source") - .title("title") - .description("description") - .imageUrl("imageUrl") - .url("url") + .category("Technology") + .publishedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .region("US") + .score(95.5) + .source("X") + .title("AI Revolution in 2025") + .description("AI is transforming every industry") + .imageUrl("https://example.com/images/ai.jpg") + .url("https://example.com/article/ai-revolution") .build() - assertThat(radarItem.category()).isEqualTo("category") - assertThat(radarItem.publishedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(radarItem.region()).isEqualTo("region") - assertThat(radarItem.score()).isEqualTo(0.0) - assertThat(radarItem.source()).isEqualTo("source") - assertThat(radarItem.title()).isEqualTo("title") - assertThat(radarItem.description()).contains("description") - assertThat(radarItem.imageUrl()).contains("imageUrl") - assertThat(radarItem.url()).contains("url") + assertThat(radarItem.category()).isEqualTo("Technology") + assertThat(radarItem.publishedAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(radarItem.region()).isEqualTo("US") + assertThat(radarItem.score()).isEqualTo(95.5) + assertThat(radarItem.source()).isEqualTo("X") + assertThat(radarItem.title()).isEqualTo("AI Revolution in 2025") + assertThat(radarItem.description()).contains("AI is transforming every industry") + assertThat(radarItem.imageUrl()).contains("https://example.com/images/ai.jpg") + assertThat(radarItem.url()).contains("https://example.com/article/ai-revolution") } @Test @@ -42,15 +41,15 @@ internal class RadarItemTest { val jsonMapper = jsonMapper() val radarItem = RadarItem.builder() - .category("category") - .publishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .region("region") - .score(0.0) - .source("source") - .title("title") - .description("description") - .imageUrl("imageUrl") - .url("url") + .category("Technology") + .publishedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .region("US") + .score(95.5) + .source("X") + .title("AI Revolution in 2025") + .description("AI is transforming every industry") + .imageUrl("https://example.com/images/ai.jpg") + .url("https://example.com/article/ai-revolution") .build() val roundtrippedRadarItem = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParamsTest.kt index e234008..7ff3ba6 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsParamsTest.kt @@ -15,7 +15,7 @@ internal class RadarRetrieveTrendingTopicsParamsTest { .count(0L) .hours(0L) .region("region") - .source("source") + .source(RadarRetrieveTrendingTopicsParams.Source.GITHUB) .build() } @@ -27,7 +27,7 @@ internal class RadarRetrieveTrendingTopicsParamsTest { .count(0L) .hours(0L) .region("region") - .source("source") + .source(RadarRetrieveTrendingTopicsParams.Source.GITHUB) .build() val queryParams = params._queryParams() @@ -39,7 +39,7 @@ internal class RadarRetrieveTrendingTopicsParamsTest { .put("count", "0") .put("hours", "0") .put("region", "region") - .put("source", "source") + .put("source", "github") .build() ) } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponseTest.kt index 69bab7d..b3d64e3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/radar/RadarRetrieveTrendingTopicsResponseTest.kt @@ -16,15 +16,15 @@ internal class RadarRetrieveTrendingTopicsResponseTest { RadarRetrieveTrendingTopicsResponse.builder() .addItem( RadarRetrieveTrendingTopicsResponse.Item.builder() - .category("category") - .publishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .region("region") - .score(0.0) - .source("source") - .title("title") - .description("description") - .imageUrl("imageUrl") - .url("url") + .category("Technology") + .publishedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .region("US") + .score(95.5) + .source("X") + .title("AI Revolution in 2025") + .description("AI is transforming every industry") + .imageUrl("https://example.com/images/ai.jpg") + .url("https://example.com/article/ai-revolution") .build() ) .total(0L) @@ -33,15 +33,15 @@ internal class RadarRetrieveTrendingTopicsResponseTest { assertThat(radarRetrieveTrendingTopicsResponse.items()) .containsExactly( RadarRetrieveTrendingTopicsResponse.Item.builder() - .category("category") - .publishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .region("region") - .score(0.0) - .source("source") - .title("title") - .description("description") - .imageUrl("imageUrl") - .url("url") + .category("Technology") + .publishedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .region("US") + .score(95.5) + .source("X") + .title("AI Revolution in 2025") + .description("AI is transforming every industry") + .imageUrl("https://example.com/images/ai.jpg") + .url("https://example.com/article/ai-revolution") .build() ) assertThat(radarRetrieveTrendingTopicsResponse.total()).isEqualTo(0L) @@ -54,15 +54,15 @@ internal class RadarRetrieveTrendingTopicsResponseTest { RadarRetrieveTrendingTopicsResponse.builder() .addItem( RadarRetrieveTrendingTopicsResponse.Item.builder() - .category("category") - .publishedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .region("region") - .score(0.0) - .source("source") - .title("title") - .description("description") - .imageUrl("imageUrl") - .url("url") + .category("Technology") + .publishedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .region("US") + .score(95.5) + .source("X") + .title("AI Revolution in 2025") + .description("AI is transforming every industry") + .imageUrl("https://example.com/images/ai.jpg") + .url("https://example.com/article/ai-revolution") .build() ) .total(0L) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeParamsTest.kt index edd2d44..262cc4d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeParamsTest.kt @@ -9,15 +9,15 @@ internal class StyleAnalyzeParamsTest { @Test fun create() { - StyleAnalyzeParams.builder().username("username").build() + StyleAnalyzeParams.builder().username("elonmusk").build() } @Test fun body() { - val params = StyleAnalyzeParams.builder().username("username").build() + val params = StyleAnalyzeParams.builder().username("elonmusk").build() val body = params._body() - assertThat(body.username()).isEqualTo("username") + assertThat(body.username()).isEqualTo("elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponseTest.kt index 2596c26..9b495ae 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponseTest.kt @@ -14,34 +14,34 @@ internal class StyleAnalyzeResponseTest { fun create() { val styleAnalyzeResponse = StyleAnalyzeResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleAnalyzeResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() assertThat(styleAnalyzeResponse.fetchedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(styleAnalyzeResponse.isOwnAccount()).isEqualTo(true) - assertThat(styleAnalyzeResponse.tweetCount()).isEqualTo(0L) + assertThat(styleAnalyzeResponse.tweetCount()).isEqualTo(50L) assertThat(styleAnalyzeResponse.tweets()) .containsExactly( StyleAnalyzeResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - assertThat(styleAnalyzeResponse.xUsername()).isEqualTo("xUsername") + assertThat(styleAnalyzeResponse.xUsername()).isEqualTo("elonmusk") } @Test @@ -49,18 +49,18 @@ internal class StyleAnalyzeResponseTest { val jsonMapper = jsonMapper() val styleAnalyzeResponse = StyleAnalyzeResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleAnalyzeResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() val roundtrippedStyleAnalyzeResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponseTest.kt index f3eb86e..6cdf5e2 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponseTest.kt @@ -16,34 +16,34 @@ internal class StyleCompareResponseTest { StyleCompareResponse.builder() .style1( StyleCompareResponse.Style1.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style1.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) .style2( StyleCompareResponse.Style2.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style2.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) .build() @@ -51,35 +51,35 @@ internal class StyleCompareResponseTest { assertThat(styleCompareResponse.style1()) .isEqualTo( StyleCompareResponse.Style1.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style1.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) assertThat(styleCompareResponse.style2()) .isEqualTo( StyleCompareResponse.Style2.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style2.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) } @@ -91,34 +91,34 @@ internal class StyleCompareResponseTest { StyleCompareResponse.builder() .style1( StyleCompareResponse.Style1.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style1.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) .style2( StyleCompareResponse.Style2.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleCompareResponse.Style2.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParamsTest.kt deleted file mode 100644 index 92e1c66..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleDeleteParamsTest { - - @Test - fun create() { - StyleDeleteParams.builder().username("username").build() - } - - @Test - fun pathParams() { - val params = StyleDeleteParams.builder().username("username").build() - - assertThat(params._pathParam(0)).isEqualTo("username") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParamsTest.kt deleted file mode 100644 index 28bcb46..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleGetPerformanceParamsTest { - - @Test - fun create() { - StyleGetPerformanceParams.builder().username("username").build() - } - - @Test - fun pathParams() { - val params = StyleGetPerformanceParams.builder().username("username").build() - - assertThat(params._pathParam(0)).isEqualTo("username") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponseTest.kt deleted file mode 100644 index cb8c136..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponseTest.kt +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleGetPerformanceResponseTest { - - @Test - fun create() { - val styleGetPerformanceResponse = - StyleGetPerformanceResponse.builder() - .tweetCount(0L) - .addTweet( - StyleGetPerformanceResponse.Tweet.builder() - .id("id") - .text("text") - .createdAt("createdAt") - .likeCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) - .build() - ) - .xUsername("xUsername") - .build() - - assertThat(styleGetPerformanceResponse.tweetCount()).isEqualTo(0L) - assertThat(styleGetPerformanceResponse.tweets()) - .containsExactly( - StyleGetPerformanceResponse.Tweet.builder() - .id("id") - .text("text") - .createdAt("createdAt") - .likeCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) - .build() - ) - assertThat(styleGetPerformanceResponse.xUsername()).isEqualTo("xUsername") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val styleGetPerformanceResponse = - StyleGetPerformanceResponse.builder() - .tweetCount(0L) - .addTweet( - StyleGetPerformanceResponse.Tweet.builder() - .id("id") - .text("text") - .createdAt("createdAt") - .likeCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) - .build() - ) - .xUsername("xUsername") - .build() - - val roundtrippedStyleGetPerformanceResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(styleGetPerformanceResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedStyleGetPerformanceResponse).isEqualTo(styleGetPerformanceResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponseTest.kt index f6c86f5..fa6ba47 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleListResponseTest.kt @@ -16,10 +16,10 @@ internal class StyleListResponseTest { StyleListResponse.builder() .addStyle( StyleListResponse.Style.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) - .xUsername("xUsername") + .tweetCount(50L) + .xUsername("elonmusk") .build() ) .build() @@ -27,10 +27,10 @@ internal class StyleListResponseTest { assertThat(styleListResponse.styles()) .containsExactly( StyleListResponse.Style.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) - .xUsername("xUsername") + .tweetCount(50L) + .xUsername("elonmusk") .build() ) } @@ -42,10 +42,10 @@ internal class StyleListResponseTest { StyleListResponse.builder() .addStyle( StyleListResponse.Style.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) - .xUsername("xUsername") + .tweetCount(50L) + .xUsername("elonmusk") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummaryTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummaryTest.kt index 0e9c3c9..6b85d82 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummaryTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileSummaryTest.kt @@ -14,17 +14,17 @@ internal class StyleProfileSummaryTest { fun create() { val styleProfileSummary = StyleProfileSummary.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) - .xUsername("xUsername") + .tweetCount(50L) + .xUsername("elonmusk") .build() assertThat(styleProfileSummary.fetchedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(styleProfileSummary.isOwnAccount()).isEqualTo(true) - assertThat(styleProfileSummary.tweetCount()).isEqualTo(0L) - assertThat(styleProfileSummary.xUsername()).isEqualTo("xUsername") + assertThat(styleProfileSummary.tweetCount()).isEqualTo(50L) + assertThat(styleProfileSummary.xUsername()).isEqualTo("elonmusk") } @Test @@ -32,10 +32,10 @@ internal class StyleProfileSummaryTest { val jsonMapper = jsonMapper() val styleProfileSummary = StyleProfileSummary.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) - .xUsername("xUsername") + .tweetCount(50L) + .xUsername("elonmusk") .build() val roundtrippedStyleProfileSummary = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileTest.kt index 641364a..a9e0c6b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleProfileTest.kt @@ -14,34 +14,33 @@ internal class StyleProfileTest { fun create() { val styleProfile = StyleProfile.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleProfile.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() - assertThat(styleProfile.fetchedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(styleProfile.fetchedAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(styleProfile.isOwnAccount()).isEqualTo(true) - assertThat(styleProfile.tweetCount()).isEqualTo(0L) + assertThat(styleProfile.tweetCount()).isEqualTo(50L) assertThat(styleProfile.tweets()) .containsExactly( StyleProfile.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - assertThat(styleProfile.xUsername()).isEqualTo("xUsername") + assertThat(styleProfile.xUsername()).isEqualTo("elonmusk") } @Test @@ -49,18 +48,18 @@ internal class StyleProfileTest { val jsonMapper = jsonMapper() val styleProfile = StyleProfile.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .fetchedAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .isOwnAccount(true) - .tweetCount(0L) + .tweetCount(50L) .addTweet( StyleProfile.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") + .id("1234567890") + .text("Just launched our new feature!") + .authorUsername("elonmusk") + .createdAt("2025-01-15T12:00:00Z") .build() ) - .xUsername("xUsername") + .xUsername("elonmusk") .build() val roundtrippedStyleProfile = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParamsTest.kt deleted file mode 100644 index 315a4e0..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleRetrieveParamsTest { - - @Test - fun create() { - StyleRetrieveParams.builder().username("username").build() - } - - @Test - fun pathParams() { - val params = StyleRetrieveParams.builder().username("username").build() - - assertThat(params._pathParam(0)).isEqualTo("username") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponseTest.kt deleted file mode 100644 index 866d927..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponseTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleRetrieveResponseTest { - - @Test - fun create() { - val styleRetrieveResponse = - StyleRetrieveResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isOwnAccount(true) - .tweetCount(0L) - .addTweet( - StyleRetrieveResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - .xUsername("xUsername") - .build() - - assertThat(styleRetrieveResponse.fetchedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(styleRetrieveResponse.isOwnAccount()).isEqualTo(true) - assertThat(styleRetrieveResponse.tweetCount()).isEqualTo(0L) - assertThat(styleRetrieveResponse.tweets()) - .containsExactly( - StyleRetrieveResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - assertThat(styleRetrieveResponse.xUsername()).isEqualTo("xUsername") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val styleRetrieveResponse = - StyleRetrieveResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isOwnAccount(true) - .tweetCount(0L) - .addTweet( - StyleRetrieveResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - .xUsername("xUsername") - .build() - - val roundtrippedStyleRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(styleRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedStyleRetrieveResponse).isEqualTo(styleRetrieveResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParamsTest.kt deleted file mode 100644 index a9132d3..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParamsTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleUpdateParamsTest { - - @Test - fun create() { - StyleUpdateParams.builder() - .username("username") - .label("label") - .addTweet(StyleUpdateParams.Tweet.builder().text("text").build()) - .build() - } - - @Test - fun pathParams() { - val params = - StyleUpdateParams.builder() - .username("username") - .label("label") - .addTweet(StyleUpdateParams.Tweet.builder().text("text").build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("username") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - StyleUpdateParams.builder() - .username("username") - .label("label") - .addTweet(StyleUpdateParams.Tweet.builder().text("text").build()) - .build() - - val body = params._body() - - assertThat(body.label()).isEqualTo("label") - assertThat(body.tweets()) - .containsExactly(StyleUpdateParams.Tweet.builder().text("text").build()) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponseTest.kt deleted file mode 100644 index fcb3bcd..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponseTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.styles - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class StyleUpdateResponseTest { - - @Test - fun create() { - val styleUpdateResponse = - StyleUpdateResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isOwnAccount(true) - .tweetCount(0L) - .addTweet( - StyleUpdateResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - .xUsername("xUsername") - .build() - - assertThat(styleUpdateResponse.fetchedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(styleUpdateResponse.isOwnAccount()).isEqualTo(true) - assertThat(styleUpdateResponse.tweetCount()).isEqualTo(0L) - assertThat(styleUpdateResponse.tweets()) - .containsExactly( - StyleUpdateResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - assertThat(styleUpdateResponse.xUsername()).isEqualTo("xUsername") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val styleUpdateResponse = - StyleUpdateResponse.builder() - .fetchedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .isOwnAccount(true) - .tweetCount(0L) - .addTweet( - StyleUpdateResponse.Tweet.builder() - .id("id") - .text("text") - .authorUsername("authorUsername") - .createdAt("createdAt") - .build() - ) - .xUsername("xUsername") - .build() - - val roundtrippedStyleUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(styleUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedStyleUpdateResponse).isEqualTo(styleUpdateResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/subscribe/SubscribeCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/subscribe/SubscribeCreateResponseTest.kt index 9524bc5..807b46b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/subscribe/SubscribeCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/subscribe/SubscribeCreateResponseTest.kt @@ -13,13 +13,14 @@ internal class SubscribeCreateResponseTest { fun create() { val subscribeCreateResponse = SubscribeCreateResponse.builder() - .url("https://example.com") - .message("message") + .url("https://checkout.stripe.com/c/pay/cs_test_123") + .message("Checkout session created") .status(SubscribeCreateResponse.Status.CHECKOUT_CREATED) .build() - assertThat(subscribeCreateResponse.url()).isEqualTo("https://example.com") - assertThat(subscribeCreateResponse.message()).contains("message") + assertThat(subscribeCreateResponse.url()) + .isEqualTo("https://checkout.stripe.com/c/pay/cs_test_123") + assertThat(subscribeCreateResponse.message()).contains("Checkout session created") assertThat(subscribeCreateResponse.status()) .contains(SubscribeCreateResponse.Status.CHECKOUT_CREATED) } @@ -29,8 +30,8 @@ internal class SubscribeCreateResponseTest { val jsonMapper = jsonMapper() val subscribeCreateResponse = SubscribeCreateResponse.builder() - .url("https://example.com") - .message("message") + .url("https://checkout.stripe.com/c/pay/cs_test_123") + .message("Checkout session created") .status(SubscribeCreateResponse.Status.CHECKOUT_CREATED) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateParamsTest.kt index ade9f5b..f1f6a06 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateParamsTest.kt @@ -9,16 +9,23 @@ internal class TicketCreateParamsTest { @Test fun create() { - TicketCreateParams.builder().body("body").subject("subject").build() + TicketCreateParams.builder() + .body("I am unable to connect my X account. Please help.") + .subject("Cannot connect X account") + .build() } @Test fun body() { - val params = TicketCreateParams.builder().body("body").subject("subject").build() + val params = + TicketCreateParams.builder() + .body("I am unable to connect my X account. Please help.") + .subject("Cannot connect X account") + .build() val body = params._body() - assertThat(body.body()).isEqualTo("body") - assertThat(body.subject()).isEqualTo("subject") + assertThat(body.body()).isEqualTo("I am unable to connect my X account. Please help.") + assertThat(body.subject()).isEqualTo("Cannot connect X account") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateResponseTest.kt index 927f112..45d4ee8 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketCreateResponseTest.kt @@ -11,15 +11,15 @@ internal class TicketCreateResponseTest { @Test fun create() { - val ticketCreateResponse = TicketCreateResponse.builder().publicId("publicId").build() + val ticketCreateResponse = TicketCreateResponse.builder().publicId("tk_abc123").build() - assertThat(ticketCreateResponse.publicId()).contains("publicId") + assertThat(ticketCreateResponse.publicId()).contains("tk_abc123") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val ticketCreateResponse = TicketCreateResponse.builder().publicId("publicId").build() + val ticketCreateResponse = TicketCreateResponse.builder().publicId("tk_abc123").build() val roundtrippedTicketCreateResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketListResponseTest.kt index 1da918b..5ed7eda 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketListResponseTest.kt @@ -17,12 +17,12 @@ internal class TicketListResponseTest { TicketListResponse.builder() .addTicket( TicketListResponse.Ticket.builder() - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .messageCount(0L) - .publicId("publicId") - .status("status") - .subject("subject") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .messageCount(2L) + .publicId("tk_abc123") + .status("open") + .subject("Cannot connect X account") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) .build() ) .build() @@ -30,12 +30,12 @@ internal class TicketListResponseTest { assertThat(ticketListResponse.tickets().getOrNull()) .containsExactly( TicketListResponse.Ticket.builder() - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .messageCount(0L) - .publicId("publicId") - .status("status") - .subject("subject") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .messageCount(2L) + .publicId("tk_abc123") + .status("open") + .subject("Cannot connect X account") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) .build() ) } @@ -47,12 +47,12 @@ internal class TicketListResponseTest { TicketListResponse.builder() .addTicket( TicketListResponse.Ticket.builder() - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .messageCount(0L) - .publicId("publicId") - .status("status") - .subject("subject") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .messageCount(2L) + .publicId("tk_abc123") + .status("open") + .subject("Cannot connect X account") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyParamsTest.kt index c8713f6..05aff9b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyParamsTest.kt @@ -9,12 +9,12 @@ internal class TicketReplyParamsTest { @Test fun create() { - TicketReplyParams.builder().id("id").body("body").build() + TicketReplyParams.builder().id("id").body("Thank you for the update.").build() } @Test fun pathParams() { - val params = TicketReplyParams.builder().id("id").body("body").build() + val params = TicketReplyParams.builder().id("id").body("Thank you for the update.").build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -23,10 +23,10 @@ internal class TicketReplyParamsTest { @Test fun body() { - val params = TicketReplyParams.builder().id("id").body("body").build() + val params = TicketReplyParams.builder().id("id").body("Thank you for the update.").build() val body = params._body() - assertThat(body.body()).isEqualTo("body") + assertThat(body.body()).isEqualTo("Thank you for the update.") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyResponseTest.kt index 29e4a58..24e3a00 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketReplyResponseTest.kt @@ -11,15 +11,15 @@ internal class TicketReplyResponseTest { @Test fun create() { - val ticketReplyResponse = TicketReplyResponse.builder().publicId("publicId").build() + val ticketReplyResponse = TicketReplyResponse.builder().publicId("tk_abc123").build() - assertThat(ticketReplyResponse.publicId()).contains("publicId") + assertThat(ticketReplyResponse.publicId()).contains("tk_abc123") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val ticketReplyResponse = TicketReplyResponse.builder().publicId("publicId").build() + val ticketReplyResponse = TicketReplyResponse.builder().publicId("tk_abc123").build() val roundtrippedTicketReplyResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveParamsTest.kt index 0d5fa3b..303c3bd 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveParamsTest.kt @@ -9,14 +9,14 @@ internal class TicketRetrieveParamsTest { @Test fun create() { - TicketRetrieveParams.builder().id("id").build() + TicketRetrieveParams.builder().id("messages_value").build() } @Test fun pathParams() { - val params = TicketRetrieveParams.builder().id("id").build() + val params = TicketRetrieveParams.builder().id("messages_value").build() - assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(0)).isEqualTo("messages_value") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveResponseTest.kt index 362beb7..b06bbed 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketRetrieveResponseTest.kt @@ -15,35 +15,35 @@ internal class TicketRetrieveResponseTest { fun create() { val ticketRetrieveResponse = TicketRetrieveResponse.builder() - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addMessage( TicketRetrieveResponse.Message.builder() - .body("body") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .sender("sender") + .body("I am unable to connect my X account.") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .sender("user") .build() ) - .publicId("publicId") - .status("status") - .subject("subject") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .publicId("tk_abc123") + .status("open") + .subject("Cannot connect X account") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) .build() assertThat(ticketRetrieveResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .contains(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(ticketRetrieveResponse.messages().getOrNull()) .containsExactly( TicketRetrieveResponse.Message.builder() - .body("body") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .sender("sender") + .body("I am unable to connect my X account.") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .sender("user") .build() ) - assertThat(ticketRetrieveResponse.publicId()).contains("publicId") - assertThat(ticketRetrieveResponse.status()).contains("status") - assertThat(ticketRetrieveResponse.subject()).contains("subject") + assertThat(ticketRetrieveResponse.publicId()).contains("tk_abc123") + assertThat(ticketRetrieveResponse.status()).contains("open") + assertThat(ticketRetrieveResponse.subject()).contains("Cannot connect X account") assertThat(ticketRetrieveResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .contains(OffsetDateTime.parse("2025-01-16T09:30:00Z")) } @Test @@ -51,18 +51,18 @@ internal class TicketRetrieveResponseTest { val jsonMapper = jsonMapper() val ticketRetrieveResponse = TicketRetrieveResponse.builder() - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addMessage( TicketRetrieveResponse.Message.builder() - .body("body") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .sender("sender") + .body("I am unable to connect my X account.") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .sender("user") .build() ) - .publicId("publicId") - .status("status") - .subject("subject") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .publicId("tk_abc123") + .status("open") + .subject("Cannot connect X account") + .updatedAt(OffsetDateTime.parse("2025-01-16T09:30:00Z")) .build() val roundtrippedTicketRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateParamsTest.kt index ccdf24a..a009116 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateParamsTest.kt @@ -9,13 +9,13 @@ internal class TicketUpdateParamsTest { @Test fun create() { - TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.OPEN).build() + TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.RESOLVED).build() } @Test fun pathParams() { val params = - TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.OPEN).build() + TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.RESOLVED).build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -25,10 +25,10 @@ internal class TicketUpdateParamsTest { @Test fun body() { val params = - TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.OPEN).build() + TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.RESOLVED).build() val body = params._body() - assertThat(body.status()).isEqualTo(TicketUpdateParams.Status.OPEN) + assertThat(body.status()).isEqualTo(TicketUpdateParams.Status.RESOLVED) } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateResponseTest.kt index 8b68ce2..84dd475 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/support/tickets/TicketUpdateResponseTest.kt @@ -12,17 +12,17 @@ internal class TicketUpdateResponseTest { @Test fun create() { val ticketUpdateResponse = - TicketUpdateResponse.builder().publicId("publicId").status("status").build() + TicketUpdateResponse.builder().publicId("tk_abc123").status("resolved").build() - assertThat(ticketUpdateResponse.publicId()).contains("publicId") - assertThat(ticketUpdateResponse.status()).contains("status") + assertThat(ticketUpdateResponse.publicId()).contains("tk_abc123") + assertThat(ticketUpdateResponse.status()).contains("resolved") } @Test fun roundtrip() { val jsonMapper = jsonMapper() val ticketUpdateResponse = - TicketUpdateResponse.builder().publicId("publicId").status("status").build() + TicketUpdateResponse.builder().publicId("tk_abc123").status("resolved").build() val roundtrippedTicketUpdateResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/trends/TrendListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/trends/TrendListResponseTest.kt index 5f8ba02..6a4af2c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/trends/TrendListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/trends/TrendListResponseTest.kt @@ -13,29 +13,29 @@ internal class TrendListResponseTest { fun create() { val trendListResponse = TrendListResponse.builder() - .total(0L) + .total(30L) .addTrend( TrendListResponse.Trend.builder() - .name("name") - .description("description") - .query("query") - .rank(0L) + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) .build() ) - .woeid(0L) + .woeid(1L) .build() - assertThat(trendListResponse.total()).isEqualTo(0L) + assertThat(trendListResponse.total()).isEqualTo(30L) assertThat(trendListResponse.trends()) .containsExactly( TrendListResponse.Trend.builder() - .name("name") - .description("description") - .query("query") - .rank(0L) + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) .build() ) - assertThat(trendListResponse.woeid()).isEqualTo(0L) + assertThat(trendListResponse.woeid()).isEqualTo(1L) } @Test @@ -43,16 +43,16 @@ internal class TrendListResponseTest { val jsonMapper = jsonMapper() val trendListResponse = TrendListResponse.builder() - .total(0L) + .total(30L) .addTrend( TrendListResponse.Trend.builder() - .name("name") - .description("description") - .query("query") - .rank(0L) + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) .build() ) - .woeid(0L) + .woeid(1L) .build() val roundtrippedTrendListResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParamsTest.kt index fb6697d..132e0b6 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateParamsTest.kt @@ -11,7 +11,8 @@ internal class WebhookCreateParamsTest { fun create() { WebhookCreateParams.builder() .addEventType(WebhookCreateParams.EventType.TWEET_NEW) - .url("https://example.com") + .addEventType(WebhookCreateParams.EventType.FOLLOWER_GAINED) + .url("https://example.com/webhook") .build() } @@ -20,12 +21,17 @@ internal class WebhookCreateParamsTest { val params = WebhookCreateParams.builder() .addEventType(WebhookCreateParams.EventType.TWEET_NEW) - .url("https://example.com") + .addEventType(WebhookCreateParams.EventType.FOLLOWER_GAINED) + .url("https://example.com/webhook") .build() val body = params._body() - assertThat(body.eventTypes()).containsExactly(WebhookCreateParams.EventType.TWEET_NEW) - assertThat(body.url()).isEqualTo("https://example.com") + assertThat(body.eventTypes()) + .containsExactly( + WebhookCreateParams.EventType.TWEET_NEW, + WebhookCreateParams.EventType.FOLLOWER_GAINED, + ) + assertThat(body.url()).isEqualTo("https://example.com/webhook") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponseTest.kt index c289925..51648ce 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookCreateResponseTest.kt @@ -14,20 +14,24 @@ internal class WebhookCreateResponseTest { fun create() { val webhookCreateResponse = WebhookCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookCreateResponse.EventType.TWEET_NEW) - .secret("secret") - .url("https://example.com") + .addEventType(WebhookCreateResponse.EventType.FOLLOWER_GAINED) + .secret("whsec_abc123def456") + .url("https://example.com/webhook") .build() - assertThat(webhookCreateResponse.id()).isEqualTo("id") + assertThat(webhookCreateResponse.id()).isEqualTo("42") assertThat(webhookCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(webhookCreateResponse.eventTypes()) - .containsExactly(WebhookCreateResponse.EventType.TWEET_NEW) - assertThat(webhookCreateResponse.secret()).isEqualTo("secret") - assertThat(webhookCreateResponse.url()).isEqualTo("https://example.com") + .containsExactly( + WebhookCreateResponse.EventType.TWEET_NEW, + WebhookCreateResponse.EventType.FOLLOWER_GAINED, + ) + assertThat(webhookCreateResponse.secret()).isEqualTo("whsec_abc123def456") + assertThat(webhookCreateResponse.url()).isEqualTo("https://example.com/webhook") } @Test @@ -35,11 +39,12 @@ internal class WebhookCreateResponseTest { val jsonMapper = jsonMapper() val webhookCreateResponse = WebhookCreateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookCreateResponse.EventType.TWEET_NEW) - .secret("secret") - .url("https://example.com") + .addEventType(WebhookCreateResponse.EventType.FOLLOWER_GAINED) + .secret("whsec_abc123def456") + .url("https://example.com/webhook") .build() val roundtrippedWebhookCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponseTest.kt index 6487843..2dc1c7e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookListResponseTest.kt @@ -16,11 +16,12 @@ internal class WebhookListResponseTest { WebhookListResponse.builder() .addWebhook( WebhookListResponse.Webhook.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookListResponse.Webhook.EventType.TWEET_NEW) + .addEventType(WebhookListResponse.Webhook.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() ) .build() @@ -28,11 +29,12 @@ internal class WebhookListResponseTest { assertThat(webhookListResponse.webhooks()) .containsExactly( WebhookListResponse.Webhook.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookListResponse.Webhook.EventType.TWEET_NEW) + .addEventType(WebhookListResponse.Webhook.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() ) } @@ -44,11 +46,12 @@ internal class WebhookListResponseTest { WebhookListResponse.builder() .addWebhook( WebhookListResponse.Webhook.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookListResponse.Webhook.EventType.TWEET_NEW) + .addEventType(WebhookListResponse.Webhook.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTest.kt index 889a9ab..b9a13e7 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTest.kt @@ -14,18 +14,20 @@ internal class WebhookTest { fun create() { val webhook = Webhook.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Webhook.EventType.TWEET_NEW) + .addEventType(Webhook.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() - assertThat(webhook.id()).isEqualTo("id") - assertThat(webhook.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(webhook.eventTypes()).containsExactly(Webhook.EventType.TWEET_NEW) + assertThat(webhook.id()).isEqualTo("42") + assertThat(webhook.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(webhook.eventTypes()) + .containsExactly(Webhook.EventType.TWEET_NEW, Webhook.EventType.FOLLOWER_GAINED) assertThat(webhook.isActive()).isEqualTo(true) - assertThat(webhook.url()).isEqualTo("https://example.com") + assertThat(webhook.url()).isEqualTo("https://example.com/webhooks/xquik") } @Test @@ -33,11 +35,12 @@ internal class WebhookTest { val jsonMapper = jsonMapper() val webhook = Webhook.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(Webhook.EventType.TWEET_NEW) + .addEventType(Webhook.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() val roundtrippedWebhook = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTestResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTestResponseTest.kt index f93d146..e7bd9b2 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTestResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookTestResponseTest.kt @@ -12,18 +12,18 @@ internal class WebhookTestResponseTest { @Test fun create() { val webhookTestResponse = - WebhookTestResponse.builder().statusCode(0L).success(true).error("error").build() + WebhookTestResponse.builder().statusCode(200L).success(true).error("").build() - assertThat(webhookTestResponse.statusCode()).isEqualTo(0L) + assertThat(webhookTestResponse.statusCode()).isEqualTo(200L) assertThat(webhookTestResponse.success()).isEqualTo(true) - assertThat(webhookTestResponse.error()).contains("error") + assertThat(webhookTestResponse.error()).contains("") } @Test fun roundtrip() { val jsonMapper = jsonMapper() val webhookTestResponse = - WebhookTestResponse.builder().statusCode(0L).success(true).error("error").build() + WebhookTestResponse.builder().statusCode(200L).success(true).error("").build() val roundtrippedWebhookTestResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParamsTest.kt index fa95abc..6f7a854 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateParamsTest.kt @@ -13,8 +13,9 @@ internal class WebhookUpdateParamsTest { WebhookUpdateParams.builder() .id("id") .addEventType(WebhookUpdateParams.EventType.TWEET_NEW) + .addEventType(WebhookUpdateParams.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhook") .build() } @@ -33,16 +34,20 @@ internal class WebhookUpdateParamsTest { WebhookUpdateParams.builder() .id("id") .addEventType(WebhookUpdateParams.EventType.TWEET_NEW) + .addEventType(WebhookUpdateParams.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhook") .build() val body = params._body() assertThat(body.eventTypes().getOrNull()) - .containsExactly(WebhookUpdateParams.EventType.TWEET_NEW) + .containsExactly( + WebhookUpdateParams.EventType.TWEET_NEW, + WebhookUpdateParams.EventType.FOLLOWER_GAINED, + ) assertThat(body.isActive()).contains(true) - assertThat(body.url()).contains("https://example.com") + assertThat(body.url()).contains("https://example.com/webhook") } @Test diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponseTest.kt index 46e11c6..6e66ec9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponseTest.kt @@ -14,20 +14,24 @@ internal class WebhookUpdateResponseTest { fun create() { val webhookUpdateResponse = WebhookUpdateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookUpdateResponse.EventType.TWEET_NEW) + .addEventType(WebhookUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() - assertThat(webhookUpdateResponse.id()).isEqualTo("id") + assertThat(webhookUpdateResponse.id()).isEqualTo("42") assertThat(webhookUpdateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) assertThat(webhookUpdateResponse.eventTypes()) - .containsExactly(WebhookUpdateResponse.EventType.TWEET_NEW) + .containsExactly( + WebhookUpdateResponse.EventType.TWEET_NEW, + WebhookUpdateResponse.EventType.FOLLOWER_GAINED, + ) assertThat(webhookUpdateResponse.isActive()).isEqualTo(true) - assertThat(webhookUpdateResponse.url()).isEqualTo("https://example.com") + assertThat(webhookUpdateResponse.url()).isEqualTo("https://example.com/webhooks/xquik") } @Test @@ -35,11 +39,12 @@ internal class WebhookUpdateResponseTest { val jsonMapper = jsonMapper() val webhookUpdateResponse = WebhookUpdateResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) .addEventType(WebhookUpdateResponse.EventType.TWEET_NEW) + .addEventType(WebhookUpdateResponse.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhooks/xquik") .build() val roundtrippedWebhookUpdateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponseTest.kt index 228c3ab..02d174b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetArticleResponseTest.kt @@ -17,30 +17,30 @@ internal class XGetArticleResponseTest { XGetArticleResponse.Article.builder() .addContent( XGetArticleResponse.Article.Content.builder() - .height(0L) - .text("text") - .type("type") - .url("url") - .width(0L) + .height(675L) + .text("This is the first paragraph of the article.") + .type("unstyled") + .url("https://pbs.twimg.com/media/example.jpg") + .width(1200L) .build() ) - .coverImageUrl("coverImageUrl") - .createdAt("createdAt") - .likeCount(0L) - .previewText("previewText") - .quoteCount(0L) - .replyCount(0L) - .title("title") - .viewCount(0L) + .coverImageUrl("https://pbs.twimg.com/media/example.jpg") + .createdAt("2025-01-15T12:00:00Z") + .likeCount(150L) + .previewText("A deep dive into the latest AI trends...") + .quoteCount(8L) + .replyCount(23L) + .title("The Future of AI") + .viewCount(5000L) .build() ) .author( XGetArticleResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") + .id("9876543210") + .followers(150000000L) + .username("elonmusk") .verified(true) - .profilePicture("profilePicture") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") .build() ) .build() @@ -50,31 +50,31 @@ internal class XGetArticleResponseTest { XGetArticleResponse.Article.builder() .addContent( XGetArticleResponse.Article.Content.builder() - .height(0L) - .text("text") - .type("type") - .url("url") - .width(0L) + .height(675L) + .text("This is the first paragraph of the article.") + .type("unstyled") + .url("https://pbs.twimg.com/media/example.jpg") + .width(1200L) .build() ) - .coverImageUrl("coverImageUrl") - .createdAt("createdAt") - .likeCount(0L) - .previewText("previewText") - .quoteCount(0L) - .replyCount(0L) - .title("title") - .viewCount(0L) + .coverImageUrl("https://pbs.twimg.com/media/example.jpg") + .createdAt("2025-01-15T12:00:00Z") + .likeCount(150L) + .previewText("A deep dive into the latest AI trends...") + .quoteCount(8L) + .replyCount(23L) + .title("The Future of AI") + .viewCount(5000L) .build() ) assertThat(xGetArticleResponse.author()) .contains( XGetArticleResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") + .id("9876543210") + .followers(150000000L) + .username("elonmusk") .verified(true) - .profilePicture("profilePicture") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") .build() ) } @@ -88,30 +88,30 @@ internal class XGetArticleResponseTest { XGetArticleResponse.Article.builder() .addContent( XGetArticleResponse.Article.Content.builder() - .height(0L) - .text("text") - .type("type") - .url("url") - .width(0L) + .height(675L) + .text("This is the first paragraph of the article.") + .type("unstyled") + .url("https://pbs.twimg.com/media/example.jpg") + .width(1200L) .build() ) - .coverImageUrl("coverImageUrl") - .createdAt("createdAt") - .likeCount(0L) - .previewText("previewText") - .quoteCount(0L) - .replyCount(0L) - .title("title") - .viewCount(0L) + .coverImageUrl("https://pbs.twimg.com/media/example.jpg") + .createdAt("2025-01-15T12:00:00Z") + .likeCount(150L) + .previewText("A deep dive into the latest AI trends...") + .quoteCount(8L) + .replyCount(23L) + .title("The Future of AI") + .viewCount(5000L) .build() ) .author( XGetArticleResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") + .id("9876543210") + .followers(150000000L) + .username("elonmusk") .verified(true) - .profilePicture("profilePicture") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponseTest.kt index 56414e3..c6eced1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponseTest.kt @@ -14,52 +14,54 @@ internal class XGetHomeTimelineResponseTest { val xGetHomeTimelineResponse = XGetHomeTimelineResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( XGetHomeTimelineResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( XGetHomeTimelineResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(xGetHomeTimelineResponse.hasNextPage()).isEqualTo(true) - assertThat(xGetHomeTimelineResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(xGetHomeTimelineResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(xGetHomeTimelineResponse.tweets()) .containsExactly( XGetHomeTimelineResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( XGetHomeTimelineResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class XGetHomeTimelineResponseTest { val xGetHomeTimelineResponse = XGetHomeTimelineResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( XGetHomeTimelineResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( XGetHomeTimelineResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsResponseTest.kt index 8327a41..26a082c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetNotificationsResponseTest.kt @@ -14,26 +14,26 @@ internal class XGetNotificationsResponseTest { val xGetNotificationsResponse = XGetNotificationsResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addNotification( XGetNotificationsResponse.Notification.builder() - .id("id") - .message("message") - .timestamp("timestamp") - .type("type") + .id("1234567890") + .message("elonmusk liked your tweet") + .timestamp("2025-01-15T12:00:00Z") + .type("like") .build() ) .build() assertThat(xGetNotificationsResponse.hasNextPage()).isEqualTo(true) - assertThat(xGetNotificationsResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(xGetNotificationsResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(xGetNotificationsResponse.notifications()) .containsExactly( XGetNotificationsResponse.Notification.builder() - .id("id") - .message("message") - .timestamp("timestamp") - .type("type") + .id("1234567890") + .message("elonmusk liked your tweet") + .timestamp("2025-01-15T12:00:00Z") + .type("like") .build() ) } @@ -44,13 +44,13 @@ internal class XGetNotificationsResponseTest { val xGetNotificationsResponse = XGetNotificationsResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addNotification( XGetNotificationsResponse.Notification.builder() - .id("id") - .message("message") - .timestamp("timestamp") - .type("type") + .id("1234567890") + .message("elonmusk liked your tweet") + .timestamp("2025-01-15T12:00:00Z") + .type("like") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponseTest.kt new file mode 100644 index 0000000..f005c33 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponseTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class XGetTrendsResponseTest { + + @Test + fun create() { + val xGetTrendsResponse = + XGetTrendsResponse.builder() + .count(30L) + .addTrend( + XGetTrendsResponse.Trend.builder() + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) + .build() + ) + .woeid(1L) + .build() + + assertThat(xGetTrendsResponse.count()).isEqualTo(30L) + assertThat(xGetTrendsResponse.trends()) + .containsExactly( + XGetTrendsResponse.Trend.builder() + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) + .build() + ) + assertThat(xGetTrendsResponse.woeid()).isEqualTo(1L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val xGetTrendsResponse = + XGetTrendsResponse.builder() + .count(30L) + .addTrend( + XGetTrendsResponse.Trend.builder() + .name("#AI") + .description("Artificial intelligence discussions") + .query("%23AI") + .rank(1L) + .build() + ) + .woeid(1L) + .build() + + val roundtrippedXGetTrendsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(xGetTrendsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedXGetTrendsResponse).isEqualTo(xGetTrendsResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateParamsTest.kt index 4795efd..82358fc 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateParamsTest.kt @@ -10,11 +10,11 @@ internal class AccountCreateParamsTest { @Test fun create() { AccountCreateParams.builder() - .email("email") - .password("password") - .username("username") - .proxyCountry("proxy_country") - .totpSecret("totp_secret") + .email("user@example.com") + .password("s3cur3Pa\$\$w0rd") + .username("elonmusk") + .proxyCountry("US") + .totpSecret("JBSWY3DPEHPK3PXP") .build() } @@ -22,35 +22,35 @@ internal class AccountCreateParamsTest { fun body() { val params = AccountCreateParams.builder() - .email("email") - .password("password") - .username("username") - .proxyCountry("proxy_country") - .totpSecret("totp_secret") + .email("user@example.com") + .password("s3cur3Pa\$\$w0rd") + .username("elonmusk") + .proxyCountry("US") + .totpSecret("JBSWY3DPEHPK3PXP") .build() val body = params._body() - assertThat(body.email()).isEqualTo("email") - assertThat(body.password()).isEqualTo("password") - assertThat(body.username()).isEqualTo("username") - assertThat(body.proxyCountry()).contains("proxy_country") - assertThat(body.totpSecret()).contains("totp_secret") + assertThat(body.email()).isEqualTo("user@example.com") + assertThat(body.password()).isEqualTo("s3cur3Pa\$\$w0rd") + assertThat(body.username()).isEqualTo("elonmusk") + assertThat(body.proxyCountry()).contains("US") + assertThat(body.totpSecret()).contains("JBSWY3DPEHPK3PXP") } @Test fun bodyWithoutOptionalFields() { val params = AccountCreateParams.builder() - .email("email") - .password("password") - .username("username") + .email("user@example.com") + .password("s3cur3Pa\$\$w0rd") + .username("elonmusk") .build() val body = params._body() - assertThat(body.email()).isEqualTo("email") - assertThat(body.password()).isEqualTo("password") - assertThat(body.username()).isEqualTo("username") + assertThat(body.email()).isEqualTo("user@example.com") + assertThat(body.password()).isEqualTo("s3cur3Pa\$\$w0rd") + assertThat(body.username()).isEqualTo("elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateResponseTest.kt index b4c8e98..ab5983e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountCreateResponseTest.kt @@ -13,16 +13,16 @@ internal class AccountCreateResponseTest { fun create() { val accountCreateResponse = AccountCreateResponse.builder() - .id("id") - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() - assertThat(accountCreateResponse.id()).isEqualTo("id") - assertThat(accountCreateResponse.status()).isEqualTo("status") - assertThat(accountCreateResponse.xUserId()).isEqualTo("xUserId") - assertThat(accountCreateResponse.xUsername()).isEqualTo("xUsername") + assertThat(accountCreateResponse.id()).isEqualTo("42") + assertThat(accountCreateResponse.status()).isEqualTo("active") + assertThat(accountCreateResponse.xUserId()).isEqualTo("9876543210") + assertThat(accountCreateResponse.xUsername()).isEqualTo("elonmusk") } @Test @@ -30,10 +30,10 @@ internal class AccountCreateResponseTest { val jsonMapper = jsonMapper() val accountCreateResponse = AccountCreateResponse.builder() - .id("id") - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() val roundtrippedAccountCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponseTest.kt index ecbbc93..5f752e9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountListResponseTest.kt @@ -16,11 +16,11 @@ internal class AccountListResponseTest { AccountListResponse.builder() .addAccount( AccountListResponse.Account.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() ) .build() @@ -28,11 +28,11 @@ internal class AccountListResponseTest { assertThat(accountListResponse.accounts()) .containsExactly( AccountListResponse.Account.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() ) } @@ -44,11 +44,11 @@ internal class AccountListResponseTest { AccountListResponse.builder() .addAccount( AccountListResponse.Account.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParamsTest.kt index 02c3de1..d80de6c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthParamsTest.kt @@ -11,14 +11,14 @@ internal class AccountReauthParamsTest { fun create() { AccountReauthParams.builder() .id("id") - .password("password") - .totpSecret("totp_secret") + .password("password_value") + .totpSecret("totp_secret_value") .build() } @Test fun pathParams() { - val params = AccountReauthParams.builder().id("id").password("password").build() + val params = AccountReauthParams.builder().id("id").password("password_value").build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -30,22 +30,22 @@ internal class AccountReauthParamsTest { val params = AccountReauthParams.builder() .id("id") - .password("password") - .totpSecret("totp_secret") + .password("password_value") + .totpSecret("totp_secret_value") .build() val body = params._body() - assertThat(body.password()).isEqualTo("password") - assertThat(body.totpSecret()).contains("totp_secret") + assertThat(body.password()).isEqualTo("password_value") + assertThat(body.totpSecret()).contains("totp_secret_value") } @Test fun bodyWithoutOptionalFields() { - val params = AccountReauthParams.builder().id("id").password("password").build() + val params = AccountReauthParams.builder().id("id").password("password_value").build() val body = params._body() - assertThat(body.password()).isEqualTo("password") + assertThat(body.password()).isEqualTo("password_value") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthResponseTest.kt index dbb40d5..3fa84f2 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountReauthResponseTest.kt @@ -12,18 +12,18 @@ internal class AccountReauthResponseTest { @Test fun create() { val accountReauthResponse = - AccountReauthResponse.builder().id("id").status("status").xUsername("xUsername").build() + AccountReauthResponse.builder().id("42").status("active").xUsername("elonmusk").build() - assertThat(accountReauthResponse.id()).isEqualTo("id") - assertThat(accountReauthResponse.status()).isEqualTo("status") - assertThat(accountReauthResponse.xUsername()).isEqualTo("xUsername") + assertThat(accountReauthResponse.id()).isEqualTo("42") + assertThat(accountReauthResponse.status()).isEqualTo("active") + assertThat(accountReauthResponse.xUsername()).isEqualTo("elonmusk") } @Test fun roundtrip() { val jsonMapper = jsonMapper() val accountReauthResponse = - AccountReauthResponse.builder().id("id").status("status").xUsername("xUsername").build() + AccountReauthResponse.builder().id("42").status("active").xUsername("elonmusk").build() val roundtrippedAccountReauthResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponseTest.kt index a44f418..563d73d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponseTest.kt @@ -14,27 +14,27 @@ internal class AccountRetrieveResponseTest { fun create() { val accountRetrieveResponse = AccountRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") - .cookiesObtainedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .proxyCountry("proxyCountry") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") + .cookiesObtainedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + .proxyCountry("US") + .updatedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) .build() - assertThat(accountRetrieveResponse.id()).isEqualTo("id") + assertThat(accountRetrieveResponse.id()).isEqualTo("42") assertThat(accountRetrieveResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(accountRetrieveResponse.status()).isEqualTo("status") - assertThat(accountRetrieveResponse.xUserId()).isEqualTo("xUserId") - assertThat(accountRetrieveResponse.xUsername()).isEqualTo("xUsername") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(accountRetrieveResponse.status()).isEqualTo("active") + assertThat(accountRetrieveResponse.xUserId()).isEqualTo("9876543210") + assertThat(accountRetrieveResponse.xUsername()).isEqualTo("elonmusk") assertThat(accountRetrieveResponse.cookiesObtainedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(accountRetrieveResponse.proxyCountry()).contains("proxyCountry") + .contains(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + assertThat(accountRetrieveResponse.proxyCountry()).contains("US") assertThat(accountRetrieveResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .contains(OffsetDateTime.parse("2025-03-10T08:30:00Z")) } @Test @@ -42,14 +42,14 @@ internal class AccountRetrieveResponseTest { val jsonMapper = jsonMapper() val accountRetrieveResponse = AccountRetrieveResponse.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") - .cookiesObtainedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .proxyCountry("proxyCountry") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") + .cookiesObtainedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + .proxyCountry("US") + .updatedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) .build() val roundtrippedAccountRetrieveResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetailTest.kt index baf3409..fe488ce 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetailTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountDetailTest.kt @@ -14,27 +14,27 @@ internal class XAccountDetailTest { fun create() { val xAccountDetail = XAccountDetail.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") - .cookiesObtainedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .proxyCountry("proxyCountry") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") + .cookiesObtainedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + .proxyCountry("US") + .updatedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) .build() - assertThat(xAccountDetail.id()).isEqualTo("id") + assertThat(xAccountDetail.id()).isEqualTo("42") assertThat(xAccountDetail.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(xAccountDetail.status()).isEqualTo("status") - assertThat(xAccountDetail.xUserId()).isEqualTo("xUserId") - assertThat(xAccountDetail.xUsername()).isEqualTo("xUsername") + .isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(xAccountDetail.status()).isEqualTo("active") + assertThat(xAccountDetail.xUserId()).isEqualTo("9876543210") + assertThat(xAccountDetail.xUsername()).isEqualTo("elonmusk") assertThat(xAccountDetail.cookiesObtainedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(xAccountDetail.proxyCountry()).contains("proxyCountry") + .contains(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + assertThat(xAccountDetail.proxyCountry()).contains("US") assertThat(xAccountDetail.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .contains(OffsetDateTime.parse("2025-03-10T08:30:00Z")) } @Test @@ -42,14 +42,14 @@ internal class XAccountDetailTest { val jsonMapper = jsonMapper() val xAccountDetail = XAccountDetail.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") - .cookiesObtainedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .proxyCountry("proxyCountry") - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") + .cookiesObtainedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) + .proxyCountry("US") + .updatedAt(OffsetDateTime.parse("2025-03-10T08:30:00Z")) .build() val roundtrippedXAccountDetail = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountTest.kt index c2ac0fc..1a63e2a 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/XAccountTest.kt @@ -14,18 +14,18 @@ internal class XAccountTest { fun create() { val xAccount = XAccount.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() - assertThat(xAccount.id()).isEqualTo("id") - assertThat(xAccount.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(xAccount.status()).isEqualTo("status") - assertThat(xAccount.xUserId()).isEqualTo("xUserId") - assertThat(xAccount.xUsername()).isEqualTo("xUsername") + assertThat(xAccount.id()).isEqualTo("42") + assertThat(xAccount.createdAt()).isEqualTo(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + assertThat(xAccount.status()).isEqualTo("active") + assertThat(xAccount.xUserId()).isEqualTo("9876543210") + assertThat(xAccount.xUsername()).isEqualTo("elonmusk") } @Test @@ -33,11 +33,11 @@ internal class XAccountTest { val jsonMapper = jsonMapper() val xAccount = XAccount.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status("status") - .xUserId("xUserId") - .xUsername("xUsername") + .id("42") + .createdAt(OffsetDateTime.parse("2025-01-15T12:00:00Z")) + .status("active") + .xUserId("9876543210") + .xUsername("elonmusk") .build() val roundtrippedXAccount = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParamsTest.kt index ddfab7e..393b7b1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListParamsTest.kt @@ -10,18 +10,22 @@ internal class BookmarkListParamsTest { @Test fun create() { - BookmarkListParams.builder().cursor("cursor").folderId("folderId").build() + BookmarkListParams.builder().cursor("folders_value").folderId("folderId").build() } @Test fun queryParams() { - val params = BookmarkListParams.builder().cursor("cursor").folderId("folderId").build() + val params = + BookmarkListParams.builder().cursor("folders_value").folderId("folderId").build() val queryParams = params._queryParams() assertThat(queryParams) .isEqualTo( - QueryParams.builder().put("cursor", "cursor").put("folderId", "folderId").build() + QueryParams.builder() + .put("cursor", "folders_value") + .put("folderId", "folderId") + .build() ) } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponseTest.kt index 298f48c..9b938f0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponseTest.kt @@ -14,52 +14,54 @@ internal class BookmarkListResponseTest { val bookmarkListResponse = BookmarkListResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( BookmarkListResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( BookmarkListResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(bookmarkListResponse.hasNextPage()).isEqualTo(true) - assertThat(bookmarkListResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(bookmarkListResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(bookmarkListResponse.tweets()) .containsExactly( BookmarkListResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( BookmarkListResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class BookmarkListResponseTest { val bookmarkListResponse = BookmarkListResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( BookmarkListResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( BookmarkListResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkRetrieveFoldersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkRetrieveFoldersResponseTest.kt index 49780cd..9f9da47 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkRetrieveFoldersResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkRetrieveFoldersResponseTest.kt @@ -14,18 +14,24 @@ internal class BookmarkRetrieveFoldersResponseTest { val bookmarkRetrieveFoldersResponse = BookmarkRetrieveFoldersResponse.builder() .addFolder( - BookmarkRetrieveFoldersResponse.Folder.builder().id("id").name("name").build() + BookmarkRetrieveFoldersResponse.Folder.builder() + .id("1234567890") + .name("Read Later") + .build() ) .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .build() assertThat(bookmarkRetrieveFoldersResponse.folders()) .containsExactly( - BookmarkRetrieveFoldersResponse.Folder.builder().id("id").name("name").build() + BookmarkRetrieveFoldersResponse.Folder.builder() + .id("1234567890") + .name("Read Later") + .build() ) assertThat(bookmarkRetrieveFoldersResponse.hasNextPage()).isEqualTo(true) - assertThat(bookmarkRetrieveFoldersResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(bookmarkRetrieveFoldersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") } @Test @@ -34,10 +40,13 @@ internal class BookmarkRetrieveFoldersResponseTest { val bookmarkRetrieveFoldersResponse = BookmarkRetrieveFoldersResponse.builder() .addFolder( - BookmarkRetrieveFoldersResponse.Folder.builder().id("id").name("name").build() + BookmarkRetrieveFoldersResponse.Folder.builder() + .id("1234567890") + .name("Read Later") + .build() ) .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .build() val roundtrippedBookmarkRetrieveFoldersResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResultTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResultTest.kt index b17ae88..8fcdd3c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResultTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityActionResultTest.kt @@ -13,12 +13,12 @@ internal class CommunityActionResultTest { fun create() { val communityActionResult = CommunityActionResult.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() - assertThat(communityActionResult.communityId()).isEqualTo("communityId") - assertThat(communityActionResult.communityName()).isEqualTo("communityName") + assertThat(communityActionResult.communityId()).isEqualTo("1500000000000000000") + assertThat(communityActionResult.communityName()).isEqualTo("Tesla Fans") } @Test @@ -26,8 +26,8 @@ internal class CommunityActionResultTest { val jsonMapper = jsonMapper() val communityActionResult = CommunityActionResult.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() val roundtrippedCommunityActionResult = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParamsTest.kt index adb3541..b946c33 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateParamsTest.kt @@ -10,9 +10,9 @@ internal class CommunityCreateParamsTest { @Test fun create() { CommunityCreateParams.builder() - .account("account") - .name("name") - .description("description") + .account("@elonmusk") + .name("Example Name") + .description("A community for Tesla enthusiasts") .build() } @@ -20,25 +20,26 @@ internal class CommunityCreateParamsTest { fun body() { val params = CommunityCreateParams.builder() - .account("account") - .name("name") - .description("description") + .account("@elonmusk") + .name("Example Name") + .description("A community for Tesla enthusiasts") .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).contains("description") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.name()).isEqualTo("Example Name") + assertThat(body.description()).contains("A community for Tesla enthusiasts") } @Test fun bodyWithoutOptionalFields() { - val params = CommunityCreateParams.builder().account("account").name("name").build() + val params = + CommunityCreateParams.builder().account("@elonmusk").name("Example Name").build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.name()).isEqualTo("name") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.name()).isEqualTo("Example Name") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateResponseTest.kt index 342545a..a26fe7a 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityCreateResponseTest.kt @@ -13,12 +13,12 @@ internal class CommunityCreateResponseTest { fun create() { val communityCreateResponse = CommunityCreateResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() - assertThat(communityCreateResponse.communityId()).isEqualTo("communityId") - assertThat(communityCreateResponse.communityName()).contains("communityName") + assertThat(communityCreateResponse.communityId()).isEqualTo("1500000000000000000") + assertThat(communityCreateResponse.communityName()).contains("Tesla Fans") } @Test @@ -26,8 +26,8 @@ internal class CommunityCreateResponseTest { val jsonMapper = jsonMapper() val communityCreateResponse = CommunityCreateResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() val roundtrippedCommunityCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParamsTest.kt index 118e1d3..f2c8e26 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityDeleteParamsTest.kt @@ -11,8 +11,8 @@ internal class CommunityDeleteParamsTest { fun create() { CommunityDeleteParams.builder() .id("id") - .account("account") - .communityName("community_name") + .account("@elonmusk") + .communityName("Tesla Fans") .build() } @@ -21,8 +21,8 @@ internal class CommunityDeleteParamsTest { val params = CommunityDeleteParams.builder() .id("id") - .account("account") - .communityName("community_name") + .account("@elonmusk") + .communityName("Tesla Fans") .build() assertThat(params._pathParam(0)).isEqualTo("id") @@ -35,13 +35,13 @@ internal class CommunityDeleteParamsTest { val params = CommunityDeleteParams.builder() .id("id") - .account("account") - .communityName("community_name") + .account("@elonmusk") + .communityName("Tesla Fans") .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.communityName()).isEqualTo("community_name") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.communityName()).isEqualTo("Tesla Fans") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponseTest.kt index e253e1f..a1ada19 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveInfoResponseTest.kt @@ -3,7 +3,6 @@ package com.x_twitter_scraper.api.models.x.communities import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,11 +13,59 @@ internal class CommunityRetrieveInfoResponseTest { fun create() { val communityRetrieveInfoResponse = CommunityRetrieveInfoResponse.builder() - .community(JsonValue.from(mapOf())) + .community( + CommunityRetrieveInfoResponse.Community.builder() + .id("1500000000000000000") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("Tesla Fans") + .primaryTopic( + CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() + .id("id") + .name("name") + .build() + ) + .addRule( + CommunityRetrieveInfoResponse.Community.Rule.builder() + .id("id") + .description("description") + .name("name") + .build() + ) + .build() + ) .build() - assertThat(communityRetrieveInfoResponse._community()) - .isEqualTo(JsonValue.from(mapOf())) + assertThat(communityRetrieveInfoResponse.community()) + .isEqualTo( + CommunityRetrieveInfoResponse.Community.builder() + .id("1500000000000000000") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("Tesla Fans") + .primaryTopic( + CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() + .id("id") + .name("name") + .build() + ) + .addRule( + CommunityRetrieveInfoResponse.Community.Rule.builder() + .id("id") + .description("description") + .name("name") + .build() + ) + .build() + ) } @Test @@ -26,7 +73,31 @@ internal class CommunityRetrieveInfoResponseTest { val jsonMapper = jsonMapper() val communityRetrieveInfoResponse = CommunityRetrieveInfoResponse.builder() - .community(JsonValue.from(mapOf())) + .community( + CommunityRetrieveInfoResponse.Community.builder() + .id("1500000000000000000") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("Tesla Fans") + .primaryTopic( + CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() + .id("id") + .name("name") + .build() + ) + .addRule( + CommunityRetrieveInfoResponse.Community.Rule.builder() + .id("id") + .description("description") + .name("name") + .build() + ) + .build() + ) .build() val roundtrippedCommunityRetrieveInfoResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponseTest.kt new file mode 100644 index 0000000..44d7da0 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommunityRetrieveMembersResponseTest { + + @Test + fun create() { + val communityRetrieveMembersResponse = + CommunityRetrieveMembersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + CommunityRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(communityRetrieveMembersResponse.hasNextPage()).isEqualTo(true) + assertThat(communityRetrieveMembersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(communityRetrieveMembersResponse.users()) + .containsExactly( + CommunityRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val communityRetrieveMembersResponse = + CommunityRetrieveMembersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + CommunityRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedCommunityRetrieveMembersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(communityRetrieveMembersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommunityRetrieveMembersResponse) + .isEqualTo(communityRetrieveMembersResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponseTest.kt new file mode 100644 index 0000000..3c77a26 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommunityRetrieveModeratorsResponseTest { + + @Test + fun create() { + val communityRetrieveModeratorsResponse = + CommunityRetrieveModeratorsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + CommunityRetrieveModeratorsResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(communityRetrieveModeratorsResponse.hasNextPage()).isEqualTo(true) + assertThat(communityRetrieveModeratorsResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(communityRetrieveModeratorsResponse.users()) + .containsExactly( + CommunityRetrieveModeratorsResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val communityRetrieveModeratorsResponse = + CommunityRetrieveModeratorsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + CommunityRetrieveModeratorsResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedCommunityRetrieveModeratorsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(communityRetrieveModeratorsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommunityRetrieveModeratorsResponse) + .isEqualTo(communityRetrieveModeratorsResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponseTest.kt new file mode 100644 index 0000000..ef226bd --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponseTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommunityRetrieveSearchResponseTest { + + @Test + fun create() { + val communityRetrieveSearchResponse = + CommunityRetrieveSearchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + CommunityRetrieveSearchResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + CommunityRetrieveSearchResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + assertThat(communityRetrieveSearchResponse.hasNextPage()).isEqualTo(true) + assertThat(communityRetrieveSearchResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(communityRetrieveSearchResponse.tweets()) + .containsExactly( + CommunityRetrieveSearchResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + CommunityRetrieveSearchResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val communityRetrieveSearchResponse = + CommunityRetrieveSearchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + CommunityRetrieveSearchResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + CommunityRetrieveSearchResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + val roundtrippedCommunityRetrieveSearchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(communityRetrieveSearchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommunityRetrieveSearchResponse) + .isEqualTo(communityRetrieveSearchResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParamsTest.kt index e447269..46fb3a3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateParamsTest.kt @@ -9,12 +9,12 @@ internal class JoinCreateParamsTest { @Test fun create() { - JoinCreateParams.builder().id("id").account("account").build() + JoinCreateParams.builder().id("id").account("@elonmusk").build() } @Test fun pathParams() { - val params = JoinCreateParams.builder().id("id").account("account").build() + val params = JoinCreateParams.builder().id("id").account("@elonmusk").build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -23,10 +23,10 @@ internal class JoinCreateParamsTest { @Test fun body() { - val params = JoinCreateParams.builder().id("id").account("account").build() + val params = JoinCreateParams.builder().id("id").account("@elonmusk").build() val body = params._body() - assertThat(body.account()).isEqualTo("account") + assertThat(body.account()).isEqualTo("@elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponseTest.kt index d0367bc..e3dcece 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponseTest.kt @@ -13,12 +13,12 @@ internal class JoinCreateResponseTest { fun create() { val joinCreateResponse = JoinCreateResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() - assertThat(joinCreateResponse.communityId()).isEqualTo("communityId") - assertThat(joinCreateResponse.communityName()).isEqualTo("communityName") + assertThat(joinCreateResponse.communityId()).isEqualTo("1500000000000000000") + assertThat(joinCreateResponse.communityName()).isEqualTo("Tesla Fans") } @Test @@ -26,8 +26,8 @@ internal class JoinCreateResponseTest { val jsonMapper = jsonMapper() val joinCreateResponse = JoinCreateResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() val roundtrippedJoinCreateResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParamsTest.kt index 031ac7d..973c769 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllParamsTest.kt @@ -9,12 +9,12 @@ internal class JoinDeleteAllParamsTest { @Test fun create() { - JoinDeleteAllParams.builder().id("id").account("account").build() + JoinDeleteAllParams.builder().id("id").account("@elonmusk").build() } @Test fun pathParams() { - val params = JoinDeleteAllParams.builder().id("id").account("account").build() + val params = JoinDeleteAllParams.builder().id("id").account("@elonmusk").build() assertThat(params._pathParam(0)).isEqualTo("id") // out-of-bound path param @@ -23,10 +23,10 @@ internal class JoinDeleteAllParamsTest { @Test fun body() { - val params = JoinDeleteAllParams.builder().id("id").account("account").build() + val params = JoinDeleteAllParams.builder().id("id").account("@elonmusk").build() val body = params._body() - assertThat(body.account()).isEqualTo("account") + assertThat(body.account()).isEqualTo("@elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponseTest.kt index 37c2a4e..4c6840b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponseTest.kt @@ -13,12 +13,12 @@ internal class JoinDeleteAllResponseTest { fun create() { val joinDeleteAllResponse = JoinDeleteAllResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() - assertThat(joinDeleteAllResponse.communityId()).isEqualTo("communityId") - assertThat(joinDeleteAllResponse.communityName()).isEqualTo("communityName") + assertThat(joinDeleteAllResponse.communityId()).isEqualTo("1500000000000000000") + assertThat(joinDeleteAllResponse.communityName()).isEqualTo("Tesla Fans") } @Test @@ -26,8 +26,8 @@ internal class JoinDeleteAllResponseTest { val jsonMapper = jsonMapper() val joinDeleteAllResponse = JoinDeleteAllResponse.builder() - .communityId("communityId") - .communityName("communityName") + .communityId("1500000000000000000") + .communityName("Tesla Fans") .build() val roundtrippedJoinDeleteAllResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponseTest.kt new file mode 100644 index 0000000..a9bc15e --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.communities.tweets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TweetListResponseTest { + + @Test + fun create() { + val tweetListResponse = + TweetListResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + assertThat(tweetListResponse.hasNextPage()).isEqualTo(true) + assertThat(tweetListResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(tweetListResponse.tweets()) + .containsExactly( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tweetListResponse = + TweetListResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + val roundtrippedTweetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tweetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTweetListResponse).isEqualTo(tweetListResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryResponseTest.kt index ea4860e..950154e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmRetrieveHistoryResponseTest.kt @@ -16,28 +16,28 @@ internal class DmRetrieveHistoryResponseTest { .hasNextPage(true) .addMessage( DmRetrieveHistoryResponse.Message.builder() - .id("id") - .createdAt("createdAt") - .receiverId("receiverId") - .senderId("senderId") - .text("text") + .id("1234567890123456789") + .createdAt("2025-01-15T12:00:00Z") + .receiverId("1234567890") + .senderId("9876543210") + .text("Hey, how are you?") .build() ) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .build() assertThat(dmRetrieveHistoryResponse.hasNextPage()).isEqualTo(true) assertThat(dmRetrieveHistoryResponse.messages()) .containsExactly( DmRetrieveHistoryResponse.Message.builder() - .id("id") - .createdAt("createdAt") - .receiverId("receiverId") - .senderId("senderId") - .text("text") + .id("1234567890123456789") + .createdAt("2025-01-15T12:00:00Z") + .receiverId("1234567890") + .senderId("9876543210") + .text("Hey, how are you?") .build() ) - assertThat(dmRetrieveHistoryResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(dmRetrieveHistoryResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") } @Test @@ -48,14 +48,14 @@ internal class DmRetrieveHistoryResponseTest { .hasNextPage(true) .addMessage( DmRetrieveHistoryResponse.Message.builder() - .id("id") - .createdAt("createdAt") - .receiverId("receiverId") - .senderId("senderId") - .text("text") + .id("1234567890123456789") + .createdAt("2025-01-15T12:00:00Z") + .receiverId("1234567890") + .senderId("9876543210") + .text("Hey, how are you?") .build() ) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .build() val roundtrippedDmRetrieveHistoryResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParamsTest.kt index 1daeac8..9ca955a 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendParamsTest.kt @@ -12,16 +12,21 @@ internal class DmSendParamsTest { fun create() { DmSendParams.builder() .userId("userId") - .account("account") - .text("text") - .addMediaId("string") - .replyToMessageId("reply_to_message_id") + .account("@elonmusk") + .text("Example text content") + .addMediaId("1234567890123456789") + .replyToMessageId("1234567890123456789") .build() } @Test fun pathParams() { - val params = DmSendParams.builder().userId("userId").account("account").text("text").build() + val params = + DmSendParams.builder() + .userId("userId") + .account("@elonmusk") + .text("Example text content") + .build() assertThat(params._pathParam(0)).isEqualTo("userId") // out-of-bound path param @@ -33,27 +38,32 @@ internal class DmSendParamsTest { val params = DmSendParams.builder() .userId("userId") - .account("account") - .text("text") - .addMediaId("string") - .replyToMessageId("reply_to_message_id") + .account("@elonmusk") + .text("Example text content") + .addMediaId("1234567890123456789") + .replyToMessageId("1234567890123456789") .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.text()).isEqualTo("text") - assertThat(body.mediaIds().getOrNull()).containsExactly("string") - assertThat(body.replyToMessageId()).contains("reply_to_message_id") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.text()).isEqualTo("Example text content") + assertThat(body.mediaIds().getOrNull()).containsExactly("1234567890123456789") + assertThat(body.replyToMessageId()).contains("1234567890123456789") } @Test fun bodyWithoutOptionalFields() { - val params = DmSendParams.builder().userId("userId").account("account").text("text").build() + val params = + DmSendParams.builder() + .userId("userId") + .account("@elonmusk") + .text("Example text content") + .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.text()).isEqualTo("text") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.text()).isEqualTo("Example text content") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendResponseTest.kt index 4dd78c2..429ffec 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/dm/DmSendResponseTest.kt @@ -11,15 +11,15 @@ internal class DmSendResponseTest { @Test fun create() { - val dmSendResponse = DmSendResponse.builder().messageId("messageId").build() + val dmSendResponse = DmSendResponse.builder().messageId("1234567890123456789").build() - assertThat(dmSendResponse.messageId()).isEqualTo("messageId") + assertThat(dmSendResponse.messageId()).isEqualTo("1234567890123456789") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val dmSendResponse = DmSendResponse.builder().messageId("messageId").build() + val dmSendResponse = DmSendResponse.builder().messageId("1234567890123456789").build() val roundtrippedDmSendResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/followers/FollowerCheckResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/followers/FollowerCheckResponseTest.kt index e31d9d2..d5be570 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/followers/FollowerCheckResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/followers/FollowerCheckResponseTest.kt @@ -13,16 +13,16 @@ internal class FollowerCheckResponseTest { fun create() { val followerCheckResponse = FollowerCheckResponse.builder() - .isFollowedBy(true) + .isFollowedBy(false) .isFollowing(true) - .sourceUsername("sourceUsername") - .targetUsername("targetUsername") + .sourceUsername("elonmusk") + .targetUsername("jack") .build() - assertThat(followerCheckResponse.isFollowedBy()).isEqualTo(true) + assertThat(followerCheckResponse.isFollowedBy()).isEqualTo(false) assertThat(followerCheckResponse.isFollowing()).isEqualTo(true) - assertThat(followerCheckResponse.sourceUsername()).isEqualTo("sourceUsername") - assertThat(followerCheckResponse.targetUsername()).isEqualTo("targetUsername") + assertThat(followerCheckResponse.sourceUsername()).isEqualTo("elonmusk") + assertThat(followerCheckResponse.targetUsername()).isEqualTo("jack") } @Test @@ -30,10 +30,10 @@ internal class FollowerCheckResponseTest { val jsonMapper = jsonMapper() val followerCheckResponse = FollowerCheckResponse.builder() - .isFollowedBy(true) + .isFollowedBy(false) .isFollowing(true) - .sourceUsername("sourceUsername") - .targetUsername("targetUsername") + .sourceUsername("elonmusk") + .targetUsername("jack") .build() val roundtrippedFollowerCheckResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponseTest.kt new file mode 100644 index 0000000..b85f1a4 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveFollowersResponseTest { + + @Test + fun create() { + val listRetrieveFollowersResponse = + ListRetrieveFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + ListRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(listRetrieveFollowersResponse.hasNextPage()).isEqualTo(true) + assertThat(listRetrieveFollowersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(listRetrieveFollowersResponse.users()) + .containsExactly( + ListRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listRetrieveFollowersResponse = + ListRetrieveFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + ListRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedListRetrieveFollowersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listRetrieveFollowersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListRetrieveFollowersResponse) + .isEqualTo(listRetrieveFollowersResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponseTest.kt new file mode 100644 index 0000000..00ff923 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveMembersResponseTest { + + @Test + fun create() { + val listRetrieveMembersResponse = + ListRetrieveMembersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + ListRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(listRetrieveMembersResponse.hasNextPage()).isEqualTo(true) + assertThat(listRetrieveMembersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(listRetrieveMembersResponse.users()) + .containsExactly( + ListRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listRetrieveMembersResponse = + ListRetrieveMembersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + ListRetrieveMembersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedListRetrieveMembersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listRetrieveMembersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListRetrieveMembersResponse).isEqualTo(listRetrieveMembersResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponseTest.kt new file mode 100644 index 0000000..a267b88 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.lists + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveTweetsResponseTest { + + @Test + fun create() { + val listRetrieveTweetsResponse = + ListRetrieveTweetsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + ListRetrieveTweetsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + ListRetrieveTweetsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + assertThat(listRetrieveTweetsResponse.hasNextPage()).isEqualTo(true) + assertThat(listRetrieveTweetsResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(listRetrieveTweetsResponse.tweets()) + .containsExactly( + ListRetrieveTweetsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + ListRetrieveTweetsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listRetrieveTweetsResponse = + ListRetrieveTweetsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + ListRetrieveTweetsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + ListRetrieveTweetsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + val roundtrippedListRetrieveTweetsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listRetrieveTweetsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListRetrieveTweetsResponse).isEqualTo(listRetrieveTweetsResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadParamsTest.kt index 28f7c31..15ae2d7 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadParamsTest.kt @@ -10,18 +10,26 @@ internal class MediaDownloadParamsTest { @Test fun create() { - MediaDownloadParams.builder().addTweetId("string").tweetInput("tweetInput").build() + MediaDownloadParams.builder() + .addTweetId("1234567890") + .addTweetId("1234567891") + .tweetInput("https://x.com/elonmusk/status/1234567890") + .build() } @Test fun body() { val params = - MediaDownloadParams.builder().addTweetId("string").tweetInput("tweetInput").build() + MediaDownloadParams.builder() + .addTweetId("1234567890") + .addTweetId("1234567891") + .tweetInput("https://x.com/elonmusk/status/1234567890") + .build() val body = params._body() - assertThat(body.tweetIds().getOrNull()).containsExactly("string") - assertThat(body.tweetInput()).contains("tweetInput") + assertThat(body.tweetIds().getOrNull()).containsExactly("1234567890", "1234567891") + assertThat(body.tweetInput()).contains("https://x.com/elonmusk/status/1234567890") } @Test diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadResponseTest.kt index 0e2f1ed..aef93b3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaDownloadResponseTest.kt @@ -13,18 +13,18 @@ internal class MediaDownloadResponseTest { fun create() { val mediaDownloadResponse = MediaDownloadResponse.builder() - .cacheHit(true) - .galleryUrl("galleryUrl") - .totalMedia(0L) - .totalTweets(0L) - .tweetId("tweetId") + .cacheHit(false) + .galleryUrl("https://xquik.com/gallery/abc123") + .totalMedia(5L) + .totalTweets(2L) + .tweetId("1234567890") .build() - assertThat(mediaDownloadResponse.cacheHit()).contains(true) - assertThat(mediaDownloadResponse.galleryUrl()).contains("galleryUrl") - assertThat(mediaDownloadResponse.totalMedia()).contains(0L) - assertThat(mediaDownloadResponse.totalTweets()).contains(0L) - assertThat(mediaDownloadResponse.tweetId()).contains("tweetId") + assertThat(mediaDownloadResponse.cacheHit()).contains(false) + assertThat(mediaDownloadResponse.galleryUrl()).contains("https://xquik.com/gallery/abc123") + assertThat(mediaDownloadResponse.totalMedia()).contains(5L) + assertThat(mediaDownloadResponse.totalTweets()).contains(2L) + assertThat(mediaDownloadResponse.tweetId()).contains("1234567890") } @Test @@ -32,11 +32,11 @@ internal class MediaDownloadResponseTest { val jsonMapper = jsonMapper() val mediaDownloadResponse = MediaDownloadResponse.builder() - .cacheHit(true) - .galleryUrl("galleryUrl") - .totalMedia(0L) - .totalTweets(0L) - .tweetId("tweetId") + .cacheHit(false) + .galleryUrl("https://xquik.com/gallery/abc123") + .totalMedia(5L) + .totalTweets(2L) + .tweetId("1234567890") .build() val roundtrippedMediaDownloadResponse = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParamsTest.kt index 45aeb56..f46933e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadParamsTest.kt @@ -12,7 +12,7 @@ internal class MediaUploadParamsTest { @Test fun create() { MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .isLongVideo(true) .build() @@ -22,7 +22,7 @@ internal class MediaUploadParamsTest { fun body() { val params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .isLongVideo(true) .build() @@ -39,7 +39,7 @@ internal class MediaUploadParamsTest { ) .isEqualTo( mapOf( - "account" to MultipartField.of("account"), + "account" to MultipartField.of("@elonmusk"), "file" to MultipartField.of("Example data".byteInputStream()), "is_long_video" to MultipartField.of(true), ) @@ -53,7 +53,7 @@ internal class MediaUploadParamsTest { fun bodyWithoutOptionalFields() { val params = MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() @@ -69,7 +69,7 @@ internal class MediaUploadParamsTest { ) .isEqualTo( mapOf( - "account" to MultipartField.of("account"), + "account" to MultipartField.of("@elonmusk"), "file" to MultipartField.of("Example data".byteInputStream()), ) .mapValues { (_, field) -> diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadResponseTest.kt index 435c442..f412d91 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/media/MediaUploadResponseTest.kt @@ -11,15 +11,17 @@ internal class MediaUploadResponseTest { @Test fun create() { - val mediaUploadResponse = MediaUploadResponse.builder().mediaId("mediaId").build() + val mediaUploadResponse = + MediaUploadResponse.builder().mediaId("1234567890123456789").build() - assertThat(mediaUploadResponse.mediaId()).isEqualTo("mediaId") + assertThat(mediaUploadResponse.mediaId()).isEqualTo("1234567890123456789") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val mediaUploadResponse = MediaUploadResponse.builder().mediaId("mediaId").build() + val mediaUploadResponse = + MediaUploadResponse.builder().mediaId("1234567890123456789").build() val roundtrippedMediaUploadResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParamsTest.kt index a43d18a..e549e29 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateAvatarParamsTest.kt @@ -12,7 +12,7 @@ internal class ProfileUpdateAvatarParamsTest { @Test fun create() { ProfileUpdateAvatarParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() } @@ -21,7 +21,7 @@ internal class ProfileUpdateAvatarParamsTest { fun body() { val params = ProfileUpdateAvatarParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() @@ -37,7 +37,7 @@ internal class ProfileUpdateAvatarParamsTest { ) .isEqualTo( mapOf( - "account" to MultipartField.of("account"), + "account" to MultipartField.of("@elonmusk"), "file" to MultipartField.of("Example data".byteInputStream()), ) .mapValues { (_, field) -> diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParamsTest.kt index 4ea8b9d..8f88c2d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateBannerParamsTest.kt @@ -12,7 +12,7 @@ internal class ProfileUpdateBannerParamsTest { @Test fun create() { ProfileUpdateBannerParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() } @@ -21,7 +21,7 @@ internal class ProfileUpdateBannerParamsTest { fun body() { val params = ProfileUpdateBannerParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() @@ -37,7 +37,7 @@ internal class ProfileUpdateBannerParamsTest { ) .isEqualTo( mapOf( - "account" to MultipartField.of("account"), + "account" to MultipartField.of("@elonmusk"), "file" to MultipartField.of("Example data".byteInputStream()), ) .mapValues { (_, field) -> diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParamsTest.kt index 253f6e0..176eab1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/profile/ProfileUpdateParamsTest.kt @@ -10,11 +10,11 @@ internal class ProfileUpdateParamsTest { @Test fun create() { ProfileUpdateParams.builder() - .account("account") - .description("description") - .location("location") - .name("name") - .url("url") + .account("@elonmusk") + .description("description_value") + .location("location_value") + .name("Example Name") + .url("https://xquik.com/example") .build() } @@ -22,28 +22,28 @@ internal class ProfileUpdateParamsTest { fun body() { val params = ProfileUpdateParams.builder() - .account("account") - .description("description") - .location("location") - .name("name") - .url("url") + .account("@elonmusk") + .description("description_value") + .location("location_value") + .name("Example Name") + .url("https://xquik.com/example") .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.description()).contains("description") - assertThat(body.location()).contains("location") - assertThat(body.name()).contains("name") - assertThat(body.url()).contains("url") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.description()).contains("description_value") + assertThat(body.location()).contains("location_value") + assertThat(body.name()).contains("Example Name") + assertThat(body.url()).contains("https://xquik.com/example") } @Test fun bodyWithoutOptionalFields() { - val params = ProfileUpdateParams.builder().account("account").build() + val params = ProfileUpdateParams.builder().account("@elonmusk").build() val body = params._body() - assertThat(body.account()).isEqualTo("account") + assertThat(body.account()).isEqualTo("@elonmusk") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweetTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweetTest.kt index a4057ed..141813e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweetTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweetTest.kt @@ -13,43 +13,45 @@ internal class SearchTweetTest { fun create() { val searchTweet = SearchTweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( SearchTweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() - assertThat(searchTweet.id()).isEqualTo("id") - assertThat(searchTweet.text()).isEqualTo("text") + assertThat(searchTweet.id()).isEqualTo("1234567890") + assertThat(searchTweet.text()).isEqualTo("Just launched our new feature!") assertThat(searchTweet.author()) .contains( SearchTweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - assertThat(searchTweet.bookmarkCount()).contains(0L) - assertThat(searchTweet.createdAt()).contains("createdAt") - assertThat(searchTweet.likeCount()).contains(0L) - assertThat(searchTweet.quoteCount()).contains(0L) - assertThat(searchTweet.replyCount()).contains(0L) - assertThat(searchTweet.retweetCount()).contains(0L) - assertThat(searchTweet.viewCount()).contains(0L) + assertThat(searchTweet.bookmarkCount()).contains(2L) + assertThat(searchTweet.createdAt()).contains("2025-01-15T12:00:00Z") + assertThat(searchTweet.isNoteTweet()).contains(false) + assertThat(searchTweet.likeCount()).contains(42L) + assertThat(searchTweet.quoteCount()).contains(1L) + assertThat(searchTweet.replyCount()).contains(3L) + assertThat(searchTweet.retweetCount()).contains(5L) + assertThat(searchTweet.viewCount()).contains(1500L) } @Test @@ -57,23 +59,24 @@ internal class SearchTweetTest { val jsonMapper = jsonMapper() val searchTweet = SearchTweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( SearchTweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() val roundtrippedSearchTweet = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthorTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthorTest.kt index 3f30b7b..469570e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthorTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetAuthorTest.kt @@ -13,18 +13,19 @@ internal class TweetAuthorTest { fun create() { val tweetAuthor = TweetAuthor.builder() - .id("id") - .followers(0L) - .username("username") + .id("9876543210") + .followers(150000000L) + .username("elonmusk") .verified(true) - .profilePicture("profilePicture") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") .build() - assertThat(tweetAuthor.id()).isEqualTo("id") - assertThat(tweetAuthor.followers()).isEqualTo(0L) - assertThat(tweetAuthor.username()).isEqualTo("username") + assertThat(tweetAuthor.id()).isEqualTo("9876543210") + assertThat(tweetAuthor.followers()).isEqualTo(150000000L) + assertThat(tweetAuthor.username()).isEqualTo("elonmusk") assertThat(tweetAuthor.verified()).isEqualTo(true) - assertThat(tweetAuthor.profilePicture()).contains("profilePicture") + assertThat(tweetAuthor.profilePicture()) + .contains("https://pbs.twimg.com/profile_images/example.jpg") } @Test @@ -32,11 +33,11 @@ internal class TweetAuthorTest { val jsonMapper = jsonMapper() val tweetAuthor = TweetAuthor.builder() - .id("id") - .followers(0L) - .username("username") + .id("9876543210") + .followers(150000000L) + .username("elonmusk") .verified(true) - .profilePicture("profilePicture") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") .build() val roundtrippedTweetAuthor = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateParamsTest.kt index 994b196..942e966 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateParamsTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateParamsTest.kt @@ -11,13 +11,13 @@ internal class TweetCreateParamsTest { @Test fun create() { TweetCreateParams.builder() - .account("account") - .text("text") - .attachmentUrl("attachment_url") - .communityId("community_id") - .isNoteTweet(true) - .addMediaId("string") - .replyToTweetId("reply_to_tweet_id") + .account("@elonmusk") + .text("Just launched our new feature!") + .attachmentUrl("https://x.com/elonmusk/status/1234567890") + .communityId("1500000000000000000") + .isNoteTweet(false) + .addMediaId("1234567890123456789") + .replyToTweetId("1234567890") .build() } @@ -25,33 +25,37 @@ internal class TweetCreateParamsTest { fun body() { val params = TweetCreateParams.builder() - .account("account") - .text("text") - .attachmentUrl("attachment_url") - .communityId("community_id") - .isNoteTweet(true) - .addMediaId("string") - .replyToTweetId("reply_to_tweet_id") + .account("@elonmusk") + .text("Just launched our new feature!") + .attachmentUrl("https://x.com/elonmusk/status/1234567890") + .communityId("1500000000000000000") + .isNoteTweet(false) + .addMediaId("1234567890123456789") + .replyToTweetId("1234567890") .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.text()).isEqualTo("text") - assertThat(body.attachmentUrl()).contains("attachment_url") - assertThat(body.communityId()).contains("community_id") - assertThat(body.isNoteTweet()).contains(true) - assertThat(body.mediaIds().getOrNull()).containsExactly("string") - assertThat(body.replyToTweetId()).contains("reply_to_tweet_id") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.text()).isEqualTo("Just launched our new feature!") + assertThat(body.attachmentUrl()).contains("https://x.com/elonmusk/status/1234567890") + assertThat(body.communityId()).contains("1500000000000000000") + assertThat(body.isNoteTweet()).contains(false) + assertThat(body.mediaIds().getOrNull()).containsExactly("1234567890123456789") + assertThat(body.replyToTweetId()).contains("1234567890") } @Test fun bodyWithoutOptionalFields() { - val params = TweetCreateParams.builder().account("account").text("text").build() + val params = + TweetCreateParams.builder() + .account("@elonmusk") + .text("Just launched our new feature!") + .build() val body = params._body() - assertThat(body.account()).isEqualTo("account") - assertThat(body.text()).isEqualTo("text") + assertThat(body.account()).isEqualTo("@elonmusk") + assertThat(body.text()).isEqualTo("Just launched our new feature!") } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateResponseTest.kt index ff0c922..3aee791 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetCreateResponseTest.kt @@ -11,15 +11,15 @@ internal class TweetCreateResponseTest { @Test fun create() { - val tweetCreateResponse = TweetCreateResponse.builder().tweetId("tweetId").build() + val tweetCreateResponse = TweetCreateResponse.builder().tweetId("1234567890").build() - assertThat(tweetCreateResponse.tweetId()).isEqualTo("tweetId") + assertThat(tweetCreateResponse.tweetId()).isEqualTo("1234567890") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val tweetCreateResponse = TweetCreateResponse.builder().tweetId("tweetId").build() + val tweetCreateResponse = TweetCreateResponse.builder().tweetId("1234567890").build() val roundtrippedTweetCreateResponse = jsonMapper.readValue( diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParamsTest.kt deleted file mode 100644 index f189077..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TweetDeleteParamsTest { - - @Test - fun create() { - TweetDeleteParams.builder().tweetId("tweetId").account("account").build() - } - - @Test - fun pathParams() { - val params = TweetDeleteParams.builder().tweetId("tweetId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = TweetDeleteParams.builder().tweetId("tweetId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponseTest.kt deleted file mode 100644 index b478ed5..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TweetDeleteResponseTest { - - @Test - fun create() { - val tweetDeleteResponse = TweetDeleteResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tweetDeleteResponse = TweetDeleteResponse.builder().build() - - val roundtrippedTweetDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tweetDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTweetDeleteResponse).isEqualTo(tweetDeleteResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetailTest.kt index 1185ce8..62535f5 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetailTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetailTest.kt @@ -3,7 +3,9 @@ package com.x_twitter_scraper.api.models.x.tweets import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,26 +15,73 @@ internal class TweetDetailTest { fun create() { val tweetDetail = TweetDetail.builder() - .id("id") - .bookmarkCount(0L) - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .text("text") - .viewCount(0L) - .createdAt("createdAt") + .id("1234567890") + .bookmarkCount(2L) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .text("Just launched our new feature!") + .viewCount(1500L) + .conversationId("1234567890") + .createdAt("2025-01-15T12:00:00Z") + .entities( + TweetDetail.Entities.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .isNoteTweet(false) + .isQuoteStatus(false) + .isReply(false) + .addMedia( + TweetDetail.Media.builder() + .mediaUrl("https://pbs.twimg.com/media/example.jpg") + .type(TweetDetail.Media.Type.PHOTO) + .url("https://t.co/abc123") + .build() + ) + .quotedTweet( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source("Twitter Web App") .build() - assertThat(tweetDetail.id()).isEqualTo("id") - assertThat(tweetDetail.bookmarkCount()).isEqualTo(0L) - assertThat(tweetDetail.likeCount()).isEqualTo(0L) - assertThat(tweetDetail.quoteCount()).isEqualTo(0L) - assertThat(tweetDetail.replyCount()).isEqualTo(0L) - assertThat(tweetDetail.retweetCount()).isEqualTo(0L) - assertThat(tweetDetail.text()).isEqualTo("text") - assertThat(tweetDetail.viewCount()).isEqualTo(0L) - assertThat(tweetDetail.createdAt()).contains("createdAt") + assertThat(tweetDetail.id()).isEqualTo("1234567890") + assertThat(tweetDetail.bookmarkCount()).isEqualTo(2L) + assertThat(tweetDetail.likeCount()).isEqualTo(42L) + assertThat(tweetDetail.quoteCount()).isEqualTo(1L) + assertThat(tweetDetail.replyCount()).isEqualTo(3L) + assertThat(tweetDetail.retweetCount()).isEqualTo(5L) + assertThat(tweetDetail.text()).isEqualTo("Just launched our new feature!") + assertThat(tweetDetail.viewCount()).isEqualTo(1500L) + assertThat(tweetDetail.conversationId()).contains("1234567890") + assertThat(tweetDetail.createdAt()).contains("2025-01-15T12:00:00Z") + assertThat(tweetDetail.entities()) + .contains( + TweetDetail.Entities.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tweetDetail.isNoteTweet()).contains(false) + assertThat(tweetDetail.isQuoteStatus()).contains(false) + assertThat(tweetDetail.isReply()).contains(false) + assertThat(tweetDetail.media().getOrNull()) + .containsExactly( + TweetDetail.Media.builder() + .mediaUrl("https://pbs.twimg.com/media/example.jpg") + .type(TweetDetail.Media.Type.PHOTO) + .url("https://t.co/abc123") + .build() + ) + assertThat(tweetDetail.quotedTweet()) + .contains( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tweetDetail.source()).contains("Twitter Web App") } @Test @@ -40,15 +89,37 @@ internal class TweetDetailTest { val jsonMapper = jsonMapper() val tweetDetail = TweetDetail.builder() - .id("id") - .bookmarkCount(0L) - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .text("text") - .viewCount(0L) - .createdAt("createdAt") + .id("1234567890") + .bookmarkCount(2L) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .text("Just launched our new feature!") + .viewCount(1500L) + .conversationId("1234567890") + .createdAt("2025-01-15T12:00:00Z") + .entities( + TweetDetail.Entities.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .isNoteTweet(false) + .isQuoteStatus(false) + .isReply(false) + .addMedia( + TweetDetail.Media.builder() + .mediaUrl("https://pbs.twimg.com/media/example.jpg") + .type(TweetDetail.Media.Type.PHOTO) + .url("https://t.co/abc123") + .build() + ) + .quotedTweet( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .source("Twitter Web App") .build() val roundtrippedTweetDetail = diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponseTest.kt index 0dfc6da..21c259e 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponseTest.kt @@ -14,39 +14,39 @@ internal class TweetGetFavoritersResponseTest { val tweetGetFavoritersResponse = TweetGetFavoritersResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( TweetGetFavoritersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) .build() assertThat(tweetGetFavoritersResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetGetFavoritersResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetGetFavoritersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetGetFavoritersResponse.users()) .containsExactly( TweetGetFavoritersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) @@ -58,19 +58,19 @@ internal class TweetGetFavoritersResponseTest { val tweetGetFavoritersResponse = TweetGetFavoritersResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( TweetGetFavoritersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponseTest.kt index 8106a27..b8557ae 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponseTest.kt @@ -14,52 +14,54 @@ internal class TweetGetQuotesResponseTest { val tweetGetQuotesResponse = TweetGetQuotesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetQuotesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetQuotesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(tweetGetQuotesResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetGetQuotesResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetGetQuotesResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetGetQuotesResponse.tweets()) .containsExactly( TweetGetQuotesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetQuotesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class TweetGetQuotesResponseTest { val tweetGetQuotesResponse = TweetGetQuotesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetQuotesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetQuotesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponseTest.kt index 0ee7c4f..a9122d7 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponseTest.kt @@ -14,52 +14,54 @@ internal class TweetGetRepliesResponseTest { val tweetGetRepliesResponse = TweetGetRepliesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetRepliesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetRepliesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(tweetGetRepliesResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetGetRepliesResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetGetRepliesResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetGetRepliesResponse.tweets()) .containsExactly( TweetGetRepliesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetRepliesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class TweetGetRepliesResponseTest { val tweetGetRepliesResponse = TweetGetRepliesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetRepliesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetRepliesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponseTest.kt index 61f76bf..0c77229 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponseTest.kt @@ -14,39 +14,39 @@ internal class TweetGetRetweetersResponseTest { val tweetGetRetweetersResponse = TweetGetRetweetersResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( TweetGetRetweetersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) .build() assertThat(tweetGetRetweetersResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetGetRetweetersResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetGetRetweetersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetGetRetweetersResponse.users()) .containsExactly( TweetGetRetweetersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) @@ -58,19 +58,19 @@ internal class TweetGetRetweetersResponseTest { val tweetGetRetweetersResponse = TweetGetRetweetersResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( TweetGetRetweetersResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponseTest.kt index 97557c1..68b2d47 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponseTest.kt @@ -14,52 +14,54 @@ internal class TweetGetThreadResponseTest { val tweetGetThreadResponse = TweetGetThreadResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetThreadResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetThreadResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(tweetGetThreadResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetGetThreadResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetGetThreadResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetGetThreadResponse.tweets()) .containsExactly( TweetGetThreadResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetThreadResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class TweetGetThreadResponseTest { val tweetGetThreadResponse = TweetGetThreadResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetGetThreadResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetGetThreadResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponseTest.kt new file mode 100644 index 0000000..44f869a --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.tweets + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TweetListResponseTest { + + @Test + fun create() { + val tweetListResponse = + TweetListResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + assertThat(tweetListResponse.hasNextPage()).isEqualTo(true) + assertThat(tweetListResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(tweetListResponse.tweets()) + .containsExactly( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tweetListResponse = + TweetListResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + TweetListResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + TweetListResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + val roundtrippedTweetListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tweetListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTweetListResponse).isEqualTo(tweetListResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParamsTest.kt deleted file mode 100644 index 1cc7034..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TweetRetrieveParamsTest { - - @Test - fun create() { - TweetRetrieveParams.builder().tweetId("tweetId").build() - } - - @Test - fun pathParams() { - val params = TweetRetrieveParams.builder().tweetId("tweetId").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponseTest.kt deleted file mode 100644 index 5fc5f66..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponseTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TweetRetrieveResponseTest { - - @Test - fun create() { - val tweetRetrieveResponse = - TweetRetrieveResponse.builder() - .tweet( - TweetRetrieveResponse.Tweet.builder() - .id("id") - .bookmarkCount(0L) - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .text("text") - .viewCount(0L) - .createdAt("createdAt") - .build() - ) - .author( - TweetRetrieveResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") - .verified(true) - .profilePicture("profilePicture") - .build() - ) - .build() - - assertThat(tweetRetrieveResponse.tweet()) - .isEqualTo( - TweetRetrieveResponse.Tweet.builder() - .id("id") - .bookmarkCount(0L) - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .text("text") - .viewCount(0L) - .createdAt("createdAt") - .build() - ) - assertThat(tweetRetrieveResponse.author()) - .contains( - TweetRetrieveResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") - .verified(true) - .profilePicture("profilePicture") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tweetRetrieveResponse = - TweetRetrieveResponse.builder() - .tweet( - TweetRetrieveResponse.Tweet.builder() - .id("id") - .bookmarkCount(0L) - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .text("text") - .viewCount(0L) - .createdAt("createdAt") - .build() - ) - .author( - TweetRetrieveResponse.Author.builder() - .id("id") - .followers(0L) - .username("username") - .verified(true) - .profilePicture("profilePicture") - .build() - ) - .build() - - val roundtrippedTweetRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tweetRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTweetRetrieveResponse).isEqualTo(tweetRetrieveResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt index 6ad492c..0497e0d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt @@ -14,52 +14,54 @@ internal class TweetSearchResponseTest { val tweetSearchResponse = TweetSearchResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetSearchResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetSearchResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(tweetSearchResponse.hasNextPage()).isEqualTo(true) - assertThat(tweetSearchResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(tweetSearchResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(tweetSearchResponse.tweets()) .containsExactly( TweetSearchResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetSearchResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class TweetSearchResponseTest { val tweetSearchResponse = TweetSearchResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( TweetSearchResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( TweetSearchResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParamsTest.kt deleted file mode 100644 index 73b4c8b..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LikeCreateParamsTest { - - @Test - fun create() { - LikeCreateParams.builder().tweetId("tweetId").account("account").build() - } - - @Test - fun pathParams() { - val params = LikeCreateParams.builder().tweetId("tweetId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = LikeCreateParams.builder().tweetId("tweetId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponseTest.kt deleted file mode 100644 index a02900d..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LikeCreateResponseTest { - - @Test - fun create() { - val likeCreateResponse = LikeCreateResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val likeCreateResponse = LikeCreateResponse.builder().build() - - val roundtrippedLikeCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(likeCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedLikeCreateResponse).isEqualTo(likeCreateResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParamsTest.kt deleted file mode 100644 index 1d35a5b..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LikeDeleteParamsTest { - - @Test - fun create() { - LikeDeleteParams.builder().tweetId("tweetId").account("account").build() - } - - @Test - fun pathParams() { - val params = LikeDeleteParams.builder().tweetId("tweetId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = LikeDeleteParams.builder().tweetId("tweetId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponseTest.kt deleted file mode 100644 index 649ffc3..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.like - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class LikeDeleteResponseTest { - - @Test - fun create() { - val likeDeleteResponse = LikeDeleteResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val likeDeleteResponse = LikeDeleteResponse.builder().build() - - val roundtrippedLikeDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(likeDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedLikeDeleteResponse).isEqualTo(likeDeleteResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParamsTest.kt deleted file mode 100644 index dc53a0f..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RetweetCreateParamsTest { - - @Test - fun create() { - RetweetCreateParams.builder().tweetId("tweetId").account("account").build() - } - - @Test - fun pathParams() { - val params = RetweetCreateParams.builder().tweetId("tweetId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = RetweetCreateParams.builder().tweetId("tweetId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponseTest.kt deleted file mode 100644 index 09299c7..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RetweetCreateResponseTest { - - @Test - fun create() { - val retweetCreateResponse = RetweetCreateResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val retweetCreateResponse = RetweetCreateResponse.builder().build() - - val roundtrippedRetweetCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(retweetCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRetweetCreateResponse).isEqualTo(retweetCreateResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParamsTest.kt deleted file mode 100644 index dfac66e..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RetweetDeleteParamsTest { - - @Test - fun create() { - RetweetDeleteParams.builder().tweetId("tweetId").account("account").build() - } - - @Test - fun pathParams() { - val params = RetweetDeleteParams.builder().tweetId("tweetId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("tweetId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = RetweetDeleteParams.builder().tweetId("tweetId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponseTest.kt deleted file mode 100644 index 333d8e9..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.tweets.retweet - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RetweetDeleteResponseTest { - - @Test - fun create() { - val retweetDeleteResponse = RetweetDeleteResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val retweetDeleteResponse = RetweetDeleteResponse.builder().build() - - val roundtrippedRetweetDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(retweetDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRetweetDeleteResponse).isEqualTo(retweetDeleteResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfileTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfileTest.kt index 3c08f53..39c41fa 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfileTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserProfileTest.kt @@ -13,29 +13,30 @@ internal class UserProfileTest { fun create() { val userProfile = UserProfile.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() - assertThat(userProfile.id()).isEqualTo("id") - assertThat(userProfile.name()).isEqualTo("name") - assertThat(userProfile.username()).isEqualTo("username") - assertThat(userProfile.createdAt()).contains("createdAt") - assertThat(userProfile.description()).contains("description") - assertThat(userProfile.followers()).contains(0L) - assertThat(userProfile.following()).contains(0L) - assertThat(userProfile.location()).contains("location") - assertThat(userProfile.profilePicture()).contains("profilePicture") - assertThat(userProfile.statusesCount()).contains(0L) + assertThat(userProfile.id()).isEqualTo("9876543210") + assertThat(userProfile.name()).isEqualTo("Elon Musk") + assertThat(userProfile.username()).isEqualTo("elonmusk") + assertThat(userProfile.createdAt()).contains("2009-06-02T20:12:29Z") + assertThat(userProfile.description()).contains("CEO of Tesla, SpaceX, and X") + assertThat(userProfile.followers()).contains(150000000L) + assertThat(userProfile.following()).contains(500L) + assertThat(userProfile.location()).contains("Austin, TX") + assertThat(userProfile.profilePicture()) + .contains("https://pbs.twimg.com/profile_images/example.jpg") + assertThat(userProfile.statusesCount()).contains(35000L) assertThat(userProfile.verified()).contains(true) } @@ -44,16 +45,16 @@ internal class UserProfileTest { val jsonMapper = jsonMapper() val userProfile = UserProfile.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponseTest.kt new file mode 100644 index 0000000..181fa94 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveBatchResponseTest { + + @Test + fun create() { + val userRetrieveBatchResponse = + UserRetrieveBatchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveBatchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(userRetrieveBatchResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveBatchResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveBatchResponse.users()) + .containsExactly( + UserRetrieveBatchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveBatchResponse = + UserRetrieveBatchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveBatchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedUserRetrieveBatchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveBatchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveBatchResponse).isEqualTo(userRetrieveBatchResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponseTest.kt new file mode 100644 index 0000000..a24bffc --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveFollowersResponseTest { + + @Test + fun create() { + val userRetrieveFollowersResponse = + UserRetrieveFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(userRetrieveFollowersResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveFollowersResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveFollowersResponse.users()) + .containsExactly( + UserRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveFollowersResponse = + UserRetrieveFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedUserRetrieveFollowersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveFollowersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveFollowersResponse) + .isEqualTo(userRetrieveFollowersResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponseTest.kt index 3df4255..97279c1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponseTest.kt @@ -14,39 +14,40 @@ internal class UserRetrieveFollowersYouKnowResponseTest { val userRetrieveFollowersYouKnowResponse = UserRetrieveFollowersYouKnowResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( UserRetrieveFollowersYouKnowResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) .build() assertThat(userRetrieveFollowersYouKnowResponse.hasNextPage()).isEqualTo(true) - assertThat(userRetrieveFollowersYouKnowResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(userRetrieveFollowersYouKnowResponse.nextCursor()) + .isEqualTo("DAACCgACGRElMJcAAA") assertThat(userRetrieveFollowersYouKnowResponse.users()) .containsExactly( UserRetrieveFollowersYouKnowResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) @@ -58,19 +59,19 @@ internal class UserRetrieveFollowersYouKnowResponseTest { val userRetrieveFollowersYouKnowResponse = UserRetrieveFollowersYouKnowResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addUser( UserRetrieveFollowersYouKnowResponse.User.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) .verified(true) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponseTest.kt new file mode 100644 index 0000000..b913ade --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveFollowingResponseTest { + + @Test + fun create() { + val userRetrieveFollowingResponse = + UserRetrieveFollowingResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveFollowingResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(userRetrieveFollowingResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveFollowingResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveFollowingResponse.users()) + .containsExactly( + UserRetrieveFollowingResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveFollowingResponse = + UserRetrieveFollowingResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveFollowingResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedUserRetrieveFollowingResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveFollowingResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveFollowingResponse) + .isEqualTo(userRetrieveFollowingResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponseTest.kt index 7995f07..5f9ee61 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponseTest.kt @@ -14,52 +14,54 @@ internal class UserRetrieveLikesResponseTest { val userRetrieveLikesResponse = UserRetrieveLikesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveLikesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveLikesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(userRetrieveLikesResponse.hasNextPage()).isEqualTo(true) - assertThat(userRetrieveLikesResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(userRetrieveLikesResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(userRetrieveLikesResponse.tweets()) .containsExactly( UserRetrieveLikesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveLikesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class UserRetrieveLikesResponseTest { val userRetrieveLikesResponse = UserRetrieveLikesResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveLikesResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveLikesResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponseTest.kt index 0fff71c..161bdb7 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponseTest.kt @@ -14,52 +14,54 @@ internal class UserRetrieveMediaResponseTest { val userRetrieveMediaResponse = UserRetrieveMediaResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveMediaResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveMediaResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(userRetrieveMediaResponse.hasNextPage()).isEqualTo(true) - assertThat(userRetrieveMediaResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(userRetrieveMediaResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(userRetrieveMediaResponse.tweets()) .containsExactly( UserRetrieveMediaResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveMediaResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class UserRetrieveMediaResponseTest { val userRetrieveMediaResponse = UserRetrieveMediaResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveMediaResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveMediaResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponseTest.kt new file mode 100644 index 0000000..de0b14a --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveMentionsResponseTest { + + @Test + fun create() { + val userRetrieveMentionsResponse = + UserRetrieveMentionsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + UserRetrieveMentionsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + UserRetrieveMentionsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + assertThat(userRetrieveMentionsResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveMentionsResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveMentionsResponse.tweets()) + .containsExactly( + UserRetrieveMentionsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + UserRetrieveMentionsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveMentionsResponse = + UserRetrieveMentionsResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addTweet( + UserRetrieveMentionsResponse.Tweet.builder() + .id("1234567890") + .text("Just launched our new feature!") + .author( + UserRetrieveMentionsResponse.Tweet.Author.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .verified(true) + .build() + ) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) + .build() + ) + .build() + + val roundtrippedUserRetrieveMentionsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveMentionsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveMentionsResponse).isEqualTo(userRetrieveMentionsResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParamsTest.kt deleted file mode 100644 index 56e2f19..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UserRetrieveParamsTest { - - @Test - fun create() { - UserRetrieveParams.builder().username("username").build() - } - - @Test - fun pathParams() { - val params = UserRetrieveParams.builder().username("username").build() - - assertThat(params._pathParam(0)).isEqualTo("username") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponseTest.kt deleted file mode 100644 index 3e41731..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponseTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UserRetrieveResponseTest { - - @Test - fun create() { - val userRetrieveResponse = - UserRetrieveResponse.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) - .verified(true) - .build() - - assertThat(userRetrieveResponse.id()).isEqualTo("id") - assertThat(userRetrieveResponse.name()).isEqualTo("name") - assertThat(userRetrieveResponse.username()).isEqualTo("username") - assertThat(userRetrieveResponse.createdAt()).contains("createdAt") - assertThat(userRetrieveResponse.description()).contains("description") - assertThat(userRetrieveResponse.followers()).contains(0L) - assertThat(userRetrieveResponse.following()).contains(0L) - assertThat(userRetrieveResponse.location()).contains("location") - assertThat(userRetrieveResponse.profilePicture()).contains("profilePicture") - assertThat(userRetrieveResponse.statusesCount()).contains(0L) - assertThat(userRetrieveResponse.verified()).contains(true) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val userRetrieveResponse = - UserRetrieveResponse.builder() - .id("id") - .name("name") - .username("username") - .createdAt("createdAt") - .description("description") - .followers(0L) - .following(0L) - .location("location") - .profilePicture("profilePicture") - .statusesCount(0L) - .verified(true) - .build() - - val roundtrippedUserRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(userRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUserRetrieveResponse).isEqualTo(userRetrieveResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponseTest.kt new file mode 100644 index 0000000..a7bdff6 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveSearchResponseTest { + + @Test + fun create() { + val userRetrieveSearchResponse = + UserRetrieveSearchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveSearchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(userRetrieveSearchResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveSearchResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveSearchResponse.users()) + .containsExactly( + UserRetrieveSearchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveSearchResponse = + UserRetrieveSearchResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveSearchResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedUserRetrieveSearchResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveSearchResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveSearchResponse).isEqualTo(userRetrieveSearchResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponseTest.kt index 422c459..fe7bdf1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponseTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponseTest.kt @@ -14,52 +14,54 @@ internal class UserRetrieveTweetsResponseTest { val userRetrieveTweetsResponse = UserRetrieveTweetsResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveTweetsResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveTweetsResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() assertThat(userRetrieveTweetsResponse.hasNextPage()).isEqualTo(true) - assertThat(userRetrieveTweetsResponse.nextCursor()).isEqualTo("next_cursor") + assertThat(userRetrieveTweetsResponse.nextCursor()).isEqualTo("DAACCgACGRElMJcAAA") assertThat(userRetrieveTweetsResponse.tweets()) .containsExactly( UserRetrieveTweetsResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveTweetsResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) } @@ -70,26 +72,27 @@ internal class UserRetrieveTweetsResponseTest { val userRetrieveTweetsResponse = UserRetrieveTweetsResponse.builder() .hasNextPage(true) - .nextCursor("next_cursor") + .nextCursor("DAACCgACGRElMJcAAA") .addTweet( UserRetrieveTweetsResponse.Tweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( UserRetrieveTweetsResponse.Tweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() ) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponseTest.kt new file mode 100644 index 0000000..8625635 --- /dev/null +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.models.x.users + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.x_twitter_scraper.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRetrieveVerifiedFollowersResponseTest { + + @Test + fun create() { + val userRetrieveVerifiedFollowersResponse = + UserRetrieveVerifiedFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveVerifiedFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + assertThat(userRetrieveVerifiedFollowersResponse.hasNextPage()).isEqualTo(true) + assertThat(userRetrieveVerifiedFollowersResponse.nextCursor()) + .isEqualTo("DAACCgACGRElMJcAAA") + assertThat(userRetrieveVerifiedFollowersResponse.users()) + .containsExactly( + UserRetrieveVerifiedFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRetrieveVerifiedFollowersResponse = + UserRetrieveVerifiedFollowersResponse.builder() + .hasNextPage(true) + .nextCursor("DAACCgACGRElMJcAAA") + .addUser( + UserRetrieveVerifiedFollowersResponse.User.builder() + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") + .createdAt("2009-06-02T20:12:29Z") + .description("CEO of Tesla, SpaceX, and X") + .followers(150000000L) + .following(500L) + .location("Austin, TX") + .profilePicture("https://pbs.twimg.com/profile_images/example.jpg") + .statusesCount(35000L) + .verified(true) + .build() + ) + .build() + + val roundtrippedUserRetrieveVerifiedFollowersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRetrieveVerifiedFollowersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRetrieveVerifiedFollowersResponse) + .isEqualTo(userRetrieveVerifiedFollowersResponse) + } +} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParamsTest.kt deleted file mode 100644 index 08e035d..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FollowCreateParamsTest { - - @Test - fun create() { - FollowCreateParams.builder().userId("userId").account("account").build() - } - - @Test - fun pathParams() { - val params = FollowCreateParams.builder().userId("userId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("userId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = FollowCreateParams.builder().userId("userId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponseTest.kt deleted file mode 100644 index a0d188a..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FollowCreateResponseTest { - - @Test - fun create() { - val followCreateResponse = FollowCreateResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val followCreateResponse = FollowCreateResponse.builder().build() - - val roundtrippedFollowCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(followCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFollowCreateResponse).isEqualTo(followCreateResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParamsTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParamsTest.kt deleted file mode 100644 index a6cb012..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FollowDeleteAllParamsTest { - - @Test - fun create() { - FollowDeleteAllParams.builder().userId("userId").account("account").build() - } - - @Test - fun pathParams() { - val params = FollowDeleteAllParams.builder().userId("userId").account("account").build() - - assertThat(params._pathParam(0)).isEqualTo("userId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = FollowDeleteAllParams.builder().userId("userId").account("account").build() - - val body = params._body() - - assertThat(body.account()).isEqualTo("account") - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponseTest.kt deleted file mode 100644 index ebde54b..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.x.users.follow - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.x_twitter_scraper.api.core.jsonMapper -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FollowDeleteAllResponseTest { - - @Test - fun create() { - val followDeleteAllResponse = FollowDeleteAllResponse.builder().build() - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val followDeleteAllResponse = FollowDeleteAllResponse.builder().build() - - val roundtrippedFollowDeleteAllResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(followDeleteAllResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFollowDeleteAllResponse).isEqualTo(followDeleteAllResponse) - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncTest.kt index 7dcb61f..00d8ce3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/AccountServiceAsyncTest.kt @@ -38,7 +38,7 @@ internal class AccountServiceAsyncTest { val responseFuture = accountServiceAsync.setXUsername( - AccountSetXUsernameParams.builder().username("username").build() + AccountSetXUsernameParams.builder().username("elonmusk").build() ) val response = responseFuture.get() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncTest.kt index e5d31b9..c6972b9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ApiKeyServiceAsyncTest.kt @@ -20,7 +20,7 @@ internal class ApiKeyServiceAsyncTest { val apiKeyServiceAsync = client.apiKeys() val apiKeyFuture = - apiKeyServiceAsync.create(ApiKeyCreateParams.builder().name("name").build()) + apiKeyServiceAsync.create(ApiKeyCreateParams.builder().name("My API Key").build()) val apiKey = apiKeyFuture.get() apiKey.validate() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ComposeServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ComposeServiceAsyncTest.kt index 8113fa0..b12a563 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ComposeServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ComposeServiceAsyncTest.kt @@ -23,16 +23,16 @@ internal class ComposeServiceAsyncTest { composeServiceAsync.create( ComposeCreateParams.builder() .step(ComposeCreateParams.Step.COMPOSE) - .additionalContext("additionalContext") - .callToAction("callToAction") - .draft("draft") + .additionalContext("https://x.com/elonmusk/status/1234567890") + .callToAction("Follow for more") + .draft("AI is changing everything. Here's why.") .goal(ComposeCreateParams.Goal.ENGAGEMENT) - .hasLink(true) - .hasMedia(true) - .mediaType(ComposeCreateParams.MediaType.PHOTO) - .styleUsername("styleUsername") - .tone("tone") - .topic("topic") + .hasLink(false) + .hasMedia(false) + .mediaType(ComposeCreateParams.MediaType.NONE) + .styleUsername("elonmusk") + .tone("professional") + .topic("AI trends in 2025") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/CreditServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/CreditServiceAsyncTest.kt index 9a0d25e..c4af183 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/CreditServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/CreditServiceAsyncTest.kt @@ -36,7 +36,9 @@ internal class CreditServiceAsyncTest { val creditServiceAsync = client.credits() val responseFuture = - creditServiceAsync.topupBalance(CreditTopupBalanceParams.builder().amount(0L).build()) + creditServiceAsync.topupBalance( + CreditTopupBalanceParams.builder().amount(10000L).build() + ) val response = responseFuture.get() response.validate() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DraftServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DraftServiceAsyncTest.kt index 2880c87..4399a0c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DraftServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DraftServiceAsyncTest.kt @@ -23,9 +23,9 @@ internal class DraftServiceAsyncTest { val draftFuture = draftServiceAsync.create( DraftCreateParams.builder() - .text("text") + .text("AI is the future of productivity") .goal(DraftCreateParams.Goal.ENGAGEMENT) - .topic("topic") + .topic("AI trends") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DrawServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DrawServiceAsyncTest.kt index 6db6db5..5814bdc 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DrawServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/DrawServiceAsyncTest.kt @@ -91,18 +91,18 @@ internal class DrawServiceAsyncTest { val responseFuture = drawServiceAsync.run( DrawRunParams.builder() - .tweetUrl("https://example.com") - .backupCount(0L) - .filterAccountAgeDays(0L) - .filterLanguage("filterLanguage") - .filterMinFollowers(0L) - .mustFollowUsername("mustFollowUsername") + .tweetUrl("https://x.com/elonmusk/status/1234567890") + .backupCount(2L) + .filterAccountAgeDays(30L) + .filterLanguage("en") + .filterMinFollowers(50L) + .mustFollowUsername("elonmusk") .mustRetweet(true) - .addRequiredHashtag("string") - .addRequiredKeyword("string") - .addRequiredMention("string") + .addRequiredHashtag("#giveaway") + .addRequiredKeyword("entered") + .addRequiredMention("@elonmusk") .uniqueAuthorsOnly(true) - .winnerCount(0L) + .winnerCount(3L) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ExtractionServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ExtractionServiceAsyncTest.kt index 4921d0c..3feaf38 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ExtractionServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/ExtractionServiceAsyncTest.kt @@ -58,7 +58,7 @@ internal class ExtractionServiceAsyncTest { .after("after") .limit(1L) .status(ExtractionListParams.Status.RUNNING) - .toolType(ExtractionListParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListParams.ToolType.FOLLOWER_EXPLORER) .build() ) @@ -79,16 +79,16 @@ internal class ExtractionServiceAsyncTest { val responseFuture = extractionServiceAsync.estimateCost( ExtractionEstimateCostParams.builder() - .toolType(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() ) @@ -132,16 +132,16 @@ internal class ExtractionServiceAsyncTest { val responseFuture = extractionServiceAsync.run( ExtractionRunParams.builder() - .toolType(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/IntegrationServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/IntegrationServiceAsyncTest.kt index 26a7d41..9676561 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/IntegrationServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/IntegrationServiceAsyncTest.kt @@ -3,7 +3,6 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync -import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.models.integrations.IntegrationCreateParams import com.x_twitter_scraper.api.models.integrations.IntegrationListDeliveriesParams import com.x_twitter_scraper.api.models.integrations.IntegrationUpdateParams @@ -25,9 +24,12 @@ internal class IntegrationServiceAsyncTest { val integrationFuture = integrationServiceAsync.create( IntegrationCreateParams.builder() - .config(IntegrationCreateParams.Config.builder().chatId("chatId").build()) + .config( + IntegrationCreateParams.Config.builder().chatId("-1001234567890").build() + ) .addEventType(IntegrationCreateParams.EventType.TWEET_NEW) - .name("name") + .addEventType(IntegrationCreateParams.EventType.FOLLOWER_GAINED) + .name("My Telegram Bot") .type(IntegrationCreateParams.Type.TELEGRAM) .build() ) @@ -67,20 +69,13 @@ internal class IntegrationServiceAsyncTest { IntegrationUpdateParams.builder() .id("id") .addEventType(IntegrationUpdateParams.EventType.TWEET_NEW) - .filters( - IntegrationUpdateParams.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .addEventType(IntegrationUpdateParams.EventType.FOLLOWER_GAINED) + .filters(IntegrationUpdateParams.Filters.builder().build()) .isActive(true) - .messageTemplate( - IntegrationUpdateParams.MessageTemplate.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") + .messageTemplate(IntegrationUpdateParams.MessageTemplate.builder().build()) + .name("My Telegram Bot") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/MonitorServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/MonitorServiceAsyncTest.kt index 18d795b..8d10dfc 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/MonitorServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/MonitorServiceAsyncTest.kt @@ -24,7 +24,8 @@ internal class MonitorServiceAsyncTest { monitorServiceAsync.create( MonitorCreateParams.builder() .addEventType(MonitorCreateParams.EventType.TWEET_NEW) - .username("username") + .addEventType(MonitorCreateParams.EventType.FOLLOWER_GAINED) + .username("elonmusk") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/RadarServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/RadarServiceAsyncTest.kt index 986fe74..5da1d08 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/RadarServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/RadarServiceAsyncTest.kt @@ -26,7 +26,7 @@ internal class RadarServiceAsyncTest { .count(0L) .hours(0L) .region("region") - .source("source") + .source(RadarRetrieveTrendingTopicsParams.Source.GITHUB) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncTest.kt index 449e6bc..4703c3f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncTest.kt @@ -5,51 +5,11 @@ package com.x_twitter_scraper.api.services.async import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleCompareParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class StyleServiceAsyncTest { - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleServiceAsync = client.styles() - - val styleFuture = styleServiceAsync.retrieve("username") - - val style = styleFuture.get() - style.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun update() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleServiceAsync = client.styles() - - val styleFuture = - styleServiceAsync.update( - StyleUpdateParams.builder() - .username("username") - .label("label") - .addTweet(StyleUpdateParams.Tweet.builder().text("text").build()) - .build() - ) - - val style = styleFuture.get() - style.validate() - } - @Disabled("Mock server tests are disabled") @Test fun list() { @@ -66,21 +26,6 @@ internal class StyleServiceAsyncTest { styles.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleServiceAsync = client.styles() - - val future = styleServiceAsync.delete("username") - - val response = future.get() - } - @Disabled("Mock server tests are disabled") @Test fun analyze() { @@ -92,7 +37,7 @@ internal class StyleServiceAsyncTest { val styleServiceAsync = client.styles() val responseFuture = - styleServiceAsync.analyze(StyleAnalyzeParams.builder().username("username").build()) + styleServiceAsync.analyze(StyleAnalyzeParams.builder().username("elonmusk").build()) val response = responseFuture.get() response.validate() @@ -116,20 +61,4 @@ internal class StyleServiceAsyncTest { val response = responseFuture.get() response.validate() } - - @Disabled("Mock server tests are disabled") - @Test - fun getPerformance() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleServiceAsync = client.styles() - - val responseFuture = styleServiceAsync.getPerformance("username") - - val response = responseFuture.get() - response.validate() - } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/WebhookServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/WebhookServiceAsyncTest.kt index 25ddc82..29c593c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/WebhookServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/WebhookServiceAsyncTest.kt @@ -24,7 +24,8 @@ internal class WebhookServiceAsyncTest { webhookServiceAsync.create( WebhookCreateParams.builder() .addEventType(WebhookCreateParams.EventType.TWEET_NEW) - .url("https://example.com") + .addEventType(WebhookCreateParams.EventType.FOLLOWER_GAINED) + .url("https://example.com/webhook") .build() ) @@ -47,8 +48,9 @@ internal class WebhookServiceAsyncTest { WebhookUpdateParams.builder() .id("id") .addEventType(WebhookUpdateParams.EventType.TWEET_NEW) + .addEventType(WebhookUpdateParams.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhook") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncTest.kt index 0c4d7e3..49373f1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/XServiceAsyncTest.kt @@ -80,8 +80,9 @@ internal class XServiceAsyncTest { .build() val xServiceAsync = client.x() - val future = xServiceAsync.getTrends() + val responseFuture = xServiceAsync.getTrends() - val response = future.get() + val response = responseFuture.get() + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/support/TicketServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/support/TicketServiceAsyncTest.kt index 0d433e5..954d9b0 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/support/TicketServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/support/TicketServiceAsyncTest.kt @@ -23,7 +23,10 @@ internal class TicketServiceAsyncTest { val ticketFuture = ticketServiceAsync.create( - TicketCreateParams.builder().body("body").subject("subject").build() + TicketCreateParams.builder() + .body("I am unable to connect my X account. Please help.") + .subject("Cannot connect X account") + .build() ) val ticket = ticketFuture.get() @@ -40,7 +43,7 @@ internal class TicketServiceAsyncTest { .build() val ticketServiceAsync = client.support().tickets() - val ticketFuture = ticketServiceAsync.retrieve("id") + val ticketFuture = ticketServiceAsync.retrieve("messages_value") val ticket = ticketFuture.get() ticket.validate() @@ -58,7 +61,10 @@ internal class TicketServiceAsyncTest { val ticketFuture = ticketServiceAsync.update( - TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.OPEN).build() + TicketUpdateParams.builder() + .id("id") + .status(TicketUpdateParams.Status.RESOLVED) + .build() ) val ticket = ticketFuture.get() @@ -92,7 +98,9 @@ internal class TicketServiceAsyncTest { val ticketServiceAsync = client.support().tickets() val responseFuture = - ticketServiceAsync.reply(TicketReplyParams.builder().id("id").body("body").build()) + ticketServiceAsync.reply( + TicketReplyParams.builder().id("id").body("Thank you for the update.").build() + ) val response = responseFuture.get() response.validate() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncTest.kt index f127267..ce916d1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/AccountServiceAsyncTest.kt @@ -23,11 +23,11 @@ internal class AccountServiceAsyncTest { val accountFuture = accountServiceAsync.create( AccountCreateParams.builder() - .email("email") - .password("password") - .username("username") - .proxyCountry("proxy_country") - .totpSecret("totp_secret") + .email("user@example.com") + .password("s3cur3Pa\$\$w0rd") + .username("elonmusk") + .proxyCountry("US") + .totpSecret("JBSWY3DPEHPK3PXP") .build() ) @@ -97,8 +97,8 @@ internal class AccountServiceAsyncTest { accountServiceAsync.reauth( AccountReauthParams.builder() .id("id") - .password("password") - .totpSecret("totp_secret") + .password("password_value") + .totpSecret("totp_secret_value") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/BookmarkServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/BookmarkServiceAsyncTest.kt index 3166994..0e38399 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/BookmarkServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/BookmarkServiceAsyncTest.kt @@ -21,7 +21,7 @@ internal class BookmarkServiceAsyncTest { val bookmarksFuture = bookmarkServiceAsync.list( - BookmarkListParams.builder().cursor("cursor").folderId("folderId").build() + BookmarkListParams.builder().cursor("folders_value").folderId("folderId").build() ) val bookmarks = bookmarksFuture.get() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncTest.kt index 0270e33..4c25913 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/CommunityServiceAsyncTest.kt @@ -26,9 +26,9 @@ internal class CommunityServiceAsyncTest { val communityFuture = communityServiceAsync.create( CommunityCreateParams.builder() - .account("account") - .name("name") - .description("description") + .account("@elonmusk") + .name("Example Name") + .description("A community for Tesla enthusiasts") .build() ) @@ -50,8 +50,8 @@ internal class CommunityServiceAsyncTest { communityServiceAsync.delete( CommunityDeleteParams.builder() .id("id") - .account("account") - .communityName("community_name") + .account("@elonmusk") + .communityName("Tesla Fans") .build() ) @@ -85,12 +85,13 @@ internal class CommunityServiceAsyncTest { .build() val communityServiceAsync = client.x().communities() - val future = + val responseFuture = communityServiceAsync.retrieveMembers( CommunityRetrieveMembersParams.builder().id("id").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -103,12 +104,13 @@ internal class CommunityServiceAsyncTest { .build() val communityServiceAsync = client.x().communities() - val future = + val responseFuture = communityServiceAsync.retrieveModerators( CommunityRetrieveModeratorsParams.builder().id("id").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -121,7 +123,7 @@ internal class CommunityServiceAsyncTest { .build() val communityServiceAsync = client.x().communities() - val future = + val responseFuture = communityServiceAsync.retrieveSearch( CommunityRetrieveSearchParams.builder() .q("q") @@ -130,6 +132,7 @@ internal class CommunityServiceAsyncTest { .build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/DmServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/DmServiceAsyncTest.kt index d685da8..932bdda 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/DmServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/DmServiceAsyncTest.kt @@ -47,10 +47,10 @@ internal class DmServiceAsyncTest { dmServiceAsync.send( DmSendParams.builder() .userId("userId") - .account("account") - .text("text") - .addMediaId("string") - .replyToMessageId("reply_to_message_id") + .account("@elonmusk") + .text("Example text content") + .addMediaId("1234567890123456789") + .replyToMessageId("1234567890123456789") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncTest.kt index 1ee5232..a12206d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ListServiceAsyncTest.kt @@ -21,12 +21,13 @@ internal class ListServiceAsyncTest { .build() val listServiceAsync = client.x().lists() - val future = + val responseFuture = listServiceAsync.retrieveFollowers( ListRetrieveFollowersParams.builder().id("id").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -39,12 +40,13 @@ internal class ListServiceAsyncTest { .build() val listServiceAsync = client.x().lists() - val future = + val responseFuture = listServiceAsync.retrieveMembers( ListRetrieveMembersParams.builder().id("id").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -57,7 +59,7 @@ internal class ListServiceAsyncTest { .build() val listServiceAsync = client.x().lists() - val future = + val responseFuture = listServiceAsync.retrieveTweets( ListRetrieveTweetsParams.builder() .id("id") @@ -68,6 +70,7 @@ internal class ListServiceAsyncTest { .build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/MediaServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/MediaServiceAsyncTest.kt index 75562fa..fe181cf 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/MediaServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/MediaServiceAsyncTest.kt @@ -22,7 +22,11 @@ internal class MediaServiceAsyncTest { val responseFuture = mediaServiceAsync.download( - MediaDownloadParams.builder().addTweetId("string").tweetInput("tweetInput").build() + MediaDownloadParams.builder() + .addTweetId("1234567890") + .addTweetId("1234567891") + .tweetInput("https://x.com/elonmusk/status/1234567890") + .build() ) val response = responseFuture.get() @@ -42,7 +46,7 @@ internal class MediaServiceAsyncTest { val responseFuture = mediaServiceAsync.upload( MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .isLongVideo(true) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ProfileServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ProfileServiceAsyncTest.kt index edac164..3bf1ce7 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ProfileServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/ProfileServiceAsyncTest.kt @@ -24,11 +24,11 @@ internal class ProfileServiceAsyncTest { val profileFuture = profileServiceAsync.update( ProfileUpdateParams.builder() - .account("account") - .description("description") - .location("location") - .name("name") - .url("url") + .account("@elonmusk") + .description("description_value") + .location("location_value") + .name("Example Name") + .url("https://xquik.com/example") .build() ) @@ -49,7 +49,7 @@ internal class ProfileServiceAsyncTest { val responseFuture = profileServiceAsync.updateAvatar( ProfileUpdateAvatarParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() ) @@ -71,7 +71,7 @@ internal class ProfileServiceAsyncTest { val responseFuture = profileServiceAsync.updateBanner( ProfileUpdateBannerParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncTest.kt index 6cfc93f..5147143 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.x_twitter_scraper.api.services.async.x import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetRepliesParams @@ -30,13 +29,13 @@ internal class TweetServiceAsyncTest { val tweetFuture = tweetServiceAsync.create( TweetCreateParams.builder() - .account("account") - .text("text") - .attachmentUrl("attachment_url") - .communityId("community_id") - .isNoteTweet(true) - .addMediaId("string") - .replyToTweetId("reply_to_tweet_id") + .account("@elonmusk") + .text("Just launched our new feature!") + .attachmentUrl("https://x.com/elonmusk/status/1234567890") + .communityId("1500000000000000000") + .isNoteTweet(false) + .addMediaId("1234567890123456789") + .replyToTweetId("1234567890") .build() ) @@ -44,22 +43,6 @@ internal class TweetServiceAsyncTest { tweet.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val tweetServiceAsync = client.x().tweets() - - val tweetFuture = tweetServiceAsync.retrieve("tweetId") - - val tweet = tweetFuture.get() - tweet.validate() - } - @Disabled("Mock server tests are disabled") @Test fun list() { @@ -70,28 +53,10 @@ internal class TweetServiceAsyncTest { .build() val tweetServiceAsync = client.x().tweets() - val future = tweetServiceAsync.list(TweetListParams.builder().ids("ids").build()) - - val response = future.get() - } - - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val tweetServiceAsync = client.x().tweets() - - val tweetFuture = - tweetServiceAsync.delete( - TweetDeleteParams.builder().tweetId("tweetId").account("account").build() - ) + val tweetsFuture = tweetServiceAsync.list(TweetListParams.builder().ids("ids").build()) - val tweet = tweetFuture.get() - tweet.validate() + val tweets = tweetsFuture.get() + tweets.validate() } @Disabled("Mock server tests are disabled") diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncTest.kt index 47e6b87..e85e3a8 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsyncTest.kt @@ -18,22 +18,6 @@ import org.junit.jupiter.api.Test internal class UserServiceAsyncTest { - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val userServiceAsync = client.x().users() - - val userFuture = userServiceAsync.retrieve("username") - - val user = userFuture.get() - user.validate() - } - @Disabled("Mock server tests are disabled") @Test fun retrieveBatch() { @@ -44,10 +28,11 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveBatch(UserRetrieveBatchParams.builder().ids("ids").build()) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -60,12 +45,13 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveFollowers( UserRetrieveFollowersParams.builder().id("id").cursor("cursor").pageSize(0L).build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -97,12 +83,13 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveFollowing( UserRetrieveFollowingParams.builder().id("id").cursor("cursor").pageSize(0L).build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -153,7 +140,7 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveMentions( UserRetrieveMentionsParams.builder() .id("id") @@ -163,7 +150,8 @@ internal class UserServiceAsyncTest { .build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -176,12 +164,13 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveSearch( UserRetrieveSearchParams.builder().q("q").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -218,11 +207,12 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveVerifiedFollowers( UserRetrieveVerifiedFollowersParams.builder().id("id").cursor("cursor").build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/JoinServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/JoinServiceAsyncTest.kt index 5cf1117..18b9323 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/JoinServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/JoinServiceAsyncTest.kt @@ -21,7 +21,9 @@ internal class JoinServiceAsyncTest { val joinServiceAsync = client.x().communities().join() val joinFuture = - joinServiceAsync.create(JoinCreateParams.builder().id("id").account("account").build()) + joinServiceAsync.create( + JoinCreateParams.builder().id("id").account("@elonmusk").build() + ) val join = joinFuture.get() join.validate() @@ -39,7 +41,7 @@ internal class JoinServiceAsyncTest { val responseFuture = joinServiceAsync.deleteAll( - JoinDeleteAllParams.builder().id("id").account("account").build() + JoinDeleteAllParams.builder().id("id").account("@elonmusk").build() ) val response = responseFuture.get() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncTest.kt index 74a0871..d1463d9 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/communities/TweetServiceAsyncTest.kt @@ -19,11 +19,12 @@ internal class TweetServiceAsyncTest { .build() val tweetServiceAsync = client.x().communities().tweets() - val future = + val tweetsFuture = tweetServiceAsync.list( TweetListParams.builder().q("q").cursor("cursor").queryType("queryType").build() ) - val response = future.get() + val tweets = tweetsFuture.get() + tweets.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncTest.kt deleted file mode 100644 index dc55c35..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.async.x.tweets - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class LikeServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val likeServiceAsync = client.x().tweets().like() - - val likeFuture = - likeServiceAsync.create( - LikeCreateParams.builder().tweetId("tweetId").account("account").build() - ) - - val like = likeFuture.get() - like.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val likeServiceAsync = client.x().tweets().like() - - val likeFuture = - likeServiceAsync.delete( - LikeDeleteParams.builder().tweetId("tweetId").account("account").build() - ) - - val like = likeFuture.get() - like.validate() - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncTest.kt deleted file mode 100644 index 54c3b64..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.async.x.tweets - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class RetweetServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val retweetServiceAsync = client.x().tweets().retweet() - - val retweetFuture = - retweetServiceAsync.create( - RetweetCreateParams.builder().tweetId("tweetId").account("account").build() - ) - - val retweet = retweetFuture.get() - retweet.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val retweetServiceAsync = client.x().tweets().retweet() - - val retweetFuture = - retweetServiceAsync.delete( - RetweetDeleteParams.builder().tweetId("tweetId").account("account").build() - ) - - val retweet = retweetFuture.get() - retweet.validate() - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncTest.kt deleted file mode 100644 index 6448570..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.async.x.users - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class FollowServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val followServiceAsync = client.x().users().follow() - - val followFuture = - followServiceAsync.create( - FollowCreateParams.builder().userId("userId").account("account").build() - ) - - val follow = followFuture.get() - follow.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun deleteAll() { - val client = - XTwitterScraperOkHttpClientAsync.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val followServiceAsync = client.x().users().follow() - - val responseFuture = - followServiceAsync.deleteAll( - FollowDeleteAllParams.builder().userId("userId").account("account").build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceTest.kt index ff83fc1..949e341 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/AccountServiceTest.kt @@ -37,7 +37,7 @@ internal class AccountServiceTest { val response = accountService.setXUsername( - AccountSetXUsernameParams.builder().username("username").build() + AccountSetXUsernameParams.builder().username("elonmusk").build() ) response.validate() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceTest.kt index a88d574..5edbc5c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ApiKeyServiceTest.kt @@ -19,7 +19,7 @@ internal class ApiKeyServiceTest { .build() val apiKeyService = client.apiKeys() - val apiKey = apiKeyService.create(ApiKeyCreateParams.builder().name("name").build()) + val apiKey = apiKeyService.create(ApiKeyCreateParams.builder().name("My API Key").build()) apiKey.validate() } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ComposeServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ComposeServiceTest.kt index 9d700f2..219a3f3 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ComposeServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ComposeServiceTest.kt @@ -23,16 +23,16 @@ internal class ComposeServiceTest { composeService.create( ComposeCreateParams.builder() .step(ComposeCreateParams.Step.COMPOSE) - .additionalContext("additionalContext") - .callToAction("callToAction") - .draft("draft") + .additionalContext("https://x.com/elonmusk/status/1234567890") + .callToAction("Follow for more") + .draft("AI is changing everything. Here's why.") .goal(ComposeCreateParams.Goal.ENGAGEMENT) - .hasLink(true) - .hasMedia(true) - .mediaType(ComposeCreateParams.MediaType.PHOTO) - .styleUsername("styleUsername") - .tone("tone") - .topic("topic") + .hasLink(false) + .hasMedia(false) + .mediaType(ComposeCreateParams.MediaType.NONE) + .styleUsername("elonmusk") + .tone("professional") + .topic("AI trends in 2025") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/CreditServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/CreditServiceTest.kt index 35c9eac..f24d1ef 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/CreditServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/CreditServiceTest.kt @@ -35,7 +35,7 @@ internal class CreditServiceTest { val creditService = client.credits() val response = - creditService.topupBalance(CreditTopupBalanceParams.builder().amount(0L).build()) + creditService.topupBalance(CreditTopupBalanceParams.builder().amount(10000L).build()) response.validate() } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DraftServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DraftServiceTest.kt index e8bec3b..74075af 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DraftServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DraftServiceTest.kt @@ -23,9 +23,9 @@ internal class DraftServiceTest { val draft = draftService.create( DraftCreateParams.builder() - .text("text") + .text("AI is the future of productivity") .goal(DraftCreateParams.Goal.ENGAGEMENT) - .topic("topic") + .topic("AI trends") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DrawServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DrawServiceTest.kt index 4d23fdb..d3f084f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DrawServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/DrawServiceTest.kt @@ -87,18 +87,18 @@ internal class DrawServiceTest { val response = drawService.run( DrawRunParams.builder() - .tweetUrl("https://example.com") - .backupCount(0L) - .filterAccountAgeDays(0L) - .filterLanguage("filterLanguage") - .filterMinFollowers(0L) - .mustFollowUsername("mustFollowUsername") + .tweetUrl("https://x.com/elonmusk/status/1234567890") + .backupCount(2L) + .filterAccountAgeDays(30L) + .filterLanguage("en") + .filterMinFollowers(50L) + .mustFollowUsername("elonmusk") .mustRetweet(true) - .addRequiredHashtag("string") - .addRequiredKeyword("string") - .addRequiredMention("string") + .addRequiredHashtag("#giveaway") + .addRequiredKeyword("entered") + .addRequiredMention("@elonmusk") .uniqueAuthorsOnly(true) - .winnerCount(0L) + .winnerCount(3L) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ExtractionServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ExtractionServiceTest.kt index 6290398..8390c94 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ExtractionServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/ExtractionServiceTest.kt @@ -57,7 +57,7 @@ internal class ExtractionServiceTest { .after("after") .limit(1L) .status(ExtractionListParams.Status.RUNNING) - .toolType(ExtractionListParams.ToolType.ARTICLE_EXTRACTOR) + .toolType(ExtractionListParams.ToolType.FOLLOWER_EXPLORER) .build() ) @@ -77,16 +77,16 @@ internal class ExtractionServiceTest { val response = extractionService.estimateCost( ExtractionEstimateCostParams.builder() - .toolType(ExtractionEstimateCostParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionEstimateCostParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() ) @@ -128,16 +128,16 @@ internal class ExtractionServiceTest { val response = extractionService.run( ExtractionRunParams.builder() - .toolType(ExtractionRunParams.ToolType.ARTICLE_EXTRACTOR) - .advancedQuery("advancedQuery") - .exactPhrase("exactPhrase") - .excludeWords("excludeWords") - .searchQuery("searchQuery") - .targetCommunityId("targetCommunityId") - .targetListId("targetListId") - .targetSpaceId("targetSpaceId") - .targetTweetId("targetTweetId") - .targetUsername("targetUsername") + .toolType(ExtractionRunParams.ToolType.FOLLOWER_EXPLORER) + .advancedQuery("min_faves:100") + .exactPhrase("artificial intelligence") + .excludeWords("spam") + .searchQuery("AI trends 2025") + .targetCommunityId("1500000000000000000") + .targetListId("1234567890") + .targetSpaceId("1vOGwMdBqpwGB") + .targetTweetId("1234567890") + .targetUsername("elonmusk") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/IntegrationServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/IntegrationServiceTest.kt index fae20ae..5dc9f40 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/IntegrationServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/IntegrationServiceTest.kt @@ -3,7 +3,6 @@ package com.x_twitter_scraper.api.services.blocking import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient -import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.models.integrations.IntegrationCreateParams import com.x_twitter_scraper.api.models.integrations.IntegrationListDeliveriesParams import com.x_twitter_scraper.api.models.integrations.IntegrationUpdateParams @@ -25,9 +24,12 @@ internal class IntegrationServiceTest { val integration = integrationService.create( IntegrationCreateParams.builder() - .config(IntegrationCreateParams.Config.builder().chatId("chatId").build()) + .config( + IntegrationCreateParams.Config.builder().chatId("-1001234567890").build() + ) .addEventType(IntegrationCreateParams.EventType.TWEET_NEW) - .name("name") + .addEventType(IntegrationCreateParams.EventType.FOLLOWER_GAINED) + .name("My Telegram Bot") .type(IntegrationCreateParams.Type.TELEGRAM) .build() ) @@ -65,20 +67,13 @@ internal class IntegrationServiceTest { IntegrationUpdateParams.builder() .id("id") .addEventType(IntegrationUpdateParams.EventType.TWEET_NEW) - .filters( - IntegrationUpdateParams.Filters.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) + .addEventType(IntegrationUpdateParams.EventType.FOLLOWER_GAINED) + .filters(IntegrationUpdateParams.Filters.builder().build()) .isActive(true) - .messageTemplate( - IntegrationUpdateParams.MessageTemplate.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .name("name") + .messageTemplate(IntegrationUpdateParams.MessageTemplate.builder().build()) + .name("My Telegram Bot") .scopeAllMonitors(true) - .silentPush(true) + .silentPush(false) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/MonitorServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/MonitorServiceTest.kt index edef10a..368c3ee 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/MonitorServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/MonitorServiceTest.kt @@ -24,7 +24,8 @@ internal class MonitorServiceTest { monitorService.create( MonitorCreateParams.builder() .addEventType(MonitorCreateParams.EventType.TWEET_NEW) - .username("username") + .addEventType(MonitorCreateParams.EventType.FOLLOWER_GAINED) + .username("elonmusk") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/RadarServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/RadarServiceTest.kt index 9ace4e3..0cbc254 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/RadarServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/RadarServiceTest.kt @@ -26,7 +26,7 @@ internal class RadarServiceTest { .count(0L) .hours(0L) .region("region") - .source("source") + .source(RadarRetrieveTrendingTopicsParams.Source.GITHUB) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceTest.kt index 87344b8..fcd7b5d 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceTest.kt @@ -5,49 +5,11 @@ package com.x_twitter_scraper.api.services.blocking import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient import com.x_twitter_scraper.api.models.styles.StyleAnalyzeParams import com.x_twitter_scraper.api.models.styles.StyleCompareParams -import com.x_twitter_scraper.api.models.styles.StyleUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class StyleServiceTest { - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleService = client.styles() - - val style = styleService.retrieve("username") - - style.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun update() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleService = client.styles() - - val style = - styleService.update( - StyleUpdateParams.builder() - .username("username") - .label("label") - .addTweet(StyleUpdateParams.Tweet.builder().text("text").build()) - .build() - ) - - style.validate() - } - @Disabled("Mock server tests are disabled") @Test fun list() { @@ -63,19 +25,6 @@ internal class StyleServiceTest { styles.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleService = client.styles() - - styleService.delete("username") - } - @Disabled("Mock server tests are disabled") @Test fun analyze() { @@ -87,7 +36,7 @@ internal class StyleServiceTest { val styleService = client.styles() val response = - styleService.analyze(StyleAnalyzeParams.builder().username("username").build()) + styleService.analyze(StyleAnalyzeParams.builder().username("elonmusk").build()) response.validate() } @@ -109,19 +58,4 @@ internal class StyleServiceTest { response.validate() } - - @Disabled("Mock server tests are disabled") - @Test - fun getPerformance() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val styleService = client.styles() - - val response = styleService.getPerformance("username") - - response.validate() - } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/WebhookServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/WebhookServiceTest.kt index af6ca38..c126a0c 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/WebhookServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/WebhookServiceTest.kt @@ -24,7 +24,8 @@ internal class WebhookServiceTest { webhookService.create( WebhookCreateParams.builder() .addEventType(WebhookCreateParams.EventType.TWEET_NEW) - .url("https://example.com") + .addEventType(WebhookCreateParams.EventType.FOLLOWER_GAINED) + .url("https://example.com/webhook") .build() ) @@ -46,8 +47,9 @@ internal class WebhookServiceTest { WebhookUpdateParams.builder() .id("id") .addEventType(WebhookUpdateParams.EventType.TWEET_NEW) + .addEventType(WebhookUpdateParams.EventType.FOLLOWER_GAINED) .isActive(true) - .url("https://example.com") + .url("https://example.com/webhook") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceTest.kt index fb97889..5a99e8a 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/XServiceTest.kt @@ -77,6 +77,8 @@ internal class XServiceTest { .build() val xService = client.x() - xService.getTrends() + val response = xService.getTrends() + + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/support/TicketServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/support/TicketServiceTest.kt index e576210..5af2627 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/support/TicketServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/support/TicketServiceTest.kt @@ -23,7 +23,10 @@ internal class TicketServiceTest { val ticket = ticketService.create( - TicketCreateParams.builder().body("body").subject("subject").build() + TicketCreateParams.builder() + .body("I am unable to connect my X account. Please help.") + .subject("Cannot connect X account") + .build() ) ticket.validate() @@ -39,7 +42,7 @@ internal class TicketServiceTest { .build() val ticketService = client.support().tickets() - val ticket = ticketService.retrieve("id") + val ticket = ticketService.retrieve("messages_value") ticket.validate() } @@ -56,7 +59,10 @@ internal class TicketServiceTest { val ticket = ticketService.update( - TicketUpdateParams.builder().id("id").status(TicketUpdateParams.Status.OPEN).build() + TicketUpdateParams.builder() + .id("id") + .status(TicketUpdateParams.Status.RESOLVED) + .build() ) ticket.validate() @@ -88,7 +94,9 @@ internal class TicketServiceTest { val ticketService = client.support().tickets() val response = - ticketService.reply(TicketReplyParams.builder().id("id").body("body").build()) + ticketService.reply( + TicketReplyParams.builder().id("id").body("Thank you for the update.").build() + ) response.validate() } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceTest.kt index 7753a42..6f5ef0f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/AccountServiceTest.kt @@ -23,11 +23,11 @@ internal class AccountServiceTest { val account = accountService.create( AccountCreateParams.builder() - .email("email") - .password("password") - .username("username") - .proxyCountry("proxy_country") - .totpSecret("totp_secret") + .email("user@example.com") + .password("s3cur3Pa\$\$w0rd") + .username("elonmusk") + .proxyCountry("US") + .totpSecret("JBSWY3DPEHPK3PXP") .build() ) @@ -93,8 +93,8 @@ internal class AccountServiceTest { accountService.reauth( AccountReauthParams.builder() .id("id") - .password("password") - .totpSecret("totp_secret") + .password("password_value") + .totpSecret("totp_secret_value") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/BookmarkServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/BookmarkServiceTest.kt index c1a4634..d249229 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/BookmarkServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/BookmarkServiceTest.kt @@ -21,7 +21,7 @@ internal class BookmarkServiceTest { val bookmarks = bookmarkService.list( - BookmarkListParams.builder().cursor("cursor").folderId("folderId").build() + BookmarkListParams.builder().cursor("folders_value").folderId("folderId").build() ) bookmarks.validate() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceTest.kt index b1f4fe9..6b67085 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/CommunityServiceTest.kt @@ -26,9 +26,9 @@ internal class CommunityServiceTest { val community = communityService.create( CommunityCreateParams.builder() - .account("account") - .name("name") - .description("description") + .account("@elonmusk") + .name("Example Name") + .description("A community for Tesla enthusiasts") .build() ) @@ -49,8 +49,8 @@ internal class CommunityServiceTest { communityService.delete( CommunityDeleteParams.builder() .id("id") - .account("account") - .communityName("community_name") + .account("@elonmusk") + .communityName("Tesla Fans") .build() ) @@ -82,9 +82,12 @@ internal class CommunityServiceTest { .build() val communityService = client.x().communities() - communityService.retrieveMembers( - CommunityRetrieveMembersParams.builder().id("id").cursor("cursor").build() - ) + val response = + communityService.retrieveMembers( + CommunityRetrieveMembersParams.builder().id("id").cursor("cursor").build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -97,9 +100,12 @@ internal class CommunityServiceTest { .build() val communityService = client.x().communities() - communityService.retrieveModerators( - CommunityRetrieveModeratorsParams.builder().id("id").cursor("cursor").build() - ) + val response = + communityService.retrieveModerators( + CommunityRetrieveModeratorsParams.builder().id("id").cursor("cursor").build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -112,12 +118,15 @@ internal class CommunityServiceTest { .build() val communityService = client.x().communities() - communityService.retrieveSearch( - CommunityRetrieveSearchParams.builder() - .q("q") - .cursor("cursor") - .queryType("queryType") - .build() - ) + val response = + communityService.retrieveSearch( + CommunityRetrieveSearchParams.builder() + .q("q") + .cursor("cursor") + .queryType("queryType") + .build() + ) + + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/DmServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/DmServiceTest.kt index 17f6111..6082cf4 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/DmServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/DmServiceTest.kt @@ -46,10 +46,10 @@ internal class DmServiceTest { dmService.send( DmSendParams.builder() .userId("userId") - .account("account") - .text("text") - .addMediaId("string") - .replyToMessageId("reply_to_message_id") + .account("@elonmusk") + .text("Example text content") + .addMediaId("1234567890123456789") + .replyToMessageId("1234567890123456789") .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceTest.kt index ae1a90c..cf25344 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ListServiceTest.kt @@ -21,9 +21,12 @@ internal class ListServiceTest { .build() val listService = client.x().lists() - listService.retrieveFollowers( - ListRetrieveFollowersParams.builder().id("id").cursor("cursor").build() - ) + val response = + listService.retrieveFollowers( + ListRetrieveFollowersParams.builder().id("id").cursor("cursor").build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -36,9 +39,12 @@ internal class ListServiceTest { .build() val listService = client.x().lists() - listService.retrieveMembers( - ListRetrieveMembersParams.builder().id("id").cursor("cursor").build() - ) + val response = + listService.retrieveMembers( + ListRetrieveMembersParams.builder().id("id").cursor("cursor").build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -51,14 +57,17 @@ internal class ListServiceTest { .build() val listService = client.x().lists() - listService.retrieveTweets( - ListRetrieveTweetsParams.builder() - .id("id") - .cursor("cursor") - .includeReplies(true) - .sinceTime("sinceTime") - .untilTime("untilTime") - .build() - ) + val response = + listService.retrieveTweets( + ListRetrieveTweetsParams.builder() + .id("id") + .cursor("cursor") + .includeReplies(true) + .sinceTime("sinceTime") + .untilTime("untilTime") + .build() + ) + + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/MediaServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/MediaServiceTest.kt index b776fe3..bfc87cf 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/MediaServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/MediaServiceTest.kt @@ -22,7 +22,11 @@ internal class MediaServiceTest { val response = mediaService.download( - MediaDownloadParams.builder().addTweetId("string").tweetInput("tweetInput").build() + MediaDownloadParams.builder() + .addTweetId("1234567890") + .addTweetId("1234567891") + .tweetInput("https://x.com/elonmusk/status/1234567890") + .build() ) response.validate() @@ -41,7 +45,7 @@ internal class MediaServiceTest { val response = mediaService.upload( MediaUploadParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .isLongVideo(true) .build() diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ProfileServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ProfileServiceTest.kt index 84ab4e2..5eaf84f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ProfileServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/ProfileServiceTest.kt @@ -24,11 +24,11 @@ internal class ProfileServiceTest { val profile = profileService.update( ProfileUpdateParams.builder() - .account("account") - .description("description") - .location("location") - .name("name") - .url("url") + .account("@elonmusk") + .description("description_value") + .location("location_value") + .name("Example Name") + .url("https://xquik.com/example") .build() ) @@ -48,7 +48,7 @@ internal class ProfileServiceTest { val response = profileService.updateAvatar( ProfileUpdateAvatarParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() ) @@ -69,7 +69,7 @@ internal class ProfileServiceTest { val response = profileService.updateBanner( ProfileUpdateBannerParams.builder() - .account("account") + .account("@elonmusk") .file("Example data".byteInputStream()) .build() ) diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceTest.kt index d24d259..672946f 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceTest.kt @@ -4,7 +4,6 @@ package com.x_twitter_scraper.api.services.blocking.x import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient import com.x_twitter_scraper.api.models.x.tweets.TweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.TweetDeleteParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetFavoritersParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetQuotesParams import com.x_twitter_scraper.api.models.x.tweets.TweetGetRepliesParams @@ -30,34 +29,19 @@ internal class TweetServiceTest { val tweet = tweetService.create( TweetCreateParams.builder() - .account("account") - .text("text") - .attachmentUrl("attachment_url") - .communityId("community_id") - .isNoteTweet(true) - .addMediaId("string") - .replyToTweetId("reply_to_tweet_id") + .account("@elonmusk") + .text("Just launched our new feature!") + .attachmentUrl("https://x.com/elonmusk/status/1234567890") + .communityId("1500000000000000000") + .isNoteTweet(false) + .addMediaId("1234567890123456789") + .replyToTweetId("1234567890") .build() ) tweet.validate() } - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val tweetService = client.x().tweets() - - val tweet = tweetService.retrieve("tweetId") - - tweet.validate() - } - @Disabled("Mock server tests are disabled") @Test fun list() { @@ -68,25 +52,9 @@ internal class TweetServiceTest { .build() val tweetService = client.x().tweets() - tweetService.list(TweetListParams.builder().ids("ids").build()) - } + val tweets = tweetService.list(TweetListParams.builder().ids("ids").build()) - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val tweetService = client.x().tweets() - - val tweet = - tweetService.delete( - TweetDeleteParams.builder().tweetId("tweetId").account("account").build() - ) - - tweet.validate() + tweets.validate() } @Disabled("Mock server tests are disabled") diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceTest.kt index aeb59f4..52dc4f4 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserServiceTest.kt @@ -18,21 +18,6 @@ import org.junit.jupiter.api.Test internal class UserServiceTest { - @Disabled("Mock server tests are disabled") - @Test - fun retrieve() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val userService = client.x().users() - - val user = userService.retrieve("username") - - user.validate() - } - @Disabled("Mock server tests are disabled") @Test fun retrieveBatch() { @@ -43,7 +28,10 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveBatch(UserRetrieveBatchParams.builder().ids("ids").build()) + val response = + userService.retrieveBatch(UserRetrieveBatchParams.builder().ids("ids").build()) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -56,9 +44,12 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveFollowers( - UserRetrieveFollowersParams.builder().id("id").cursor("cursor").pageSize(0L).build() - ) + val response = + userService.retrieveFollowers( + UserRetrieveFollowersParams.builder().id("id").cursor("cursor").pageSize(0L).build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -89,9 +80,12 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveFollowing( - UserRetrieveFollowingParams.builder().id("id").cursor("cursor").pageSize(0L).build() - ) + val response = + userService.retrieveFollowing( + UserRetrieveFollowingParams.builder().id("id").cursor("cursor").pageSize(0L).build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -140,14 +134,17 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveMentions( - UserRetrieveMentionsParams.builder() - .id("id") - .cursor("cursor") - .sinceTime("sinceTime") - .untilTime("untilTime") - .build() - ) + val response = + userService.retrieveMentions( + UserRetrieveMentionsParams.builder() + .id("id") + .cursor("cursor") + .sinceTime("sinceTime") + .untilTime("untilTime") + .build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -160,9 +157,12 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveSearch( - UserRetrieveSearchParams.builder().q("q").cursor("cursor").build() - ) + val response = + userService.retrieveSearch( + UserRetrieveSearchParams.builder().q("q").cursor("cursor").build() + ) + + response.validate() } @Disabled("Mock server tests are disabled") @@ -198,8 +198,11 @@ internal class UserServiceTest { .build() val userService = client.x().users() - userService.retrieveVerifiedFollowers( - UserRetrieveVerifiedFollowersParams.builder().id("id").cursor("cursor").build() - ) + val response = + userService.retrieveVerifiedFollowers( + UserRetrieveVerifiedFollowersParams.builder().id("id").cursor("cursor").build() + ) + + response.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/JoinServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/JoinServiceTest.kt index 7064a29..8b649e1 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/JoinServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/JoinServiceTest.kt @@ -21,7 +21,7 @@ internal class JoinServiceTest { val joinService = client.x().communities().join() val join = - joinService.create(JoinCreateParams.builder().id("id").account("account").build()) + joinService.create(JoinCreateParams.builder().id("id").account("@elonmusk").build()) join.validate() } @@ -37,7 +37,9 @@ internal class JoinServiceTest { val joinService = client.x().communities().join() val response = - joinService.deleteAll(JoinDeleteAllParams.builder().id("id").account("account").build()) + joinService.deleteAll( + JoinDeleteAllParams.builder().id("id").account("@elonmusk").build() + ) response.validate() } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceTest.kt index b5459f1..2acb50b 100644 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceTest.kt +++ b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/communities/TweetServiceTest.kt @@ -19,8 +19,11 @@ internal class TweetServiceTest { .build() val tweetService = client.x().communities().tweets() - tweetService.list( - TweetListParams.builder().q("q").cursor("cursor").queryType("queryType").build() - ) + val tweets = + tweetService.list( + TweetListParams.builder().q("q").cursor("cursor").queryType("queryType").build() + ) + + tweets.validate() } } diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceTest.kt deleted file mode 100644 index 82858aa..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.blocking.x.tweets - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient -import com.x_twitter_scraper.api.models.x.tweets.like.LikeCreateParams -import com.x_twitter_scraper.api.models.x.tweets.like.LikeDeleteParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class LikeServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val likeService = client.x().tweets().like() - - val like = - likeService.create( - LikeCreateParams.builder().tweetId("tweetId").account("account").build() - ) - - like.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val likeService = client.x().tweets().like() - - val like = - likeService.delete( - LikeDeleteParams.builder().tweetId("tweetId").account("account").build() - ) - - like.validate() - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceTest.kt deleted file mode 100644 index 60e61a9..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.blocking.x.tweets - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetCreateParams -import com.x_twitter_scraper.api.models.x.tweets.retweet.RetweetDeleteParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class RetweetServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val retweetService = client.x().tweets().retweet() - - val retweet = - retweetService.create( - RetweetCreateParams.builder().tweetId("tweetId").account("account").build() - ) - - retweet.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun delete() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val retweetService = client.x().tweets().retweet() - - val retweet = - retweetService.delete( - RetweetDeleteParams.builder().tweetId("tweetId").account("account").build() - ) - - retweet.validate() - } -} diff --git a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceTest.kt deleted file mode 100644 index 2e955cf..0000000 --- a/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.services.blocking.x.users - -import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient -import com.x_twitter_scraper.api.models.x.users.follow.FollowCreateParams -import com.x_twitter_scraper.api.models.x.users.follow.FollowDeleteAllParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class FollowServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val followService = client.x().users().follow() - - val follow = - followService.create( - FollowCreateParams.builder().userId("userId").account("account").build() - ) - - follow.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun deleteAll() { - val client = - XTwitterScraperOkHttpClient.builder() - .apiKey("My API Key") - .bearerToken("My Bearer Token") - .build() - val followService = client.x().users().follow() - - val response = - followService.deleteAll( - FollowDeleteAllParams.builder().userId("userId").account("account").build() - ) - - response.validate() - } -} diff --git a/x-twitter-scraper-java-proguard-test/src/test/kotlin/com/x_twitter_scraper/api/proguard/ProGuardCompatibilityTest.kt b/x-twitter-scraper-java-proguard-test/src/test/kotlin/com/x_twitter_scraper/api/proguard/ProGuardCompatibilityTest.kt index 90b3003..48be3db 100644 --- a/x-twitter-scraper-java-proguard-test/src/test/kotlin/com/x_twitter_scraper/api/proguard/ProGuardCompatibilityTest.kt +++ b/x-twitter-scraper-java-proguard-test/src/test/kotlin/com/x_twitter_scraper/api/proguard/ProGuardCompatibilityTest.kt @@ -79,23 +79,24 @@ internal class ProGuardCompatibilityTest { val jsonMapper = jsonMapper() val searchTweet = SearchTweet.builder() - .id("id") - .text("text") + .id("1234567890") + .text("Just launched our new feature!") .author( SearchTweet.Author.builder() - .id("id") - .name("name") - .username("username") + .id("9876543210") + .name("Elon Musk") + .username("elonmusk") .verified(true) .build() ) - .bookmarkCount(0L) - .createdAt("createdAt") - .likeCount(0L) - .quoteCount(0L) - .replyCount(0L) - .retweetCount(0L) - .viewCount(0L) + .bookmarkCount(2L) + .createdAt("2025-01-15T12:00:00Z") + .isNoteTweet(false) + .likeCount(42L) + .quoteCount(1L) + .replyCount(3L) + .retweetCount(5L) + .viewCount(1500L) .build() val roundtrippedSearchTweet =