Skip to content

Commit d2c5ea0

Browse files
feat(api): propagate production write-action contract
1 parent 6b33a54 commit d2c5ea0

123 files changed

Lines changed: 92784 additions & 2601 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 122
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik/x-twitter-scraper-d053a3e575a411e23fdd316b0b97626192c13564ef91814a4831e20a809cfdc5.yml
3-
openapi_spec_hash: 0dc9eb7d023b1a16c08c6fec5a231957
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik/x-twitter-scraper-1a468d8933b6612e40e8b8ebdf84f9e3f014799d0e9a05789b93a242324cd158.yml
3+
openapi_spec_hash: 25b9bc2b3b13c649eccc0a8624c233d3
44
config_hash: 4b64fbd16fd09008417c5a460d27f053

x-twitter-scraper-java-core/src/main/kotlin/com/x_twitter_scraper/api/models/Error.kt

Lines changed: 155 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,99 @@ class Error
3737
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
3838
private constructor(
3939
private val error: JsonField<InnerError>,
40+
private val message: JsonField<String>,
41+
private val reason: JsonField<String>,
42+
private val retryAfter: JsonField<Long>,
43+
private val retryAfterMs: JsonField<Long>,
4044
private val additionalProperties: MutableMap<String, JsonValue>,
4145
) {
4246

4347
@JsonCreator
4448
private constructor(
45-
@JsonProperty("error") @ExcludeMissing error: JsonField<InnerError> = JsonMissing.of()
46-
) : this(error, mutableMapOf())
49+
@JsonProperty("error") @ExcludeMissing error: JsonField<InnerError> = JsonMissing.of(),
50+
@JsonProperty("message") @ExcludeMissing message: JsonField<String> = JsonMissing.of(),
51+
@JsonProperty("reason") @ExcludeMissing reason: JsonField<String> = JsonMissing.of(),
52+
@JsonProperty("retryAfter") @ExcludeMissing retryAfter: JsonField<Long> = JsonMissing.of(),
53+
@JsonProperty("retryAfterMs")
54+
@ExcludeMissing
55+
retryAfterMs: JsonField<Long> = JsonMissing.of(),
56+
) : this(error, message, reason, retryAfter, retryAfterMs, mutableMapOf())
4757

4858
/**
4959
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
5060
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
5161
*/
5262
fun error(): InnerError = error.getRequired("error")
5363

64+
/**
65+
* Human-readable error guidance.
66+
*
67+
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if
68+
* the server responded with an unexpected value).
69+
*/
70+
fun message(): Optional<String> = message.getOptional("message")
71+
72+
/**
73+
* Machine-readable reason for a login cooldown.
74+
*
75+
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if
76+
* the server responded with an unexpected value).
77+
*/
78+
fun reason(): Optional<String> = reason.getOptional("reason")
79+
80+
/**
81+
* Required wait in seconds.
82+
*
83+
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if
84+
* the server responded with an unexpected value).
85+
*/
86+
fun retryAfter(): Optional<Long> = retryAfter.getOptional("retryAfter")
87+
88+
/**
89+
* Required wait in milliseconds.
90+
*
91+
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type (e.g. if
92+
* the server responded with an unexpected value).
93+
*/
94+
fun retryAfterMs(): Optional<Long> = retryAfterMs.getOptional("retryAfterMs")
95+
5496
/**
5597
* Returns the raw JSON value of [error].
5698
*
5799
* Unlike [error], this method doesn't throw if the JSON field has an unexpected type.
58100
*/
59101
@JsonProperty("error") @ExcludeMissing fun _error(): JsonField<InnerError> = error
60102

103+
/**
104+
* Returns the raw JSON value of [message].
105+
*
106+
* Unlike [message], this method doesn't throw if the JSON field has an unexpected type.
107+
*/
108+
@JsonProperty("message") @ExcludeMissing fun _message(): JsonField<String> = message
109+
110+
/**
111+
* Returns the raw JSON value of [reason].
112+
*
113+
* Unlike [reason], this method doesn't throw if the JSON field has an unexpected type.
114+
*/
115+
@JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField<String> = reason
116+
117+
/**
118+
* Returns the raw JSON value of [retryAfter].
119+
*
120+
* Unlike [retryAfter], this method doesn't throw if the JSON field has an unexpected type.
121+
*/
122+
@JsonProperty("retryAfter") @ExcludeMissing fun _retryAfter(): JsonField<Long> = retryAfter
123+
124+
/**
125+
* Returns the raw JSON value of [retryAfterMs].
126+
*
127+
* Unlike [retryAfterMs], this method doesn't throw if the JSON field has an unexpected type.
128+
*/
129+
@JsonProperty("retryAfterMs")
130+
@ExcludeMissing
131+
fun _retryAfterMs(): JsonField<Long> = retryAfterMs
132+
61133
@JsonAnySetter
62134
private fun putAdditionalProperty(key: String, value: JsonValue) {
63135
additionalProperties.put(key, value)
@@ -87,11 +159,19 @@ private constructor(
87159
class Builder internal constructor() {
88160

89161
private var error: JsonField<InnerError>? = null
162+
private var message: JsonField<String> = JsonMissing.of()
163+
private var reason: JsonField<String> = JsonMissing.of()
164+
private var retryAfter: JsonField<Long> = JsonMissing.of()
165+
private var retryAfterMs: JsonField<Long> = JsonMissing.of()
90166
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
91167

92168
@JvmSynthetic
93169
internal fun from(error: Error) = apply {
94170
this.error = error.error
171+
message = error.message
172+
reason = error.reason
173+
retryAfter = error.retryAfter
174+
retryAfterMs = error.retryAfterMs
95175
additionalProperties = error.additionalProperties.toMutableMap()
96176
}
97177

@@ -114,6 +194,51 @@ private constructor(
114194
fun error(structured: InnerError.StructuredError) =
115195
error(InnerError.ofStructured(structured))
116196

197+
/** Human-readable error guidance. */
198+
fun message(message: String) = message(JsonField.of(message))
199+
200+
/**
201+
* Sets [Builder.message] to an arbitrary JSON value.
202+
*
203+
* You should usually call [Builder.message] with a well-typed [String] value instead. This
204+
* method is primarily for setting the field to an undocumented or not yet supported value.
205+
*/
206+
fun message(message: JsonField<String>) = apply { this.message = message }
207+
208+
/** Machine-readable reason for a login cooldown. */
209+
fun reason(reason: String) = reason(JsonField.of(reason))
210+
211+
/**
212+
* Sets [Builder.reason] to an arbitrary JSON value.
213+
*
214+
* You should usually call [Builder.reason] with a well-typed [String] value instead. This
215+
* method is primarily for setting the field to an undocumented or not yet supported value.
216+
*/
217+
fun reason(reason: JsonField<String>) = apply { this.reason = reason }
218+
219+
/** Required wait in seconds. */
220+
fun retryAfter(retryAfter: Long) = retryAfter(JsonField.of(retryAfter))
221+
222+
/**
223+
* Sets [Builder.retryAfter] to an arbitrary JSON value.
224+
*
225+
* You should usually call [Builder.retryAfter] with a well-typed [Long] value instead. This
226+
* method is primarily for setting the field to an undocumented or not yet supported value.
227+
*/
228+
fun retryAfter(retryAfter: JsonField<Long>) = apply { this.retryAfter = retryAfter }
229+
230+
/** Required wait in milliseconds. */
231+
fun retryAfterMs(retryAfterMs: Long) = retryAfterMs(JsonField.of(retryAfterMs))
232+
233+
/**
234+
* Sets [Builder.retryAfterMs] to an arbitrary JSON value.
235+
*
236+
* You should usually call [Builder.retryAfterMs] with a well-typed [Long] value instead.
237+
* This method is primarily for setting the field to an undocumented or not yet supported
238+
* value.
239+
*/
240+
fun retryAfterMs(retryAfterMs: JsonField<Long>) = apply { this.retryAfterMs = retryAfterMs }
241+
117242
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
118243
this.additionalProperties.clear()
119244
putAllAdditionalProperties(additionalProperties)
@@ -146,7 +271,14 @@ private constructor(
146271
* @throws IllegalStateException if any required field is unset.
147272
*/
148273
fun build(): Error =
149-
Error(checkRequired("error", error), additionalProperties.toMutableMap())
274+
Error(
275+
checkRequired("error", error),
276+
message,
277+
reason,
278+
retryAfter,
279+
retryAfterMs,
280+
additionalProperties.toMutableMap(),
281+
)
150282
}
151283

152284
private var validated: Boolean = false
@@ -165,6 +297,10 @@ private constructor(
165297
}
166298

167299
error().validate()
300+
message()
301+
reason()
302+
retryAfter()
303+
retryAfterMs()
168304
validated = true
169305
}
170306

@@ -181,7 +317,13 @@ private constructor(
181317
*
182318
* Used for best match union deserialization.
183319
*/
184-
@JvmSynthetic internal fun validity(): Int = (error.asKnown().getOrNull()?.validity() ?: 0)
320+
@JvmSynthetic
321+
internal fun validity(): Int =
322+
(error.asKnown().getOrNull()?.validity() ?: 0) +
323+
(if (message.asKnown().isPresent) 1 else 0) +
324+
(if (reason.asKnown().isPresent) 1 else 0) +
325+
(if (retryAfter.asKnown().isPresent) 1 else 0) +
326+
(if (retryAfterMs.asKnown().isPresent) 1 else 0)
185327

186328
@JsonDeserialize(using = InnerError.Deserializer::class)
187329
@JsonSerialize(using = InnerError.Serializer::class)
@@ -548,8 +690,6 @@ private constructor(
548690

549691
@JvmField val X_WRITE_FAILED = of("x_write_failed")
550692

551-
@JvmField val X_WRITE_UNCONFIRMED = of("x_write_unconfirmed")
552-
553693
@JvmStatic fun of(value: String) = LegacyErrorCode(JsonField.of(value))
554694
}
555695

@@ -621,7 +761,6 @@ private constructor(
621761
X_USER_LOOKUP_FAILED,
622762
X_WRITE_AMBIGUOUS,
623763
X_WRITE_FAILED,
624-
X_WRITE_UNCONFIRMED,
625764
}
626765

627766
/**
@@ -700,7 +839,6 @@ private constructor(
700839
X_USER_LOOKUP_FAILED,
701840
X_WRITE_AMBIGUOUS,
702841
X_WRITE_FAILED,
703-
X_WRITE_UNCONFIRMED,
704842
/**
705843
* An enum member indicating that [LegacyErrorCode] was instantiated with an unknown
706844
* value.
@@ -783,7 +921,6 @@ private constructor(
783921
X_USER_LOOKUP_FAILED -> Value.X_USER_LOOKUP_FAILED
784922
X_WRITE_AMBIGUOUS -> Value.X_WRITE_AMBIGUOUS
785923
X_WRITE_FAILED -> Value.X_WRITE_FAILED
786-
X_WRITE_UNCONFIRMED -> Value.X_WRITE_UNCONFIRMED
787924
else -> Value._UNKNOWN
788925
}
789926

@@ -864,7 +1001,6 @@ private constructor(
8641001
X_USER_LOOKUP_FAILED -> Known.X_USER_LOOKUP_FAILED
8651002
X_WRITE_AMBIGUOUS -> Known.X_WRITE_AMBIGUOUS
8661003
X_WRITE_FAILED -> Known.X_WRITE_FAILED
867-
X_WRITE_UNCONFIRMED -> Known.X_WRITE_UNCONFIRMED
8681004
else ->
8691005
throw XTwitterScraperInvalidDataException("Unknown LegacyErrorCode: $value")
8701006
}
@@ -1304,8 +1440,6 @@ private constructor(
13041440

13051441
@JvmField val X_WRITE_FAILED = of("x_write_failed")
13061442

1307-
@JvmField val X_WRITE_UNCONFIRMED = of("x_write_unconfirmed")
1308-
13091443
@JvmStatic fun of(value: String) = Code(JsonField.of(value))
13101444
}
13111445

@@ -1377,7 +1511,6 @@ private constructor(
13771511
X_USER_LOOKUP_FAILED,
13781512
X_WRITE_AMBIGUOUS,
13791513
X_WRITE_FAILED,
1380-
X_WRITE_UNCONFIRMED,
13811514
}
13821515

13831516
/**
@@ -1456,7 +1589,6 @@ private constructor(
14561589
X_USER_LOOKUP_FAILED,
14571590
X_WRITE_AMBIGUOUS,
14581591
X_WRITE_FAILED,
1459-
X_WRITE_UNCONFIRMED,
14601592
/**
14611593
* An enum member indicating that [Code] was instantiated with an unknown value.
14621594
*/
@@ -1538,7 +1670,6 @@ private constructor(
15381670
X_USER_LOOKUP_FAILED -> Value.X_USER_LOOKUP_FAILED
15391671
X_WRITE_AMBIGUOUS -> Value.X_WRITE_AMBIGUOUS
15401672
X_WRITE_FAILED -> Value.X_WRITE_FAILED
1541-
X_WRITE_UNCONFIRMED -> Value.X_WRITE_UNCONFIRMED
15421673
else -> Value._UNKNOWN
15431674
}
15441675

@@ -1619,7 +1750,6 @@ private constructor(
16191750
X_USER_LOOKUP_FAILED -> Known.X_USER_LOOKUP_FAILED
16201751
X_WRITE_AMBIGUOUS -> Known.X_WRITE_AMBIGUOUS
16211752
X_WRITE_FAILED -> Known.X_WRITE_FAILED
1622-
X_WRITE_UNCONFIRMED -> Known.X_WRITE_UNCONFIRMED
16231753
else -> throw XTwitterScraperInvalidDataException("Unknown Code: $value")
16241754
}
16251755

@@ -1887,12 +2017,19 @@ private constructor(
18872017

18882018
return other is Error &&
18892019
error == other.error &&
2020+
message == other.message &&
2021+
reason == other.reason &&
2022+
retryAfter == other.retryAfter &&
2023+
retryAfterMs == other.retryAfterMs &&
18902024
additionalProperties == other.additionalProperties
18912025
}
18922026

1893-
private val hashCode: Int by lazy { Objects.hash(error, additionalProperties) }
2027+
private val hashCode: Int by lazy {
2028+
Objects.hash(error, message, reason, retryAfter, retryAfterMs, additionalProperties)
2029+
}
18942030

18952031
override fun hashCode(): Int = hashCode
18962032

1897-
override fun toString() = "Error{error=$error, additionalProperties=$additionalProperties}"
2033+
override fun toString() =
2034+
"Error{error=$error, message=$message, reason=$reason, retryAfter=$retryAfter, retryAfterMs=$retryAfterMs, additionalProperties=$additionalProperties}"
18982035
}

0 commit comments

Comments
 (0)