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 1/4] 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 2/4] 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 3/4] 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 deff6f36cc1b12586bcd74e74582eafa8ca12067 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:42 +0000 Subject: [PATCH 4/4] release: 0.3.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..6b7b74c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.3.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2239e78..4073737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.3.0 (2026-04-02) + +Full Changelog: [v0.2.0...v0.3.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.2.0...v0.3.0) + +### Features + +* **api:** api update ([be5b4f9](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/be5b4f9f89ea2e7606d57cb7f0ea809c17c4096f)) +* **api:** api update ([a4e0acd](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/a4e0acdd9e95507a2d69d05b50c5b8c114c7cd0b)) + ## 0.2.0 (2026-04-01) Full Changelog: [v0.1.0...v0.2.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.1.0...v0.2.0) diff --git a/README.md b/README.md index 39d4d2e..752032b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java)](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0) -[![javadoc](https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0/javadoc.svg)](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java)](https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0) +[![javadoc](https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [xquik.com](https://xquik.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2.0). +The REST API documentation can be found on [xquik.com](https://xquik.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.3.0). @@ -26,7 +26,7 @@ The REST API documentation can be found on [xquik.com](https://xquik.com). Javad ### Gradle ```kotlin -implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0") +implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.3.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0") com.x_twitter_scraper.api x-twitter-scraper-java - 0.2.0 + 0.3.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 81f4172..93d1d37 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.x_twitter_scraper.api" - version = "0.2.0" // x-release-please-version + version = "0.3.0" // x-release-please-version } subprojects {