From a4e0acdd9e95507a2d69d05b50c5b8c114c7cd0b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 07:49:48 +0000 Subject: [PATCH 01/23] feat(api): api update --- .stats.yml | 4 +- .../models/compose/ComposeCreateResponse.kt | 195 +++- .../api/models/events/EventDetail.kt | 4 + .../models/events/EventRetrieveResponse.kt | 4 + .../extractions/ExtractionRetrieveResponse.kt | 4 + .../api/models/integrations/Integration.kt | 8 + .../integrations/IntegrationCreateResponse.kt | 8 + .../integrations/IntegrationListResponse.kt | 8 + .../IntegrationRetrieveResponse.kt | 8 + .../integrations/IntegrationUpdateParams.kt | 14 + .../integrations/IntegrationUpdateResponse.kt | 8 + .../CommunityRetrieveInfoResponse.kt | 981 +++++++++++++++++- .../services/async/AccountServiceAsyncImpl.kt | 6 +- .../services/async/ApiKeyServiceAsyncImpl.kt | 18 +- .../async/x/AccountServiceAsyncImpl.kt | 30 +- .../services/blocking/AccountServiceImpl.kt | 2 +- .../services/blocking/ApiKeyServiceImpl.kt | 6 +- .../services/blocking/x/AccountServiceImpl.kt | 10 +- .../compose/ComposeCreateResponseTest.kt | 17 +- .../CommunityRetrieveInfoResponseTest.kt | 81 +- 20 files changed, 1369 insertions(+), 47 deletions(-) diff --git a/.stats.yml b/.stats.yml index 58aca93..68ba24f 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 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-93bb7d4f1475c8043af464ec88244a034456c549136c8477f284f0a33192e1c9.yml +openapi_spec_hash: 74dca63c872249274ad99b111dea0833 config_hash: 8894c96caeb6df84c9394518810221bd 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/events/EventDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventDetail.kt index c6b2f6b..90158a7 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 @@ -53,6 +53,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). */ @@ -203,6 +205,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)) /** @@ -356,6 +359,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( 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..8316411 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 @@ -53,6 +53,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). */ @@ -203,6 +205,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)) /** @@ -356,6 +359,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( 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/integrations/Integration.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt index d5e93ca..1519889 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 @@ -83,6 +83,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). */ @@ -119,6 +121,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 +305,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)) /** @@ -378,6 +383,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 +535,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( @@ -902,6 +909,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/IntegrationCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt index ce362aa..b1a8b89 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 @@ -83,6 +83,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). */ @@ -119,6 +121,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 +305,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)) /** @@ -378,6 +383,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 +535,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( @@ -902,6 +909,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/IntegrationListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt index c75b31a..0bb4b6b 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 @@ -243,6 +243,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). @@ -285,6 +287,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 +475,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)) /** @@ -553,6 +558,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 +712,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( @@ -1084,6 +1091,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..adfadfa 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 @@ -83,6 +83,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). */ @@ -119,6 +121,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 +305,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)) /** @@ -378,6 +383,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 +535,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( @@ -902,6 +909,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..187cd1e 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 @@ -40,6 +40,8 @@ private constructor( 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 +54,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). */ @@ -198,6 +202,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 +224,7 @@ private constructor( */ fun isActive(isActive: JsonField) = apply { body.isActive(isActive) } + /** Custom message template (JSON) */ fun messageTemplate(messageTemplate: MessageTemplate) = apply { body.messageTemplate(messageTemplate) } @@ -463,6 +469,8 @@ private constructor( 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 +483,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). */ @@ -625,6 +635,7 @@ private constructor( } } + /** Event filter rules (JSON) */ fun filters(filters: Filters) = filters(JsonField.of(filters)) /** @@ -647,6 +658,7 @@ private constructor( */ fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + /** Custom message template (JSON) */ fun messageTemplate(messageTemplate: MessageTemplate) = messageTemplate(JsonField.of(messageTemplate)) @@ -963,6 +975,7 @@ private constructor( override fun toString() = value.toString() } + /** Event filter rules (JSON) */ class Filters @JsonCreator private constructor( @@ -1062,6 +1075,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..22121e8 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 @@ -83,6 +83,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). */ @@ -119,6 +121,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 +305,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)) /** @@ -378,6 +383,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 +535,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( @@ -902,6 +909,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/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..3caed40 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(), + ) + + /** + * Community 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 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") + + /** + * Community description + * + * @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") + + /** + * Community name + * + * @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() + } + + /** Community ID */ + 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 } + + /** Community description */ + 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 + } + + /** Community name */ + 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/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/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/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/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/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..8393d71 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,16 @@ internal class ComposeCreateResponseTest { fun create() { val composeCreateResponse = ComposeCreateResponse.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .feedback("feedback") + .score(0.0) + .addSuggestion("string") + .text("text") .build() + + assertThat(composeCreateResponse.feedback()).contains("feedback") + assertThat(composeCreateResponse.score()).contains(0.0) + assertThat(composeCreateResponse.suggestions().getOrNull()).containsExactly("string") + assertThat(composeCreateResponse.text()).contains("text") } @Test @@ -23,7 +31,10 @@ internal class ComposeCreateResponseTest { val jsonMapper = jsonMapper() val composeCreateResponse = ComposeCreateResponse.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .feedback("feedback") + .score(0.0) + .addSuggestion("string") + .text("text") .build() val roundtrippedComposeCreateResponse = 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..35e2c16 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("id") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("name") + .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("id") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("name") + .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("id") + .bannerUrl("banner_url") + .createdAt("created_at") + .description("description") + .joinPolicy("join_policy") + .memberCount(0L) + .moderatorCount(0L) + .name("name") + .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 = From be5b4f9f89ea2e7606d57cb7f0ea809c17c4096f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 16:15:19 +0000 Subject: [PATCH 02/23] feat(api): api update --- .stats.yml | 6 +- .../RadarRetrieveTrendingTopicsParams.kt | 177 ++- .../api/models/styles/StyleDeleteParams.kt | 229 ---- .../styles/StyleGetPerformanceParams.kt | 195 ---- .../styles/StyleGetPerformanceResponse.kt | 647 ----------- .../api/models/styles/StyleRetrieveParams.kt | 189 ---- .../models/styles/StyleRetrieveResponse.kt | 609 ---------- .../api/models/styles/StyleUpdateParams.kt | 688 ----------- .../api/models/styles/StyleUpdateResponse.kt | 609 ---------- .../api/models/x/tweets/TweetDeleteParams.kt | 437 ------- .../models/x/tweets/TweetDeleteResponse.kt | 158 --- .../models/x/tweets/TweetRetrieveParams.kt | 189 ---- .../models/x/tweets/TweetRetrieveResponse.kt | 1001 ----------------- .../models/x/tweets/like/LikeCreateParams.kt | 437 ------- .../x/tweets/like/LikeCreateResponse.kt | 158 --- .../models/x/tweets/like/LikeDeleteParams.kt | 437 ------- .../x/tweets/like/LikeDeleteResponse.kt | 158 --- .../x/tweets/retweet/RetweetCreateParams.kt | 437 ------- .../x/tweets/retweet/RetweetCreateResponse.kt | 158 --- .../x/tweets/retweet/RetweetDeleteParams.kt | 437 ------- .../x/tweets/retweet/RetweetDeleteResponse.kt | 158 --- .../api/models/x/users/UserRetrieveParams.kt | 189 ---- .../models/x/users/UserRetrieveResponse.kt | 534 --------- .../x/users/follow/FollowCreateParams.kt | 437 ------- .../x/users/follow/FollowCreateResponse.kt | 158 --- .../x/users/follow/FollowDeleteAllParams.kt | 437 ------- .../x/users/follow/FollowDeleteAllResponse.kt | 158 --- .../api/services/async/StyleServiceAsync.kt | 289 ----- .../services/async/StyleServiceAsyncImpl.kt | 165 --- .../api/services/async/x/TweetServiceAsync.kt | 136 --- .../services/async/x/TweetServiceAsyncImpl.kt | 89 -- .../api/services/async/x/UserServiceAsync.kt | 80 -- .../services/async/x/UserServiceAsyncImpl.kt | 44 - .../async/x/tweets/LikeServiceAsync.kt | 112 -- .../async/x/tweets/LikeServiceAsyncImpl.kt | 105 -- .../async/x/tweets/RetweetServiceAsync.kt | 116 -- .../async/x/tweets/RetweetServiceAsyncImpl.kt | 105 -- .../async/x/users/FollowServiceAsync.kt | 116 -- .../async/x/users/FollowServiceAsyncImpl.kt | 105 -- .../api/services/blocking/StyleService.kt | 281 ----- .../api/services/blocking/StyleServiceImpl.kt | 151 --- .../api/services/blocking/x/TweetService.kt | 135 --- .../services/blocking/x/TweetServiceImpl.kt | 83 -- .../api/services/blocking/x/UserService.kt | 80 -- .../services/blocking/x/UserServiceImpl.kt | 41 - .../services/blocking/x/tweets/LikeService.kt | 106 -- .../blocking/x/tweets/LikeServiceImpl.kt | 98 -- .../blocking/x/tweets/RetweetService.kt | 112 -- .../blocking/x/tweets/RetweetServiceImpl.kt | 98 -- .../blocking/x/users/FollowService.kt | 114 -- .../blocking/x/users/FollowServiceImpl.kt | 98 -- .../RadarRetrieveTrendingTopicsParamsTest.kt | 6 +- .../models/styles/StyleDeleteParamsTest.kt | 23 - .../styles/StyleGetPerformanceParamsTest.kt | 23 - .../styles/StyleGetPerformanceResponseTest.kt | 75 -- .../models/styles/StyleRetrieveParamsTest.kt | 23 - .../styles/StyleRetrieveResponseTest.kt | 74 -- .../models/styles/StyleUpdateParamsTest.kt | 48 - .../models/styles/StyleUpdateResponseTest.kt | 74 -- .../models/x/tweets/TweetDeleteParamsTest.kt | 32 - .../x/tweets/TweetDeleteResponseTest.kt | 30 - .../x/tweets/TweetRetrieveParamsTest.kt | 23 - .../x/tweets/TweetRetrieveResponseTest.kt | 103 -- .../x/tweets/like/LikeCreateParamsTest.kt | 32 - .../x/tweets/like/LikeCreateResponseTest.kt | 30 - .../x/tweets/like/LikeDeleteParamsTest.kt | 32 - .../x/tweets/like/LikeDeleteResponseTest.kt | 30 - .../tweets/retweet/RetweetCreateParamsTest.kt | 32 - .../retweet/RetweetCreateResponseTest.kt | 30 - .../tweets/retweet/RetweetDeleteParamsTest.kt | 32 - .../retweet/RetweetDeleteResponseTest.kt | 30 - .../models/x/users/UserRetrieveParamsTest.kt | 23 - .../x/users/UserRetrieveResponseTest.kt | 68 -- .../x/users/follow/FollowCreateParamsTest.kt | 32 - .../users/follow/FollowCreateResponseTest.kt | 30 - .../users/follow/FollowDeleteAllParamsTest.kt | 32 - .../follow/FollowDeleteAllResponseTest.kt | 30 - .../services/async/RadarServiceAsyncTest.kt | 2 +- .../services/async/StyleServiceAsyncTest.kt | 71 -- .../services/async/x/TweetServiceAsyncTest.kt | 36 - .../services/async/x/UserServiceAsyncTest.kt | 16 - .../async/x/tweets/LikeServiceAsyncTest.kt | 50 - .../async/x/tweets/RetweetServiceAsyncTest.kt | 50 - .../async/x/users/FollowServiceAsyncTest.kt | 50 - .../api/services/blocking/RadarServiceTest.kt | 2 +- .../api/services/blocking/StyleServiceTest.kt | 66 -- .../services/blocking/x/TweetServiceTest.kt | 34 - .../services/blocking/x/UserServiceTest.kt | 15 - .../blocking/x/tweets/LikeServiceTest.kt | 48 - .../blocking/x/tweets/RetweetServiceTest.kt | 48 - .../blocking/x/users/FollowServiceTest.kt | 48 - 91 files changed, 179 insertions(+), 13640 deletions(-) delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 68ba24f..5fb34d8 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-93bb7d4f1475c8043af464ec88244a034456c549136c8477f284f0a33192e1c9.yml -openapi_spec_hash: 74dca63c872249274ad99b111dea0833 +configured_endpoints: 102 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-f4a2baf44e99ee3fa87e08d50099bc70680c9ef2e612290ab1f749396266455d.yml +openapi_spec_hash: 1b7655f5b5cc5ffb69e41461cd4d9158 config_hash: 8894c96caeb6df84c9394518810221bd 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/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/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/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/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/TweetRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt deleted file mode 100644 index 08d6b1a..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt +++ /dev/null @@ -1,1001 +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.checkRequired -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 -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val tweet: JsonField, - private val author: 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()) - - /** - * @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") - - /** - * @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") - - /** - * Returns the raw JSON value of [tweet]. - * - * Unlike [tweet], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweet") @ExcludeMissing fun _tweet(): JsonField = tweet - - /** - * 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 - - @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 [TweetRetrieveResponse]. - * - * The following fields are required: - * ```java - * .tweet() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TweetRetrieveResponse]. */ - class Builder internal constructor() { - - private var tweet: JsonField? = null - private var author: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweetRetrieveResponse: TweetRetrieveResponse) = apply { - tweet = tweetRetrieveResponse.tweet - author = tweetRetrieveResponse.author - additionalProperties = tweetRetrieveResponse.additionalProperties.toMutableMap() - } - - fun tweet(tweet: Tweet) = tweet(JsonField.of(tweet)) - - /** - * Sets [Builder.tweet] 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. - */ - fun tweet(tweet: JsonField) = apply { this.tweet = tweet } - - 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 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 [TweetRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tweet() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TweetRetrieveResponse = - TweetRetrieveResponse( - checkRequired("tweet", tweet), - author, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TweetRetrieveResponse = apply { - if (validated) { - return@apply - } - - tweet().validate() - author().ifPresent { 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 = - (tweet.asKnown().getOrNull()?.validity() ?: 0) + - (author.asKnown().getOrNull()?.validity() ?: 0) - - class Tweet - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val bookmarkCount: 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("bookmarkCount") - @ExcludeMissing - bookmarkCount: 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("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("viewCount") - @ExcludeMissing - viewCount: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - ) : this( - id, - bookmarkCount, - likeCount, - quoteCount, - replyCount, - retweetCount, - text, - viewCount, - 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 bookmarkCount(): Long = bookmarkCount.getRequired("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). - */ - fun likeCount(): Long = likeCount.getRequired("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). - */ - fun quoteCount(): Long = quoteCount.getRequired("quoteCount") - - /** - * @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 replyCount(): Long = replyCount.getRequired("replyCount") - - /** - * @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 retweetCount(): Long = retweetCount.getRequired("retweetCount") - - /** - * @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 or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun viewCount(): Long = viewCount.getRequired("viewCount") - - /** - * @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 [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 [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 [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]. - * - * Unlike [viewCount], this method doesn't throw if the JSON field has an unexpected type. - */ - @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) - } - - @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() - * .bookmarkCount() - * .likeCount() - * .quoteCount() - * .replyCount() - * .retweetCount() - * .text() - * .viewCount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tweet]. */ - 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 createdAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tweet: Tweet) = apply { - id = tweet.id - bookmarkCount = tweet.bookmarkCount - 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() - } - - 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 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 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 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)) - - /** - * 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 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() - * .bookmarkCount() - * .likeCount() - * .quoteCount() - * .replyCount() - * .retweetCount() - * .text() - * .viewCount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - 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), - createdAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tweet = apply { - if (validated) { - return@apply - } - - id() - bookmarkCount() - likeCount() - quoteCount() - replyCount() - retweetCount() - text() - viewCount() - 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 (bookmarkCount.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, - ) - } - - 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 - 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 { - - /** - * Returns a mutable builder for constructing an instance of [Author]. - * - * The following fields are required: - * ```java - * .id() - * .followers() - * .username() - * .verified() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** 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)) - - /** - * 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 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 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 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 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() - * .followers() - * .username() - * .verified() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - 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 - } - - id() - followers() - username() - verified() - profilePicture() - 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 (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 equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Author && - id == other.id && - followers == other.followers && - username == other.username && - verified == other.verified && - profilePicture == other.profilePicture && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, followers, username, verified, profilePicture, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Author{id=$id, followers=$followers, username=$username, verified=$verified, profilePicture=$profilePicture, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TweetRetrieveResponse && - tweet == other.tweet && - author == other.author && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(tweet, author, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TweetRetrieveResponse{tweet=$tweet, author=$author, additionalProperties=$additionalProperties}" -} 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/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/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/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/x/TweetServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsync.kt index ef4a35a..d070b7b 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 @@ -8,8 +8,6 @@ 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 +19,6 @@ 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.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,41 +54,6 @@ 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 = list(params, RequestOptions.none()) @@ -105,28 +64,6 @@ interface TweetServiceAsync { 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 - /** Get users who liked a tweet */ fun getFavoriters(id: String): CompletableFuture = getFavoriters(id, TweetGetFavoritersParams.none()) @@ -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,47 +284,6 @@ 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]. @@ -403,36 +297,6 @@ interface TweetServiceAsync { 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> - /** * Returns a raw HTTP response for `get /x/tweets/{id}/favoriters`, but is otherwise the * same as [TweetServiceAsync.getFavoriters]. 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..478d49f 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 @@ -19,8 +19,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 +30,6 @@ 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.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,13 +67,6 @@ 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, @@ -87,13 +74,6 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie // 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() } - override fun getFavoriters( params: TweetGetFavoritersParams, requestOptions: RequestOptions, @@ -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,39 +172,6 @@ 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() override fun list( @@ -250,40 +195,6 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - 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) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val getFavoritersHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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..068ee12 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 @@ -16,8 +16,6 @@ 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.UserRetrieveSearchParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse @@ -41,44 +39,8 @@ 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()) @@ -392,50 +354,8 @@ 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]. 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..4f78238 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 @@ -26,8 +26,6 @@ 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.UserRetrieveSearchParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse @@ -53,16 +51,8 @@ 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, @@ -150,42 +140,8 @@ 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) - - override fun retrieve( - params: UserRetrieveParams, - 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("x", "users", 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 retrieveBatchHandler: Handler = emptyHandler() override fun retrieveBatch( 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/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/x/TweetService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetService.kt index 6ef7d9f..5435a04 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 @@ -9,8 +9,6 @@ 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 +20,6 @@ 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.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,64 +54,12 @@ 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()) /** @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, - 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 - /** Get users who liked a tweet */ fun getFavoriters(id: String): TweetGetFavoritersResponse = getFavoriters(id, TweetGetFavoritersParams.none()) @@ -291,10 +233,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,50 +252,6 @@ 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]. @@ -370,37 +266,6 @@ interface TweetService { 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 - /** * Returns a raw HTTP response for `get /x/tweets/{id}/favoriters`, but is otherwise the * same as [TweetService.getFavoriters]. 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..52a31e2 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 @@ -19,8 +19,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 +30,6 @@ 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.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,25 +66,11 @@ 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) { // get /x/tweets withRawResponse().list(params, requestOptions) } - override fun delete( - params: TweetDeleteParams, - requestOptions: RequestOptions, - ): TweetDeleteResponse = - // delete /x/tweets/{tweetId} - withRawResponse().delete(params, requestOptions).parse() - override fun getFavoriters( params: TweetGetFavoritersParams, requestOptions: RequestOptions, @@ -154,10 +134,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,36 +166,6 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TweetRetrieveParams, - 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 { @@ -235,37 +183,6 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt } } - 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) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val getFavoritersHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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..4014e76 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 @@ -17,8 +17,6 @@ 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.UserRetrieveSearchParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse @@ -41,41 +39,8 @@ 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) = retrieveBatch(params, RequestOptions.none()) @@ -359,53 +324,8 @@ 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]. 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..9090449 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 @@ -26,8 +26,6 @@ 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.UserRetrieveSearchParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsParams import com.x_twitter_scraper.api.models.x.users.UserRetrieveTweetsResponse @@ -51,16 +49,8 @@ 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, - requestOptions: RequestOptions, - ): UserRetrieveResponse = - // get /x/users/{username} - withRawResponse().retrieve(params, requestOptions).parse() - override fun retrieveBatch(params: UserRetrieveBatchParams, requestOptions: RequestOptions) { // get /x/users/batch withRawResponse().retrieveBatch(params, requestOptions) @@ -148,39 +138,8 @@ 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) - - override fun retrieve( - params: UserRetrieveParams, - 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("x", "users", 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 retrieveBatchHandler: Handler = emptyHandler() override fun retrieveBatch( 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/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/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/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/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/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/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/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/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/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..33f85fa 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() { @@ -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/x/TweetServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/TweetServiceAsyncTest.kt index 6cfc93f..ad27bfe 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 @@ -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() { @@ -75,25 +58,6 @@ internal class TweetServiceAsyncTest { 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 tweet = tweetFuture.get() - tweet.validate() - } - @Disabled("Mock server tests are disabled") @Test fun getFavoriters() { 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..c3c0bff 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() { 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/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..7960a05 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() { @@ -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/x/TweetServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/TweetServiceTest.kt index d24d259..50dee08 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 @@ -43,21 +42,6 @@ internal class TweetServiceTest { 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() { @@ -71,24 +55,6 @@ internal class TweetServiceTest { 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() - } - @Disabled("Mock server tests are disabled") @Test fun getFavoriters() { 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..9769cce 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() { 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() - } -} From 48624d395d356803ad94140b16fa38f899003ca8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 18:15:22 +0000 Subject: [PATCH 03/23] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5fb34d8..6527155 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 102 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-f4a2baf44e99ee3fa87e08d50099bc70680c9ef2e612290ab1f749396266455d.yml -openapi_spec_hash: 1b7655f5b5cc5ffb69e41461cd4d9158 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-46a9af86900d469595bc007c73410022306d0863a896758d9c3c1250fbe937a3.yml +openapi_spec_hash: d858851b15eb367466f343da3cb2d556 config_hash: 8894c96caeb6df84c9394518810221bd From ca924a7fe2182a40687e9da03b761f72d4b95ff4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 4 Apr 2026 00:15:19 +0000 Subject: [PATCH 04/23] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6527155..6ecd182 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 102 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-46a9af86900d469595bc007c73410022306d0863a896758d9c3c1250fbe937a3.yml -openapi_spec_hash: d858851b15eb367466f343da3cb2d556 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-88d47b7e48bca9b85d068845f7d100d3e6fb5d488b848ce3c47448990afdb9f9.yml +openapi_spec_hash: 55e7bd0cceeebe8fd4a89fc918336531 config_hash: 8894c96caeb6df84c9394518810221bd From f8f51380d7cb3d07a0be410e69492edf9fba07cc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 4 Apr 2026 13:15:19 +0000 Subject: [PATCH 05/23] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/x/tweets/TweetSearchParams.kt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6ecd182..8500022 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 102 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-88d47b7e48bca9b85d068845f7d100d3e6fb5d488b848ce3c47448990afdb9f9.yml -openapi_spec_hash: 55e7bd0cceeebe8fd4a89fc918336531 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-cc76e6e9b7122fdacc45fbd7cf4603aaaca4906ae2de0984b51a5fc7cf8dadd6.yml +openapi_spec_hash: 0b1bc061a669d7c77e5bf1476d083a2d config_hash: 8894c96caeb6df84c9394518810221bd 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 } /** From d4be9ff16190320b7cdaffae495057ee2ceda50c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 7 Apr 2026 14:15:20 +0000 Subject: [PATCH 06/23] feat(api): api update --- .stats.yml | 4 +- .../api/models/PaginatedTweets.kt | 45 +- .../api/models/x/XGetHomeTimelineResponse.kt | 45 +- .../x/bookmarks/BookmarkListResponse.kt | 45 +- .../api/models/x/tweets/SearchTweet.kt | 43 +- .../api/models/x/tweets/TweetDetail.kt | 639 +++++++++++++++++- .../models/x/tweets/TweetGetQuotesResponse.kt | 45 +- .../x/tweets/TweetGetRepliesResponse.kt | 45 +- .../models/x/tweets/TweetGetThreadResponse.kt | 45 +- .../models/x/tweets/TweetSearchResponse.kt | 45 +- .../x/users/UserRetrieveLikesResponse.kt | 45 +- .../x/users/UserRetrieveMediaResponse.kt | 45 +- .../x/users/UserRetrieveTweetsResponse.kt | 45 +- .../api/models/PaginatedTweetsTest.kt | 3 + .../models/x/XGetHomeTimelineResponseTest.kt | 3 + .../x/bookmarks/BookmarkListResponseTest.kt | 3 + .../api/models/x/tweets/SearchTweetTest.kt | 3 + .../api/models/x/tweets/TweetDetailTest.kt | 45 ++ .../x/tweets/TweetGetQuotesResponseTest.kt | 3 + .../x/tweets/TweetGetRepliesResponseTest.kt | 3 + .../x/tweets/TweetGetThreadResponseTest.kt | 3 + .../x/tweets/TweetSearchResponseTest.kt | 3 + .../x/users/UserRetrieveLikesResponseTest.kt | 3 + .../x/users/UserRetrieveMediaResponseTest.kt | 3 + .../x/users/UserRetrieveTweetsResponseTest.kt | 3 + .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 26 files changed, 1200 insertions(+), 15 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8500022..193a413 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 102 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-cc76e6e9b7122fdacc45fbd7cf4603aaaca4906ae2de0984b51a5fc7cf8dadd6.yml -openapi_spec_hash: 0b1bc061a669d7c77e5bf1476d083a2d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-61e27e87d4182e5230beae1edaf864a00a5c5f9b96defcdb9a4503544463328f.yml +openapi_spec_hash: 782f8974cd27e51c8a7993f61b139f72 config_hash: 8894c96caeb6df84c9394518810221bd 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..6085676 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/XGetHomeTimelineResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt index 5947b26..2f4f80c 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/bookmarks/BookmarkListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt index d228cae..b3c0965 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/SearchTweet.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/SearchTweet.kt index c4f15ff..b58ef19 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 @@ -25,6 +25,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 +43,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 +59,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -93,6 +98,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -160,6 +173,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 +253,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 +268,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 +331,18 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -397,6 +433,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -418,6 +455,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -446,6 +484,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 +769,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 +785,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -757,5 +798,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/TweetDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt index e1c572b..fca2b33 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,15 +6,19 @@ 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 class TweetDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) @@ -27,7 +31,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: JsonValue, + private val isNoteTweet: JsonField, + private val isQuoteStatus: JsonField, + private val isReply: JsonField, + private val media: JsonField>, + private val quotedTweet: JsonValue, + private val source: JsonField, private val additionalProperties: MutableMap, ) { @@ -45,7 +57,21 @@ 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: JsonValue = 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: JsonValue = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), ) : this( id, bookmarkCount, @@ -55,7 +81,15 @@ private constructor( retweetCount, text, viewCount, + conversationId, createdAt, + entities, + isNoteTweet, + isQuoteStatus, + isReply, + media, + quotedTweet, + source, mutableMapOf(), ) @@ -107,12 +141,80 @@ 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) + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = tweetDetail.entities().convert(MyClass.class); + * ``` + */ + @JsonProperty("entities") @ExcludeMissing fun _entities(): JsonValue = 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 + * + * This arbitrary value can be deserialized into a custom type using the `convert` method: + * ```java + * MyClass myObject = tweetDetail.quotedTweet().convert(MyClass.class); + * ``` + */ + @JsonProperty("quoted_tweet") @ExcludeMissing fun _quotedTweet(): JsonValue = quotedTweet + + /** + * 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 +275,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 +291,45 @@ 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 [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 [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 +373,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: JsonValue = 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: JsonValue = JsonMissing.of() + private var source: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -236,7 +394,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 +490,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 +515,86 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** Parsed entities from the tweet text (URLs, mentions, hashtags, media) */ + fun entities(entities: JsonValue) = 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: JsonValue) = 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 +643,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 +671,13 @@ private constructor( retweetCount() text() viewCount() + conversationId() createdAt() + isNoteTweet() + isQuoteStatus() + isReply() + media().ifPresent { it.forEach { it.validate() } } + source() validated = true } @@ -430,7 +704,352 @@ 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) + + (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) + + (if (source.asKnown().isPresent) 1 else 0) + + 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}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -446,7 +1065,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 +1087,15 @@ private constructor( retweetCount, text, viewCount, + conversationId, createdAt, + entities, + isNoteTweet, + isQuoteStatus, + isReply, + media, + quotedTweet, + source, additionalProperties, ) } @@ -468,5 +1103,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/TweetGetQuotesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt index 193f45b..c3d319b 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/TweetGetRepliesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt index cfcb6ae..bfc3b2c 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/TweetGetThreadResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt index 13a5560..34cf1b2 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/TweetSearchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt index f40c2f2..d3c7b61 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/UserRetrieveLikesResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt index 77788f2..f27d179 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/UserRetrieveMediaResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt index 3444c0e..e0272e7 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/UserRetrieveTweetsResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt index 236d37f..6bcf2b4 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 @@ -252,6 +252,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 +272,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 +294,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -330,6 +335,14 @@ private constructor( */ fun createdAt(): Optional = createdAt.getOptional("createdAt") + /** + * 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") + /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -398,6 +411,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 +492,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 +507,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 +573,20 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** 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 + } + fun likeCount(likeCount: Long) = likeCount(JsonField.of(likeCount)) /** @@ -645,6 +683,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -666,6 +705,7 @@ private constructor( author().ifPresent { it.validate() } bookmarkCount() createdAt() + isNoteTweet() likeCount() quoteCount() replyCount() @@ -695,6 +735,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 +1025,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 +1041,7 @@ private constructor( author, bookmarkCount, createdAt, + isNoteTweet, likeCount, quoteCount, replyCount, @@ -1011,7 +1054,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/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..40d6a6b 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 @@ -29,6 +29,7 @@ internal class PaginatedTweetsTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class PaginatedTweetsTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class PaginatedTweetsTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..b197f5b 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 @@ -29,6 +29,7 @@ internal class XGetHomeTimelineResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class XGetHomeTimelineResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class XGetHomeTimelineResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..7a1c229 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 @@ -29,6 +29,7 @@ internal class BookmarkListResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class BookmarkListResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class BookmarkListResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..026bdd2 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 @@ -25,6 +25,7 @@ internal class SearchTweetTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -45,6 +46,7 @@ internal class SearchTweetTest { ) assertThat(searchTweet.bookmarkCount()).contains(0L) assertThat(searchTweet.createdAt()).contains("createdAt") + assertThat(searchTweet.isNoteTweet()).contains(true) assertThat(searchTweet.likeCount()).contains(0L) assertThat(searchTweet.quoteCount()).contains(0L) assertThat(searchTweet.replyCount()).contains(0L) @@ -69,6 +71,7 @@ internal class SearchTweetTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..563e758 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 @@ -21,7 +23,21 @@ internal class TweetDetailTest { .retweetCount(0L) .text("text") .viewCount(0L) + .conversationId("conversationId") .createdAt("createdAt") + .entities(JsonValue.from(mapOf())) + .isNoteTweet(true) + .isQuoteStatus(true) + .isReply(true) + .addMedia( + TweetDetail.Media.builder() + .mediaUrl("mediaUrl") + .type(TweetDetail.Media.Type.PHOTO) + .url("url") + .build() + ) + .quotedTweet(JsonValue.from(mapOf())) + .source("source") .build() assertThat(tweetDetail.id()).isEqualTo("id") @@ -32,7 +48,22 @@ internal class TweetDetailTest { assertThat(tweetDetail.retweetCount()).isEqualTo(0L) assertThat(tweetDetail.text()).isEqualTo("text") assertThat(tweetDetail.viewCount()).isEqualTo(0L) + assertThat(tweetDetail.conversationId()).contains("conversationId") assertThat(tweetDetail.createdAt()).contains("createdAt") + assertThat(tweetDetail._entities()).isEqualTo(JsonValue.from(mapOf())) + assertThat(tweetDetail.isNoteTweet()).contains(true) + assertThat(tweetDetail.isQuoteStatus()).contains(true) + assertThat(tweetDetail.isReply()).contains(true) + assertThat(tweetDetail.media().getOrNull()) + .containsExactly( + TweetDetail.Media.builder() + .mediaUrl("mediaUrl") + .type(TweetDetail.Media.Type.PHOTO) + .url("url") + .build() + ) + assertThat(tweetDetail._quotedTweet()).isEqualTo(JsonValue.from(mapOf())) + assertThat(tweetDetail.source()).contains("source") } @Test @@ -48,7 +79,21 @@ internal class TweetDetailTest { .retweetCount(0L) .text("text") .viewCount(0L) + .conversationId("conversationId") .createdAt("createdAt") + .entities(JsonValue.from(mapOf())) + .isNoteTweet(true) + .isQuoteStatus(true) + .isReply(true) + .addMedia( + TweetDetail.Media.builder() + .mediaUrl("mediaUrl") + .type(TweetDetail.Media.Type.PHOTO) + .url("url") + .build() + ) + .quotedTweet(JsonValue.from(mapOf())) + .source("source") .build() val roundtrippedTweetDetail = 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..f12a927 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 @@ -29,6 +29,7 @@ internal class TweetGetQuotesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class TweetGetQuotesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class TweetGetQuotesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..c165ee0 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 @@ -29,6 +29,7 @@ internal class TweetGetRepliesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class TweetGetRepliesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class TweetGetRepliesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..8aea35b 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 @@ -29,6 +29,7 @@ internal class TweetGetThreadResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class TweetGetThreadResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class TweetGetThreadResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..2a30ca3 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 @@ -29,6 +29,7 @@ internal class TweetSearchResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class TweetSearchResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class TweetSearchResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..5226432 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 @@ -29,6 +29,7 @@ internal class UserRetrieveLikesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class UserRetrieveLikesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class UserRetrieveLikesResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..7f84b63 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 @@ -29,6 +29,7 @@ internal class UserRetrieveMediaResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class UserRetrieveMediaResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class UserRetrieveMediaResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..eb9af84 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 @@ -29,6 +29,7 @@ internal class UserRetrieveTweetsResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -55,6 +56,7 @@ internal class UserRetrieveTweetsResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) @@ -85,6 +87,7 @@ internal class UserRetrieveTweetsResponseTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) 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..2e6c3f2 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 @@ -91,6 +91,7 @@ internal class ProGuardCompatibilityTest { ) .bookmarkCount(0L) .createdAt("createdAt") + .isNoteTweet(true) .likeCount(0L) .quoteCount(0L) .replyCount(0L) From 85f67881300bb5cdb912fe7c59edcd0af640a14f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 20:41:49 +0000 Subject: [PATCH 07/23] feat(api): api update --- .stats.yml | 4 +- README.md | 8 +- .../x-twitter-scraper.publish.gradle.kts | 2 +- .../com/x_twitter_scraper/api/models/Error.kt | 1 + .../x_twitter_scraper/api/models/EventType.kt | 1 + .../api/models/PaginatedTweets.kt | 6 +- .../api/models/PaginatedUsers.kt | 2 + .../api/models/apikeys/ApiKey.kt | 1 + .../api/models/apikeys/ApiKeyListResponse.kt | 1 + .../api/models/drafts/Draft.kt | 1 + .../api/models/drafts/DraftCreateResponse.kt | 1 + .../api/models/drafts/DraftDetail.kt | 1 + .../api/models/drafts/DraftListParams.kt | 2 + .../api/models/drafts/DraftListResponse.kt | 1 + .../models/drafts/DraftRetrieveResponse.kt | 1 + .../api/models/draws/DrawDetail.kt | 1 + .../api/models/draws/DrawExportParams.kt | 3 + .../api/models/draws/DrawListItem.kt | 1 + .../api/models/draws/DrawListParams.kt | 6 +- .../api/models/draws/DrawListResponse.kt | 1 + .../api/models/draws/DrawRetrieveResponse.kt | 5 + .../api/models/draws/DrawRunResponse.kt | 1 + .../api/models/draws/Winner.kt | 1 + .../api/models/events/Event.kt | 5 + .../api/models/events/EventDetail.kt | 5 + .../api/models/events/EventListParams.kt | 11 +- .../api/models/events/EventListResponse.kt | 5 + .../models/events/EventRetrieveResponse.kt | 5 + .../ExtractionEstimateCostParams.kt | 31 +- .../ExtractionExportResultsParams.kt | 3 + .../api/models/extractions/ExtractionJob.kt | 5 + .../extractions/ExtractionListParams.kt | 12 +- .../extractions/ExtractionListResponse.kt | 5 + .../extractions/ExtractionRetrieveParams.kt | 6 +- .../models/extractions/ExtractionRunParams.kt | 7 + .../extractions/ExtractionRunResponse.kt | 4 + .../api/models/integrations/Integration.kt | 5 + .../integrations/IntegrationCreateParams.kt | 7 + .../integrations/IntegrationCreateResponse.kt | 5 + .../integrations/IntegrationDelivery.kt | 1 + .../IntegrationListDeliveriesParams.kt | 2 + .../IntegrationListDeliveriesResponse.kt | 1 + .../integrations/IntegrationListResponse.kt | 5 + .../IntegrationRetrieveResponse.kt | 5 + .../integrations/IntegrationUpdateParams.kt | 7 + .../integrations/IntegrationUpdateResponse.kt | 5 + .../api/models/monitors/Monitor.kt | 5 + .../models/monitors/MonitorCreateParams.kt | 7 + .../models/monitors/MonitorCreateResponse.kt | 4 + .../models/monitors/MonitorListResponse.kt | 5 + .../monitors/MonitorRetrieveResponse.kt | 5 + .../models/monitors/MonitorUpdateParams.kt | 7 + .../models/monitors/MonitorUpdateResponse.kt | 5 + .../api/models/radar/RadarItem.kt | 1 + .../RadarRetrieveTrendingTopicsResponse.kt | 1 + .../api/models/styles/StyleAnalyzeResponse.kt | 1 + .../api/models/styles/StyleCompareResponse.kt | 8 + .../api/models/styles/StyleListResponse.kt | 1 + .../api/models/styles/StyleProfile.kt | 1 + .../api/models/styles/StyleProfileSummary.kt | 1 + .../api/models/trends/TrendListParams.kt | 4 +- .../api/models/webhooks/Delivery.kt | 1 + .../api/models/webhooks/Webhook.kt | 5 + .../models/webhooks/WebhookCreateParams.kt | 7 + .../models/webhooks/WebhookCreateResponse.kt | 4 + .../webhooks/WebhookListDeliveriesResponse.kt | 1 + .../models/webhooks/WebhookListResponse.kt | 5 + .../models/webhooks/WebhookUpdateParams.kt | 7 + .../models/webhooks/WebhookUpdateResponse.kt | 5 + .../api/models/x/XGetArticleResponse.kt | 4 + .../api/models/x/XGetHomeTimelineParams.kt | 4 +- .../api/models/x/XGetHomeTimelineResponse.kt | 6 +- .../api/models/x/XGetNotificationsParams.kt | 4 +- .../api/models/x/XGetTrendsResponse.kt | 520 ++++++++ .../models/x/accounts/AccountListResponse.kt | 1 + .../models/x/accounts/AccountReauthParams.kt | 16 +- .../x/accounts/AccountRetrieveResponse.kt | 1 + .../api/models/x/accounts/XAccount.kt | 1 + .../api/models/x/accounts/XAccountDetail.kt | 1 + .../models/x/bookmarks/BookmarkListParams.kt | 4 +- .../x/bookmarks/BookmarkListResponse.kt | 6 +- .../x/communities/CommunityActionResult.kt | 1 + .../x/communities/CommunityCreateParams.kt | 8 +- .../x/communities/CommunityDeleteParams.kt | 8 +- .../CommunityRetrieveInfoResponse.kt | 12 +- .../CommunityRetrieveMembersResponse.kt | 816 +++++++++++++ .../CommunityRetrieveModeratorsParams.kt | 4 +- .../CommunityRetrieveModeratorsResponse.kt | 817 +++++++++++++ .../CommunityRetrieveSearchParams.kt | 4 +- .../CommunityRetrieveSearchResponse.kt | 1085 +++++++++++++++++ .../x/communities/join/JoinCreateParams.kt | 9 +- .../x/communities/join/JoinCreateResponse.kt | 1 + .../x/communities/join/JoinDeleteAllParams.kt | 9 +- .../communities/join/JoinDeleteAllResponse.kt | 1 + .../x/communities/tweets/TweetListParams.kt | 12 +- .../x/communities/tweets/TweetListResponse.kt | 1082 ++++++++++++++++ .../models/x/dm/DmRetrieveHistoryParams.kt | 4 +- .../api/models/x/dm/DmSendParams.kt | 8 +- .../x/lists/ListRetrieveFollowersParams.kt | 4 +- .../x/lists/ListRetrieveFollowersResponse.kt | 814 +++++++++++++ .../x/lists/ListRetrieveMembersParams.kt | 4 +- .../x/lists/ListRetrieveMembersResponse.kt | 813 ++++++++++++ .../x/lists/ListRetrieveTweetsParams.kt | 4 +- .../x/lists/ListRetrieveTweetsResponse.kt | 1082 ++++++++++++++++ .../api/models/x/media/MediaUploadParams.kt | 8 +- .../x/profile/ProfileUpdateAvatarParams.kt | 8 +- .../x/profile/ProfileUpdateBannerParams.kt | 8 +- .../models/x/profile/ProfileUpdateParams.kt | 8 +- .../api/models/x/tweets/SearchTweet.kt | 5 +- .../api/models/x/tweets/TweetAuthor.kt | 1 + .../api/models/x/tweets/TweetDetail.kt | 275 ++++- .../x/tweets/TweetGetFavoritersParams.kt | 4 +- .../x/tweets/TweetGetFavoritersResponse.kt | 2 + .../models/x/tweets/TweetGetQuotesParams.kt | 16 +- .../models/x/tweets/TweetGetQuotesResponse.kt | 6 +- .../models/x/tweets/TweetGetRepliesParams.kt | 12 +- .../x/tweets/TweetGetRepliesResponse.kt | 6 +- .../x/tweets/TweetGetRetweetersParams.kt | 4 +- .../x/tweets/TweetGetRetweetersResponse.kt | 2 + .../models/x/tweets/TweetGetThreadParams.kt | 4 +- .../models/x/tweets/TweetGetThreadResponse.kt | 6 +- .../api/models/x/tweets/TweetListResponse.kt | 1082 ++++++++++++++++ .../models/x/tweets/TweetSearchResponse.kt | 6 +- .../api/models/x/users/UserProfile.kt | 1 + .../x/users/UserRetrieveBatchResponse.kt | 813 ++++++++++++ .../x/users/UserRetrieveFollowersParams.kt | 4 +- .../x/users/UserRetrieveFollowersResponse.kt | 814 +++++++++++++ .../UserRetrieveFollowersYouKnowParams.kt | 4 +- .../UserRetrieveFollowersYouKnowResponse.kt | 2 + .../x/users/UserRetrieveFollowingParams.kt | 8 +- .../x/users/UserRetrieveFollowingResponse.kt | 814 +++++++++++++ .../models/x/users/UserRetrieveLikesParams.kt | 4 +- .../x/users/UserRetrieveLikesResponse.kt | 6 +- .../models/x/users/UserRetrieveMediaParams.kt | 4 +- .../x/users/UserRetrieveMediaResponse.kt | 6 +- .../x/users/UserRetrieveMentionsParams.kt | 12 +- .../x/users/UserRetrieveMentionsResponse.kt | 1082 ++++++++++++++++ .../x/users/UserRetrieveSearchParams.kt | 8 +- .../x/users/UserRetrieveSearchResponse.kt | 813 ++++++++++++ .../x/users/UserRetrieveTweetsParams.kt | 4 +- .../x/users/UserRetrieveTweetsResponse.kt | 6 +- .../UserRetrieveVerifiedFollowersParams.kt | 4 +- .../UserRetrieveVerifiedFollowersResponse.kt | 817 +++++++++++++ .../api/services/async/TrendServiceAsync.kt | 2 +- .../api/services/async/XServiceAsync.kt | 25 +- .../api/services/async/XServiceAsyncImpl.kt | 19 +- .../services/async/x/CommunityServiceAsync.kt | 85 +- .../async/x/CommunityServiceAsyncImpl.kt | 55 +- .../api/services/async/x/ListServiceAsync.kt | 112 +- .../services/async/x/ListServiceAsyncImpl.kt | 57 +- .../api/services/async/x/TweetServiceAsync.kt | 10 +- .../services/async/x/TweetServiceAsyncImpl.kt | 19 +- .../api/services/async/x/UserServiceAsync.kt | 166 ++- .../services/async/x/UserServiceAsyncImpl.kt | 110 +- .../async/x/communities/TweetServiceAsync.kt | 11 +- .../x/communities/TweetServiceAsyncImpl.kt | 21 +- .../api/services/blocking/TrendService.kt | 2 +- .../api/services/blocking/XService.kt | 22 +- .../api/services/blocking/XServiceImpl.kt | 23 +- .../services/blocking/x/CommunityService.kt | 88 +- .../blocking/x/CommunityServiceImpl.kt | 58 +- .../api/services/blocking/x/ListService.kt | 107 +- .../services/blocking/x/ListServiceImpl.kt | 63 +- .../api/services/blocking/x/TweetService.kt | 14 +- .../services/blocking/x/TweetServiceImpl.kt | 23 +- .../api/services/blocking/x/UserService.kt | 172 ++- .../services/blocking/x/UserServiceImpl.kt | 122 +- .../blocking/x/communities/TweetService.kt | 15 +- .../x/communities/TweetServiceImpl.kt | 25 +- .../x_twitter_scraper/api/models/ErrorTest.kt | 6 +- .../api/models/PaginatedTweetsTest.kt | 84 +- .../api/models/PaginatedUsersTest.kt | 66 +- .../account/AccountRetrieveResponseTest.kt | 30 +- .../account/AccountSetXUsernameParamsTest.kt | 6 +- .../AccountSetXUsernameResponseTest.kt | 6 +- .../models/apikeys/ApiKeyCreateParamsTest.kt | 6 +- .../apikeys/ApiKeyCreateResponseTest.kt | 30 +- .../models/compose/ComposeCreateParamsTest.kt | 54 +- .../compose/ComposeCreateResponseTest.kt | 29 +- .../CreditRetrieveBalanceResponseTest.kt | 24 +- .../credits/CreditTopupBalanceParamsTest.kt | 6 +- .../models/drafts/DraftCreateParamsTest.kt | 16 +- .../models/drafts/DraftCreateResponseTest.kt | 36 +- .../api/models/drafts/DraftDetailTest.kt | 38 +- .../models/drafts/DraftListResponseTest.kt | 42 +- .../drafts/DraftRetrieveResponseTest.kt | 36 +- .../api/models/drafts/DraftTest.kt | 30 +- .../api/models/draws/DrawDetailTest.kt | 6 +- .../api/models/draws/DrawListResponseTest.kt | 12 +- .../models/draws/DrawRetrieveResponseTest.kt | 6 +- .../api/models/draws/DrawRunParamsTest.kt | 65 +- .../api/models/draws/DrawRunResponseTest.kt | 24 +- .../api/models/events/EventDetailTest.kt | 37 +- .../models/events/EventListResponseTest.kt | 12 +- .../events/EventRetrieveResponseTest.kt | 36 +- .../ExtractionEstimateCostParamsTest.kt | 64 +- .../ExtractionEstimateCostResponseTest.kt | 24 +- .../models/extractions/ExtractionJobTest.kt | 6 +- .../extractions/ExtractionListParamsTest.kt | 6 +- .../extractions/ExtractionListResponseTest.kt | 18 +- .../ExtractionRetrieveResponseTest.kt | 24 +- .../extractions/ExtractionRunParamsTest.kt | 64 +- .../extractions/ExtractionRunResponseTest.kt | 12 +- .../IntegrationCreateParamsTest.kt | 20 +- .../IntegrationCreateResponseTest.kt | 50 +- .../integrations/IntegrationDeliveryTest.kt | 60 +- .../IntegrationListDeliveriesResponseTest.kt | 60 +- .../IntegrationListResponseTest.kt | 45 +- .../IntegrationRetrieveResponseTest.kt | 50 +- .../models/integrations/IntegrationTest.kt | 48 +- .../IntegrationUpdateParamsTest.kt | 55 +- .../IntegrationUpdateResponseTest.kt | 50 +- .../monitors/MonitorCreateParamsTest.kt | 14 +- .../monitors/MonitorCreateResponseTest.kt | 31 +- .../monitors/MonitorListResponseTest.kt | 27 +- .../monitors/MonitorRetrieveResponseTest.kt | 31 +- .../api/models/monitors/MonitorTest.kt | 29 +- .../monitors/MonitorUpdateResponseTest.kt | 31 +- .../api/models/radar/RadarItemTest.kt | 55 +- ...RadarRetrieveTrendingTopicsResponseTest.kt | 54 +- .../models/styles/StyleAnalyzeParamsTest.kt | 6 +- .../models/styles/StyleAnalyzeResponseTest.kt | 42 +- .../models/styles/StyleCompareResponseTest.kt | 84 +- .../models/styles/StyleListResponseTest.kt | 18 +- .../models/styles/StyleProfileSummaryTest.kt | 18 +- .../api/models/styles/StyleProfileTest.kt | 43 +- .../subscribe/SubscribeCreateResponseTest.kt | 13 +- .../support/tickets/TicketCreateParamsTest.kt | 15 +- .../tickets/TicketCreateResponseTest.kt | 6 +- .../support/tickets/TicketListResponseTest.kt | 36 +- .../support/tickets/TicketReplyParamsTest.kt | 8 +- .../tickets/TicketReplyResponseTest.kt | 6 +- .../tickets/TicketRetrieveParamsTest.kt | 6 +- .../tickets/TicketRetrieveResponseTest.kt | 48 +- .../support/tickets/TicketUpdateParamsTest.kt | 8 +- .../tickets/TicketUpdateResponseTest.kt | 8 +- .../models/trends/TrendListResponseTest.kt | 36 +- .../webhooks/WebhookCreateParamsTest.kt | 14 +- .../webhooks/WebhookCreateResponseTest.kt | 31 +- .../webhooks/WebhookListResponseTest.kt | 21 +- .../api/models/webhooks/WebhookTest.kt | 23 +- .../webhooks/WebhookTestResponseTest.kt | 8 +- .../webhooks/WebhookUpdateParamsTest.kt | 13 +- .../webhooks/WebhookUpdateResponseTest.kt | 25 +- .../api/models/x/XGetArticleResponseTest.kt | 102 +- .../models/x/XGetHomeTimelineResponseTest.kt | 84 +- .../models/x/XGetNotificationsResponseTest.kt | 30 +- .../api/models/x/XGetTrendsResponseTest.kt | 66 + .../x/accounts/AccountCreateParamsTest.kt | 42 +- .../x/accounts/AccountCreateResponseTest.kt | 24 +- .../x/accounts/AccountListResponseTest.kt | 30 +- .../x/accounts/AccountReauthParamsTest.kt | 18 +- .../x/accounts/AccountReauthResponseTest.kt | 10 +- .../x/accounts/AccountRetrieveResponseTest.kt | 48 +- .../models/x/accounts/XAccountDetailTest.kt | 48 +- .../api/models/x/accounts/XAccountTest.kt | 30 +- .../x/bookmarks/BookmarkListParamsTest.kt | 10 +- .../x/bookmarks/BookmarkListResponseTest.kt | 84 +- .../BookmarkRetrieveFoldersResponseTest.kt | 21 +- .../communities/CommunityActionResultTest.kt | 12 +- .../communities/CommunityCreateParamsTest.kt | 25 +- .../CommunityCreateResponseTest.kt | 12 +- .../communities/CommunityDeleteParamsTest.kt | 16 +- .../CommunityRetrieveInfoResponseTest.kt | 12 +- .../CommunityRetrieveMembersResponseTest.kt | 88 ++ ...CommunityRetrieveModeratorsResponseTest.kt | 88 ++ .../CommunityRetrieveSearchResponseTest.kt | 109 ++ .../communities/join/JoinCreateParamsTest.kt | 8 +- .../join/JoinCreateResponseTest.kt | 12 +- .../join/JoinDeleteAllParamsTest.kt | 8 +- .../join/JoinDeleteAllResponseTest.kt | 12 +- .../tweets/TweetListResponseTest.kt | 108 ++ .../x/dm/DmRetrieveHistoryResponseTest.kt | 36 +- .../api/models/x/dm/DmSendParamsTest.kt | 42 +- .../api/models/x/dm/DmSendResponseTest.kt | 6 +- .../x/followers/FollowerCheckResponseTest.kt | 18 +- .../ListRetrieveFollowersResponseTest.kt | 88 ++ .../lists/ListRetrieveMembersResponseTest.kt | 87 ++ .../x/lists/ListRetrieveTweetsResponseTest.kt | 108 ++ .../models/x/media/MediaDownloadParamsTest.kt | 16 +- .../x/media/MediaDownloadResponseTest.kt | 30 +- .../models/x/media/MediaUploadParamsTest.kt | 10 +- .../models/x/media/MediaUploadResponseTest.kt | 8 +- .../profile/ProfileUpdateAvatarParamsTest.kt | 6 +- .../profile/ProfileUpdateBannerParamsTest.kt | 6 +- .../x/profile/ProfileUpdateParamsTest.kt | 34 +- .../api/models/x/tweets/SearchTweetTest.kt | 78 +- .../api/models/x/tweets/TweetAuthorTest.kt | 25 +- .../models/x/tweets/TweetCreateParamsTest.kt | 52 +- .../x/tweets/TweetCreateResponseTest.kt | 6 +- .../api/models/x/tweets/TweetDetailTest.kt | 134 +- .../tweets/TweetGetFavoritersResponseTest.kt | 66 +- .../x/tweets/TweetGetQuotesResponseTest.kt | 84 +- .../x/tweets/TweetGetRepliesResponseTest.kt | 84 +- .../tweets/TweetGetRetweetersResponseTest.kt | 66 +- .../x/tweets/TweetGetThreadResponseTest.kt | 84 +- .../models/x/tweets/TweetListResponseTest.kt | 108 ++ .../x/tweets/TweetSearchResponseTest.kt | 84 +- .../api/models/x/users/UserProfileTest.kt | 61 +- .../x/users/UserRetrieveBatchResponseTest.kt | 87 ++ .../UserRetrieveFollowersResponseTest.kt | 88 ++ ...serRetrieveFollowersYouKnowResponseTest.kt | 67 +- .../UserRetrieveFollowingResponseTest.kt | 88 ++ .../x/users/UserRetrieveLikesResponseTest.kt | 84 +- .../x/users/UserRetrieveMediaResponseTest.kt | 84 +- .../users/UserRetrieveMentionsResponseTest.kt | 108 ++ .../x/users/UserRetrieveSearchResponseTest.kt | 87 ++ .../x/users/UserRetrieveTweetsResponseTest.kt | 84 +- ...erRetrieveVerifiedFollowersResponseTest.kt | 89 ++ .../services/async/AccountServiceAsyncTest.kt | 2 +- .../services/async/ApiKeyServiceAsyncTest.kt | 2 +- .../services/async/ComposeServiceAsyncTest.kt | 18 +- .../services/async/CreditServiceAsyncTest.kt | 4 +- .../services/async/DraftServiceAsyncTest.kt | 4 +- .../services/async/DrawServiceAsyncTest.kt | 20 +- .../async/ExtractionServiceAsyncTest.kt | 42 +- .../async/IntegrationServiceAsyncTest.kt | 25 +- .../services/async/MonitorServiceAsyncTest.kt | 3 +- .../services/async/StyleServiceAsyncTest.kt | 2 +- .../services/async/WebhookServiceAsyncTest.kt | 6 +- .../api/services/async/XServiceAsyncTest.kt | 5 +- .../async/support/TicketServiceAsyncTest.kt | 16 +- .../async/x/AccountServiceAsyncTest.kt | 14 +- .../async/x/BookmarkServiceAsyncTest.kt | 2 +- .../async/x/CommunityServiceAsyncTest.kt | 25 +- .../services/async/x/DmServiceAsyncTest.kt | 8 +- .../services/async/x/ListServiceAsyncTest.kt | 15 +- .../services/async/x/MediaServiceAsyncTest.kt | 8 +- .../async/x/ProfileServiceAsyncTest.kt | 14 +- .../services/async/x/TweetServiceAsyncTest.kt | 19 +- .../services/async/x/UserServiceAsyncTest.kt | 30 +- .../x/communities/JoinServiceAsyncTest.kt | 6 +- .../x/communities/TweetServiceAsyncTest.kt | 5 +- .../services/blocking/AccountServiceTest.kt | 2 +- .../services/blocking/ApiKeyServiceTest.kt | 2 +- .../services/blocking/ComposeServiceTest.kt | 18 +- .../services/blocking/CreditServiceTest.kt | 2 +- .../api/services/blocking/DraftServiceTest.kt | 4 +- .../api/services/blocking/DrawServiceTest.kt | 20 +- .../blocking/ExtractionServiceTest.kt | 42 +- .../blocking/IntegrationServiceTest.kt | 25 +- .../services/blocking/MonitorServiceTest.kt | 3 +- .../api/services/blocking/StyleServiceTest.kt | 2 +- .../services/blocking/WebhookServiceTest.kt | 6 +- .../api/services/blocking/XServiceTest.kt | 4 +- .../blocking/support/TicketServiceTest.kt | 16 +- .../services/blocking/x/AccountServiceTest.kt | 14 +- .../blocking/x/BookmarkServiceTest.kt | 2 +- .../blocking/x/CommunityServiceTest.kt | 45 +- .../api/services/blocking/x/DmServiceTest.kt | 8 +- .../services/blocking/x/ListServiceTest.kt | 39 +- .../services/blocking/x/MediaServiceTest.kt | 8 +- .../services/blocking/x/ProfileServiceTest.kt | 14 +- .../services/blocking/x/TweetServiceTest.kt | 18 +- .../services/blocking/x/UserServiceTest.kt | 60 +- .../blocking/x/communities/JoinServiceTest.kt | 6 +- .../x/communities/TweetServiceTest.kt | 9 +- .../api/proguard/ProGuardCompatibilityTest.kt | 26 +- 358 files changed, 18903 insertions(+), 3019 deletions(-) create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetTrendsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 193a413..d99ab81 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 102 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-61e27e87d4182e5230beae1edaf864a00a5c5f9b96defcdb9a4503544463328f.yml -openapi_spec_hash: 782f8974cd27e51c8a7993f61b139f72 +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/README.md b/README.md index 39d4d2e..a0e5e75 100644 --- a/README.md +++ b/README.md @@ -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/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 6085676..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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/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 90158a7..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( @@ -73,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). */ @@ -240,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)) /** @@ -459,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 8316411..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( @@ -73,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). */ @@ -240,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)) /** @@ -459,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/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 1519889..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( @@ -97,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). */ @@ -327,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)) /** @@ -635,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 { /** 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 b1a8b89..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( @@ -97,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). */ @@ -327,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)) /** @@ -635,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 { /** 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 0bb4b6b..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( @@ -259,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). @@ -500,6 +503,7 @@ private constructor( this.createdAt = createdAt } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -815,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 { 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 adfadfa..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( @@ -97,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). */ @@ -327,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)) /** @@ -635,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 { /** 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 187cd1e..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,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). */ @@ -182,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) } /** @@ -463,6 +466,8 @@ 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). */ @@ -610,6 +615,7 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } + /** Array of event types to subscribe to. */ fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) /** @@ -822,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 { /** 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 22121e8..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( @@ -97,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). */ @@ -327,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)) /** @@ -635,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 { /** 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/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/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/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 2f4f80c..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 b3c0965..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 3caed40..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 @@ -220,7 +220,7 @@ private constructor( ) /** - * Community ID + * 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 @@ -245,7 +245,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("created_at") /** - * Community description + * 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). @@ -277,7 +277,7 @@ private constructor( fun moderatorCount(): Optional = moderatorCount.getOptional("moderator_count") /** - * Community name + * 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). @@ -437,7 +437,7 @@ private constructor( additionalProperties = community.additionalProperties.toMutableMap() } - /** Community ID */ + /** Unique community identifier */ fun id(id: String) = id(JsonField.of(id)) /** @@ -473,7 +473,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Community description */ + /** About text for the community */ fun description(description: String) = description(JsonField.of(description)) /** @@ -525,7 +525,7 @@ private constructor( this.moderatorCount = moderatorCount } - /** Community name */ + /** Display name of the community */ fun name(name: String) = name(JsonField.of(name)) /** 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 b58ef19..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( @@ -99,7 +100,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -331,7 +332,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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/TweetDetail.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetail.kt index fca2b33..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 @@ -20,6 +20,7 @@ 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( @@ -33,12 +34,12 @@ private constructor( private val viewCount: JsonField, private val conversationId: JsonField, private val createdAt: JsonField, - private val entities: JsonValue, + private val entities: JsonField, private val isNoteTweet: JsonField, private val isQuoteStatus: JsonField, private val isReply: JsonField, private val media: JsonField>, - private val quotedTweet: JsonValue, + private val quotedTweet: JsonField, private val source: JsonField, private val additionalProperties: MutableMap, ) { @@ -61,7 +62,7 @@ private constructor( @ExcludeMissing conversationId: JsonField = JsonMissing.of(), @JsonProperty("createdAt") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("entities") @ExcludeMissing entities: JsonValue = JsonMissing.of(), + @JsonProperty("entities") @ExcludeMissing entities: JsonField = JsonMissing.of(), @JsonProperty("isNoteTweet") @ExcludeMissing isNoteTweet: JsonField = JsonMissing.of(), @@ -70,7 +71,9 @@ private constructor( isQuoteStatus: JsonField = JsonMissing.of(), @JsonProperty("isReply") @ExcludeMissing isReply: JsonField = JsonMissing.of(), @JsonProperty("media") @ExcludeMissing media: JsonField> = JsonMissing.of(), - @JsonProperty("quoted_tweet") @ExcludeMissing quotedTweet: JsonValue = JsonMissing.of(), + @JsonProperty("quoted_tweet") + @ExcludeMissing + quotedTweet: JsonField = JsonMissing.of(), @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), ) : this( id, @@ -158,12 +161,10 @@ private constructor( /** * Parsed entities from the tweet text (URLs, mentions, hashtags, media) * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = tweetDetail.entities().convert(MyClass.class); - * ``` + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("entities") @ExcludeMissing fun _entities(): JsonValue = entities + fun entities(): Optional = entities.getOptional("entities") /** * Whether this is a Note Tweet (long-form post, up to 25,000 characters) @@ -200,12 +201,10 @@ private constructor( /** * The quoted tweet object, present when isQuoteStatus is true * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = tweetDetail.quotedTweet().convert(MyClass.class); - * ``` + * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("quoted_tweet") @ExcludeMissing fun _quotedTweet(): JsonValue = quotedTweet + fun quotedTweet(): Optional = quotedTweet.getOptional("quoted_tweet") /** * Client application used to post this tweet @@ -291,6 +290,13 @@ 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]. * @@ -323,6 +329,15 @@ private constructor( */ @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]. * @@ -375,12 +390,12 @@ private constructor( private var viewCount: JsonField? = null private var conversationId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() - private var entities: JsonValue = 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: JsonValue = JsonMissing.of() + private var quotedTweet: JsonField = JsonMissing.of() private var source: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -516,7 +531,16 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** Parsed entities from the tweet text (URLs, mentions, hashtags, media) */ - fun entities(entities: JsonValue) = apply { this.entities = entities } + 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)) @@ -582,7 +606,18 @@ private constructor( } /** The quoted tweet object, present when isQuoteStatus is true */ - fun quotedTweet(quotedTweet: JsonValue) = apply { this.quotedTweet = quotedTweet } + 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)) @@ -673,10 +708,12 @@ private constructor( viewCount() conversationId() createdAt() + entities().ifPresent { it.validate() } isNoteTweet() isQuoteStatus() isReply() media().ifPresent { it.forEach { it.validate() } } + quotedTweet().ifPresent { it.validate() } source() validated = true } @@ -706,12 +743,114 @@ private constructor( (if (viewCount.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( @@ -1051,6 +1190,106 @@ private constructor( "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) { return true 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 c3d319b..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 bfc3b2c..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 34cf1b2..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt new file mode 100644 index 0000000..e8c3be9 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt @@ -0,0 +1,1082 @@ +// 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.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/tweets/TweetSearchResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt index d3c7b61..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 f27d179..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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 e0272e7..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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/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 6bcf2b4..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( @@ -336,7 +338,7 @@ private constructor( fun createdAt(): Optional = createdAt.getOptional("createdAt") /** - * Whether this is a Note Tweet (long-form post, up to 25,000 characters) + * 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). @@ -573,7 +575,7 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Whether this is a Note Tweet (long-form post, up to 25,000 characters) */ + /** True for Note Tweets (long-form content, up to 25,000 characters) */ fun isNoteTweet(isNoteTweet: Boolean) = isNoteTweet(JsonField.of(isNoteTweet)) /** 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/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/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 d070b7b..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,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.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse @@ -19,6 +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.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 @@ -55,14 +55,14 @@ interface TweetServiceAsync { ): CompletableFuture /** 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 + ): CompletableFuture /** Get users who liked a tweet */ fun getFavoriters(id: String): CompletableFuture = @@ -288,14 +288,14 @@ interface TweetServiceAsync { * 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 + ): 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 478d49f..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 @@ -30,6 +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.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 @@ -70,9 +70,9 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun list( params: TweetListParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /x/tweets - withRawResponse().list(params, requestOptions).thenAccept {} + withRawResponse().list(params, requestOptions).thenApply { it.parse() } override fun getFavoriters( params: TweetGetFavoritersParams, @@ -172,12 +172,13 @@ class TweetServiceAsyncImpl internal constructor(private val clientOptions: Clie } } - 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) @@ -190,7 +191,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/UserServiceAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/async/x/UserServiceAsync.kt index 068ee12..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,22 +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.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 @@ -42,17 +47,18 @@ interface UserServiceAsync { fun follow(): FollowServiceAsync /** 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 */ @@ -60,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 */ @@ -124,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 */ @@ -132,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 */ @@ -230,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 */ @@ -238,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 = @@ -309,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 */ @@ -317,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. */ @@ -360,20 +389,24 @@ interface UserServiceAsync { * 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 */ @@ -381,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) /** @@ -455,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 */ @@ -463,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) /** @@ -580,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 */ @@ -588,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 @@ -674,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 */ @@ -683,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 4f78238..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,19 +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.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 @@ -56,16 +61,16 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien 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, @@ -77,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, @@ -98,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, @@ -119,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 { @@ -142,12 +147,13 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun follow(): FollowServiceAsync.WithRawResponse = follow - private val retrieveBatchHandler: Handler = emptyHandler() + private val retrieveBatchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): CompletableFuture { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -160,17 +166,24 @@ class UserServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response.use { retrieveBatchHandler.handle(it) } + response + .use { retrieveBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - 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()) @@ -186,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() + } + } } } } @@ -224,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()) @@ -245,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() + } + } } } } @@ -316,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()) @@ -337,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) @@ -360,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() + } + } } } } @@ -398,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()) @@ -419,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/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/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 5435a04..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,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.tweets.TweetCreateParams import com.x_twitter_scraper.api.models.x.tweets.TweetCreateResponse @@ -20,6 +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.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 @@ -55,10 +55,13 @@ interface TweetService { ): TweetCreateResponse /** 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()) + fun list( + params: TweetListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TweetListResponse /** Get users who liked a tweet */ fun getFavoriters(id: String): TweetGetFavoritersResponse = @@ -257,14 +260,15 @@ 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 /** * 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 52a31e2..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 @@ -30,6 +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.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 @@ -66,10 +66,9 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt // post /x/tweets withRawResponse().create(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) - } + withRawResponse().list(params, requestOptions).parse() override fun getFavoriters( params: TweetGetFavoritersParams, @@ -166,9 +165,13 @@ class TweetServiceImpl internal constructor(private val clientOptions: ClientOpt } } - 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) @@ -179,7 +182,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/UserService.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/services/blocking/x/UserService.kt index 4014e76..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,22 +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.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 @@ -42,43 +47,48 @@ interface UserService { fun follow(): FollowService /** 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 */ @@ -120,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 */ @@ -212,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 = @@ -284,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 */ @@ -292,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. */ @@ -331,22 +355,23 @@ interface UserService { * [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 */ @@ -355,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) /** @@ -435,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 */ @@ -444,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) /** @@ -567,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 */ @@ -576,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) /** @@ -607,7 +653,9 @@ interface UserService { * [UserService.retrieveSearch]. */ @MustBeClosed - fun retrieveSearch(params: UserRetrieveSearchParams): HttpResponse = + fun retrieveSearch( + params: UserRetrieveSearchParams + ): HttpResponseFor = retrieveSearch(params, RequestOptions.none()) /** @see retrieveSearch */ @@ -615,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 @@ -669,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 */ @@ -679,7 +729,7 @@ interface UserService { params: UserRetrieveVerifiedFollowersParams = UserRetrieveVerifiedFollowersParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = + ): HttpResponseFor = retrieveVerifiedFollowers(params.toBuilder().id(id).build(), requestOptions) /** @see retrieveVerifiedFollowers */ @@ -687,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 9090449..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,19 +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.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,18 +56,19 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun follow(): FollowService = follow - override fun retrieveBatch(params: UserRetrieveBatchParams, requestOptions: RequestOptions) { + 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, @@ -74,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, @@ -96,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, @@ -116,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 { @@ -140,12 +145,13 @@ class UserServiceImpl internal constructor(private val clientOptions: ClientOpti override fun follow(): FollowService.WithRawResponse = follow - private val retrieveBatchHandler: Handler = emptyHandler() + private val retrieveBatchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieveBatch( params: UserRetrieveBatchParams, requestOptions: RequestOptions, - ): HttpResponse { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -156,16 +162,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 { retrieveBatchHandler.handle(it) } + response + .use { retrieveBatchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } - 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()) @@ -179,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() + } + } } } @@ -213,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()) @@ -232,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() + } + } } } @@ -296,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()) @@ -315,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) @@ -335,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() + } + } } } @@ -369,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()) @@ -388,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/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 40d6a6b..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 8393d71..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 @@ -14,16 +14,20 @@ internal class ComposeCreateResponseTest { fun create() { val composeCreateResponse = ComposeCreateResponse.builder() - .feedback("feedback") - .score(0.0) - .addSuggestion("string") - .text("text") + .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("feedback") - assertThat(composeCreateResponse.score()).contains(0.0) - assertThat(composeCreateResponse.suggestions().getOrNull()).containsExactly("string") - assertThat(composeCreateResponse.text()).contains("text") + 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 @@ -31,10 +35,11 @@ internal class ComposeCreateResponseTest { val jsonMapper = jsonMapper() val composeCreateResponse = ComposeCreateResponse.builder() - .feedback("feedback") - .score(0.0) - .addSuggestion("string") - .text("text") + .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/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/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/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 b197f5b..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 7a1c229..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 35e2c16..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 @@ -15,14 +15,14 @@ internal class CommunityRetrieveInfoResponseTest { CommunityRetrieveInfoResponse.builder() .community( CommunityRetrieveInfoResponse.Community.builder() - .id("id") + .id("1500000000000000000") .bannerUrl("banner_url") .createdAt("created_at") .description("description") .joinPolicy("join_policy") .memberCount(0L) .moderatorCount(0L) - .name("name") + .name("Tesla Fans") .primaryTopic( CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() .id("id") @@ -43,14 +43,14 @@ internal class CommunityRetrieveInfoResponseTest { assertThat(communityRetrieveInfoResponse.community()) .isEqualTo( CommunityRetrieveInfoResponse.Community.builder() - .id("id") + .id("1500000000000000000") .bannerUrl("banner_url") .createdAt("created_at") .description("description") .joinPolicy("join_policy") .memberCount(0L) .moderatorCount(0L) - .name("name") + .name("Tesla Fans") .primaryTopic( CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() .id("id") @@ -75,14 +75,14 @@ internal class CommunityRetrieveInfoResponseTest { CommunityRetrieveInfoResponse.builder() .community( CommunityRetrieveInfoResponse.Community.builder() - .id("id") + .id("1500000000000000000") .bannerUrl("banner_url") .createdAt("created_at") .description("description") .joinPolicy("join_policy") .memberCount(0L) .moderatorCount(0L) - .name("name") + .name("Tesla Fans") .primaryTopic( CommunityRetrieveInfoResponse.Community.PrimaryTopic.builder() .id("id") 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 026bdd2..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,45 +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") - .isNoteTweet(true) - .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.isNoteTweet()).contains(true) - 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 @@ -59,24 +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") - .isNoteTweet(true) - .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/TweetDetailTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDetailTest.kt index 563e758..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 @@ -15,55 +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) - .conversationId("conversationId") - .createdAt("createdAt") - .entities(JsonValue.from(mapOf())) - .isNoteTweet(true) - .isQuoteStatus(true) - .isReply(true) + .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("mediaUrl") + .mediaUrl("https://pbs.twimg.com/media/example.jpg") .type(TweetDetail.Media.Type.PHOTO) - .url("url") + .url("https://t.co/abc123") + .build() + ) + .quotedTweet( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .quotedTweet(JsonValue.from(mapOf())) - .source("source") + .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.conversationId()).contains("conversationId") - assertThat(tweetDetail.createdAt()).contains("createdAt") - assertThat(tweetDetail._entities()).isEqualTo(JsonValue.from(mapOf())) - assertThat(tweetDetail.isNoteTweet()).contains(true) - assertThat(tweetDetail.isQuoteStatus()).contains(true) - assertThat(tweetDetail.isReply()).contains(true) + 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("mediaUrl") + .mediaUrl("https://pbs.twimg.com/media/example.jpg") .type(TweetDetail.Media.Type.PHOTO) - .url("url") + .url("https://t.co/abc123") .build() ) - assertThat(tweetDetail._quotedTweet()).isEqualTo(JsonValue.from(mapOf())) - assertThat(tweetDetail.source()).contains("source") + assertThat(tweetDetail.quotedTweet()) + .contains( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tweetDetail.source()).contains("Twitter Web App") } @Test @@ -71,29 +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) - .conversationId("conversationId") - .createdAt("createdAt") - .entities(JsonValue.from(mapOf())) - .isNoteTweet(true) - .isQuoteStatus(true) - .isReply(true) + .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("mediaUrl") + .mediaUrl("https://pbs.twimg.com/media/example.jpg") .type(TweetDetail.Media.Type.PHOTO) - .url("url") + .url("https://t.co/abc123") + .build() + ) + .quotedTweet( + TweetDetail.QuotedTweet.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .quotedTweet(JsonValue.from(mapOf())) - .source("source") + .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 f12a927..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 c165ee0..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 8aea35b..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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/TweetSearchResponseTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt index 2a30ca3..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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/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 5226432..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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 7f84b63..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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/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 eb9af84..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,54 +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") - .isNoteTweet(true) - .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") - .isNoteTweet(true) - .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() ) } @@ -72,27 +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") - .isNoteTweet(true) - .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/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/StyleServiceAsyncTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/StyleServiceAsyncTest.kt index 33f85fa..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 @@ -37,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() 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 ad27bfe..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 @@ -29,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() ) @@ -53,9 +53,10 @@ internal class TweetServiceAsyncTest { .build() val tweetServiceAsync = client.x().tweets() - val future = tweetServiceAsync.list(TweetListParams.builder().ids("ids").build()) + val tweetsFuture = tweetServiceAsync.list(TweetListParams.builder().ids("ids").build()) - val response = future.get() + 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 c3c0bff..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 @@ -28,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") @@ -44,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") @@ -81,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") @@ -137,7 +140,7 @@ internal class UserServiceAsyncTest { .build() val userServiceAsync = client.x().users() - val future = + val responseFuture = userServiceAsync.retrieveMentions( UserRetrieveMentionsParams.builder() .id("id") @@ -147,7 +150,8 @@ internal class UserServiceAsyncTest { .build() ) - val response = future.get() + val response = responseFuture.get() + response.validate() } @Disabled("Mock server tests are disabled") @@ -160,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") @@ -202,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/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/StyleServiceTest.kt b/x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/StyleServiceTest.kt index 7960a05..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 @@ -36,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() } 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 50dee08..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 @@ -29,13 +29,13 @@ 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() ) @@ -52,7 +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()) + + 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 9769cce..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 @@ -28,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") @@ -41,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") @@ -74,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") @@ -125,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") @@ -145,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") @@ -183,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-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 2e6c3f2..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,24 +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") - .isNoteTweet(true) - .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 = From 91fe7314ce8e6e9db863a4bc4863333ffb94fc5c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:01:01 +0000 Subject: [PATCH 08/23] feat(api): api update --- .github/workflows/publish-sonatype.yml | 41 - .github/workflows/release-doctor.yml | 24 - .release-please-manifest.json | 3 - .stats.yml | 8 +- README.md | 152 +- bin/check-release-environment | 33 - build.gradle.kts | 2 +- .../x-twitter-scraper.publish.gradle.kts | 6 +- release-please-config.json | 67 - .../okhttp/XTwitterScraperOkHttpClient.kt | 13 + .../XTwitterScraperOkHttpClientAsync.kt | 13 + .../x_twitter_scraper/api/core/AutoPager.kt | 21 + .../api/core/AutoPagerAsync.kt | 88 ++ .../com/x_twitter_scraper/api/core/Check.kt | 2 +- .../api/core/ClientOptions.kt | 50 + .../com/x_twitter_scraper/api/core/Page.kt | 33 + .../x_twitter_scraper/api/core/PageAsync.kt | 35 + .../api/models/PaginatedTweets.kt | 842 +---------- .../api/models/PaginatedUsers.kt | 575 +------- .../api/models/apikeys/ApiKeyListResponse.kt | 375 +---- .../api/models/drafts/DraftCreateResponse.kt | 348 ----- .../api/models/drafts/DraftListResponse.kt | 303 ---- .../models/drafts/DraftRetrieveResponse.kt | 348 ----- .../api/models/draws/DrawListResponse.kt | 438 +----- .../api/models/draws/DrawRetrieveResponse.kt | 1006 +------------ .../api/models/draws/DrawRunResponse.kt | 277 ---- .../api/models/events/Event.kt | 170 +-- .../api/models/events/EventDetail.kt | 170 +-- .../api/models/events/EventListParams.kt | 159 +- .../api/models/events/EventListResponse.kt | 604 -------- .../models/events/EventRetrieveResponse.kt | 651 --------- .../extractions/ExtractionListResponse.kt | 766 +--------- .../api/models/integrations/Integration.kt | 155 +- .../integrations/IntegrationCreateParams.kt | 155 +- .../integrations/IntegrationCreateResponse.kt | 1058 -------------- .../IntegrationListDeliveriesResponse.kt | 541 +------ .../integrations/IntegrationListResponse.kt | 1067 -------------- .../IntegrationRetrieveResponse.kt | 1058 -------------- .../integrations/IntegrationUpdateParams.kt | 156 +- .../integrations/IntegrationUpdateResponse.kt | 1058 -------------- .../api/models/monitors/Monitor.kt | 156 +- .../models/monitors/MonitorCreateParams.kt | 156 +- .../models/monitors/MonitorCreateResponse.kt | 156 +- .../models/monitors/MonitorListResponse.kt | 534 ------- .../monitors/MonitorRetrieveResponse.kt | 527 ------- .../models/monitors/MonitorUpdateParams.kt | 156 +- .../models/monitors/MonitorUpdateResponse.kt | 527 ------- .../RadarRetrieveTrendingTopicsResponse.kt | 497 +------ .../api/models/styles/StyleCompareResponse.kt | 1278 +---------------- .../api/models/styles/StyleDeleteParams.kt | 229 +++ .../styles/StyleGetPerformanceParams.kt | 191 +++ ...onse.kt => StyleGetPerformanceResponse.kt} | 297 ++-- .../api/models/styles/StyleListResponse.kt | 313 +--- .../api/models/styles/StyleRetrieveParams.kt | 189 +++ .../api/models/styles/StyleUpdateParams.kt | 687 +++++++++ .../api/models/webhooks/Webhook.kt | 156 +- .../models/webhooks/WebhookCreateParams.kt | 156 +- .../models/webhooks/WebhookCreateResponse.kt | 156 +- .../webhooks/WebhookListDeliveriesResponse.kt | 448 ------ .../models/webhooks/WebhookListResponse.kt | 489 ------- .../models/webhooks/WebhookUpdateParams.kt | 156 +- .../models/webhooks/WebhookUpdateResponse.kt | 494 ------- .../api/models/x/XGetArticleResponse.kt | 333 +---- .../api/models/x/XGetHomeTimelineResponse.kt | 1082 -------------- .../x/accounts/AccountBulkRetryParams.kt | 214 +++ .../x/accounts/AccountBulkRetryResponse.kt | 173 +++ .../models/x/accounts/AccountListResponse.kt | 331 +---- .../x/accounts/AccountRetrieveResponse.kt | 450 ------ .../models/x/bookmarks/BookmarkListPage.kt | 133 ++ .../x/bookmarks/BookmarkListPageAsync.kt | 148 ++ .../x/bookmarks/BookmarkListResponse.kt | 1082 -------------- .../CommunityRetrieveMembersResponse.kt | 816 ----------- .../CommunityRetrieveModeratorsResponse.kt | 817 ----------- .../CommunityRetrieveSearchResponse.kt | 1085 -------------- .../x/communities/join/JoinCreateResponse.kt | 255 ---- .../communities/join/JoinDeleteAllResponse.kt | 255 ---- .../tweets/TweetListByCommunityPage.kt | 133 ++ .../tweets/TweetListByCommunityPageAsync.kt | 149 ++ .../tweets/TweetListByCommunityParams.kt | 216 +++ .../x/communities/tweets/TweetListPage.kt | 132 ++ .../communities/tweets/TweetListPageAsync.kt | 147 ++ .../x/communities/tweets/TweetListResponse.kt | 1082 -------------- .../x/lists/ListRetrieveFollowersResponse.kt | 814 ----------- .../x/lists/ListRetrieveMembersResponse.kt | 813 ----------- .../x/lists/ListRetrieveTweetsResponse.kt | 1082 -------------- .../api/models/x/tweets/TweetDeleteParams.kt | 437 ++++++ .../models/x/tweets/TweetDeleteResponse.kt | 158 ++ .../x/tweets/TweetGetFavoritersResponse.kt | 813 ----------- .../models/x/tweets/TweetGetQuotesResponse.kt | 1082 -------------- .../x/tweets/TweetGetRepliesResponse.kt | 1082 -------------- .../x/tweets/TweetGetRetweetersResponse.kt | 813 ----------- .../models/x/tweets/TweetGetThreadResponse.kt | 1082 -------------- .../api/models/x/tweets/TweetListResponse.kt | 1082 -------------- .../models/x/tweets/TweetRetrieveParams.kt | 189 +++ .../models/x/tweets/TweetRetrieveResponse.kt | 213 +++ .../models/x/tweets/TweetSearchResponse.kt | 1082 -------------- .../models/x/tweets/like/LikeCreateParams.kt | 437 ++++++ .../x/tweets/like/LikeCreateResponse.kt | 158 ++ .../models/x/tweets/like/LikeDeleteParams.kt | 437 ++++++ .../x/tweets/like/LikeDeleteResponse.kt | 158 ++ .../x/tweets/retweet/RetweetCreateParams.kt | 437 ++++++ .../x/tweets/retweet/RetweetCreateResponse.kt | 158 ++ .../x/tweets/retweet/RetweetDeleteParams.kt | 437 ++++++ .../x/tweets/retweet/RetweetDeleteResponse.kt | 158 ++ .../x/users/UserRetrieveBatchResponse.kt | 813 ----------- .../x/users/UserRetrieveFollowersResponse.kt | 814 ----------- .../UserRetrieveFollowersYouKnowResponse.kt | 817 ----------- .../x/users/UserRetrieveFollowingResponse.kt | 814 ----------- .../x/users/UserRetrieveLikesResponse.kt | 1082 -------------- .../x/users/UserRetrieveMediaResponse.kt | 1082 -------------- .../x/users/UserRetrieveMentionsResponse.kt | 1082 -------------- .../api/models/x/users/UserRetrieveParams.kt | 189 +++ .../x/users/UserRetrieveSearchResponse.kt | 813 ----------- .../x/users/UserRetrieveTweetsResponse.kt | 1082 -------------- .../UserRetrieveVerifiedFollowersResponse.kt | 817 ----------- .../x/users/follow/FollowCreateParams.kt | 437 ++++++ .../x/users/follow/FollowCreateResponse.kt | 158 ++ .../x/users/follow/FollowDeleteAllParams.kt | 437 ++++++ .../x/users/follow/FollowDeleteAllResponse.kt | 158 ++ .../api/services/async/DraftServiceAsync.kt | 43 +- .../services/async/DraftServiceAsyncImpl.kt | 19 +- .../api/services/async/EventServiceAsync.kt | 32 +- .../services/async/EventServiceAsyncImpl.kt | 10 +- .../services/async/IntegrationServiceAsync.kt | 74 +- .../async/IntegrationServiceAsyncImpl.kt | 28 +- .../api/services/async/MonitorServiceAsync.kt | 66 +- .../services/async/MonitorServiceAsyncImpl.kt | 18 +- .../api/services/async/StyleServiceAsync.kt | 285 +++- .../services/async/StyleServiceAsyncImpl.kt | 173 ++- .../api/services/async/WebhookServiceAsync.kt | 34 +- .../services/async/WebhookServiceAsyncImpl.kt | 9 +- .../api/services/async/XServiceAsync.kt | 20 +- .../api/services/async/XServiceAsyncImpl.kt | 10 +- .../services/async/x/AccountServiceAsync.kt | 78 +- .../async/x/AccountServiceAsyncImpl.kt | 54 +- .../services/async/x/BookmarkServiceAsync.kt | 18 +- .../async/x/BookmarkServiceAsyncImpl.kt | 19 +- .../services/async/x/CommunityServiceAsync.kt | 72 +- .../async/x/CommunityServiceAsyncImpl.kt | 29 +- .../api/services/async/x/ListServiceAsync.kt | 93 +- .../services/async/x/ListServiceAsyncImpl.kt | 29 +- .../api/services/async/x/TweetServiceAsync.kt | 304 ++-- .../services/async/x/TweetServiceAsyncImpl.kt | 154 +- .../api/services/async/x/UserServiceAsync.kt | 339 +++-- .../services/async/x/UserServiceAsyncImpl.kt | 137 +- .../async/x/communities/JoinServiceAsync.kt | 35 +- .../x/communities/JoinServiceAsyncImpl.kt | 19 +- .../async/x/communities/TweetServiceAsync.kt | 93 +- .../x/communities/TweetServiceAsyncImpl.kt | 71 +- .../async/x/tweets/LikeServiceAsync.kt | 112 ++ .../async/x/tweets/LikeServiceAsyncImpl.kt | 105 ++ .../async/x/tweets/RetweetServiceAsync.kt | 112 ++ .../async/x/tweets/RetweetServiceAsyncImpl.kt | 105 ++ .../async/x/users/FollowServiceAsync.kt | 114 ++ .../async/x/users/FollowServiceAsyncImpl.kt | 105 ++ .../api/services/blocking/DraftService.kt | 40 +- .../api/services/blocking/DraftServiceImpl.kt | 22 +- .../api/services/blocking/EventService.kt | 30 +- .../api/services/blocking/EventServiceImpl.kt | 10 +- .../services/blocking/IntegrationService.kt | 74 +- .../blocking/IntegrationServiceImpl.kt | 28 +- .../api/services/blocking/MonitorService.kt | 66 +- .../services/blocking/MonitorServiceImpl.kt | 24 +- .../api/services/blocking/StyleService.kt | 274 +++- .../api/services/blocking/StyleServiceImpl.kt | 159 +- .../api/services/blocking/WebhookService.kt | 36 +- .../services/blocking/WebhookServiceImpl.kt | 12 +- .../api/services/blocking/XService.kt | 21 +- .../api/services/blocking/XServiceImpl.kt | 10 +- .../api/services/blocking/x/AccountService.kt | 78 +- .../services/blocking/x/AccountServiceImpl.kt | 47 +- .../services/blocking/x/BookmarkService.kt | 18 +- .../blocking/x/BookmarkServiceImpl.kt | 18 +- .../services/blocking/x/CommunityService.kt | 77 +- .../blocking/x/CommunityServiceImpl.kt | 29 +- .../api/services/blocking/x/ListService.kt | 91 +- .../services/blocking/x/ListServiceImpl.kt | 29 +- .../api/services/blocking/x/TweetService.kt | 285 ++-- .../services/blocking/x/TweetServiceImpl.kt | 148 +- .../api/services/blocking/x/UserService.kt | 344 ++--- .../services/blocking/x/UserServiceImpl.kt | 131 +- .../blocking/x/communities/JoinService.kt | 36 +- .../blocking/x/communities/JoinServiceImpl.kt | 19 +- .../blocking/x/communities/TweetService.kt | 90 +- .../x/communities/TweetServiceImpl.kt | 66 +- .../services/blocking/x/tweets/LikeService.kt | 106 ++ .../blocking/x/tweets/LikeServiceImpl.kt | 98 ++ .../blocking/x/tweets/RetweetService.kt | 112 ++ .../blocking/x/tweets/RetweetServiceImpl.kt | 98 ++ .../blocking/x/users/FollowService.kt | 110 ++ .../blocking/x/users/FollowServiceImpl.kt | 98 ++ .../api/core/AutoPagerAsyncTest.kt | 182 +++ .../api/core/AutoPagerTest.kt | 41 + .../api/models/PaginatedTweetsTest.kt | 13 +- .../api/models/PaginatedUsersTest.kt | 7 +- .../models/apikeys/ApiKeyListResponseTest.kt | 6 +- .../models/drafts/DraftCreateResponseTest.kt | 56 - .../models/drafts/DraftListResponseTest.kt | 6 +- .../drafts/DraftRetrieveResponseTest.kt | 56 - .../api/models/draws/DrawListResponseTest.kt | 6 +- .../models/draws/DrawRetrieveResponseTest.kt | 90 +- .../api/models/draws/DrawRunResponseTest.kt | 6 +- .../api/models/events/EventDetailTest.kt | 7 +- .../api/models/events/EventListParamsTest.kt | 5 +- .../models/events/EventListResponseTest.kt | 19 +- .../events/EventRetrieveResponseTest.kt | 72 - .../api/models/events/EventTest.kt | 7 +- .../extractions/ExtractionListResponseTest.kt | 18 +- .../IntegrationCreateParamsTest.kt | 14 +- .../IntegrationCreateResponseTest.kt | 105 -- .../IntegrationListDeliveriesResponseTest.kt | 6 +- .../IntegrationListResponseTest.kt | 37 +- .../IntegrationRetrieveResponseTest.kt | 105 -- .../models/integrations/IntegrationTest.kt | 11 +- .../IntegrationUpdateParamsTest.kt | 13 +- .../IntegrationUpdateResponseTest.kt | 105 -- .../monitors/MonitorCreateParamsTest.kt | 14 +- .../monitors/MonitorCreateResponseTest.kt | 14 +- .../monitors/MonitorListResponseTest.kt | 19 +- .../monitors/MonitorRetrieveResponseTest.kt | 61 - .../api/models/monitors/MonitorTest.kt | 11 +- .../monitors/MonitorUpdateParamsTest.kt | 8 +- .../monitors/MonitorUpdateResponseTest.kt | 61 - ...RadarRetrieveTrendingTopicsResponseTest.kt | 6 +- .../models/styles/StyleAnalyzeResponseTest.kt | 74 - .../models/styles/StyleCompareResponseTest.kt | 24 +- .../models/styles/StyleDeleteParamsTest.kt | 23 + .../styles/StyleGetPerformanceParamsTest.kt | 23 + .../styles/StyleGetPerformanceResponseTest.kt | 75 + .../models/styles/StyleListResponseTest.kt | 6 +- .../models/styles/StyleRetrieveParamsTest.kt | 23 + .../models/styles/StyleUpdateParamsTest.kt | 64 + .../webhooks/WebhookCreateParamsTest.kt | 14 +- .../webhooks/WebhookCreateResponseTest.kt | 14 +- .../WebhookListDeliveriesResponseTest.kt | 6 +- .../webhooks/WebhookListResponseTest.kt | 19 +- .../api/models/webhooks/WebhookTest.kt | 11 +- .../webhooks/WebhookUpdateParamsTest.kt | 13 +- .../webhooks/WebhookUpdateResponseTest.kt | 58 - .../api/models/x/XGetArticleResponseTest.kt | 7 +- .../models/x/XGetHomeTimelineResponseTest.kt | 108 -- .../x/accounts/AccountBulkRetryParamsTest.kt | 13 + .../accounts/AccountBulkRetryResponseTest.kt | 32 + .../x/accounts/AccountListResponseTest.kt | 6 +- .../x/accounts/AccountRetrieveResponseTest.kt | 63 - .../x/bookmarks/BookmarkListResponseTest.kt | 108 -- .../CommunityRetrieveMembersResponseTest.kt | 88 -- ...CommunityRetrieveModeratorsResponseTest.kt | 88 -- .../CommunityRetrieveSearchResponseTest.kt | 109 -- .../join/JoinCreateResponseTest.kt | 41 - .../join/JoinDeleteAllResponseTest.kt | 41 - .../tweets/TweetListByCommunityParamsTest.kt | 42 + .../tweets/TweetListResponseTest.kt | 108 -- .../ListRetrieveFollowersResponseTest.kt | 88 -- .../lists/ListRetrieveMembersResponseTest.kt | 87 -- .../x/lists/ListRetrieveTweetsResponseTest.kt | 108 -- .../models/x/tweets/TweetDeleteParamsTest.kt | 32 + .../x/tweets/TweetDeleteResponseTest.kt | 30 + .../tweets/TweetGetFavoritersResponseTest.kt | 87 -- .../x/tweets/TweetGetQuotesResponseTest.kt | 108 -- .../x/tweets/TweetGetRepliesResponseTest.kt | 108 -- .../tweets/TweetGetRetweetersResponseTest.kt | 87 -- .../x/tweets/TweetGetThreadResponseTest.kt | 108 -- .../models/x/tweets/TweetListResponseTest.kt | 108 -- .../x/tweets/TweetRetrieveParamsTest.kt | 23 + .../x/tweets/TweetRetrieveResponseTest.kt | 170 +++ .../x/tweets/TweetSearchResponseTest.kt | 108 -- .../x/tweets/like/LikeCreateParamsTest.kt | 32 + .../x/tweets/like/LikeCreateResponseTest.kt | 30 + .../x/tweets/like/LikeDeleteParamsTest.kt | 32 + .../x/tweets/like/LikeDeleteResponseTest.kt | 30 + .../tweets/retweet/RetweetCreateParamsTest.kt | 32 + .../retweet/RetweetCreateResponseTest.kt | 30 + .../tweets/retweet/RetweetDeleteParamsTest.kt | 32 + .../retweet/RetweetDeleteResponseTest.kt | 30 + .../x/users/UserRetrieveBatchResponseTest.kt | 87 -- .../UserRetrieveFollowersResponseTest.kt | 88 -- ...serRetrieveFollowersYouKnowResponseTest.kt | 89 -- .../UserRetrieveFollowingResponseTest.kt | 88 -- .../x/users/UserRetrieveLikesResponseTest.kt | 108 -- .../x/users/UserRetrieveMediaResponseTest.kt | 108 -- .../users/UserRetrieveMentionsResponseTest.kt | 108 -- .../models/x/users/UserRetrieveParamsTest.kt | 23 + .../x/users/UserRetrieveSearchResponseTest.kt | 87 -- .../x/users/UserRetrieveTweetsResponseTest.kt | 108 -- ...erRetrieveVerifiedFollowersResponseTest.kt | 89 -- .../x/users/follow/FollowCreateParamsTest.kt | 32 + .../users/follow/FollowCreateResponseTest.kt | 30 + .../users/follow/FollowDeleteAllParamsTest.kt | 32 + .../follow/FollowDeleteAllResponseTest.kt | 30 + .../services/async/DraftServiceAsyncTest.kt | 12 +- .../services/async/EventServiceAsyncTest.kt | 9 +- .../async/IntegrationServiceAsyncTest.kt | 8 +- .../services/async/MonitorServiceAsyncTest.kt | 7 +- .../services/async/StyleServiceAsyncTest.kt | 81 +- .../services/async/WebhookServiceAsyncTest.kt | 8 +- .../api/services/async/XServiceAsyncTest.kt | 6 +- .../async/x/AccountServiceAsyncTest.kt | 22 +- .../async/x/BookmarkServiceAsyncTest.kt | 10 +- .../async/x/CommunityServiceAsyncTest.kt | 18 +- .../services/async/x/ListServiceAsyncTest.kt | 18 +- .../services/async/x/TweetServiceAsyncTest.kt | 79 +- .../services/async/x/UserServiceAsyncTest.kt | 76 +- .../x/communities/JoinServiceAsyncTest.kt | 12 +- .../x/communities/TweetServiceAsyncTest.kt | 25 +- .../async/x/tweets/LikeServiceAsyncTest.kt | 50 + .../async/x/tweets/RetweetServiceAsyncTest.kt | 50 + .../async/x/users/FollowServiceAsyncTest.kt | 50 + .../api/services/blocking/DraftServiceTest.kt | 8 +- .../api/services/blocking/EventServiceTest.kt | 7 +- .../blocking/IntegrationServiceTest.kt | 8 +- .../services/blocking/MonitorServiceTest.kt | 7 +- .../api/services/blocking/StyleServiceTest.kt | 74 +- .../services/blocking/WebhookServiceTest.kt | 8 +- .../api/services/blocking/XServiceTest.kt | 4 +- .../services/blocking/x/AccountServiceTest.kt | 19 +- .../blocking/x/BookmarkServiceTest.kt | 8 +- .../blocking/x/CommunityServiceTest.kt | 12 +- .../services/blocking/x/ListServiceTest.kt | 12 +- .../services/blocking/x/TweetServiceTest.kt | 60 +- .../services/blocking/x/UserServiceTest.kt | 55 +- .../blocking/x/communities/JoinServiceTest.kt | 8 +- .../x/communities/TweetServiceTest.kt | 22 +- .../blocking/x/tweets/LikeServiceTest.kt | 44 + .../blocking/x/tweets/RetweetServiceTest.kt | 48 + .../blocking/x/users/FollowServiceTest.kt | 46 + 326 files changed, 14844 insertions(+), 50763 deletions(-) delete mode 100644 .github/workflows/publish-sonatype.yml delete mode 100644 .github/workflows/release-doctor.yml delete mode 100644 .release-please-manifest.json delete mode 100644 bin/check-release-environment delete mode 100644 release-please-config.json create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPager.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPagerAsync.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Page.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/PageAsync.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt rename x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/{StyleAnalyzeResponse.kt => StyleGetPerformanceResponse.kt} (69%) create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountBulkRetryParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountBulkRetryResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListPage.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListPageAsync.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListByCommunityPage.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListByCommunityPageAsync.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListByCommunityParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListPage.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListPageAsync.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParams.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponse.kt delete mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponse.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParams.kt create mode 100644 x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponse.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/core/AutoPagerAsyncTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/core/AutoPagerTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleRetrieveParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/styles/StyleUpdateParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/webhooks/WebhookUpdateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/XGetHomeTimelineResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountBulkRetryParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountBulkRetryResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/accounts/AccountRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/bookmarks/BookmarkListResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveMembersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveModeratorsResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/CommunityRetrieveSearchResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinCreateResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/join/JoinDeleteAllResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListByCommunityParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/communities/tweets/TweetListResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveFollowersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveMembersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/lists/ListRetrieveTweetsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetDeleteResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetFavoritersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetQuotesResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRepliesResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetRetweetersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetGetThreadResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetListResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetRetrieveResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/TweetSearchResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeCreateResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/like/LikeDeleteResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetCreateResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/tweets/retweet/RetweetDeleteResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveBatchResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowersYouKnowResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveFollowingResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveLikesResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMediaResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveMentionsResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveParamsTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveSearchResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveTweetsResponseTest.kt delete mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/UserRetrieveVerifiedFollowersResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowCreateResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllParamsTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/models/x/users/follow/FollowDeleteAllResponseTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/LikeServiceAsyncTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/tweets/RetweetServiceAsyncTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/async/x/users/FollowServiceAsyncTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/LikeServiceTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/tweets/RetweetServiceTest.kt create mode 100644 x-twitter-scraper-java-core/src/test/kotlin/com/x_twitter_scraper/api/services/blocking/x/users/FollowServiceTest.kt diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml deleted file mode 100644 index 9e634cb..0000000 --- a/.github/workflows/publish-sonatype.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This workflow is triggered when a GitHub release is created. -# It can also be run manually to re-publish to Sonatype in case it failed for some reason. -# You can run this workflow by navigating to https://www.github.com/Xquik-dev/x-twitter-scraper-java/actions/workflows/publish-sonatype.yml -name: Publish Sonatype -on: - workflow_dispatch: - - release: - types: [published] - -jobs: - publish: - name: publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6 - - - name: Set up Java - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: | - 8 - 21 - cache: gradle - - - name: Set up Gradle - uses: gradle/gradle-build-action@v2 - - - name: Publish to Sonatype - run: |- - export -- GPG_SIGNING_KEY_ID - printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" - GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache - env: - SONATYPE_USERNAME: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml deleted file mode 100644 index f0a6dd9..0000000 --- a/.github/workflows/release-doctor.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Release Doctor -on: - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - release_doctor: - name: release doctor - runs-on: ubuntu-latest - if: github.repository == 'Xquik-dev/x-twitter-scraper-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') - - steps: - - uses: actions/checkout@v6 - - - name: Check release environment - run: | - bash ./bin/check-release-environment - env: - SONATYPE_USERNAME: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json deleted file mode 100644 index 10f3091..0000000 --- a/.release-please-manifest.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - ".": "0.2.0" -} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index d99ab81..eec6e85 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -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 +configured_endpoints: 117 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-3a272e3207cc0ecbfc3850635c5608190a5f4fab77368b72074d99617376b5a8.yml +openapi_spec_hash: c5aae119b546e3d97bb2be0cc7688a43 +config_hash: 68f04119c2d782a0125b03e31c3d8369 diff --git a/README.md b/README.md index a0e5e75..551428d 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,18 @@ # X Twitter Scraper Java API Library - - [![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) - - The X Twitter Scraper Java SDK provides convenient access to the [X Twitter Scraper REST API](https://xquik.com) from applications written in Java. The X Twitter Scraper Java SDK is similar to the X Twitter Scraper Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. It is generated with [Stainless](https://www.stainless.com/). - - The REST API documentation can be found on [xquik.com](https://xquik.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0). - - ## Installation - - ### Gradle ```kotlin @@ -39,8 +29,6 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0") ``` - - ## Requirements This library requires Java 8 or later. @@ -50,8 +38,8 @@ This library requires Java 8 or later. ```java import com.x_twitter_scraper.api.client.XTwitterScraperClient; import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient; +import com.x_twitter_scraper.api.models.PaginatedTweets; import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams; -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; // Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties // Or configures using the `X_TWITTER_SCRAPER_API_KEY`, `X_TWITTER_SCRAPER_BEARER_TOKEN` and `X_TWITTER_SCRAPER_BASE_URL` environment variables @@ -61,7 +49,7 @@ TweetSearchParams params = TweetSearchParams.builder() .q("from:elonmusk") .limit(10L) .build(); -TweetSearchResponse response = client.x().tweets().search(params); +PaginatedTweets paginatedTweets = client.x().tweets().search(params); ``` ## Client configuration @@ -136,7 +124,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the X Twitter Scraper API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `TweetSearchResponse`. +For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `PaginatedTweets`. ## Immutability @@ -153,8 +141,8 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.x_twitter_scraper.api.client.XTwitterScraperClient; import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient; +import com.x_twitter_scraper.api.models.PaginatedTweets; import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams; -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; import java.util.concurrent.CompletableFuture; // Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties @@ -165,7 +153,7 @@ TweetSearchParams params = TweetSearchParams.builder() .q("from:elonmusk") .limit(10L) .build(); -CompletableFuture response = client.async().x().tweets().search(params); +CompletableFuture paginatedTweets = client.async().x().tweets().search(params); ``` Or create an asynchronous client from the beginning: @@ -173,8 +161,8 @@ Or create an asynchronous client from the beginning: ```java import com.x_twitter_scraper.api.client.XTwitterScraperClientAsync; import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync; +import com.x_twitter_scraper.api.models.PaginatedTweets; import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams; -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; import java.util.concurrent.CompletableFuture; // Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties @@ -185,7 +173,7 @@ TweetSearchParams params = TweetSearchParams.builder() .q("from:elonmusk") .limit(10L) .build(); -CompletableFuture response = client.x().tweets().search(params); +CompletableFuture paginatedTweets = client.x().tweets().search(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -311,25 +299,25 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import com.x_twitter_scraper.api.core.http.Headers; import com.x_twitter_scraper.api.core.http.HttpResponseFor; +import com.x_twitter_scraper.api.models.PaginatedTweets; import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams; -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; TweetSearchParams params = TweetSearchParams.builder() .q("from:elonmusk") .limit(10L) .build(); -HttpResponseFor response = client.x().tweets().withRawResponse().search(params); +HttpResponseFor paginatedTweets = client.x().tweets().withRawResponse().search(params); -int statusCode = response.statusCode(); -Headers headers = response.headers(); +int statusCode = paginatedTweets.statusCode(); +Headers headers = paginatedTweets.headers(); ``` You can still deserialize the response into an instance of a Java class if needed: ```java -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; +import com.x_twitter_scraper.api.models.PaginatedTweets; -TweetSearchResponse parsedResponse = response.parse(); +PaginatedTweets parsedPaginatedTweets = paginatedTweets.parse(); ``` ## Error handling @@ -357,6 +345,106 @@ The SDK throws custom unchecked exception types: - [`XTwitterScraperException`](x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/errors/XTwitterScraperException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. +## Pagination + +The SDK defines methods that return a paginated lists of results. It provides convenient ways to access the results either one page at a time or item-by-item across all pages. + +### Auto-pagination + +To iterate through all results across all pages, use the `autoPager()` method, which automatically fetches more pages as needed. + +When using the synchronous client, the method returns an [`Iterable`](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html) + +```java +import com.x_twitter_scraper.api.models.PaginatedTweets; +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListPage; + +TweetListPage page = client.x().communities().tweets().list(params); + +// Process as an Iterable +for (PaginatedTweets tweet : page.autoPager()) { + System.out.println(tweet); +} + +// Process as a Stream +page.autoPager() + .stream() + .limit(50) + .forEach(tweet -> System.out.println(tweet)); +``` + +When using the asynchronous client, the method returns an [`AsyncStreamResponse`](x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/http/AsyncStreamResponse.kt): + +```java +import com.x_twitter_scraper.api.core.http.AsyncStreamResponse; +import com.x_twitter_scraper.api.models.PaginatedTweets; +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListPageAsync; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +CompletableFuture pageFuture = client.async().x().communities().tweets().list(params); + +pageFuture.thenRun(page -> page.autoPager().subscribe(tweet -> { + System.out.println(tweet); +})); + +// If you need to handle errors or completion of the stream +pageFuture.thenRun(page -> page.autoPager().subscribe(new AsyncStreamResponse.Handler<>() { + @Override + public void onNext(PaginatedTweets tweet) { + System.out.println(tweet); + } + + @Override + public void onComplete(Optional error) { + if (error.isPresent()) { + System.out.println("Something went wrong!"); + throw new RuntimeException(error.get()); + } else { + System.out.println("No more!"); + } + } +})); + +// Or use futures +pageFuture.thenRun(page -> page.autoPager() + .subscribe(tweet -> { + System.out.println(tweet); + }) + .onCompleteFuture() + .whenComplete((unused, error) -> { + if (error != null) { + System.out.println("Something went wrong!"); + throw new RuntimeException(error); + } else { + System.out.println("No more!"); + } + })); +``` + +### Manual pagination + +To access individual page items and manually request the next page, use the `items()`, +`hasNextPage()`, and `nextPage()` methods: + +```java +import com.x_twitter_scraper.api.models.PaginatedTweets; +import com.x_twitter_scraper.api.models.x.communities.tweets.TweetListPage; + +TweetListPage page = client.x().communities().tweets().list(params); +while (true) { + for (PaginatedTweets tweet : page.items()) { + System.out.println(tweet); + } + + if (!page.hasNextPage()) { + break; + } + + page = page.nextPage(); +} +``` + ## Logging The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). @@ -427,9 +515,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; +import com.x_twitter_scraper.api.models.PaginatedTweets; -TweetSearchResponse response = client.x().tweets().search( +PaginatedTweets paginatedTweets = client.x().tweets().search( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -705,17 +793,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`XT If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; +import com.x_twitter_scraper.api.models.PaginatedTweets; -TweetSearchResponse response = client.x().tweets().search(params).validate(); +PaginatedTweets paginatedTweets = client.x().tweets().search(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse; +import com.x_twitter_scraper.api.models.PaginatedTweets; -TweetSearchResponse response = client.x().tweets().search( +PaginatedTweets paginatedTweets = client.x().tweets().search( params, RequestOptions.builder().responseValidation(true).build() ); ``` @@ -770,4 +858,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/Xquik-dev/x-twitter-scraper-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/x-twitter-scraper-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment deleted file mode 100644 index 3a6a7b4..0000000 --- a/bin/check-release-environment +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -errors=() - -if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") -fi - -lenErrors=${#errors[@]} - -if [[ lenErrors -gt 0 ]]; then - echo -e "Found the following errors in the release environment:\n" - - for error in "${errors[@]}"; do - echo -e "- $error\n" - done - - exit 1 -fi - -echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 81f4172..6ee8a1b 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.2.0" } 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 c59ccf8..dc82684 100644 --- a/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/x-twitter-scraper.publish.gradle.kts @@ -60,9 +60,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git") - developerConnection.set("scm:git:git://github.com/Xquik-dev/x-twitter-scraper-java.git") - url.set("https://github.com/Xquik-dev/x-twitter-scraper-java") + connection.set("scm:git:git://github.com/stainless-sdks/x-twitter-scraper-java.git") + developerConnection.set("scm:git:git://github.com/stainless-sdks/x-twitter-scraper-java.git") + url.set("https://github.com/stainless-sdks/x-twitter-scraper-java") } } } diff --git a/release-please-config.json b/release-please-config.json deleted file mode 100644 index 8f98719..0000000 --- a/release-please-config.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "packages": { - ".": {} - }, - "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", - "include-v-in-tag": true, - "include-component-in-tag": false, - "versioning": "prerelease", - "prerelease": true, - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": false, - "pull-request-header": "Automated Release PR", - "pull-request-title-pattern": "release: ${version}", - "changelog-sections": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "perf", - "section": "Performance Improvements" - }, - { - "type": "revert", - "section": "Reverts" - }, - { - "type": "chore", - "section": "Chores" - }, - { - "type": "docs", - "section": "Documentation" - }, - { - "type": "style", - "section": "Styles" - }, - { - "type": "refactor", - "section": "Refactors" - }, - { - "type": "test", - "section": "Tests", - "hidden": true - }, - { - "type": "build", - "section": "Build System" - }, - { - "type": "ci", - "section": "Continuous Integration", - "hidden": true - } - ], - "release-type": "simple", - "extra-files": [ - "README.md", - "build.gradle.kts" - ] -} \ No newline at end of file diff --git a/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClient.kt b/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClient.kt index a34145b..4798105 100644 --- a/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClient.kt +++ b/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClient.kt @@ -8,6 +8,7 @@ import com.x_twitter_scraper.api.client.XTwitterScraperClientImpl import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.Sleeper import com.x_twitter_scraper.api.core.Timeout +import com.x_twitter_scraper.api.core.http.AsyncStreamResponse import com.x_twitter_scraper.api.core.http.Headers import com.x_twitter_scraper.api.core.http.HttpClient import com.x_twitter_scraper.api.core.http.QueryParams @@ -16,6 +17,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.Executor import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -184,6 +186,17 @@ class XTwitterScraperOkHttpClient private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The executor to use for running [AsyncStreamResponse.Handler] callbacks. + * + * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. + */ + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + clientOptions.streamHandlerExecutor(streamHandlerExecutor) + } + /** * The interface to use for delaying execution, like during retries. * diff --git a/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClientAsync.kt b/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClientAsync.kt index adf8bb1..d002629 100644 --- a/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClientAsync.kt +++ b/x-twitter-scraper-java-client-okhttp/src/main/kotlin/com/x_twitter_scraper/api/client/okhttp/XTwitterScraperOkHttpClientAsync.kt @@ -8,6 +8,7 @@ import com.x_twitter_scraper.api.client.XTwitterScraperClientAsyncImpl import com.x_twitter_scraper.api.core.ClientOptions import com.x_twitter_scraper.api.core.Sleeper import com.x_twitter_scraper.api.core.Timeout +import com.x_twitter_scraper.api.core.http.AsyncStreamResponse import com.x_twitter_scraper.api.core.http.Headers import com.x_twitter_scraper.api.core.http.HttpClient import com.x_twitter_scraper.api.core.http.QueryParams @@ -16,6 +17,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.Executor import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -186,6 +188,17 @@ class XTwitterScraperOkHttpClientAsync private constructor() { */ fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + /** + * The executor to use for running [AsyncStreamResponse.Handler] callbacks. + * + * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. + */ + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + clientOptions.streamHandlerExecutor(streamHandlerExecutor) + } + /** * The interface to use for delaying execution, like during retries. * diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPager.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPager.kt new file mode 100644 index 0000000..ad6650a --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPager.kt @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.core + +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class AutoPager private constructor(private val firstPage: Page) : Iterable { + + companion object { + + fun from(firstPage: Page): AutoPager = AutoPager(firstPage) + } + + override fun iterator(): Iterator = + generateSequence(firstPage) { if (it.hasNextPage()) it.nextPage() else null } + .flatMap { it.items() } + .iterator() + + fun stream(): Stream = StreamSupport.stream(spliterator(), false) +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPagerAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPagerAsync.kt new file mode 100644 index 0000000..2c1c7b5 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/AutoPagerAsync.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.core + +import com.x_twitter_scraper.api.core.http.AsyncStreamResponse +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletionException +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +class AutoPagerAsync +private constructor(private val firstPage: PageAsync, private val defaultExecutor: Executor) : + AsyncStreamResponse { + + companion object { + + fun from(firstPage: PageAsync, defaultExecutor: Executor): AutoPagerAsync = + AutoPagerAsync(firstPage, defaultExecutor) + } + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + override fun subscribe(handler: AsyncStreamResponse.Handler): AsyncStreamResponse = + subscribe(handler, defaultExecutor) + + override fun subscribe( + handler: AsyncStreamResponse.Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + fun PageAsync.handle(): CompletableFuture { + if (state.get() == State.CLOSED) { + return CompletableFuture.completedFuture(null) + } + + items().forEach { handler.onNext(it) } + return if (hasNextPage()) nextPage().thenCompose { it.handle() } + else CompletableFuture.completedFuture(null) + } + + executor.execute { + firstPage.handle().whenComplete { _, error -> + val actualError = + if (error is CompletionException && error.cause != null) error.cause else error + try { + handler.onComplete(Optional.ofNullable(actualError)) + } finally { + try { + if (actualError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(actualError) + } + } finally { + close() + } + } + } + } + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } +} + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Check.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Check.kt index ac0d703..02a38c9 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Check.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/Xquik-dev/x-twitter-scraper-java#jackson for more information. +See https://www.github.com/stainless-sdks/x-twitter-scraper-java#jackson for more information. """ .trimIndent() } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/ClientOptions.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/ClientOptions.kt index a049f9e..4a08a94 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/ClientOptions.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/ClientOptions.kt @@ -3,6 +3,7 @@ package com.x_twitter_scraper.api.core import com.fasterxml.jackson.databind.json.JsonMapper +import com.x_twitter_scraper.api.core.http.AsyncStreamResponse import com.x_twitter_scraper.api.core.http.Headers import com.x_twitter_scraper.api.core.http.HttpClient import com.x_twitter_scraper.api.core.http.PhantomReachableClosingHttpClient @@ -11,6 +12,11 @@ import com.x_twitter_scraper.api.core.http.RetryingHttpClient import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.ThreadFactory +import java.util.concurrent.atomic.AtomicLong import kotlin.jvm.optionals.getOrNull /** A class representing the SDK client configuration. */ @@ -40,6 +46,14 @@ private constructor( * and rarely needs to be overridden. */ @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The executor to use for running [AsyncStreamResponse.Handler] callbacks. + * + * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. + */ + @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, /** * The interface to use for delaying execution, like during retries. * @@ -145,6 +159,7 @@ private constructor( private var httpClient: HttpClient? = null private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() + private var streamHandlerExecutor: Executor? = null private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null @@ -161,6 +176,7 @@ private constructor( httpClient = clientOptions.originalHttpClient checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper + streamHandlerExecutor = clientOptions.streamHandlerExecutor sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl @@ -203,6 +219,20 @@ private constructor( */ fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + /** + * The executor to use for running [AsyncStreamResponse.Handler] callbacks. + * + * Defaults to a dedicated cached thread pool. + * + * This class takes ownership of the executor and shuts it down, if possible, when closed. + */ + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = + if (streamHandlerExecutor is ExecutorService) + PhantomReachableExecutorService(streamHandlerExecutor) + else streamHandlerExecutor + } + /** * The interface to use for delaying execution, like during retries. * @@ -409,6 +439,24 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val streamHandlerExecutor = + streamHandlerExecutor + ?: PhantomReachableExecutorService( + Executors.newCachedThreadPool( + object : ThreadFactory { + + private val threadFactory: ThreadFactory = + Executors.defaultThreadFactory() + private val count = AtomicLong(0) + + override fun newThread(runnable: Runnable): Thread = + threadFactory.newThread(runnable).also { + it.name = + "x-twitter-scraper-stream-handler-thread-${count.getAndIncrement()}" + } + } + ) + ) val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val headers = Headers.builder() @@ -435,6 +483,7 @@ private constructor( .build(), checkJacksonVersionCompatibility, jsonMapper, + streamHandlerExecutor, sleeper, clock, baseUrl, @@ -461,6 +510,7 @@ private constructor( */ fun close() { httpClient.close() + (streamHandlerExecutor as? ExecutorService)?.shutdown() sleeper.close() } diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Page.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Page.kt new file mode 100644 index 0000000..fced237 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/Page.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.core + +/** + * An interface representing a single page, with items of type [T], from a paginated endpoint + * response. + * + * Implementations of this interface are expected to request additional pages synchronously. For + * asynchronous pagination, see the [PageAsync] interface. + */ +interface Page { + + /** + * Returns whether there's another page after this one. + * + * The method generally doesn't make requests so the result depends entirely on the data in this + * page. If a significant amount of time has passed between requesting this page and calling + * this method, then the result could be stale. + */ + fun hasNextPage(): Boolean + + /** + * Returns the page after this one by making another request. + * + * @throws IllegalStateException if it's impossible to get the next page. This exception is + * avoidable by calling [hasNextPage] first. + */ + fun nextPage(): Page + + /** Returns the items in this page. */ + fun items(): List +} diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/PageAsync.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/PageAsync.kt new file mode 100644 index 0000000..5c27af5 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/core/PageAsync.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.x_twitter_scraper.api.core + +import java.util.concurrent.CompletableFuture + +/** + * An interface representing a single page, with items of type [T], from a paginated endpoint + * response. + * + * Implementations of this interface are expected to request additional pages asynchronously. For + * synchronous pagination, see the [Page] interface. + */ +interface PageAsync { + + /** + * Returns whether there's another page after this one. + * + * The method generally doesn't make requests so the result depends entirely on the data in this + * page. If a significant amount of time has passed between requesting this page and calling + * this method, then the result could be stale. + */ + fun hasNextPage(): Boolean + + /** + * Returns the page after this one by making another request. + * + * @throws IllegalStateException if it's impossible to get the next page. This exception is + * avoidable by calling [hasNextPage] first. + */ + fun nextPage(): CompletableFuture> + + /** Returns the items in this page. */ + fun items(): List +} 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 80222dd..2817a3e 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedTweets.kt @@ -14,9 +14,9 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.x.tweets.SearchTweet import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Paginated list of tweets with cursor-based navigation. */ @@ -25,7 +25,7 @@ class PaginatedTweets private constructor( private val hasNextPage: JsonField, private val nextCursor: JsonField, - private val tweets: JsonField>, + private val tweets: JsonField>, private val additionalProperties: MutableMap, ) { @@ -37,7 +37,9 @@ private constructor( @JsonProperty("next_cursor") @ExcludeMissing nextCursor: JsonField = JsonMissing.of(), - @JsonProperty("tweets") @ExcludeMissing tweets: JsonField> = JsonMissing.of(), + @JsonProperty("tweets") + @ExcludeMissing + tweets: JsonField> = JsonMissing.of(), ) : this(hasNextPage, nextCursor, tweets, mutableMapOf()) /** @@ -56,7 +58,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun tweets(): List = tweets.getRequired("tweets") + fun tweets(): List = tweets.getRequired("tweets") /** * Returns the raw JSON value of [hasNextPage]. @@ -79,7 +81,7 @@ private constructor( * * Unlike [tweets], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets + @JsonProperty("tweets") @ExcludeMissing fun _tweets(): JsonField> = tweets @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -113,7 +115,7 @@ private constructor( private var hasNextPage: JsonField? = null private var nextCursor: JsonField? = null - private var tweets: JsonField>? = null + private var tweets: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -146,25 +148,25 @@ private constructor( */ fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } - fun tweets(tweets: List) = tweets(JsonField.of(tweets)) + fun tweets(tweets: List) = tweets(JsonField.of(tweets)) /** * Sets [Builder.tweets] to an arbitrary JSON value. * - * You should usually call [Builder.tweets] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.tweets] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun tweets(tweets: JsonField>) = apply { + fun tweets(tweets: JsonField>) = apply { this.tweets = tweets.map { it.toMutableList() } } /** - * Adds a single [Tweet] to [tweets]. + * Adds a single [SearchTweet] to [tweets]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addTweet(tweet: Tweet) = apply { + fun addTweet(tweet: SearchTweet) = apply { tweets = (tweets ?: JsonField.of(mutableListOf())).also { checkKnown("tweets", it).add(tweet) @@ -245,820 +247,6 @@ 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( - 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 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 7d6465f..f7a0acf 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/PaginatedUsers.kt @@ -14,9 +14,9 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.x.users.UserProfile import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Paginated list of user profiles with cursor-based navigation. */ @@ -25,7 +25,7 @@ class PaginatedUsers private constructor( private val hasNextPage: JsonField, private val nextCursor: JsonField, - private val users: JsonField>, + private val users: JsonField>, private val additionalProperties: MutableMap, ) { @@ -37,7 +37,9 @@ private constructor( @JsonProperty("next_cursor") @ExcludeMissing nextCursor: JsonField = JsonMissing.of(), - @JsonProperty("users") @ExcludeMissing users: JsonField> = JsonMissing.of(), + @JsonProperty("users") + @ExcludeMissing + users: JsonField> = JsonMissing.of(), ) : this(hasNextPage, nextCursor, users, mutableMapOf()) /** @@ -56,7 +58,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun users(): List = users.getRequired("users") + fun users(): List = users.getRequired("users") /** * Returns the raw JSON value of [hasNextPage]. @@ -79,7 +81,7 @@ private constructor( * * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users + @JsonProperty("users") @ExcludeMissing fun _users(): JsonField> = users @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -113,7 +115,7 @@ private constructor( private var hasNextPage: JsonField? = null private var nextCursor: JsonField? = null - private var users: JsonField>? = null + private var users: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -146,25 +148,25 @@ private constructor( */ fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } - fun users(users: List) = users(JsonField.of(users)) + fun users(users: List) = users(JsonField.of(users)) /** * Sets [Builder.users] to an arbitrary JSON value. * - * You should usually call [Builder.users] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.users] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun users(users: JsonField>) = apply { + fun users(users: JsonField>) = apply { this.users = users.map { it.toMutableList() } } /** - * Adds a single [User] to [users]. + * Adds a single [UserProfile] to [users]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addUser(user: User) = apply { + fun addUser(user: UserProfile) = apply { users = (users ?: JsonField.of(mutableListOf())).also { checkKnown("users", it).add(user) } } @@ -243,553 +245,6 @@ 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( - private val id: JsonField, - private val name: JsonField, - private val username: JsonField, - private val createdAt: JsonField, - private val description: JsonField, - private val followers: JsonField, - private val following: JsonField, - private val location: JsonField, - private val profilePicture: JsonField, - private val statusesCount: JsonField, - private val verified: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("username") - @ExcludeMissing - username: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("followers") - @ExcludeMissing - followers: JsonField = JsonMissing.of(), - @JsonProperty("following") - @ExcludeMissing - following: JsonField = JsonMissing.of(), - @JsonProperty("location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("profilePicture") - @ExcludeMissing - profilePicture: JsonField = JsonMissing.of(), - @JsonProperty("statusesCount") - @ExcludeMissing - statusesCount: JsonField = JsonMissing.of(), - @JsonProperty("verified") - @ExcludeMissing - verified: JsonField = JsonMissing.of(), - ) : this( - id, - name, - username, - createdAt, - description, - followers, - following, - location, - profilePicture, - statusesCount, - verified, - mutableMapOf(), - ) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun username(): String = username.getRequired("username") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): Optional = createdAt.getOptional("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun followers(): Optional = followers.getOptional("followers") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun following(): Optional = following.getOptional("following") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("location") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun profilePicture(): Optional = profilePicture.getOptional("profilePicture") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun statusesCount(): Optional = statusesCount.getOptional("statusesCount") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun verified(): Optional = verified.getOptional("verified") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [followers]. - * - * Unlike [followers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("followers") @ExcludeMissing fun _followers(): JsonField = followers - - /** - * Returns the raw JSON value of [following]. - * - * Unlike [following], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("following") @ExcludeMissing fun _following(): JsonField = following - - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location - - /** - * Returns the raw JSON value of [profilePicture]. - * - * Unlike [profilePicture], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("profilePicture") - @ExcludeMissing - fun _profilePicture(): JsonField = profilePicture - - /** - * Returns the raw JSON value of [statusesCount]. - * - * Unlike [statusesCount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("statusesCount") - @ExcludeMissing - fun _statusesCount(): JsonField = statusesCount - - /** - * Returns the raw JSON value of [verified]. - * - * Unlike [verified], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("verified") @ExcludeMissing fun _verified(): JsonField = verified - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [User]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [User]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var username: JsonField? = null - private var createdAt: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var followers: JsonField = JsonMissing.of() - private var following: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var profilePicture: JsonField = JsonMissing.of() - private var statusesCount: JsonField = JsonMissing.of() - private var verified: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(user: User) = apply { - id = user.id - name = user.name - username = user.username - createdAt = user.createdAt - description = user.description - followers = user.followers - following = user.following - location = user.location - profilePicture = user.profilePicture - statusesCount = user.statusesCount - verified = user.verified - additionalProperties = user.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun username(username: String) = username(JsonField.of(username)) - - /** - * Sets [Builder.username] to an arbitrary JSON value. - * - * You should usually call [Builder.username] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun username(username: JsonField) = apply { this.username = username } - - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - fun description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - fun followers(followers: Long) = followers(JsonField.of(followers)) - - /** - * Sets [Builder.followers] to an arbitrary JSON value. - * - * You should usually call [Builder.followers] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun followers(followers: JsonField) = apply { this.followers = followers } - - fun following(following: Long) = following(JsonField.of(following)) - - /** - * Sets [Builder.following] to an arbitrary JSON value. - * - * You should usually call [Builder.following] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun following(following: JsonField) = apply { this.following = following } - - fun location(location: String) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON value. - * - * You should usually call [Builder.location] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun location(location: JsonField) = apply { this.location = location } - - fun profilePicture(profilePicture: String) = - profilePicture(JsonField.of(profilePicture)) - - /** - * Sets [Builder.profilePicture] to an arbitrary JSON value. - * - * You should usually call [Builder.profilePicture] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun profilePicture(profilePicture: JsonField) = apply { - this.profilePicture = profilePicture - } - - fun statusesCount(statusesCount: Long) = statusesCount(JsonField.of(statusesCount)) - - /** - * Sets [Builder.statusesCount] to an arbitrary JSON value. - * - * You should usually call [Builder.statusesCount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun statusesCount(statusesCount: JsonField) = apply { - this.statusesCount = statusesCount - } - - fun verified(verified: Boolean) = verified(JsonField.of(verified)) - - /** - * Sets [Builder.verified] to an arbitrary JSON value. - * - * You should usually call [Builder.verified] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun verified(verified: JsonField) = apply { this.verified = verified } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [User]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * .username() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): User = - User( - checkRequired("id", id), - checkRequired("name", name), - checkRequired("username", username), - createdAt, - description, - followers, - following, - location, - profilePicture, - statusesCount, - verified, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): User = apply { - if (validated) { - return@apply - } - - id() - name() - username() - createdAt() - description() - followers() - following() - location() - profilePicture() - statusesCount() - verified() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: XTwitterScraperInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (username.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (followers.asKnown().isPresent) 1 else 0) + - (if (following.asKnown().isPresent) 1 else 0) + - (if (location.asKnown().isPresent) 1 else 0) + - (if (profilePicture.asKnown().isPresent) 1 else 0) + - (if (statusesCount.asKnown().isPresent) 1 else 0) + - (if (verified.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - id == other.id && - name == other.name && - username == other.username && - createdAt == other.createdAt && - description == other.description && - followers == other.followers && - following == other.following && - location == other.location && - profilePicture == other.profilePicture && - statusesCount == other.statusesCount && - verified == other.verified && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - name, - username, - createdAt, - description, - followers, - following, - location, - profilePicture, - statusesCount, - verified, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "User{id=$id, name=$name, username=$username, createdAt=$createdAt, description=$description, followers=$followers, following=$following, location=$location, profilePicture=$profilePicture, statusesCount=$statusesCount, verified=$verified, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt index edd6128..dc1a8f1 100644 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/apikeys/ApiKeyListResponse.kt @@ -14,36 +14,34 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException -import java.time.OffsetDateTime import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull class ApiKeyListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val keys: JsonField>, + private val keys: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("keys") @ExcludeMissing keys: JsonField> = JsonMissing.of() + @JsonProperty("keys") @ExcludeMissing keys: JsonField> = JsonMissing.of() ) : this(keys, mutableMapOf()) /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun keys(): List = keys.getRequired("keys") + fun keys(): List = keys.getRequired("keys") /** * Returns the raw JSON value of [keys]. * * Unlike [keys], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("keys") @ExcludeMissing fun _keys(): JsonField> = keys + @JsonProperty("keys") @ExcludeMissing fun _keys(): JsonField> = keys @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -73,7 +71,7 @@ private constructor( /** A builder for [ApiKeyListResponse]. */ class Builder internal constructor() { - private var keys: JsonField>? = null + private var keys: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -82,22 +80,25 @@ private constructor( additionalProperties = apiKeyListResponse.additionalProperties.toMutableMap() } - fun keys(keys: List) = keys(JsonField.of(keys)) + fun keys(keys: List) = keys(JsonField.of(keys)) /** * Sets [Builder.keys] to an arbitrary JSON value. * - * You should usually call [Builder.keys] with a well-typed `List` value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.keys] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun keys(keys: JsonField>) = apply { this.keys = keys.map { it.toMutableList() } } + fun keys(keys: JsonField>) = apply { + this.keys = keys.map { it.toMutableList() } + } /** - * Adds a single [Key] to [keys]. + * Adds a single [ApiKey] to [keys]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addKey(key: Key) = apply { + fun addKey(key: ApiKey) = apply { keys = (keys ?: JsonField.of(mutableListOf())).also { checkKnown("keys", it).add(key) } } @@ -167,354 +168,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val isActive: JsonField, - private val name: JsonField, - private val prefix: JsonField, - private val lastUsedAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("isActive") - @ExcludeMissing - isActive: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("prefix") @ExcludeMissing prefix: JsonField = JsonMissing.of(), - @JsonProperty("lastUsedAt") - @ExcludeMissing - lastUsedAt: JsonField = JsonMissing.of(), - ) : this(id, createdAt, isActive, name, prefix, lastUsedAt, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun prefix(): String = prefix.getRequired("prefix") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun lastUsedAt(): Optional = lastUsedAt.getOptional("lastUsedAt") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * 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 [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [prefix]. - * - * Unlike [prefix], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("prefix") @ExcludeMissing fun _prefix(): JsonField = prefix - - /** - * Returns the raw JSON value of [lastUsedAt]. - * - * Unlike [lastUsedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lastUsedAt") - @ExcludeMissing - fun _lastUsedAt(): JsonField = lastUsedAt - - @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 [Key]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .isActive() - * .name() - * .prefix() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Key]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var isActive: JsonField? = null - private var name: JsonField? = null - private var prefix: JsonField? = null - private var lastUsedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(key: Key) = apply { - id = key.id - createdAt = key.createdAt - isActive = key.isActive - name = key.name - prefix = key.prefix - lastUsedAt = key.lastUsedAt - additionalProperties = key.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 prefix(prefix: String) = prefix(JsonField.of(prefix)) - - /** - * Sets [Builder.prefix] to an arbitrary JSON value. - * - * You should usually call [Builder.prefix] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun prefix(prefix: JsonField) = apply { this.prefix = prefix } - - fun lastUsedAt(lastUsedAt: OffsetDateTime) = lastUsedAt(JsonField.of(lastUsedAt)) - - /** - * Sets [Builder.lastUsedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.lastUsedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lastUsedAt(lastUsedAt: JsonField) = apply { - this.lastUsedAt = lastUsedAt - } - - 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 [Key]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .isActive() - * .name() - * .prefix() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Key = - Key( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("isActive", isActive), - checkRequired("name", name), - checkRequired("prefix", prefix), - lastUsedAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Key = apply { - if (validated) { - return@apply - } - - id() - createdAt() - isActive() - name() - prefix() - lastUsedAt() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (prefix.asKnown().isPresent) 1 else 0) + - (if (lastUsedAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Key && - id == other.id && - createdAt == other.createdAt && - isActive == other.isActive && - name == other.name && - prefix == other.prefix && - lastUsedAt == other.lastUsedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, isActive, name, prefix, lastUsedAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Key{id=$id, createdAt=$createdAt, isActive=$isActive, name=$name, prefix=$prefix, lastUsedAt=$lastUsedAt, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt deleted file mode 100644 index db3edc3..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftCreateResponse.kt +++ /dev/null @@ -1,348 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.drafts - -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.time.OffsetDateTime -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( - private val id: JsonField, - private val createdAt: JsonField, - private val text: JsonField, - private val updatedAt: JsonField, - private val goal: JsonField, - private val topic: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("updatedAt") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("goal") @ExcludeMissing goal: JsonField = JsonMissing.of(), - @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of(), - ) : this(id, createdAt, text, updatedAt, goal, topic, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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). - */ - fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updatedAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun goal(): Optional = goal.getOptional("goal") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun topic(): Optional = topic.getOptional("topic") - - /** - * 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 [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 [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 [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updatedAt") - @ExcludeMissing - fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [goal]. - * - * Unlike [goal], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("goal") @ExcludeMissing fun _goal(): JsonField = goal - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic - - @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 [DraftCreateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * .updatedAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var text: JsonField? = null - private var updatedAt: JsonField? = null - private var goal: JsonField = JsonMissing.of() - private var topic: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftCreateResponse: DraftCreateResponse) = apply { - id = draftCreateResponse.id - createdAt = draftCreateResponse.createdAt - text = draftCreateResponse.text - updatedAt = draftCreateResponse.updatedAt - goal = draftCreateResponse.goal - topic = draftCreateResponse.topic - additionalProperties = draftCreateResponse.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 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 updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - fun goal(goal: String) = goal(JsonField.of(goal)) - - /** - * Sets [Builder.goal] to an arbitrary JSON value. - * - * You should usually call [Builder.goal] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun goal(goal: JsonField) = apply { this.goal = goal } - - fun topic(topic: String) = topic(JsonField.of(topic)) - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun topic(topic: JsonField) = apply { this.topic = topic } - - 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 [DraftCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * .updatedAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftCreateResponse = - DraftCreateResponse( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("text", text), - checkRequired("updatedAt", updatedAt), - goal, - topic, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftCreateResponse = apply { - if (validated) { - return@apply - } - - id() - createdAt() - text() - updatedAt() - goal() - topic() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (text.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (goal.asKnown().isPresent) 1 else 0) + - (if (topic.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftCreateResponse && - id == other.id && - createdAt == other.createdAt && - text == other.text && - updatedAt == other.updatedAt && - goal == other.goal && - topic == other.topic && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, text, updatedAt, goal, topic, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftCreateResponse{id=$id, createdAt=$createdAt, text=$text, updatedAt=$updatedAt, goal=$goal, topic=$topic, additionalProperties=$additionalProperties}" -} 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 95098f6..ee471eb 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 @@ -14,7 +14,6 @@ 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 @@ -236,308 +235,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val text: JsonField, - private val goal: JsonField, - private val topic: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("goal") @ExcludeMissing goal: JsonField = JsonMissing.of(), - @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of(), - ) : this(id, createdAt, text, goal, topic, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun 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 goal(): Optional = goal.getOptional("goal") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun topic(): Optional = topic.getOptional("topic") - - /** - * 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 [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 [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 [goal]. - * - * Unlike [goal], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("goal") @ExcludeMissing fun _goal(): JsonField = goal - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic - - @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 [Draft]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Draft]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var text: JsonField? = null - private var goal: JsonField = JsonMissing.of() - private var topic: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draft: Draft) = apply { - id = draft.id - createdAt = draft.createdAt - text = draft.text - goal = draft.goal - topic = draft.topic - additionalProperties = draft.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 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 goal(goal: String) = goal(JsonField.of(goal)) - - /** - * Sets [Builder.goal] to an arbitrary JSON value. - * - * You should usually call [Builder.goal] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun goal(goal: JsonField) = apply { this.goal = goal } - - fun topic(topic: String) = topic(JsonField.of(topic)) - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun topic(topic: JsonField) = apply { this.topic = topic } - - 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 [Draft]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Draft = - Draft( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("text", text), - goal, - topic, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Draft = apply { - if (validated) { - return@apply - } - - id() - createdAt() - text() - goal() - topic() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (text.asKnown().isPresent) 1 else 0) + - (if (goal.asKnown().isPresent) 1 else 0) + - (if (topic.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Draft && - id == other.id && - createdAt == other.createdAt && - text == other.text && - goal == other.goal && - topic == other.topic && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, text, goal, topic, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Draft{id=$id, createdAt=$createdAt, text=$text, goal=$goal, topic=$topic, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt deleted file mode 100644 index 23e4330..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/drafts/DraftRetrieveResponse.kt +++ /dev/null @@ -1,348 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.drafts - -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.time.OffsetDateTime -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( - private val id: JsonField, - private val createdAt: JsonField, - private val text: JsonField, - private val updatedAt: JsonField, - private val goal: JsonField, - private val topic: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("updatedAt") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("goal") @ExcludeMissing goal: JsonField = JsonMissing.of(), - @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of(), - ) : this(id, createdAt, text, updatedAt, goal, topic, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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). - */ - fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updatedAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun goal(): Optional = goal.getOptional("goal") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun topic(): Optional = topic.getOptional("topic") - - /** - * 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 [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 [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 [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updatedAt") - @ExcludeMissing - fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [goal]. - * - * Unlike [goal], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("goal") @ExcludeMissing fun _goal(): JsonField = goal - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic - - @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 [DraftRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * .updatedAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftRetrieveResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var text: JsonField? = null - private var updatedAt: JsonField? = null - private var goal: JsonField = JsonMissing.of() - private var topic: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftRetrieveResponse: DraftRetrieveResponse) = apply { - id = draftRetrieveResponse.id - createdAt = draftRetrieveResponse.createdAt - text = draftRetrieveResponse.text - updatedAt = draftRetrieveResponse.updatedAt - goal = draftRetrieveResponse.goal - topic = draftRetrieveResponse.topic - additionalProperties = draftRetrieveResponse.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 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 updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - fun goal(goal: String) = goal(JsonField.of(goal)) - - /** - * Sets [Builder.goal] to an arbitrary JSON value. - * - * You should usually call [Builder.goal] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun goal(goal: JsonField) = apply { this.goal = goal } - - fun topic(topic: String) = topic(JsonField.of(topic)) - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun topic(topic: JsonField) = apply { this.topic = topic } - - 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 [DraftRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .text() - * .updatedAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftRetrieveResponse = - DraftRetrieveResponse( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("text", text), - checkRequired("updatedAt", updatedAt), - goal, - topic, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftRetrieveResponse = apply { - if (validated) { - return@apply - } - - id() - createdAt() - text() - updatedAt() - goal() - topic() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (text.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (goal.asKnown().isPresent) 1 else 0) + - (if (topic.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftRetrieveResponse && - id == other.id && - createdAt == other.createdAt && - text == other.text && - updatedAt == other.updatedAt && - goal == other.goal && - topic == other.topic && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, text, updatedAt, goal, topic, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftRetrieveResponse{id=$id, createdAt=$createdAt, text=$text, updatedAt=$updatedAt, goal=$goal, topic=$topic, additionalProperties=$additionalProperties}" -} 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 9dff273..0dd6e51 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 @@ -14,7 +14,6 @@ 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 @@ -23,7 +22,7 @@ import kotlin.jvm.optionals.getOrNull class DrawListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val draws: JsonField>, + private val draws: JsonField>, private val hasMore: JsonField, private val nextCursor: JsonField, private val additionalProperties: MutableMap, @@ -31,7 +30,9 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("draws") @ExcludeMissing draws: JsonField> = JsonMissing.of(), + @JsonProperty("draws") + @ExcludeMissing + draws: JsonField> = JsonMissing.of(), @JsonProperty("hasMore") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), @JsonProperty("nextCursor") @ExcludeMissing nextCursor: JsonField = JsonMissing.of(), ) : this(draws, hasMore, nextCursor, mutableMapOf()) @@ -40,7 +41,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun draws(): List = draws.getRequired("draws") + fun draws(): List = draws.getRequired("draws") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -59,7 +60,7 @@ private constructor( * * Unlike [draws], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("draws") @ExcludeMissing fun _draws(): JsonField> = draws + @JsonProperty("draws") @ExcludeMissing fun _draws(): JsonField> = draws /** * Returns the raw JSON value of [hasMore]. @@ -104,7 +105,7 @@ private constructor( /** A builder for [DrawListResponse]. */ class Builder internal constructor() { - private var draws: JsonField>? = null + private var draws: JsonField>? = null private var hasMore: JsonField? = null private var nextCursor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -117,25 +118,25 @@ private constructor( additionalProperties = drawListResponse.additionalProperties.toMutableMap() } - fun draws(draws: List) = draws(JsonField.of(draws)) + fun draws(draws: List) = draws(JsonField.of(draws)) /** * Sets [Builder.draws] to an arbitrary JSON value. * - * You should usually call [Builder.draws] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.draws] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun draws(draws: JsonField>) = apply { + fun draws(draws: JsonField>) = apply { this.draws = draws.map { it.toMutableList() } } /** - * Adds a single [Draw] to [draws]. + * Adds a single [DrawListItem] to [draws]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addDraw(draw: Draw) = apply { + fun addDraw(draw: DrawListItem) = apply { draws = (draws ?: JsonField.of(mutableListOf())).also { checkKnown("draws", it).add(draw) } } @@ -234,417 +235,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val status: JsonField, - private val totalEntries: JsonField, - private val tweetUrl: JsonField, - private val validEntries: JsonField, - private val drawnAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("totalEntries") - @ExcludeMissing - totalEntries: JsonField = JsonMissing.of(), - @JsonProperty("tweetUrl") - @ExcludeMissing - tweetUrl: JsonField = JsonMissing.of(), - @JsonProperty("validEntries") - @ExcludeMissing - validEntries: JsonField = JsonMissing.of(), - @JsonProperty("drawnAt") - @ExcludeMissing - drawnAt: JsonField = JsonMissing.of(), - ) : this( - id, - createdAt, - status, - totalEntries, - tweetUrl, - validEntries, - drawnAt, - mutableMapOf(), - ) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun status(): String = status.getRequired("status") - - /** - * @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 totalEntries(): Long = totalEntries.getRequired("totalEntries") - - /** - * @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 tweetUrl(): String = tweetUrl.getRequired("tweetUrl") - - /** - * @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 validEntries(): Long = validEntries.getRequired("validEntries") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun drawnAt(): Optional = drawnAt.getOptional("drawnAt") - - /** - * 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 [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 [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [totalEntries]. - * - * Unlike [totalEntries], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("totalEntries") - @ExcludeMissing - fun _totalEntries(): JsonField = totalEntries - - /** - * Returns the raw JSON value of [tweetUrl]. - * - * Unlike [tweetUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetUrl") @ExcludeMissing fun _tweetUrl(): JsonField = tweetUrl - - /** - * Returns the raw JSON value of [validEntries]. - * - * Unlike [validEntries], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("validEntries") - @ExcludeMissing - fun _validEntries(): JsonField = validEntries - - /** - * Returns the raw JSON value of [drawnAt]. - * - * Unlike [drawnAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("drawnAt") @ExcludeMissing fun _drawnAt(): JsonField = drawnAt - - @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 [Draw]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .totalEntries() - * .tweetUrl() - * .validEntries() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Draw]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var status: JsonField? = null - private var totalEntries: JsonField? = null - private var tweetUrl: JsonField? = null - private var validEntries: JsonField? = null - private var drawnAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draw: Draw) = apply { - id = draw.id - createdAt = draw.createdAt - status = draw.status - totalEntries = draw.totalEntries - tweetUrl = draw.tweetUrl - validEntries = draw.validEntries - drawnAt = draw.drawnAt - additionalProperties = draw.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun totalEntries(totalEntries: Long) = totalEntries(JsonField.of(totalEntries)) - - /** - * Sets [Builder.totalEntries] to an arbitrary JSON value. - * - * You should usually call [Builder.totalEntries] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalEntries(totalEntries: JsonField) = apply { - this.totalEntries = totalEntries - } - - fun tweetUrl(tweetUrl: String) = tweetUrl(JsonField.of(tweetUrl)) - - /** - * Sets [Builder.tweetUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetUrl(tweetUrl: JsonField) = apply { this.tweetUrl = tweetUrl } - - fun validEntries(validEntries: Long) = validEntries(JsonField.of(validEntries)) - - /** - * Sets [Builder.validEntries] to an arbitrary JSON value. - * - * You should usually call [Builder.validEntries] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun validEntries(validEntries: JsonField) = apply { - this.validEntries = validEntries - } - - fun drawnAt(drawnAt: OffsetDateTime) = drawnAt(JsonField.of(drawnAt)) - - /** - * Sets [Builder.drawnAt] to an arbitrary JSON value. - * - * You should usually call [Builder.drawnAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun drawnAt(drawnAt: JsonField) = apply { this.drawnAt = drawnAt } - - 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 [Draw]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .totalEntries() - * .tweetUrl() - * .validEntries() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Draw = - Draw( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("status", status), - checkRequired("totalEntries", totalEntries), - checkRequired("tweetUrl", tweetUrl), - checkRequired("validEntries", validEntries), - drawnAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Draw = apply { - if (validated) { - return@apply - } - - id() - createdAt() - status() - totalEntries() - tweetUrl() - validEntries() - drawnAt() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (totalEntries.asKnown().isPresent) 1 else 0) + - (if (tweetUrl.asKnown().isPresent) 1 else 0) + - (if (validEntries.asKnown().isPresent) 1 else 0) + - (if (drawnAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Draw && - id == other.id && - createdAt == other.createdAt && - status == other.status && - totalEntries == other.totalEntries && - tweetUrl == other.tweetUrl && - validEntries == other.validEntries && - drawnAt == other.drawnAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - status, - totalEntries, - tweetUrl, - validEntries, - drawnAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Draw{id=$id, createdAt=$createdAt, status=$status, totalEntries=$totalEntries, tweetUrl=$tweetUrl, validEntries=$validEntries, drawnAt=$drawnAt, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRetrieveResponse.kt index 32280b4..0d99841 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 @@ -14,23 +14,21 @@ 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 DrawRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val draw: JsonField, + private val draw: JsonField, private val winners: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("draw") @ExcludeMissing draw: JsonField = JsonMissing.of(), + @JsonProperty("draw") @ExcludeMissing draw: JsonField = JsonMissing.of(), @JsonProperty("winners") @ExcludeMissing winners: JsonField> = JsonMissing.of(), ) : this(draw, winners, mutableMapOf()) @@ -40,7 +38,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun draw(): Draw = draw.getRequired("draw") + fun draw(): DrawDetail = draw.getRequired("draw") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -53,7 +51,7 @@ private constructor( * * Unlike [draw], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("draw") @ExcludeMissing fun _draw(): JsonField = draw + @JsonProperty("draw") @ExcludeMissing fun _draw(): JsonField = draw /** * Returns the raw JSON value of [winners]. @@ -91,7 +89,7 @@ private constructor( /** A builder for [DrawRetrieveResponse]. */ class Builder internal constructor() { - private var draw: JsonField? = null + private var draw: JsonField? = null private var winners: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -103,15 +101,15 @@ private constructor( } /** Full giveaway draw with tweet metrics, entries, and timing. */ - fun draw(draw: Draw) = draw(JsonField.of(draw)) + fun draw(draw: DrawDetail) = draw(JsonField.of(draw)) /** * Sets [Builder.draw] to an arbitrary JSON value. * - * You should usually call [Builder.draw] with a well-typed [Draw] value instead. This + * You should usually call [Builder.draw] with a well-typed [DrawDetail] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun draw(draw: JsonField) = apply { this.draw = draw } + fun draw(draw: JsonField) = apply { this.draw = draw } fun winners(winners: List) = winners(JsonField.of(winners)) @@ -208,994 +206,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val status: JsonField, - private val totalEntries: JsonField, - private val tweetAuthorUsername: JsonField, - private val tweetId: JsonField, - private val tweetLikeCount: JsonField, - private val tweetQuoteCount: JsonField, - private val tweetReplyCount: JsonField, - private val tweetRetweetCount: JsonField, - private val tweetText: JsonField, - private val tweetUrl: JsonField, - private val validEntries: JsonField, - private val drawnAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("totalEntries") - @ExcludeMissing - totalEntries: JsonField = JsonMissing.of(), - @JsonProperty("tweetAuthorUsername") - @ExcludeMissing - tweetAuthorUsername: JsonField = JsonMissing.of(), - @JsonProperty("tweetId") @ExcludeMissing tweetId: JsonField = JsonMissing.of(), - @JsonProperty("tweetLikeCount") - @ExcludeMissing - tweetLikeCount: JsonField = JsonMissing.of(), - @JsonProperty("tweetQuoteCount") - @ExcludeMissing - tweetQuoteCount: JsonField = JsonMissing.of(), - @JsonProperty("tweetReplyCount") - @ExcludeMissing - tweetReplyCount: JsonField = JsonMissing.of(), - @JsonProperty("tweetRetweetCount") - @ExcludeMissing - tweetRetweetCount: JsonField = JsonMissing.of(), - @JsonProperty("tweetText") - @ExcludeMissing - tweetText: JsonField = JsonMissing.of(), - @JsonProperty("tweetUrl") - @ExcludeMissing - tweetUrl: JsonField = JsonMissing.of(), - @JsonProperty("validEntries") - @ExcludeMissing - validEntries: JsonField = JsonMissing.of(), - @JsonProperty("drawnAt") - @ExcludeMissing - drawnAt: JsonField = JsonMissing.of(), - ) : this( - id, - createdAt, - status, - totalEntries, - tweetAuthorUsername, - tweetId, - tweetLikeCount, - tweetQuoteCount, - tweetReplyCount, - tweetRetweetCount, - tweetText, - tweetUrl, - validEntries, - drawnAt, - mutableMapOf(), - ) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun status(): String = status.getRequired("status") - - /** - * @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 totalEntries(): Long = totalEntries.getRequired("totalEntries") - - /** - * @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 tweetAuthorUsername(): String = tweetAuthorUsername.getRequired("tweetAuthorUsername") - - /** - * @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 tweetId(): String = tweetId.getRequired("tweetId") - - /** - * @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 tweetLikeCount(): Long = tweetLikeCount.getRequired("tweetLikeCount") - - /** - * @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 tweetQuoteCount(): Long = tweetQuoteCount.getRequired("tweetQuoteCount") - - /** - * @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 tweetReplyCount(): Long = tweetReplyCount.getRequired("tweetReplyCount") - - /** - * @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 tweetRetweetCount(): Long = tweetRetweetCount.getRequired("tweetRetweetCount") - - /** - * @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 tweetText(): String = tweetText.getRequired("tweetText") - - /** - * @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 tweetUrl(): String = tweetUrl.getRequired("tweetUrl") - - /** - * @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 validEntries(): Long = validEntries.getRequired("validEntries") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun drawnAt(): Optional = drawnAt.getOptional("drawnAt") - - /** - * 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 [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 [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [totalEntries]. - * - * Unlike [totalEntries], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("totalEntries") - @ExcludeMissing - fun _totalEntries(): JsonField = totalEntries - - /** - * Returns the raw JSON value of [tweetAuthorUsername]. - * - * Unlike [tweetAuthorUsername], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tweetAuthorUsername") - @ExcludeMissing - fun _tweetAuthorUsername(): JsonField = tweetAuthorUsername - - /** - * Returns the raw JSON value of [tweetId]. - * - * Unlike [tweetId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetId") @ExcludeMissing fun _tweetId(): JsonField = tweetId - - /** - * Returns the raw JSON value of [tweetLikeCount]. - * - * Unlike [tweetLikeCount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tweetLikeCount") - @ExcludeMissing - fun _tweetLikeCount(): JsonField = tweetLikeCount - - /** - * Returns the raw JSON value of [tweetQuoteCount]. - * - * Unlike [tweetQuoteCount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tweetQuoteCount") - @ExcludeMissing - fun _tweetQuoteCount(): JsonField = tweetQuoteCount - - /** - * Returns the raw JSON value of [tweetReplyCount]. - * - * Unlike [tweetReplyCount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tweetReplyCount") - @ExcludeMissing - fun _tweetReplyCount(): JsonField = tweetReplyCount - - /** - * Returns the raw JSON value of [tweetRetweetCount]. - * - * Unlike [tweetRetweetCount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tweetRetweetCount") - @ExcludeMissing - fun _tweetRetweetCount(): JsonField = tweetRetweetCount - - /** - * Returns the raw JSON value of [tweetText]. - * - * Unlike [tweetText], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetText") @ExcludeMissing fun _tweetText(): JsonField = tweetText - - /** - * Returns the raw JSON value of [tweetUrl]. - * - * Unlike [tweetUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetUrl") @ExcludeMissing fun _tweetUrl(): JsonField = tweetUrl - - /** - * Returns the raw JSON value of [validEntries]. - * - * Unlike [validEntries], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("validEntries") - @ExcludeMissing - fun _validEntries(): JsonField = validEntries - - /** - * Returns the raw JSON value of [drawnAt]. - * - * Unlike [drawnAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("drawnAt") @ExcludeMissing fun _drawnAt(): JsonField = drawnAt - - @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 [Draw]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .totalEntries() - * .tweetAuthorUsername() - * .tweetId() - * .tweetLikeCount() - * .tweetQuoteCount() - * .tweetReplyCount() - * .tweetRetweetCount() - * .tweetText() - * .tweetUrl() - * .validEntries() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Draw]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var status: JsonField? = null - private var totalEntries: JsonField? = null - private var tweetAuthorUsername: JsonField? = null - private var tweetId: JsonField? = null - private var tweetLikeCount: JsonField? = null - private var tweetQuoteCount: JsonField? = null - private var tweetReplyCount: JsonField? = null - private var tweetRetweetCount: JsonField? = null - private var tweetText: JsonField? = null - private var tweetUrl: JsonField? = null - private var validEntries: JsonField? = null - private var drawnAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draw: Draw) = apply { - id = draw.id - createdAt = draw.createdAt - status = draw.status - totalEntries = draw.totalEntries - tweetAuthorUsername = draw.tweetAuthorUsername - tweetId = draw.tweetId - tweetLikeCount = draw.tweetLikeCount - tweetQuoteCount = draw.tweetQuoteCount - tweetReplyCount = draw.tweetReplyCount - tweetRetweetCount = draw.tweetRetweetCount - tweetText = draw.tweetText - tweetUrl = draw.tweetUrl - validEntries = draw.validEntries - drawnAt = draw.drawnAt - additionalProperties = draw.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun totalEntries(totalEntries: Long) = totalEntries(JsonField.of(totalEntries)) - - /** - * Sets [Builder.totalEntries] to an arbitrary JSON value. - * - * You should usually call [Builder.totalEntries] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalEntries(totalEntries: JsonField) = apply { - this.totalEntries = totalEntries - } - - fun tweetAuthorUsername(tweetAuthorUsername: String) = - tweetAuthorUsername(JsonField.of(tweetAuthorUsername)) - - /** - * Sets [Builder.tweetAuthorUsername] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetAuthorUsername] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tweetAuthorUsername(tweetAuthorUsername: JsonField) = apply { - this.tweetAuthorUsername = tweetAuthorUsername - } - - fun tweetId(tweetId: String) = tweetId(JsonField.of(tweetId)) - - /** - * Sets [Builder.tweetId] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetId(tweetId: JsonField) = apply { this.tweetId = tweetId } - - fun tweetLikeCount(tweetLikeCount: Long) = tweetLikeCount(JsonField.of(tweetLikeCount)) - - /** - * Sets [Builder.tweetLikeCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetLikeCount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetLikeCount(tweetLikeCount: JsonField) = apply { - this.tweetLikeCount = tweetLikeCount - } - - fun tweetQuoteCount(tweetQuoteCount: Long) = - tweetQuoteCount(JsonField.of(tweetQuoteCount)) - - /** - * Sets [Builder.tweetQuoteCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetQuoteCount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetQuoteCount(tweetQuoteCount: JsonField) = apply { - this.tweetQuoteCount = tweetQuoteCount - } - - fun tweetReplyCount(tweetReplyCount: Long) = - tweetReplyCount(JsonField.of(tweetReplyCount)) - - /** - * Sets [Builder.tweetReplyCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetReplyCount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetReplyCount(tweetReplyCount: JsonField) = apply { - this.tweetReplyCount = tweetReplyCount - } - - fun tweetRetweetCount(tweetRetweetCount: Long) = - tweetRetweetCount(JsonField.of(tweetRetweetCount)) - - /** - * Sets [Builder.tweetRetweetCount] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetRetweetCount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetRetweetCount(tweetRetweetCount: JsonField) = apply { - this.tweetRetweetCount = tweetRetweetCount - } - - fun tweetText(tweetText: String) = tweetText(JsonField.of(tweetText)) - - /** - * Sets [Builder.tweetText] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetText] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetText(tweetText: JsonField) = apply { this.tweetText = tweetText } - - fun tweetUrl(tweetUrl: String) = tweetUrl(JsonField.of(tweetUrl)) - - /** - * Sets [Builder.tweetUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetUrl(tweetUrl: JsonField) = apply { this.tweetUrl = tweetUrl } - - fun validEntries(validEntries: Long) = validEntries(JsonField.of(validEntries)) - - /** - * Sets [Builder.validEntries] to an arbitrary JSON value. - * - * You should usually call [Builder.validEntries] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun validEntries(validEntries: JsonField) = apply { - this.validEntries = validEntries - } - - fun drawnAt(drawnAt: OffsetDateTime) = drawnAt(JsonField.of(drawnAt)) - - /** - * Sets [Builder.drawnAt] to an arbitrary JSON value. - * - * You should usually call [Builder.drawnAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun drawnAt(drawnAt: JsonField) = apply { this.drawnAt = drawnAt } - - 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 [Draw]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .totalEntries() - * .tweetAuthorUsername() - * .tweetId() - * .tweetLikeCount() - * .tweetQuoteCount() - * .tweetReplyCount() - * .tweetRetweetCount() - * .tweetText() - * .tweetUrl() - * .validEntries() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Draw = - Draw( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("status", status), - checkRequired("totalEntries", totalEntries), - checkRequired("tweetAuthorUsername", tweetAuthorUsername), - checkRequired("tweetId", tweetId), - checkRequired("tweetLikeCount", tweetLikeCount), - checkRequired("tweetQuoteCount", tweetQuoteCount), - checkRequired("tweetReplyCount", tweetReplyCount), - checkRequired("tweetRetweetCount", tweetRetweetCount), - checkRequired("tweetText", tweetText), - checkRequired("tweetUrl", tweetUrl), - checkRequired("validEntries", validEntries), - drawnAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Draw = apply { - if (validated) { - return@apply - } - - id() - createdAt() - status() - totalEntries() - tweetAuthorUsername() - tweetId() - tweetLikeCount() - tweetQuoteCount() - tweetReplyCount() - tweetRetweetCount() - tweetText() - tweetUrl() - validEntries() - drawnAt() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (totalEntries.asKnown().isPresent) 1 else 0) + - (if (tweetAuthorUsername.asKnown().isPresent) 1 else 0) + - (if (tweetId.asKnown().isPresent) 1 else 0) + - (if (tweetLikeCount.asKnown().isPresent) 1 else 0) + - (if (tweetQuoteCount.asKnown().isPresent) 1 else 0) + - (if (tweetReplyCount.asKnown().isPresent) 1 else 0) + - (if (tweetRetweetCount.asKnown().isPresent) 1 else 0) + - (if (tweetText.asKnown().isPresent) 1 else 0) + - (if (tweetUrl.asKnown().isPresent) 1 else 0) + - (if (validEntries.asKnown().isPresent) 1 else 0) + - (if (drawnAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Draw && - id == other.id && - createdAt == other.createdAt && - status == other.status && - totalEntries == other.totalEntries && - tweetAuthorUsername == other.tweetAuthorUsername && - tweetId == other.tweetId && - tweetLikeCount == other.tweetLikeCount && - tweetQuoteCount == other.tweetQuoteCount && - tweetReplyCount == other.tweetReplyCount && - tweetRetweetCount == other.tweetRetweetCount && - tweetText == other.tweetText && - tweetUrl == other.tweetUrl && - validEntries == other.validEntries && - drawnAt == other.drawnAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - status, - totalEntries, - tweetAuthorUsername, - tweetId, - tweetLikeCount, - tweetQuoteCount, - tweetReplyCount, - tweetRetweetCount, - tweetText, - tweetUrl, - validEntries, - drawnAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "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( - private val authorUsername: JsonField, - private val isBackup: JsonField, - private val position: JsonField, - private val tweetId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("authorUsername") - @ExcludeMissing - authorUsername: JsonField = JsonMissing.of(), - @JsonProperty("isBackup") - @ExcludeMissing - isBackup: JsonField = JsonMissing.of(), - @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), - @JsonProperty("tweetId") @ExcludeMissing tweetId: JsonField = JsonMissing.of(), - ) : this(authorUsername, isBackup, position, tweetId, 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 authorUsername(): String = authorUsername.getRequired("authorUsername") - - /** - * @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 isBackup(): Boolean = isBackup.getRequired("isBackup") - - /** - * @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 position(): Long = position.getRequired("position") - - /** - * @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 tweetId(): String = tweetId.getRequired("tweetId") - - /** - * 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 [isBackup]. - * - * Unlike [isBackup], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isBackup") @ExcludeMissing fun _isBackup(): JsonField = isBackup - - /** - * Returns the raw JSON value of [position]. - * - * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position - - /** - * Returns the raw JSON value of [tweetId]. - * - * Unlike [tweetId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetId") @ExcludeMissing fun _tweetId(): JsonField = tweetId - - @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 [Winner]. - * - * The following fields are required: - * ```java - * .authorUsername() - * .isBackup() - * .position() - * .tweetId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Winner]. */ - class Builder internal constructor() { - - private var authorUsername: JsonField? = null - private var isBackup: JsonField? = null - private var position: JsonField? = null - private var tweetId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(winner: Winner) = apply { - authorUsername = winner.authorUsername - isBackup = winner.isBackup - position = winner.position - tweetId = winner.tweetId - additionalProperties = winner.additionalProperties.toMutableMap() - } - - 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 isBackup(isBackup: Boolean) = isBackup(JsonField.of(isBackup)) - - /** - * Sets [Builder.isBackup] to an arbitrary JSON value. - * - * You should usually call [Builder.isBackup] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isBackup(isBackup: JsonField) = apply { this.isBackup = isBackup } - - fun position(position: Long) = position(JsonField.of(position)) - - /** - * Sets [Builder.position] to an arbitrary JSON value. - * - * You should usually call [Builder.position] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun position(position: JsonField) = apply { this.position = position } - - fun tweetId(tweetId: String) = tweetId(JsonField.of(tweetId)) - - /** - * Sets [Builder.tweetId] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetId(tweetId: JsonField) = apply { this.tweetId = tweetId } - - 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 [Winner]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .authorUsername() - * .isBackup() - * .position() - * .tweetId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Winner = - Winner( - checkRequired("authorUsername", authorUsername), - checkRequired("isBackup", isBackup), - checkRequired("position", position), - checkRequired("tweetId", tweetId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Winner = apply { - if (validated) { - return@apply - } - - authorUsername() - isBackup() - position() - tweetId() - 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 (authorUsername.asKnown().isPresent) 1 else 0) + - (if (isBackup.asKnown().isPresent) 1 else 0) + - (if (position.asKnown().isPresent) 1 else 0) + - (if (tweetId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Winner && - authorUsername == other.authorUsername && - isBackup == other.isBackup && - position == other.position && - tweetId == other.tweetId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(authorUsername, isBackup, position, tweetId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Winner{authorUsername=$authorUsername, isBackup=$isBackup, position=$position, tweetId=$tweetId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/draws/DrawRunResponse.kt index 7b4874a..ae4596e 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,283 +309,6 @@ 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( - private val authorUsername: JsonField, - private val isBackup: JsonField, - private val position: JsonField, - private val tweetId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("authorUsername") - @ExcludeMissing - authorUsername: JsonField = JsonMissing.of(), - @JsonProperty("isBackup") - @ExcludeMissing - isBackup: JsonField = JsonMissing.of(), - @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), - @JsonProperty("tweetId") @ExcludeMissing tweetId: JsonField = JsonMissing.of(), - ) : this(authorUsername, isBackup, position, tweetId, 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 authorUsername(): String = authorUsername.getRequired("authorUsername") - - /** - * @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 isBackup(): Boolean = isBackup.getRequired("isBackup") - - /** - * @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 position(): Long = position.getRequired("position") - - /** - * @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 tweetId(): String = tweetId.getRequired("tweetId") - - /** - * 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 [isBackup]. - * - * Unlike [isBackup], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isBackup") @ExcludeMissing fun _isBackup(): JsonField = isBackup - - /** - * Returns the raw JSON value of [position]. - * - * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position - - /** - * Returns the raw JSON value of [tweetId]. - * - * Unlike [tweetId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tweetId") @ExcludeMissing fun _tweetId(): JsonField = tweetId - - @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 [Winner]. - * - * The following fields are required: - * ```java - * .authorUsername() - * .isBackup() - * .position() - * .tweetId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Winner]. */ - class Builder internal constructor() { - - private var authorUsername: JsonField? = null - private var isBackup: JsonField? = null - private var position: JsonField? = null - private var tweetId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(winner: Winner) = apply { - authorUsername = winner.authorUsername - isBackup = winner.isBackup - position = winner.position - tweetId = winner.tweetId - additionalProperties = winner.additionalProperties.toMutableMap() - } - - 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 isBackup(isBackup: Boolean) = isBackup(JsonField.of(isBackup)) - - /** - * Sets [Builder.isBackup] to an arbitrary JSON value. - * - * You should usually call [Builder.isBackup] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isBackup(isBackup: JsonField) = apply { this.isBackup = isBackup } - - fun position(position: Long) = position(JsonField.of(position)) - - /** - * Sets [Builder.position] to an arbitrary JSON value. - * - * You should usually call [Builder.position] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun position(position: JsonField) = apply { this.position = position } - - fun tweetId(tweetId: String) = tweetId(JsonField.of(tweetId)) - - /** - * Sets [Builder.tweetId] to an arbitrary JSON value. - * - * You should usually call [Builder.tweetId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tweetId(tweetId: JsonField) = apply { this.tweetId = tweetId } - - 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 [Winner]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .authorUsername() - * .isBackup() - * .position() - * .tweetId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Winner = - Winner( - checkRequired("authorUsername", authorUsername), - checkRequired("isBackup", isBackup), - checkRequired("position", position), - checkRequired("tweetId", tweetId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Winner = apply { - if (validated) { - return@apply - } - - authorUsername() - isBackup() - position() - tweetId() - 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 (authorUsername.asKnown().isPresent) 1 else 0) + - (if (isBackup.asKnown().isPresent) 1 else 0) + - (if (position.asKnown().isPresent) 1 else 0) + - (if (tweetId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Winner && - authorUsername == other.authorUsername && - isBackup == other.isBackup && - position == other.position && - tweetId == other.tweetId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(authorUsername, isBackup, position, tweetId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Winner{authorUsername=$authorUsername, isBackup=$isBackup, position=$position, tweetId=$tweetId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/Event.kt index 90905c5..e633e17 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 @@ -6,7 +6,6 @@ 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 @@ -14,6 +13,7 @@ import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.EventType import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -27,7 +27,7 @@ private constructor( private val data: JsonField, private val monitorId: JsonField, private val occurredAt: JsonField, - private val type: JsonField, + private val type: JsonField, private val username: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,7 +40,7 @@ private constructor( @JsonProperty("occurredAt") @ExcludeMissing occurredAt: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), ) : this(id, data, monitorId, occurredAt, type, username, mutableMapOf()) @@ -74,7 +74,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + fun type(): EventType = type.getRequired("type") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -117,7 +117,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [username]. @@ -163,7 +163,7 @@ private constructor( private var data: JsonField? = null private var monitorId: JsonField? = null private var occurredAt: JsonField? = null - private var type: JsonField? = null + private var type: JsonField? = null private var username: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -223,15 +223,15 @@ private constructor( } /** Type of monitor event fired when account activity occurs. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: EventType) = 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 + * You should usually call [Builder.type] with a well-typed [EventType] 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 type(type: JsonField) = apply { this.type = type } fun username(username: String) = username(JsonField.of(username)) @@ -428,158 +428,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - 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 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 94a9651..eec6aec 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 @@ -6,7 +6,6 @@ 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 @@ -14,6 +13,7 @@ import com.x_twitter_scraper.api.core.JsonValue import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.EventType import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -28,7 +28,7 @@ private constructor( private val data: JsonField, private val monitorId: JsonField, private val occurredAt: JsonField, - private val type: JsonField, + private val type: JsonField, private val username: JsonField, private val xEventId: JsonField, private val additionalProperties: MutableMap, @@ -42,7 +42,7 @@ private constructor( @JsonProperty("occurredAt") @ExcludeMissing occurredAt: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), @JsonProperty("xEventId") @ExcludeMissing xEventId: JsonField = JsonMissing.of(), ) : this(id, data, monitorId, occurredAt, type, username, xEventId, mutableMapOf()) @@ -79,7 +79,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + fun type(): EventType = type.getRequired("type") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -128,7 +128,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [username]. @@ -181,7 +181,7 @@ private constructor( private var data: JsonField? = null private var monitorId: JsonField? = null private var occurredAt: JsonField? = null - private var type: JsonField? = null + private var type: JsonField? = null private var username: JsonField? = null private var xEventId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -244,15 +244,15 @@ private constructor( } /** Type of monitor event fired when account activity occurs. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: EventType) = 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 + * You should usually call [Builder.type] with a well-typed [EventType] 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 type(type: JsonField) = apply { this.type = type } fun username(username: String) = username(JsonField.of(username)) @@ -463,158 +463,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - 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 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 64661e3..d194443 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 @@ -2,13 +2,10 @@ package com.x_twitter_scraper.api.models.events -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 com.x_twitter_scraper.api.models.EventType import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -230,160 +227,6 @@ private constructor( } .build() - /** Filter events by type */ - class EventType @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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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/events/EventListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventListResponse.kt index 8d5eb62..7dbcb1c 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 @@ -6,7 +6,6 @@ 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 @@ -15,7 +14,6 @@ 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 @@ -237,608 +235,6 @@ 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( - private val id: JsonField, - private val data: JsonField, - private val monitorId: JsonField, - private val occurredAt: JsonField, - private val type: JsonField, - private val username: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("monitorId") - @ExcludeMissing - monitorId: JsonField = JsonMissing.of(), - @JsonProperty("occurredAt") - @ExcludeMissing - occurredAt: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - ) : this(id, data, monitorId, occurredAt, type, username, 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 data(): Data = data.getRequired("data") - - /** - * @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 monitorId(): String = monitorId.getRequired("monitorId") - - /** - * @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 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). - */ - fun type(): Type = type.getRequired("type") - - /** - * @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") - - /** - * 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 [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [monitorId]. - * - * Unlike [monitorId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("monitorId") @ExcludeMissing fun _monitorId(): JsonField = monitorId - - /** - * Returns the raw JSON value of [occurredAt]. - * - * Unlike [occurredAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("occurredAt") - @ExcludeMissing - fun _occurredAt(): JsonField = occurredAt - - /** - * 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 [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username - - @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 [Event]. - * - * The following fields are required: - * ```java - * .id() - * .data() - * .monitorId() - * .occurredAt() - * .type() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Event]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var data: JsonField? = null - private var monitorId: JsonField? = null - private var occurredAt: JsonField? = null - private var type: JsonField? = null - private var username: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(event: Event) = apply { - id = event.id - data = event.data - monitorId = event.monitorId - occurredAt = event.occurredAt - type = event.type - username = event.username - additionalProperties = event.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 data(data: Data) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun monitorId(monitorId: String) = monitorId(JsonField.of(monitorId)) - - /** - * Sets [Builder.monitorId] to an arbitrary JSON value. - * - * You should usually call [Builder.monitorId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun monitorId(monitorId: JsonField) = apply { this.monitorId = monitorId } - - fun occurredAt(occurredAt: OffsetDateTime) = occurredAt(JsonField.of(occurredAt)) - - /** - * Sets [Builder.occurredAt] to an arbitrary JSON value. - * - * You should usually call [Builder.occurredAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun occurredAt(occurredAt: JsonField) = apply { - this.occurredAt = occurredAt - } - - /** Type of monitor event fired when account activity occurs. */ - 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 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 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 [Event]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .data() - * .monitorId() - * .occurredAt() - * .type() - * .username() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Event = - Event( - checkRequired("id", id), - checkRequired("data", data), - checkRequired("monitorId", monitorId), - checkRequired("occurredAt", occurredAt), - checkRequired("type", type), - checkRequired("username", username), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Event = apply { - if (validated) { - return@apply - } - - id() - data().validate() - monitorId() - occurredAt() - type().validate() - username() - 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) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (monitorId.asKnown().isPresent) 1 else 0) + - (if (occurredAt.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (username.asKnown().isPresent) 1 else 0) - - class Data - @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 [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.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 [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = 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 Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - 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 Event && - id == other.id && - data == other.data && - monitorId == other.monitorId && - occurredAt == other.occurredAt && - type == other.type && - username == other.username && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, data, monitorId, occurredAt, type, username, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Event{id=$id, data=$data, monitorId=$monitorId, occurredAt=$occurredAt, type=$type, username=$username, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt deleted file mode 100644 index 977dfa6..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/events/EventRetrieveResponse.kt +++ /dev/null @@ -1,651 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.events - -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.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 - -/** Full monitor event including payload data and optional X event ID. */ -class EventRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val data: JsonField, - private val monitorId: JsonField, - private val occurredAt: JsonField, - private val type: JsonField, - private val username: JsonField, - private val xEventId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("monitorId") @ExcludeMissing monitorId: JsonField = JsonMissing.of(), - @JsonProperty("occurredAt") - @ExcludeMissing - occurredAt: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - @JsonProperty("xEventId") @ExcludeMissing xEventId: JsonField = JsonMissing.of(), - ) : this(id, data, monitorId, occurredAt, type, username, xEventId, 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") - - /** - * 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). - */ - fun data(): Data = data.getRequired("data") - - /** - * @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 monitorId(): String = monitorId.getRequired("monitorId") - - /** - * @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 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). - */ - fun type(): Type = type.getRequired("type") - - /** - * @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 xEventId(): Optional = xEventId.getOptional("xEventId") - - /** - * 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 [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [monitorId]. - * - * Unlike [monitorId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("monitorId") @ExcludeMissing fun _monitorId(): JsonField = monitorId - - /** - * Returns the raw JSON value of [occurredAt]. - * - * Unlike [occurredAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("occurredAt") - @ExcludeMissing - fun _occurredAt(): JsonField = occurredAt - - /** - * 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 [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 [xEventId]. - * - * Unlike [xEventId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xEventId") @ExcludeMissing fun _xEventId(): JsonField = xEventId - - @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 [EventRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .data() - * .monitorId() - * .occurredAt() - * .type() - * .username() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EventRetrieveResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var data: JsonField? = null - private var monitorId: JsonField? = null - private var occurredAt: JsonField? = null - private var type: JsonField? = null - private var username: JsonField? = null - private var xEventId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(eventRetrieveResponse: EventRetrieveResponse) = apply { - id = eventRetrieveResponse.id - data = eventRetrieveResponse.data - monitorId = eventRetrieveResponse.monitorId - occurredAt = eventRetrieveResponse.occurredAt - type = eventRetrieveResponse.type - username = eventRetrieveResponse.username - xEventId = eventRetrieveResponse.xEventId - additionalProperties = eventRetrieveResponse.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 } - - /** Event payload — shape varies by event type (JSON) */ - fun data(data: Data) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun monitorId(monitorId: String) = monitorId(JsonField.of(monitorId)) - - /** - * Sets [Builder.monitorId] to an arbitrary JSON value. - * - * You should usually call [Builder.monitorId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun monitorId(monitorId: JsonField) = apply { this.monitorId = monitorId } - - fun occurredAt(occurredAt: OffsetDateTime) = occurredAt(JsonField.of(occurredAt)) - - /** - * Sets [Builder.occurredAt] to an arbitrary JSON value. - * - * You should usually call [Builder.occurredAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun occurredAt(occurredAt: JsonField) = apply { - this.occurredAt = occurredAt - } - - /** Type of monitor event fired when account activity occurs. */ - 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 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 xEventId(xEventId: String) = xEventId(JsonField.of(xEventId)) - - /** - * Sets [Builder.xEventId] to an arbitrary JSON value. - * - * You should usually call [Builder.xEventId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun xEventId(xEventId: JsonField) = apply { this.xEventId = xEventId } - - 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 [EventRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .data() - * .monitorId() - * .occurredAt() - * .type() - * .username() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EventRetrieveResponse = - EventRetrieveResponse( - checkRequired("id", id), - checkRequired("data", data), - checkRequired("monitorId", monitorId), - checkRequired("occurredAt", occurredAt), - checkRequired("type", type), - checkRequired("username", username), - xEventId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EventRetrieveResponse = apply { - if (validated) { - return@apply - } - - id() - data().validate() - monitorId() - occurredAt() - type().validate() - username() - xEventId() - 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) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (monitorId.asKnown().isPresent) 1 else 0) + - (if (occurredAt.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (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( - @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 [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.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 [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = 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 Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - 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 EventRetrieveResponse && - id == other.id && - data == other.data && - monitorId == other.monitorId && - occurredAt == other.occurredAt && - type == other.type && - username == other.username && - xEventId == other.xEventId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - data, - monitorId, - occurredAt, - type, - username, - xEventId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventRetrieveResponse{id=$id, data=$data, monitorId=$monitorId, occurredAt=$occurredAt, type=$type, username=$username, xEventId=$xEventId, additionalProperties=$additionalProperties}" -} 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 bfc4718..4c0b10c 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 @@ -6,7 +6,6 @@ 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 @@ -15,7 +14,6 @@ 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 @@ -24,7 +22,7 @@ import kotlin.jvm.optionals.getOrNull class ExtractionListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val extractions: JsonField>, + private val extractions: JsonField>, private val hasMore: JsonField, private val nextCursor: JsonField, private val additionalProperties: MutableMap, @@ -34,7 +32,7 @@ private constructor( private constructor( @JsonProperty("extractions") @ExcludeMissing - extractions: JsonField> = JsonMissing.of(), + extractions: JsonField> = JsonMissing.of(), @JsonProperty("hasMore") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), @JsonProperty("nextCursor") @ExcludeMissing nextCursor: JsonField = JsonMissing.of(), ) : this(extractions, hasMore, nextCursor, mutableMapOf()) @@ -43,7 +41,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun extractions(): List = extractions.getRequired("extractions") + fun extractions(): List = extractions.getRequired("extractions") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -64,7 +62,7 @@ private constructor( */ @JsonProperty("extractions") @ExcludeMissing - fun _extractions(): JsonField> = extractions + fun _extractions(): JsonField> = extractions /** * Returns the raw JSON value of [hasMore]. @@ -109,7 +107,7 @@ private constructor( /** A builder for [ExtractionListResponse]. */ class Builder internal constructor() { - private var extractions: JsonField>? = null + private var extractions: JsonField>? = null private var hasMore: JsonField? = null private var nextCursor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -122,25 +120,25 @@ private constructor( additionalProperties = extractionListResponse.additionalProperties.toMutableMap() } - fun extractions(extractions: List) = extractions(JsonField.of(extractions)) + fun extractions(extractions: List) = extractions(JsonField.of(extractions)) /** * Sets [Builder.extractions] to an arbitrary JSON value. * - * You should usually call [Builder.extractions] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.extractions] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun extractions(extractions: JsonField>) = apply { + fun extractions(extractions: JsonField>) = apply { this.extractions = extractions.map { it.toMutableList() } } /** - * Adds a single [Extraction] to [extractions]. + * Adds a single [ExtractionJob] to [extractions]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addExtraction(extraction: Extraction) = apply { + fun addExtraction(extraction: ExtractionJob) = apply { extractions = (extractions ?: JsonField.of(mutableListOf())).also { checkKnown("extractions", it).add(extraction) @@ -241,746 +239,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val status: JsonField, - private val toolType: JsonField, - private val totalResults: JsonField, - private val completedAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("toolType") - @ExcludeMissing - toolType: JsonField = JsonMissing.of(), - @JsonProperty("totalResults") - @ExcludeMissing - totalResults: JsonField = JsonMissing.of(), - @JsonProperty("completedAt") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - ) : this(id, createdAt, status, toolType, totalResults, completedAt, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun 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). - */ - fun toolType(): ToolType = toolType.getRequired("toolType") - - /** - * @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 totalResults(): Long = totalResults.getRequired("totalResults") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun completedAt(): Optional = completedAt.getOptional("completedAt") - - /** - * 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 [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 [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [toolType]. - * - * Unlike [toolType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("toolType") @ExcludeMissing fun _toolType(): JsonField = toolType - - /** - * Returns the raw JSON value of [totalResults]. - * - * Unlike [totalResults], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("totalResults") - @ExcludeMissing - fun _totalResults(): JsonField = totalResults - - /** - * Returns the raw JSON value of [completedAt]. - * - * Unlike [completedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("completedAt") - @ExcludeMissing - fun _completedAt(): JsonField = completedAt - - @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 [Extraction]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .toolType() - * .totalResults() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Extraction]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var status: JsonField? = null - private var toolType: JsonField? = null - private var totalResults: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(extraction: Extraction) = apply { - id = extraction.id - createdAt = extraction.createdAt - status = extraction.status - toolType = extraction.toolType - totalResults = extraction.totalResults - completedAt = extraction.completedAt - additionalProperties = extraction.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - 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)) - - /** - * Sets [Builder.toolType] to an arbitrary JSON value. - * - * You should usually call [Builder.toolType] with a well-typed [ToolType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun toolType(toolType: JsonField) = apply { this.toolType = toolType } - - fun totalResults(totalResults: Long) = totalResults(JsonField.of(totalResults)) - - /** - * Sets [Builder.totalResults] to an arbitrary JSON value. - * - * You should usually call [Builder.totalResults] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalResults(totalResults: JsonField) = apply { - this.totalResults = totalResults - } - - fun completedAt(completedAt: OffsetDateTime) = completedAt(JsonField.of(completedAt)) - - /** - * Sets [Builder.completedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.completedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun completedAt(completedAt: JsonField) = apply { - this.completedAt = completedAt - } - - 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 [Extraction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .status() - * .toolType() - * .totalResults() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Extraction = - Extraction( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("status", status), - checkRequired("toolType", toolType), - checkRequired("totalResults", totalResults), - completedAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Extraction = apply { - if (validated) { - return@apply - } - - id() - createdAt() - status().validate() - toolType().validate() - totalResults() - completedAt() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (toolType.asKnown().getOrNull()?.validity() ?: 0) + - (if (totalResults.asKnown().isPresent) 1 else 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) - - class Status @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 RUNNING = of("running") - - @JvmField val COMPLETED = of("completed") - - @JvmField val FAILED = of("failed") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - RUNNING, - COMPLETED, - FAILED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] 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 { - RUNNING, - COMPLETED, - FAILED, - /** - * An enum member indicating that [Status] 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) { - RUNNING -> Value.RUNNING - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - 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) { - RUNNING -> Known.RUNNING - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - else -> throw XTwitterScraperInvalidDataException("Unknown Status: $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(): Status = 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 Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - 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 { - - /** - * 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 ARTICLE_EXTRACTOR = of("article_extractor") - - @JvmField val COMMUNITY_EXTRACTOR = of("community_extractor") - - @JvmField val COMMUNITY_MODERATOR_EXPLORER = of("community_moderator_explorer") - - @JvmField val COMMUNITY_POST_EXTRACTOR = of("community_post_extractor") - - @JvmField val COMMUNITY_SEARCH = of("community_search") - - @JvmField val FOLLOWER_EXPLORER = of("follower_explorer") - - @JvmField val FOLLOWING_EXPLORER = of("following_explorer") - - @JvmField val LIST_FOLLOWER_EXPLORER = of("list_follower_explorer") - - @JvmField val LIST_MEMBER_EXTRACTOR = of("list_member_extractor") - - @JvmField val LIST_POST_EXTRACTOR = of("list_post_extractor") - - @JvmField val MENTION_EXTRACTOR = of("mention_extractor") - - @JvmField val PEOPLE_SEARCH = of("people_search") - - @JvmField val POST_EXTRACTOR = of("post_extractor") - - @JvmField val QUOTE_EXTRACTOR = of("quote_extractor") - - @JvmField val REPLY_EXTRACTOR = of("reply_extractor") - - @JvmField val REPOST_EXTRACTOR = of("repost_extractor") - - @JvmField val SPACE_EXPLORER = of("space_explorer") - - @JvmField val THREAD_EXTRACTOR = of("thread_extractor") - - @JvmField val TWEET_SEARCH_EXTRACTOR = of("tweet_search_extractor") - - @JvmField val VERIFIED_FOLLOWER_EXPLORER = of("verified_follower_explorer") - - @JvmStatic fun of(value: String) = ToolType(JsonField.of(value)) - } - - /** An enum containing [ToolType]'s known values. */ - enum class Known { - ARTICLE_EXTRACTOR, - COMMUNITY_EXTRACTOR, - COMMUNITY_MODERATOR_EXPLORER, - COMMUNITY_POST_EXTRACTOR, - COMMUNITY_SEARCH, - FOLLOWER_EXPLORER, - FOLLOWING_EXPLORER, - LIST_FOLLOWER_EXPLORER, - LIST_MEMBER_EXTRACTOR, - LIST_POST_EXTRACTOR, - MENTION_EXTRACTOR, - PEOPLE_SEARCH, - POST_EXTRACTOR, - QUOTE_EXTRACTOR, - REPLY_EXTRACTOR, - REPOST_EXTRACTOR, - SPACE_EXPLORER, - THREAD_EXTRACTOR, - TWEET_SEARCH_EXTRACTOR, - VERIFIED_FOLLOWER_EXPLORER, - } - - /** - * An enum containing [ToolType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ToolType] 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 { - ARTICLE_EXTRACTOR, - COMMUNITY_EXTRACTOR, - COMMUNITY_MODERATOR_EXPLORER, - COMMUNITY_POST_EXTRACTOR, - COMMUNITY_SEARCH, - FOLLOWER_EXPLORER, - FOLLOWING_EXPLORER, - LIST_FOLLOWER_EXPLORER, - LIST_MEMBER_EXTRACTOR, - LIST_POST_EXTRACTOR, - MENTION_EXTRACTOR, - PEOPLE_SEARCH, - POST_EXTRACTOR, - QUOTE_EXTRACTOR, - REPLY_EXTRACTOR, - REPOST_EXTRACTOR, - SPACE_EXPLORER, - THREAD_EXTRACTOR, - TWEET_SEARCH_EXTRACTOR, - VERIFIED_FOLLOWER_EXPLORER, - /** - * An enum member indicating that [ToolType] 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) { - ARTICLE_EXTRACTOR -> Value.ARTICLE_EXTRACTOR - COMMUNITY_EXTRACTOR -> Value.COMMUNITY_EXTRACTOR - COMMUNITY_MODERATOR_EXPLORER -> Value.COMMUNITY_MODERATOR_EXPLORER - COMMUNITY_POST_EXTRACTOR -> Value.COMMUNITY_POST_EXTRACTOR - COMMUNITY_SEARCH -> Value.COMMUNITY_SEARCH - FOLLOWER_EXPLORER -> Value.FOLLOWER_EXPLORER - FOLLOWING_EXPLORER -> Value.FOLLOWING_EXPLORER - LIST_FOLLOWER_EXPLORER -> Value.LIST_FOLLOWER_EXPLORER - LIST_MEMBER_EXTRACTOR -> Value.LIST_MEMBER_EXTRACTOR - LIST_POST_EXTRACTOR -> Value.LIST_POST_EXTRACTOR - MENTION_EXTRACTOR -> Value.MENTION_EXTRACTOR - PEOPLE_SEARCH -> Value.PEOPLE_SEARCH - POST_EXTRACTOR -> Value.POST_EXTRACTOR - QUOTE_EXTRACTOR -> Value.QUOTE_EXTRACTOR - REPLY_EXTRACTOR -> Value.REPLY_EXTRACTOR - REPOST_EXTRACTOR -> Value.REPOST_EXTRACTOR - SPACE_EXPLORER -> Value.SPACE_EXPLORER - THREAD_EXTRACTOR -> Value.THREAD_EXTRACTOR - TWEET_SEARCH_EXTRACTOR -> Value.TWEET_SEARCH_EXTRACTOR - VERIFIED_FOLLOWER_EXPLORER -> Value.VERIFIED_FOLLOWER_EXPLORER - 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) { - ARTICLE_EXTRACTOR -> Known.ARTICLE_EXTRACTOR - COMMUNITY_EXTRACTOR -> Known.COMMUNITY_EXTRACTOR - COMMUNITY_MODERATOR_EXPLORER -> Known.COMMUNITY_MODERATOR_EXPLORER - COMMUNITY_POST_EXTRACTOR -> Known.COMMUNITY_POST_EXTRACTOR - COMMUNITY_SEARCH -> Known.COMMUNITY_SEARCH - FOLLOWER_EXPLORER -> Known.FOLLOWER_EXPLORER - FOLLOWING_EXPLORER -> Known.FOLLOWING_EXPLORER - LIST_FOLLOWER_EXPLORER -> Known.LIST_FOLLOWER_EXPLORER - LIST_MEMBER_EXTRACTOR -> Known.LIST_MEMBER_EXTRACTOR - LIST_POST_EXTRACTOR -> Known.LIST_POST_EXTRACTOR - MENTION_EXTRACTOR -> Known.MENTION_EXTRACTOR - PEOPLE_SEARCH -> Known.PEOPLE_SEARCH - POST_EXTRACTOR -> Known.POST_EXTRACTOR - QUOTE_EXTRACTOR -> Known.QUOTE_EXTRACTOR - REPLY_EXTRACTOR -> Known.REPLY_EXTRACTOR - REPOST_EXTRACTOR -> Known.REPOST_EXTRACTOR - SPACE_EXPLORER -> Known.SPACE_EXPLORER - THREAD_EXTRACTOR -> Known.THREAD_EXTRACTOR - TWEET_SEARCH_EXTRACTOR -> Known.TWEET_SEARCH_EXTRACTOR - VERIFIED_FOLLOWER_EXPLORER -> Known.VERIFIED_FOLLOWER_EXPLORER - else -> throw XTwitterScraperInvalidDataException("Unknown ToolType: $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(): ToolType = 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 ToolType && 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 Extraction && - id == other.id && - createdAt == other.createdAt && - status == other.status && - toolType == other.toolType && - totalResults == other.totalResults && - completedAt == other.completedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - status, - toolType, - totalResults, - completedAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Extraction{id=$id, createdAt=$createdAt, status=$status, toolType=$toolType, totalResults=$totalResults, completedAt=$completedAt, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/Integration.kt index a00121a..32b4c70 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 @@ -15,6 +15,7 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.EventType import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -639,160 +640,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - 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/integrations/IntegrationCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateParams.kt index 1081983..7e77a0f 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 @@ -18,6 +18,7 @@ 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 com.x_twitter_scraper.api.models.EventType import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull @@ -781,160 +782,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - 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/integrations/IntegrationCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt deleted file mode 100644 index 0eff30a..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationCreateResponse.kt +++ /dev/null @@ -1,1058 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.integrations - -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.time.OffsetDateTime -import java.util.Collections -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( - private val id: JsonField, - private val config: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val name: JsonField, - private val type: JsonField, - private val filters: JsonField, - private val messageTemplate: JsonField, - private val scopeAllMonitors: JsonField, - private val silentPush: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), - @JsonProperty("messageTemplate") - @ExcludeMissing - messageTemplate: JsonField = JsonMissing.of(), - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - scopeAllMonitors: JsonField = JsonMissing.of(), - @JsonProperty("silentPush") - @ExcludeMissing - silentPush: JsonField = JsonMissing.of(), - ) : this( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - 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") - - /** - * 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). - */ - fun config(): Config = config.getRequired("config") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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). - */ - fun filters(): Optional = filters.getOptional("filters") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun messageTemplate(): Optional = messageTemplate.getOptional("messageTemplate") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun scopeAllMonitors(): Optional = scopeAllMonitors.getOptional("scopeAllMonitors") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun silentPush(): Optional = silentPush.getOptional("silentPush") - - /** - * 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 [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * 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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [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 [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters - - /** - * Returns the raw JSON value of [messageTemplate]. - * - * Unlike [messageTemplate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageTemplate") - @ExcludeMissing - fun _messageTemplate(): JsonField = messageTemplate - - /** - * Returns the raw JSON value of [scopeAllMonitors]. - * - * Unlike [scopeAllMonitors], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - fun _scopeAllMonitors(): JsonField = scopeAllMonitors - - /** - * Returns the raw JSON value of [silentPush]. - * - * Unlike [silentPush], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("silentPush") @ExcludeMissing fun _silentPush(): JsonField = silentPush - - @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 [IntegrationCreateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IntegrationCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var filters: JsonField = JsonMissing.of() - private var messageTemplate: JsonField = JsonMissing.of() - private var scopeAllMonitors: JsonField = JsonMissing.of() - private var silentPush: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(integrationCreateResponse: IntegrationCreateResponse) = apply { - id = integrationCreateResponse.id - config = integrationCreateResponse.config - createdAt = integrationCreateResponse.createdAt - eventTypes = integrationCreateResponse.eventTypes.map { it.toMutableList() } - isActive = integrationCreateResponse.isActive - name = integrationCreateResponse.name - type = integrationCreateResponse.type - filters = integrationCreateResponse.filters - messageTemplate = integrationCreateResponse.messageTemplate - scopeAllMonitors = integrationCreateResponse.scopeAllMonitors - silentPush = integrationCreateResponse.silentPush - additionalProperties = integrationCreateResponse.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 } - - /** Integration config — shape varies by type (JSON) */ - fun config(config: Config) = config(JsonField.of(config)) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 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 } - - /** Event filter rules (JSON) */ - fun filters(filters: Filters) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField) = apply { this.filters = filters } - - fun messageTemplate(messageTemplate: String) = - messageTemplate(JsonField.of(messageTemplate)) - - /** - * Sets [Builder.messageTemplate] to an arbitrary JSON value. - * - * You should usually call [Builder.messageTemplate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageTemplate(messageTemplate: JsonField) = apply { - this.messageTemplate = messageTemplate - } - - fun scopeAllMonitors(scopeAllMonitors: Boolean) = - scopeAllMonitors(JsonField.of(scopeAllMonitors)) - - /** - * Sets [Builder.scopeAllMonitors] to an arbitrary JSON value. - * - * You should usually call [Builder.scopeAllMonitors] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scopeAllMonitors(scopeAllMonitors: JsonField) = apply { - this.scopeAllMonitors = scopeAllMonitors - } - - fun silentPush(silentPush: Boolean) = silentPush(JsonField.of(silentPush)) - - /** - * Sets [Builder.silentPush] to an arbitrary JSON value. - * - * You should usually call [Builder.silentPush] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun silentPush(silentPush: JsonField) = apply { this.silentPush = silentPush } - - 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 [IntegrationCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): IntegrationCreateResponse = - IntegrationCreateResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("name", name), - checkRequired("type", type), - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): IntegrationCreateResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - name() - type().validate() - filters().ifPresent { it.validate() } - messageTemplate() - scopeAllMonitors() - silentPush() - 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) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageTemplate.asKnown().isPresent) 1 else 0) + - (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( - @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 [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.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 [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = 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 Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 TELEGRAM = of("telegram") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TELEGRAM - } - - /** - * 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 { - TELEGRAM, - /** 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) { - TELEGRAM -> Value.TELEGRAM - 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) { - TELEGRAM -> Known.TELEGRAM - 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() - } - - /** Event filter rules (JSON) */ - class Filters - @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 [Filters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filters]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filters: Filters) = apply { - additionalProperties = filters.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 [Filters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Filters = Filters(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Filters = 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 Filters && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Filters{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is IntegrationCreateResponse && - id == other.id && - config == other.config && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - name == other.name && - type == other.type && - filters == other.filters && - messageTemplate == other.messageTemplate && - scopeAllMonitors == other.scopeAllMonitors && - silentPush == other.silentPush && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IntegrationCreateResponse{id=$id, config=$config, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, name=$name, type=$type, filters=$filters, messageTemplate=$messageTemplate, scopeAllMonitors=$scopeAllMonitors, silentPush=$silentPush, additionalProperties=$additionalProperties}" -} 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 b595f38..a56505f 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 @@ -14,16 +14,14 @@ 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 IntegrationListDeliveriesResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val deliveries: JsonField>, + private val deliveries: JsonField>, private val additionalProperties: MutableMap, ) { @@ -31,14 +29,14 @@ private constructor( private constructor( @JsonProperty("deliveries") @ExcludeMissing - deliveries: JsonField> = JsonMissing.of() + deliveries: JsonField> = JsonMissing.of() ) : this(deliveries, 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 deliveries(): List = deliveries.getRequired("deliveries") + fun deliveries(): List = deliveries.getRequired("deliveries") /** * Returns the raw JSON value of [deliveries]. @@ -47,7 +45,7 @@ private constructor( */ @JsonProperty("deliveries") @ExcludeMissing - fun _deliveries(): JsonField> = deliveries + fun _deliveries(): JsonField> = deliveries @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -78,7 +76,7 @@ private constructor( /** A builder for [IntegrationListDeliveriesResponse]. */ class Builder internal constructor() { - private var deliveries: JsonField>? = null + private var deliveries: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -89,25 +87,25 @@ private constructor( integrationListDeliveriesResponse.additionalProperties.toMutableMap() } - fun deliveries(deliveries: List) = deliveries(JsonField.of(deliveries)) + fun deliveries(deliveries: List) = deliveries(JsonField.of(deliveries)) /** * Sets [Builder.deliveries] to an arbitrary JSON value. * - * You should usually call [Builder.deliveries] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.deliveries] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. */ - fun deliveries(deliveries: JsonField>) = apply { + fun deliveries(deliveries: JsonField>) = apply { this.deliveries = deliveries.map { it.toMutableList() } } /** - * Adds a single [Delivery] to [deliveries]. + * Adds a single [IntegrationDelivery] to [deliveries]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addDelivery(delivery: Delivery) = apply { + fun addDelivery(delivery: IntegrationDelivery) = apply { deliveries = (deliveries ?: JsonField.of(mutableListOf())).also { checkKnown("deliveries", it).add(delivery) @@ -180,521 +178,6 @@ 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( - private val id: JsonField, - private val attempts: JsonField, - private val createdAt: JsonField, - private val eventType: JsonField, - private val status: JsonField, - private val deliveredAt: JsonField, - private val lastError: JsonField, - private val lastStatusCode: JsonField, - private val sourceId: JsonField, - private val sourceType: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("attempts") @ExcludeMissing attempts: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventType") - @ExcludeMissing - eventType: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("deliveredAt") - @ExcludeMissing - deliveredAt: JsonField = JsonMissing.of(), - @JsonProperty("lastError") - @ExcludeMissing - lastError: JsonField = JsonMissing.of(), - @JsonProperty("lastStatusCode") - @ExcludeMissing - lastStatusCode: JsonField = JsonMissing.of(), - @JsonProperty("sourceId") - @ExcludeMissing - sourceId: JsonField = JsonMissing.of(), - @JsonProperty("sourceType") - @ExcludeMissing - sourceType: JsonField = JsonMissing.of(), - ) : this( - id, - attempts, - createdAt, - eventType, - status, - deliveredAt, - lastError, - lastStatusCode, - sourceId, - sourceType, - 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 attempts(): Long = attempts.getRequired("attempts") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun eventType(): String = eventType.getRequired("eventType") - - /** - * @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 status(): String = status.getRequired("status") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun deliveredAt(): Optional = deliveredAt.getOptional("deliveredAt") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun lastError(): Optional = lastError.getOptional("lastError") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun lastStatusCode(): Optional = lastStatusCode.getOptional("lastStatusCode") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun sourceId(): Optional = sourceId.getOptional("sourceId") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun sourceType(): Optional = sourceType.getOptional("sourceType") - - /** - * 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 [attempts]. - * - * Unlike [attempts], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attempts") @ExcludeMissing fun _attempts(): JsonField = attempts - - /** - * 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 [eventType]. - * - * Unlike [eventType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventType") @ExcludeMissing fun _eventType(): JsonField = eventType - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [deliveredAt]. - * - * Unlike [deliveredAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("deliveredAt") - @ExcludeMissing - fun _deliveredAt(): JsonField = deliveredAt - - /** - * Returns the raw JSON value of [lastError]. - * - * Unlike [lastError], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lastError") @ExcludeMissing fun _lastError(): JsonField = lastError - - /** - * Returns the raw JSON value of [lastStatusCode]. - * - * Unlike [lastStatusCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("lastStatusCode") - @ExcludeMissing - fun _lastStatusCode(): JsonField = lastStatusCode - - /** - * Returns the raw JSON value of [sourceId]. - * - * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sourceId") @ExcludeMissing fun _sourceId(): JsonField = sourceId - - /** - * Returns the raw JSON value of [sourceType]. - * - * Unlike [sourceType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sourceType") - @ExcludeMissing - fun _sourceType(): JsonField = sourceType - - @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 [Delivery]. - * - * The following fields are required: - * ```java - * .id() - * .attempts() - * .createdAt() - * .eventType() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Delivery]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var attempts: JsonField? = null - private var createdAt: JsonField? = null - private var eventType: JsonField? = null - private var status: JsonField? = null - private var deliveredAt: JsonField = JsonMissing.of() - private var lastError: JsonField = JsonMissing.of() - private var lastStatusCode: JsonField = JsonMissing.of() - private var sourceId: JsonField = JsonMissing.of() - private var sourceType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(delivery: Delivery) = apply { - id = delivery.id - attempts = delivery.attempts - createdAt = delivery.createdAt - eventType = delivery.eventType - status = delivery.status - deliveredAt = delivery.deliveredAt - lastError = delivery.lastError - lastStatusCode = delivery.lastStatusCode - sourceId = delivery.sourceId - sourceType = delivery.sourceType - additionalProperties = delivery.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 attempts(attempts: Long) = attempts(JsonField.of(attempts)) - - /** - * Sets [Builder.attempts] to an arbitrary JSON value. - * - * You should usually call [Builder.attempts] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attempts(attempts: JsonField) = apply { this.attempts = attempts } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 eventType(eventType: String) = eventType(JsonField.of(eventType)) - - /** - * Sets [Builder.eventType] to an arbitrary JSON value. - * - * You should usually call [Builder.eventType] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventType(eventType: JsonField) = apply { this.eventType = eventType } - - fun status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun deliveredAt(deliveredAt: OffsetDateTime) = deliveredAt(JsonField.of(deliveredAt)) - - /** - * Sets [Builder.deliveredAt] to an arbitrary JSON value. - * - * You should usually call [Builder.deliveredAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun deliveredAt(deliveredAt: JsonField) = apply { - this.deliveredAt = deliveredAt - } - - fun lastError(lastError: String) = lastError(JsonField.of(lastError)) - - /** - * Sets [Builder.lastError] to an arbitrary JSON value. - * - * You should usually call [Builder.lastError] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lastError(lastError: JsonField) = apply { this.lastError = lastError } - - fun lastStatusCode(lastStatusCode: Long) = lastStatusCode(JsonField.of(lastStatusCode)) - - /** - * Sets [Builder.lastStatusCode] to an arbitrary JSON value. - * - * You should usually call [Builder.lastStatusCode] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lastStatusCode(lastStatusCode: JsonField) = apply { - this.lastStatusCode = lastStatusCode - } - - fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) - - /** - * Sets [Builder.sourceId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - - fun sourceType(sourceType: String) = sourceType(JsonField.of(sourceType)) - - /** - * Sets [Builder.sourceType] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceType] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceType(sourceType: JsonField) = apply { this.sourceType = sourceType } - - 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 [Delivery]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .attempts() - * .createdAt() - * .eventType() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Delivery = - Delivery( - checkRequired("id", id), - checkRequired("attempts", attempts), - checkRequired("createdAt", createdAt), - checkRequired("eventType", eventType), - checkRequired("status", status), - deliveredAt, - lastError, - lastStatusCode, - sourceId, - sourceType, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Delivery = apply { - if (validated) { - return@apply - } - - id() - attempts() - createdAt() - eventType() - status() - deliveredAt() - lastError() - lastStatusCode() - sourceId() - sourceType() - 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 (attempts.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (eventType.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (deliveredAt.asKnown().isPresent) 1 else 0) + - (if (lastError.asKnown().isPresent) 1 else 0) + - (if (lastStatusCode.asKnown().isPresent) 1 else 0) + - (if (sourceId.asKnown().isPresent) 1 else 0) + - (if (sourceType.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Delivery && - id == other.id && - attempts == other.attempts && - createdAt == other.createdAt && - eventType == other.eventType && - status == other.status && - deliveredAt == other.deliveredAt && - lastError == other.lastError && - lastStatusCode == other.lastStatusCode && - sourceId == other.sourceId && - sourceType == other.sourceType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - attempts, - createdAt, - eventType, - status, - deliveredAt, - lastError, - lastStatusCode, - sourceId, - sourceType, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Delivery{id=$id, attempts=$attempts, createdAt=$createdAt, eventType=$eventType, status=$status, deliveredAt=$deliveredAt, lastError=$lastError, lastStatusCode=$lastStatusCode, sourceId=$sourceId, sourceType=$sourceType, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationListResponse.kt index a74eb0e..9a9f4a2 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 @@ -6,7 +6,6 @@ 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 @@ -15,10 +14,8 @@ 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 IntegrationListResponse @@ -178,1070 +175,6 @@ 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( - private val id: JsonField, - private val config: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val name: JsonField, - private val type: JsonField, - private val filters: JsonField, - private val messageTemplate: JsonField, - private val scopeAllMonitors: JsonField, - private val silentPush: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") - @ExcludeMissing - isActive: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), - @JsonProperty("messageTemplate") - @ExcludeMissing - messageTemplate: JsonField = JsonMissing.of(), - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - scopeAllMonitors: JsonField = JsonMissing.of(), - @JsonProperty("silentPush") - @ExcludeMissing - silentPush: JsonField = JsonMissing.of(), - ) : this( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - 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") - - /** - * 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). - */ - fun config(): Config = config.getRequired("config") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun 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). - */ - fun filters(): Optional = filters.getOptional("filters") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun messageTemplate(): Optional = messageTemplate.getOptional("messageTemplate") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun scopeAllMonitors(): Optional = scopeAllMonitors.getOptional("scopeAllMonitors") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun silentPush(): Optional = silentPush.getOptional("silentPush") - - /** - * 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 [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * 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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [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 [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters - - /** - * Returns the raw JSON value of [messageTemplate]. - * - * Unlike [messageTemplate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("messageTemplate") - @ExcludeMissing - fun _messageTemplate(): JsonField = messageTemplate - - /** - * Returns the raw JSON value of [scopeAllMonitors]. - * - * Unlike [scopeAllMonitors], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - fun _scopeAllMonitors(): JsonField = scopeAllMonitors - - /** - * Returns the raw JSON value of [silentPush]. - * - * Unlike [silentPush], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("silentPush") - @ExcludeMissing - fun _silentPush(): JsonField = silentPush - - @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 [Integration]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Integration]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var filters: JsonField = JsonMissing.of() - private var messageTemplate: JsonField = JsonMissing.of() - private var scopeAllMonitors: JsonField = JsonMissing.of() - private var silentPush: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(integration: Integration) = apply { - id = integration.id - config = integration.config - createdAt = integration.createdAt - eventTypes = integration.eventTypes.map { it.toMutableList() } - isActive = integration.isActive - name = integration.name - type = integration.type - filters = integration.filters - messageTemplate = integration.messageTemplate - scopeAllMonitors = integration.scopeAllMonitors - silentPush = integration.silentPush - additionalProperties = integration.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 } - - /** Integration config — shape varies by type (JSON) */ - fun config(config: Config) = config(JsonField.of(config)) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 - } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 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 } - - /** Event filter rules (JSON) */ - fun filters(filters: Filters) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed [Filters] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun filters(filters: JsonField) = apply { this.filters = filters } - - fun messageTemplate(messageTemplate: String) = - messageTemplate(JsonField.of(messageTemplate)) - - /** - * Sets [Builder.messageTemplate] to an arbitrary JSON value. - * - * You should usually call [Builder.messageTemplate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageTemplate(messageTemplate: JsonField) = apply { - this.messageTemplate = messageTemplate - } - - fun scopeAllMonitors(scopeAllMonitors: Boolean) = - scopeAllMonitors(JsonField.of(scopeAllMonitors)) - - /** - * Sets [Builder.scopeAllMonitors] to an arbitrary JSON value. - * - * You should usually call [Builder.scopeAllMonitors] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scopeAllMonitors(scopeAllMonitors: JsonField) = apply { - this.scopeAllMonitors = scopeAllMonitors - } - - fun silentPush(silentPush: Boolean) = silentPush(JsonField.of(silentPush)) - - /** - * Sets [Builder.silentPush] to an arbitrary JSON value. - * - * You should usually call [Builder.silentPush] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun silentPush(silentPush: JsonField) = apply { this.silentPush = silentPush } - - 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 [Integration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Integration = - Integration( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("name", name), - checkRequired("type", type), - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Integration = apply { - if (validated) { - return@apply - } - - id() - config().validate() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - name() - type().validate() - filters().ifPresent { it.validate() } - messageTemplate() - scopeAllMonitors() - silentPush() - 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) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageTemplate.asKnown().isPresent) 1 else 0) + - (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( - @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 [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.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 [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = 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 Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 TELEGRAM = of("telegram") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TELEGRAM - } - - /** - * 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 { - TELEGRAM, - /** 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) { - TELEGRAM -> Value.TELEGRAM - 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) { - TELEGRAM -> Known.TELEGRAM - 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() - } - - /** Event filter rules (JSON) */ - class Filters - @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 [Filters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filters]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filters: Filters) = apply { - additionalProperties = filters.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 [Filters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Filters = Filters(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Filters = 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 Filters && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Filters{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Integration && - id == other.id && - config == other.config && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - name == other.name && - type == other.type && - filters == other.filters && - messageTemplate == other.messageTemplate && - scopeAllMonitors == other.scopeAllMonitors && - silentPush == other.silentPush && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Integration{id=$id, config=$config, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, name=$name, type=$type, filters=$filters, messageTemplate=$messageTemplate, scopeAllMonitors=$scopeAllMonitors, silentPush=$silentPush, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt deleted file mode 100644 index 9484811..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationRetrieveResponse.kt +++ /dev/null @@ -1,1058 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.integrations - -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.time.OffsetDateTime -import java.util.Collections -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( - private val id: JsonField, - private val config: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val name: JsonField, - private val type: JsonField, - private val filters: JsonField, - private val messageTemplate: JsonField, - private val scopeAllMonitors: JsonField, - private val silentPush: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), - @JsonProperty("messageTemplate") - @ExcludeMissing - messageTemplate: JsonField = JsonMissing.of(), - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - scopeAllMonitors: JsonField = JsonMissing.of(), - @JsonProperty("silentPush") - @ExcludeMissing - silentPush: JsonField = JsonMissing.of(), - ) : this( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - 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") - - /** - * 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). - */ - fun config(): Config = config.getRequired("config") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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). - */ - fun filters(): Optional = filters.getOptional("filters") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun messageTemplate(): Optional = messageTemplate.getOptional("messageTemplate") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun scopeAllMonitors(): Optional = scopeAllMonitors.getOptional("scopeAllMonitors") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun silentPush(): Optional = silentPush.getOptional("silentPush") - - /** - * 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 [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * 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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [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 [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters - - /** - * Returns the raw JSON value of [messageTemplate]. - * - * Unlike [messageTemplate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageTemplate") - @ExcludeMissing - fun _messageTemplate(): JsonField = messageTemplate - - /** - * Returns the raw JSON value of [scopeAllMonitors]. - * - * Unlike [scopeAllMonitors], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - fun _scopeAllMonitors(): JsonField = scopeAllMonitors - - /** - * Returns the raw JSON value of [silentPush]. - * - * Unlike [silentPush], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("silentPush") @ExcludeMissing fun _silentPush(): JsonField = silentPush - - @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 [IntegrationRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IntegrationRetrieveResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var filters: JsonField = JsonMissing.of() - private var messageTemplate: JsonField = JsonMissing.of() - private var scopeAllMonitors: JsonField = JsonMissing.of() - private var silentPush: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(integrationRetrieveResponse: IntegrationRetrieveResponse) = apply { - id = integrationRetrieveResponse.id - config = integrationRetrieveResponse.config - createdAt = integrationRetrieveResponse.createdAt - eventTypes = integrationRetrieveResponse.eventTypes.map { it.toMutableList() } - isActive = integrationRetrieveResponse.isActive - name = integrationRetrieveResponse.name - type = integrationRetrieveResponse.type - filters = integrationRetrieveResponse.filters - messageTemplate = integrationRetrieveResponse.messageTemplate - scopeAllMonitors = integrationRetrieveResponse.scopeAllMonitors - silentPush = integrationRetrieveResponse.silentPush - additionalProperties = integrationRetrieveResponse.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 } - - /** Integration config — shape varies by type (JSON) */ - fun config(config: Config) = config(JsonField.of(config)) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 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 } - - /** Event filter rules (JSON) */ - fun filters(filters: Filters) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField) = apply { this.filters = filters } - - fun messageTemplate(messageTemplate: String) = - messageTemplate(JsonField.of(messageTemplate)) - - /** - * Sets [Builder.messageTemplate] to an arbitrary JSON value. - * - * You should usually call [Builder.messageTemplate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageTemplate(messageTemplate: JsonField) = apply { - this.messageTemplate = messageTemplate - } - - fun scopeAllMonitors(scopeAllMonitors: Boolean) = - scopeAllMonitors(JsonField.of(scopeAllMonitors)) - - /** - * Sets [Builder.scopeAllMonitors] to an arbitrary JSON value. - * - * You should usually call [Builder.scopeAllMonitors] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scopeAllMonitors(scopeAllMonitors: JsonField) = apply { - this.scopeAllMonitors = scopeAllMonitors - } - - fun silentPush(silentPush: Boolean) = silentPush(JsonField.of(silentPush)) - - /** - * Sets [Builder.silentPush] to an arbitrary JSON value. - * - * You should usually call [Builder.silentPush] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun silentPush(silentPush: JsonField) = apply { this.silentPush = silentPush } - - 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 [IntegrationRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): IntegrationRetrieveResponse = - IntegrationRetrieveResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("name", name), - checkRequired("type", type), - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): IntegrationRetrieveResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - name() - type().validate() - filters().ifPresent { it.validate() } - messageTemplate() - scopeAllMonitors() - silentPush() - 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) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageTemplate.asKnown().isPresent) 1 else 0) + - (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( - @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 [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.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 [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = 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 Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 TELEGRAM = of("telegram") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TELEGRAM - } - - /** - * 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 { - TELEGRAM, - /** 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) { - TELEGRAM -> Value.TELEGRAM - 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) { - TELEGRAM -> Known.TELEGRAM - 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() - } - - /** Event filter rules (JSON) */ - class Filters - @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 [Filters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filters]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filters: Filters) = apply { - additionalProperties = filters.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 [Filters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Filters = Filters(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Filters = 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 Filters && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Filters{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is IntegrationRetrieveResponse && - id == other.id && - config == other.config && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - name == other.name && - type == other.type && - filters == other.filters && - messageTemplate == other.messageTemplate && - scopeAllMonitors == other.scopeAllMonitors && - silentPush == other.silentPush && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IntegrationRetrieveResponse{id=$id, config=$config, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, name=$name, type=$type, filters=$filters, messageTemplate=$messageTemplate, scopeAllMonitors=$scopeAllMonitors, silentPush=$silentPush, additionalProperties=$additionalProperties}" -} 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 4188c51..9da8486 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 @@ -6,7 +6,6 @@ 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 @@ -17,6 +16,7 @@ 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 com.x_twitter_scraper.api.models.EventType import java.util.Collections import java.util.Objects import java.util.Optional @@ -828,160 +828,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Event filter rules (JSON) */ class Filters @JsonCreator 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 deleted file mode 100644 index 97dc95e..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/integrations/IntegrationUpdateResponse.kt +++ /dev/null @@ -1,1058 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.integrations - -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.time.OffsetDateTime -import java.util.Collections -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( - private val id: JsonField, - private val config: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val name: JsonField, - private val type: JsonField, - private val filters: JsonField, - private val messageTemplate: JsonField, - private val scopeAllMonitors: JsonField, - private val silentPush: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), - @JsonProperty("messageTemplate") - @ExcludeMissing - messageTemplate: JsonField = JsonMissing.of(), - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - scopeAllMonitors: JsonField = JsonMissing.of(), - @JsonProperty("silentPush") - @ExcludeMissing - silentPush: JsonField = JsonMissing.of(), - ) : this( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - 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") - - /** - * 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). - */ - fun config(): Config = config.getRequired("config") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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). - */ - fun filters(): Optional = filters.getOptional("filters") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun messageTemplate(): Optional = messageTemplate.getOptional("messageTemplate") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun scopeAllMonitors(): Optional = scopeAllMonitors.getOptional("scopeAllMonitors") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun silentPush(): Optional = silentPush.getOptional("silentPush") - - /** - * 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 [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * 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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [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 [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters - - /** - * Returns the raw JSON value of [messageTemplate]. - * - * Unlike [messageTemplate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageTemplate") - @ExcludeMissing - fun _messageTemplate(): JsonField = messageTemplate - - /** - * Returns the raw JSON value of [scopeAllMonitors]. - * - * Unlike [scopeAllMonitors], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scopeAllMonitors") - @ExcludeMissing - fun _scopeAllMonitors(): JsonField = scopeAllMonitors - - /** - * Returns the raw JSON value of [silentPush]. - * - * Unlike [silentPush], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("silentPush") @ExcludeMissing fun _silentPush(): JsonField = silentPush - - @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 [IntegrationUpdateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IntegrationUpdateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var filters: JsonField = JsonMissing.of() - private var messageTemplate: JsonField = JsonMissing.of() - private var scopeAllMonitors: JsonField = JsonMissing.of() - private var silentPush: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(integrationUpdateResponse: IntegrationUpdateResponse) = apply { - id = integrationUpdateResponse.id - config = integrationUpdateResponse.config - createdAt = integrationUpdateResponse.createdAt - eventTypes = integrationUpdateResponse.eventTypes.map { it.toMutableList() } - isActive = integrationUpdateResponse.isActive - name = integrationUpdateResponse.name - type = integrationUpdateResponse.type - filters = integrationUpdateResponse.filters - messageTemplate = integrationUpdateResponse.messageTemplate - scopeAllMonitors = integrationUpdateResponse.scopeAllMonitors - silentPush = integrationUpdateResponse.silentPush - additionalProperties = integrationUpdateResponse.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 } - - /** Integration config — shape varies by type (JSON) */ - fun config(config: Config) = config(JsonField.of(config)) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 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 } - - /** Event filter rules (JSON) */ - fun filters(filters: Filters) = filters(JsonField.of(filters)) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed [Filters] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun filters(filters: JsonField) = apply { this.filters = filters } - - fun messageTemplate(messageTemplate: String) = - messageTemplate(JsonField.of(messageTemplate)) - - /** - * Sets [Builder.messageTemplate] to an arbitrary JSON value. - * - * You should usually call [Builder.messageTemplate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageTemplate(messageTemplate: JsonField) = apply { - this.messageTemplate = messageTemplate - } - - fun scopeAllMonitors(scopeAllMonitors: Boolean) = - scopeAllMonitors(JsonField.of(scopeAllMonitors)) - - /** - * Sets [Builder.scopeAllMonitors] to an arbitrary JSON value. - * - * You should usually call [Builder.scopeAllMonitors] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scopeAllMonitors(scopeAllMonitors: JsonField) = apply { - this.scopeAllMonitors = scopeAllMonitors - } - - fun silentPush(silentPush: Boolean) = silentPush(JsonField.of(silentPush)) - - /** - * Sets [Builder.silentPush] to an arbitrary JSON value. - * - * You should usually call [Builder.silentPush] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun silentPush(silentPush: JsonField) = apply { this.silentPush = silentPush } - - 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 [IntegrationUpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .createdAt() - * .eventTypes() - * .isActive() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): IntegrationUpdateResponse = - IntegrationUpdateResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("name", name), - checkRequired("type", type), - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): IntegrationUpdateResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - name() - type().validate() - filters().ifPresent { it.validate() } - messageTemplate() - scopeAllMonitors() - silentPush() - 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) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageTemplate.asKnown().isPresent) 1 else 0) + - (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( - @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 [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.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 [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = 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 Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 TELEGRAM = of("telegram") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TELEGRAM - } - - /** - * 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 { - TELEGRAM, - /** 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) { - TELEGRAM -> Value.TELEGRAM - 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) { - TELEGRAM -> Known.TELEGRAM - 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() - } - - /** Event filter rules (JSON) */ - class Filters - @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 [Filters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filters]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filters: Filters) = apply { - additionalProperties = filters.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 [Filters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Filters = Filters(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Filters = 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 Filters && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Filters{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is IntegrationUpdateResponse && - id == other.id && - config == other.config && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - name == other.name && - type == other.type && - filters == other.filters && - messageTemplate == other.messageTemplate && - scopeAllMonitors == other.scopeAllMonitors && - silentPush == other.silentPush && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - createdAt, - eventTypes, - isActive, - name, - type, - filters, - messageTemplate, - scopeAllMonitors, - silentPush, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IntegrationUpdateResponse{id=$id, config=$config, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, name=$name, type=$type, filters=$filters, messageTemplate=$messageTemplate, scopeAllMonitors=$scopeAllMonitors, silentPush=$silentPush, additionalProperties=$additionalProperties}" -} 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 d5e2352..09d619d 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 @@ -6,7 +6,6 @@ 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 @@ -15,6 +14,7 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.EventType import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -347,160 +347,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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/monitors/MonitorCreateParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateParams.kt index 3444b93..02bff00 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 @@ -6,7 +6,6 @@ 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 @@ -18,6 +17,7 @@ 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 com.x_twitter_scraper.api.models.EventType import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull @@ -504,160 +504,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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/monitors/MonitorCreateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorCreateResponse.kt index a91144e..258d721 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 @@ -6,7 +6,6 @@ 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 @@ -15,6 +14,7 @@ import com.x_twitter_scraper.api.core.checkKnown import com.x_twitter_scraper.api.core.checkRequired import com.x_twitter_scraper.api.core.toImmutable import com.x_twitter_scraper.api.errors.XTwitterScraperInvalidDataException +import com.x_twitter_scraper.api.models.EventType import java.time.OffsetDateTime import java.util.Collections import java.util.Objects @@ -313,160 +313,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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/monitors/MonitorListResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorListResponse.kt index 122f2f3..e714d7d 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 @@ -6,7 +6,6 @@ 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 @@ -15,7 +14,6 @@ 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 kotlin.jvm.optionals.getOrNull @@ -207,538 +205,6 @@ 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( - private val id: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val username: JsonField, - private val xUserId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") - @ExcludeMissing - isActive: JsonField = JsonMissing.of(), - @JsonProperty("username") - @ExcludeMissing - username: JsonField = JsonMissing.of(), - @JsonProperty("xUserId") @ExcludeMissing xUserId: JsonField = JsonMissing.of(), - ) : this(id, createdAt, eventTypes, isActive, username, xUserId, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun 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 xUserId(): String = xUserId.getRequired("xUserId") - - /** - * 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 [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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [xUserId]. - * - * Unlike [xUserId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUserId") @ExcludeMissing fun _xUserId(): JsonField = xUserId - - @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 [Monitor]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Monitor]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var username: JsonField? = null - private var xUserId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monitor: Monitor) = apply { - id = monitor.id - createdAt = monitor.createdAt - eventTypes = monitor.eventTypes.map { it.toMutableList() } - isActive = monitor.isActive - username = monitor.username - xUserId = monitor.xUserId - additionalProperties = monitor.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 - } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 xUserId(xUserId: String) = xUserId(JsonField.of(xUserId)) - - /** - * Sets [Builder.xUserId] to an arbitrary JSON value. - * - * You should usually call [Builder.xUserId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun xUserId(xUserId: JsonField) = apply { this.xUserId = xUserId } - - 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 [Monitor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Monitor = - Monitor( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("username", username), - checkRequired("xUserId", xUserId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Monitor = apply { - if (validated) { - return@apply - } - - id() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - username() - xUserId() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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 Monitor && - id == other.id && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - username == other.username && - xUserId == other.xUserId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - eventTypes, - isActive, - username, - xUserId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Monitor{id=$id, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, username=$username, xUserId=$xUserId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt deleted file mode 100644 index 73895f8..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorRetrieveResponse.kt +++ /dev/null @@ -1,527 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.monitors - -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.time.OffsetDateTime -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( - private val id: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val username: JsonField, - private val xUserId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - @JsonProperty("xUserId") @ExcludeMissing xUserId: JsonField = JsonMissing.of(), - ) : this(id, createdAt, eventTypes, isActive, username, xUserId, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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 xUserId(): String = xUserId.getRequired("xUserId") - - /** - * 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 [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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [xUserId]. - * - * Unlike [xUserId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUserId") @ExcludeMissing fun _xUserId(): JsonField = xUserId - - @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 [MonitorRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonitorRetrieveResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var username: JsonField? = null - private var xUserId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monitorRetrieveResponse: MonitorRetrieveResponse) = apply { - id = monitorRetrieveResponse.id - createdAt = monitorRetrieveResponse.createdAt - eventTypes = monitorRetrieveResponse.eventTypes.map { it.toMutableList() } - isActive = monitorRetrieveResponse.isActive - username = monitorRetrieveResponse.username - xUserId = monitorRetrieveResponse.xUserId - additionalProperties = monitorRetrieveResponse.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 xUserId(xUserId: String) = xUserId(JsonField.of(xUserId)) - - /** - * Sets [Builder.xUserId] to an arbitrary JSON value. - * - * You should usually call [Builder.xUserId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun xUserId(xUserId: JsonField) = apply { this.xUserId = xUserId } - - 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 [MonitorRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MonitorRetrieveResponse = - MonitorRetrieveResponse( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("username", username), - checkRequired("xUserId", xUserId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MonitorRetrieveResponse = apply { - if (validated) { - return@apply - } - - id() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - username() - xUserId() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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 MonitorRetrieveResponse && - id == other.id && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - username == other.username && - xUserId == other.xUserId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, eventTypes, isActive, username, xUserId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonitorRetrieveResponse{id=$id, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, username=$username, xUserId=$xUserId, additionalProperties=$additionalProperties}" -} 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 5b5dc4f..0804303 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 @@ -6,7 +6,6 @@ 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 @@ -17,6 +16,7 @@ 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 com.x_twitter_scraper.api.models.EventType import java.util.Collections import java.util.Objects import java.util.Optional @@ -486,160 +486,6 @@ 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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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/monitors/MonitorUpdateResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt deleted file mode 100644 index 51e4cbc..0000000 --- a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/monitors/MonitorUpdateResponse.kt +++ /dev/null @@ -1,527 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.x_twitter_scraper.api.models.monitors - -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.time.OffsetDateTime -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( - private val id: JsonField, - private val createdAt: JsonField, - private val eventTypes: JsonField>, - private val isActive: JsonField, - private val username: JsonField, - private val xUserId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("createdAt") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("eventTypes") - @ExcludeMissing - eventTypes: JsonField> = JsonMissing.of(), - @JsonProperty("isActive") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), - @JsonProperty("xUserId") @ExcludeMissing xUserId: JsonField = JsonMissing.of(), - ) : this(id, createdAt, eventTypes, isActive, username, xUserId, mutableMapOf()) - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("createdAt") - - /** - * 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). - */ - fun eventTypes(): List = eventTypes.getRequired("eventTypes") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun isActive(): Boolean = isActive.getRequired("isActive") - - /** - * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun 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 xUserId(): String = xUserId.getRequired("xUserId") - - /** - * 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 [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 [eventTypes]. - * - * Unlike [eventTypes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("eventTypes") - @ExcludeMissing - fun _eventTypes(): JsonField> = eventTypes - - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isActive") @ExcludeMissing fun _isActive(): JsonField = isActive - - /** - * 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 [xUserId]. - * - * Unlike [xUserId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("xUserId") @ExcludeMissing fun _xUserId(): JsonField = xUserId - - @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 [MonitorUpdateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonitorUpdateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var eventTypes: JsonField>? = null - private var isActive: JsonField? = null - private var username: JsonField? = null - private var xUserId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monitorUpdateResponse: MonitorUpdateResponse) = apply { - id = monitorUpdateResponse.id - createdAt = monitorUpdateResponse.createdAt - eventTypes = monitorUpdateResponse.eventTypes.map { it.toMutableList() } - isActive = monitorUpdateResponse.isActive - username = monitorUpdateResponse.username - xUserId = monitorUpdateResponse.xUserId - additionalProperties = monitorUpdateResponse.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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] 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 } - - /** Array of event types to subscribe to. */ - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) - - /** - * Sets [Builder.eventTypes] to an arbitrary JSON value. - * - * You should usually call [Builder.eventTypes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes.map { it.toMutableList() } - } - - /** - * Adds a single [EventType] to [eventTypes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEventType(eventType: EventType) = apply { - eventTypes = - (eventTypes ?: JsonField.of(mutableListOf())).also { - checkKnown("eventTypes", it).add(eventType) - } - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * Sets [Builder.isActive] to an arbitrary JSON value. - * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - 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 xUserId(xUserId: String) = xUserId(JsonField.of(xUserId)) - - /** - * Sets [Builder.xUserId] to an arbitrary JSON value. - * - * You should usually call [Builder.xUserId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun xUserId(xUserId: JsonField) = apply { this.xUserId = xUserId } - - 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 [MonitorUpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .eventTypes() - * .isActive() - * .username() - * .xUserId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MonitorUpdateResponse = - MonitorUpdateResponse( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("eventTypes", eventTypes).map { it.toImmutable() }, - checkRequired("isActive", isActive), - checkRequired("username", username), - checkRequired("xUserId", xUserId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MonitorUpdateResponse = apply { - if (validated) { - return@apply - } - - id() - createdAt() - eventTypes().forEach { it.validate() } - isActive() - username() - xUserId() - 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 (createdAt.asKnown().isPresent) 1 else 0) + - (eventTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (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 { - - /** - * 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 TWEET_NEW = of("tweet.new") - - @JvmField val TWEET_REPLY = of("tweet.reply") - - @JvmField val TWEET_RETWEET = of("tweet.retweet") - - @JvmField val TWEET_QUOTE = of("tweet.quote") - - @JvmField val FOLLOWER_GAINED = of("follower.gained") - - @JvmField val FOLLOWER_LOST = of("follower.lost") - - @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) - } - - /** An enum containing [EventType]'s known values. */ - enum class Known { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - } - - /** - * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventType] 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 { - TWEET_NEW, - TWEET_REPLY, - TWEET_RETWEET, - TWEET_QUOTE, - FOLLOWER_GAINED, - FOLLOWER_LOST, - /** - * An enum member indicating that [EventType] 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) { - TWEET_NEW -> Value.TWEET_NEW - TWEET_REPLY -> Value.TWEET_REPLY - TWEET_RETWEET -> Value.TWEET_RETWEET - TWEET_QUOTE -> Value.TWEET_QUOTE - FOLLOWER_GAINED -> Value.FOLLOWER_GAINED - FOLLOWER_LOST -> Value.FOLLOWER_LOST - 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) { - TWEET_NEW -> Known.TWEET_NEW - TWEET_REPLY -> Known.TWEET_REPLY - TWEET_RETWEET -> Known.TWEET_RETWEET - TWEET_QUOTE -> Known.TWEET_QUOTE - FOLLOWER_GAINED -> Known.FOLLOWER_GAINED - FOLLOWER_LOST -> Known.FOLLOWER_LOST - else -> throw XTwitterScraperInvalidDataException("Unknown EventType: $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(): EventType = 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 EventType && 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 MonitorUpdateResponse && - id == other.id && - createdAt == other.createdAt && - eventTypes == other.eventTypes && - isActive == other.isActive && - username == other.username && - xUserId == other.xUserId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, eventTypes, isActive, username, xUserId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonitorUpdateResponse{id=$id, createdAt=$createdAt, eventTypes=$eventTypes, isActive=$isActive, username=$username, xUserId=$xUserId, additionalProperties=$additionalProperties}" -} 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 8a4834d..5f17e52 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 @@ -14,23 +14,21 @@ 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 RadarRetrieveTrendingTopicsResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val items: JsonField>, + private val items: JsonField>, private val total: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), ) : this(items, total, mutableMapOf()) @@ -38,7 +36,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun items(): List = items.getRequired("items") + fun items(): List = items.getRequired("items") /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -51,7 +49,7 @@ private constructor( * * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items /** * Returns the raw JSON value of [total]. @@ -90,7 +88,7 @@ private constructor( /** A builder for [RadarRetrieveTrendingTopicsResponse]. */ class Builder internal constructor() { - private var items: JsonField>? = null + private var items: JsonField>? = null private var total: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -104,25 +102,25 @@ private constructor( radarRetrieveTrendingTopicsResponse.additionalProperties.toMutableMap() } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = items(JsonField.of(items)) /** * Sets [Builder.items] to an arbitrary JSON value. * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun items(items: JsonField>) = apply { + fun items(items: JsonField>) = apply { this.items = items.map { it.toMutableList() } } /** - * Adds a single [Item] to [items]. + * Adds a single [RadarItem] to [items]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addItem(item: Item) = apply { + fun addItem(item: RadarItem) = apply { items = (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } @@ -207,477 +205,6 @@ 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( - private val category: JsonField, - private val publishedAt: JsonField, - private val region: JsonField, - private val score: JsonField, - private val source: JsonField, - private val title: JsonField, - private val description: JsonField, - private val imageUrl: JsonField, - private val url: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("category") - @ExcludeMissing - category: JsonField = JsonMissing.of(), - @JsonProperty("publishedAt") - @ExcludeMissing - publishedAt: JsonField = JsonMissing.of(), - @JsonProperty("region") @ExcludeMissing region: JsonField = JsonMissing.of(), - @JsonProperty("score") @ExcludeMissing score: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("imageUrl") - @ExcludeMissing - imageUrl: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - ) : this( - category, - publishedAt, - region, - score, - source, - title, - description, - imageUrl, - url, - 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 category(): String = category.getRequired("category") - - /** - * @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 publishedAt(): OffsetDateTime = publishedAt.getRequired("publishedAt") - - /** - * @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 region(): String = region.getRequired("region") - - /** - * @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 score(): Double = score.getRequired("score") - - /** - * @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 source(): String = source.getRequired("source") - - /** - * @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 title(): String = title.getRequired("title") - - /** - * @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 imageUrl(): Optional = imageUrl.getOptional("imageUrl") - - /** - * @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 [category]. - * - * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category - - /** - * Returns the raw JSON value of [publishedAt]. - * - * Unlike [publishedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("publishedAt") - @ExcludeMissing - fun _publishedAt(): JsonField = publishedAt - - /** - * Returns the raw JSON value of [region]. - * - * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("region") @ExcludeMissing fun _region(): JsonField = region - - /** - * 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 [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - /** - * 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 [imageUrl]. - * - * Unlike [imageUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("imageUrl") @ExcludeMissing fun _imageUrl(): JsonField = imageUrl - - /** - * 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 [Item]. - * - * The following fields are required: - * ```java - * .category() - * .publishedAt() - * .region() - * .score() - * .source() - * .title() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var category: JsonField? = null - private var publishedAt: JsonField? = null - private var region: JsonField? = null - private var score: JsonField? = null - private var source: JsonField? = null - private var title: JsonField? = null - private var description: JsonField = JsonMissing.of() - private var imageUrl: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - category = item.category - publishedAt = item.publishedAt - region = item.region - score = item.score - source = item.source - title = item.title - description = item.description - imageUrl = item.imageUrl - url = item.url - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun category(category: String) = category(JsonField.of(category)) - - /** - * Sets [Builder.category] to an arbitrary JSON value. - * - * You should usually call [Builder.category] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun category(category: JsonField) = apply { this.category = category } - - fun publishedAt(publishedAt: OffsetDateTime) = publishedAt(JsonField.of(publishedAt)) - - /** - * Sets [Builder.publishedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.publishedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun publishedAt(publishedAt: JsonField) = apply { - this.publishedAt = publishedAt - } - - fun region(region: String) = region(JsonField.of(region)) - - /** - * Sets [Builder.region] to an arbitrary JSON value. - * - * You should usually call [Builder.region] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun region(region: JsonField) = apply { this.region = region } - - 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 } - - 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 title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - 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 imageUrl(imageUrl: String) = imageUrl(JsonField.of(imageUrl)) - - /** - * Sets [Builder.imageUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.imageUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun imageUrl(imageUrl: JsonField) = apply { this.imageUrl = imageUrl } - - 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 [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .category() - * .publishedAt() - * .region() - * .score() - * .source() - * .title() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("category", category), - checkRequired("publishedAt", publishedAt), - checkRequired("region", region), - checkRequired("score", score), - checkRequired("source", source), - checkRequired("title", title), - description, - imageUrl, - url, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - category() - publishedAt() - region() - score() - source() - title() - description() - imageUrl() - 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 (category.asKnown().isPresent) 1 else 0) + - (if (publishedAt.asKnown().isPresent) 1 else 0) + - (if (region.asKnown().isPresent) 1 else 0) + - (if (score.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (imageUrl.asKnown().isPresent) 1 else 0) + - (if (url.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - category == other.category && - publishedAt == other.publishedAt && - region == other.region && - score == other.score && - source == other.source && - title == other.title && - description == other.description && - imageUrl == other.imageUrl && - url == other.url && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - category, - publishedAt, - region, - score, - source, - title, - description, - imageUrl, - url, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{category=$category, publishedAt=$publishedAt, region=$region, score=$score, source=$source, title=$title, description=$description, imageUrl=$imageUrl, url=$url, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleCompareResponse.kt index 90baaa7..b064f3e 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 @@ -10,28 +10,24 @@ 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 StyleCompareResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val style1: JsonField, - private val style2: JsonField, + private val style1: JsonField, + private val style2: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("style1") @ExcludeMissing style1: JsonField = JsonMissing.of(), - @JsonProperty("style2") @ExcludeMissing style2: JsonField = JsonMissing.of(), + @JsonProperty("style1") @ExcludeMissing style1: JsonField = JsonMissing.of(), + @JsonProperty("style2") @ExcludeMissing style2: JsonField = JsonMissing.of(), ) : this(style1, style2, mutableMapOf()) /** @@ -40,7 +36,7 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun style1(): Style1 = style1.getRequired("style1") + fun style1(): StyleProfile = style1.getRequired("style1") /** * Full style profile with sampled tweets used for tone analysis. @@ -48,21 +44,21 @@ private constructor( * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun style2(): Style2 = style2.getRequired("style2") + fun style2(): StyleProfile = style2.getRequired("style2") /** * Returns the raw JSON value of [style1]. * * Unlike [style1], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("style1") @ExcludeMissing fun _style1(): JsonField = style1 + @JsonProperty("style1") @ExcludeMissing fun _style1(): JsonField = style1 /** * Returns the raw JSON value of [style2]. * * Unlike [style2], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("style2") @ExcludeMissing fun _style2(): JsonField = style2 + @JsonProperty("style2") @ExcludeMissing fun _style2(): JsonField = style2 @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -93,8 +89,8 @@ private constructor( /** A builder for [StyleCompareResponse]. */ class Builder internal constructor() { - private var style1: JsonField? = null - private var style2: JsonField? = null + private var style1: JsonField? = null + private var style2: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -105,26 +101,28 @@ private constructor( } /** Full style profile with sampled tweets used for tone analysis. */ - fun style1(style1: Style1) = style1(JsonField.of(style1)) + fun style1(style1: StyleProfile) = style1(JsonField.of(style1)) /** * Sets [Builder.style1] to an arbitrary JSON value. * - * You should usually call [Builder.style1] with a well-typed [Style1] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.style1] with a well-typed [StyleProfile] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun style1(style1: JsonField) = apply { this.style1 = style1 } + 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)) + fun style2(style2: StyleProfile) = style2(JsonField.of(style2)) /** * Sets [Builder.style2] to an arbitrary JSON value. * - * You should usually call [Builder.style2] with a well-typed [Style2] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.style2] with a well-typed [StyleProfile] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun style2(style2: JsonField) = apply { this.style2 = style2 } + fun style2(style2: JsonField) = apply { this.style2 = style2 } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -196,1242 +194,6 @@ 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( - 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 [Style1]. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Style1]. */ - 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(style1: Style1) = apply { - fetchedAt = style1.fetchedAt - isOwnAccount = style1.isOwnAccount - tweetCount = style1.tweetCount - tweets = style1.tweets.map { it.toMutableList() } - xUsername = style1.xUsername - additionalProperties = style1.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 [Style1]. - * - * 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(): Style1 = - Style1( - 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(): Style1 = 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 Style1 && - 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() = - "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( - 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 [Style2]. - * - * The following fields are required: - * ```java - * .fetchedAt() - * .isOwnAccount() - * .tweetCount() - * .tweets() - * .xUsername() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Style2]. */ - 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(style2: Style2) = apply { - fetchedAt = style2.fetchedAt - isOwnAccount = style2.isOwnAccount - tweetCount = style2.tweetCount - tweets = style2.tweets.map { it.toMutableList() } - xUsername = style2.xUsername - additionalProperties = style2.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 [Style2]. - * - * 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(): Style2 = - Style2( - 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(): Style2 = 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 Style2 && - 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() = - "Style2{fetchedAt=$fetchedAt, isOwnAccount=$isOwnAccount, tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt new file mode 100644 index 0000000..d913500 --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleDeleteParams.kt @@ -0,0 +1,229 @@ +// 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 id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** 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 id: 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 { + id = styleDeleteParams.id + additionalHeaders = styleDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = styleDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = styleDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.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( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + 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 && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "StyleDeleteParams{id=$id, 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 new file mode 100644 index 0000000..573cb0e --- /dev/null +++ b/x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceParams.kt @@ -0,0 +1,191 @@ +// 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 id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** 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 id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(styleGetPerformanceParams: StyleGetPerformanceParams) = apply { + id = styleGetPerformanceParams.id + additionalHeaders = styleGetPerformanceParams.additionalHeaders.toBuilder() + additionalQueryParams = styleGetPerformanceParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.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(id, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + 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 && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "StyleGetPerformanceParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} 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/StyleGetPerformanceResponse.kt similarity index 69% rename from x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleAnalyzeResponse.kt rename to x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/styles/StyleGetPerformanceResponse.kt index 9276b0a..b6f4a57 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/StyleGetPerformanceResponse.kt @@ -14,18 +14,14 @@ 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 -/** Full style profile with sampled tweets used for tone analysis. */ -class StyleAnalyzeResponse +class StyleGetPerformanceResponse @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, @@ -34,28 +30,10 @@ private constructor( @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") + ) : this(tweetCount, tweets, xUsername, mutableMapOf()) /** * @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is @@ -75,24 +53,6 @@ private constructor( */ 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]. * @@ -129,12 +89,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [StyleAnalyzeResponse]. + * Returns a mutable builder for constructing an instance of [StyleGetPerformanceResponse]. * * The following fields are required: * ```java - * .fetchedAt() - * .isOwnAccount() * .tweetCount() * .tweets() * .xUsername() @@ -143,48 +101,20 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [StyleAnalyzeResponse]. */ + /** A builder for [StyleGetPerformanceResponse]. */ 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(styleAnalyzeResponse: StyleAnalyzeResponse) = apply { - fetchedAt = styleAnalyzeResponse.fetchedAt - isOwnAccount = styleAnalyzeResponse.isOwnAccount - tweetCount = styleAnalyzeResponse.tweetCount - tweets = styleAnalyzeResponse.tweets.map { it.toMutableList() } - xUsername = styleAnalyzeResponse.xUsername - additionalProperties = styleAnalyzeResponse.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 + 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)) @@ -253,14 +183,12 @@ private constructor( } /** - * Returns an immutable instance of [StyleAnalyzeResponse]. + * Returns an immutable instance of [StyleGetPerformanceResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .fetchedAt() - * .isOwnAccount() * .tweetCount() * .tweets() * .xUsername() @@ -268,10 +196,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): StyleAnalyzeResponse = - StyleAnalyzeResponse( - checkRequired("fetchedAt", fetchedAt), - checkRequired("isOwnAccount", isOwnAccount), + fun build(): StyleGetPerformanceResponse = + StyleGetPerformanceResponse( checkRequired("tweetCount", tweetCount), checkRequired("tweets", tweets).map { it.toImmutable() }, checkRequired("xUsername", xUsername), @@ -281,13 +207,11 @@ private constructor( private var validated: Boolean = false - fun validate(): StyleAnalyzeResponse = apply { + fun validate(): StyleGetPerformanceResponse = apply { if (validated) { return@apply } - fetchedAt() - isOwnAccount() tweetCount() tweets().forEach { it.validate() } xUsername() @@ -309,9 +233,7 @@ private constructor( */ @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) + + (if (tweetCount.asKnown().isPresent) 1 else 0) + (tweets.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (xUsername.asKnown().isPresent) 1 else 0) @@ -320,8 +242,11 @@ private constructor( private constructor( private val id: JsonField, private val text: JsonField, - private val authorUsername: 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, ) { @@ -329,13 +254,29 @@ private constructor( 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()) + @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 @@ -355,13 +296,31 @@ private constructor( * @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") + 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 createdAt(): Optional = createdAt.getOptional("createdAt") + 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]. @@ -378,21 +337,42 @@ private constructor( @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text /** - * Returns the raw JSON value of [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 + + /** + * 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 [authorUsername], this method doesn't throw if the JSON field has an unexpected + * 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("authorUsername") + @JsonProperty("retweetCount") @ExcludeMissing - fun _authorUsername(): JsonField = authorUsername + fun _retweetCount(): JsonField = retweetCount /** - * Returns the raw JSON value of [createdAt]. + * Returns the raw JSON value of [viewCount]. * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [viewCount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("createdAt") @ExcludeMissing fun _createdAt(): JsonField = createdAt + @JsonProperty("viewCount") @ExcludeMissing fun _viewCount(): JsonField = viewCount @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -425,16 +405,22 @@ private 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 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 - authorUsername = tweet.authorUsername createdAt = tweet.createdAt + likeCount = tweet.likeCount + replyCount = tweet.replyCount + retweetCount = tweet.retweetCount + viewCount = tweet.viewCount additionalProperties = tweet.additionalProperties.toMutableMap() } @@ -460,30 +446,62 @@ private constructor( */ fun text(text: JsonField) = apply { this.text = text } - fun authorUsername(authorUsername: String) = - authorUsername(JsonField.of(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 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.authorUsername] to an arbitrary JSON value. + * Sets [Builder.replyCount] to an arbitrary JSON value. * - * You should usually call [Builder.authorUsername] with a well-typed [String] 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 authorUsername(authorUsername: JsonField) = apply { - this.authorUsername = authorUsername + fun retweetCount(retweetCount: JsonField) = apply { + this.retweetCount = retweetCount } - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + fun viewCount(viewCount: Long) = viewCount(JsonField.of(viewCount)) /** - * Sets [Builder.createdAt] to an arbitrary JSON value. + * Sets [Builder.viewCount] to an arbitrary JSON value. * - * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * 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 createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + fun viewCount(viewCount: JsonField) = apply { this.viewCount = viewCount } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -521,8 +539,11 @@ private constructor( Tweet( checkRequired("id", id), checkRequired("text", text), - authorUsername, createdAt, + likeCount, + replyCount, + retweetCount, + viewCount, additionalProperties.toMutableMap(), ) } @@ -536,8 +557,11 @@ private constructor( id() text() - authorUsername() createdAt() + likeCount() + replyCount() + retweetCount() + viewCount() validated = true } @@ -559,8 +583,11 @@ private constructor( 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) + (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) { @@ -570,19 +597,31 @@ private constructor( return other is Tweet && id == other.id && text == other.text && - authorUsername == other.authorUsername && 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, authorUsername, createdAt, additionalProperties) + Objects.hash( + id, + text, + createdAt, + likeCount, + replyCount, + retweetCount, + viewCount, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Tweet{id=$id, text=$text, authorUsername=$authorUsername, createdAt=$createdAt, additionalProperties=$additionalProperties}" + "Tweet{id=$id, text=$text, createdAt=$createdAt, likeCount=$likeCount, replyCount=$replyCount, retweetCount=$retweetCount, viewCount=$viewCount, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -590,9 +629,7 @@ private constructor( return true } - return other is StyleAnalyzeResponse && - fetchedAt == other.fetchedAt && - isOwnAccount == other.isOwnAccount && + return other is StyleGetPerformanceResponse && tweetCount == other.tweetCount && tweets == other.tweets && xUsername == other.xUsername && @@ -600,11 +637,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(fetchedAt, isOwnAccount, tweetCount, tweets, xUsername, additionalProperties) + Objects.hash(tweetCount, tweets, xUsername, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "StyleAnalyzeResponse{fetchedAt=$fetchedAt, isOwnAccount=$isOwnAccount, tweetCount=$tweetCount, tweets=$tweets, xUsername=$xUsername, additionalProperties=$additionalProperties}" + "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 f1402b5..909ab03 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 @@ -14,7 +14,6 @@ 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 kotlin.jvm.optionals.getOrNull @@ -22,27 +21,31 @@ import kotlin.jvm.optionals.getOrNull class StyleListResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val styles: JsonField>, + private val styles: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("styles") @ExcludeMissing styles: JsonField> = JsonMissing.of() + @JsonProperty("styles") + @ExcludeMissing + styles: JsonField> = JsonMissing.of() ) : this(styles, 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 styles(): List