Skip to content

Commit d9ec682

Browse files
feat(api): api update
1 parent aa06dd7 commit d9ec682

15 files changed

Lines changed: 127 additions & 145 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 124
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik/x-twitter-scraper-7bcac1557175956021a62532c55ce29b8822b5a41d0d59ae67787a6326c0ef8a.yml
3-
openapi_spec_hash: 04e28f19097d9b59119101492100c4ab
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik/x-twitter-scraper-f688ec225c65653bb6ba3f51fe643fc69e329fa93cdc13117060d56de13823cc.yml
3+
openapi_spec_hash: 4ad185ef874409f7cd359beed23f448f
44
config_hash: 217d68ca6999ad03cfc4922e9658297e

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import java.util.Objects
2424
import java.util.Optional
2525

2626
/**
27-
* Create a Stripe Checkout session only after the user confirms. The request never completes
28-
* payment or adds credits by itself.
27+
* Create a hosted checkout only after the user confirms. The request never completes payment or
28+
* adds credits.
2929
*/
3030
class CreditTopupBalanceParams
3131
private constructor(

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ private constructor(
3636
) : this(redirectUrl, url, mutableMapOf())
3737

3838
/**
39-
* Stable first-party Xquik redirect URL for the active Stripe Checkout session.
39+
* Stable Xquik redirect URL for the active checkout.
4040
*
4141
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
4242
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
4343
*/
4444
fun redirectUrl(): String = redirectUrl.getRequired("redirect_url")
4545

4646
/**
47-
* Same stable first-party Xquik redirect URL as redirect_url. The response never exposes a raw
48-
* Stripe Checkout URL.
47+
* Same stable Xquik redirect URL as redirect_url. The response never exposes the hosted
48+
* checkout URL.
4949
*
5050
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
5151
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -108,7 +108,7 @@ private constructor(
108108
additionalProperties = creditTopupBalanceResponse.additionalProperties.toMutableMap()
109109
}
110110

111-
/** Stable first-party Xquik redirect URL for the active Stripe Checkout session. */
111+
/** Stable Xquik redirect URL for the active checkout. */
112112
fun redirectUrl(redirectUrl: String) = redirectUrl(JsonField.of(redirectUrl))
113113

114114
/**
@@ -121,8 +121,8 @@ private constructor(
121121
fun redirectUrl(redirectUrl: JsonField<String>) = apply { this.redirectUrl = redirectUrl }
122122

123123
/**
124-
* Same stable first-party Xquik redirect URL as redirect_url. The response never exposes a
125-
* raw Stripe Checkout URL.
124+
* Same stable Xquik redirect URL as redirect_url. The response never exposes the hosted
125+
* checkout URL.
126126
*/
127127
fun url(url: String) = url(JsonField.of(url))
128128

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ import java.util.Collections
2323
import java.util.Objects
2424

2525
/**
26-
* Create a one-use Stripe-hosted checkout after the user explicitly confirms a $10-$250 USD amount.
27-
* This request creates no charge by itself. The user opens checkout_url on Stripe. This endpoint
28-
* returns the paid-read API key without requiring an Xquik account, email, dashboard, or Xquik web
29-
* page. An idempotent replay returns the same key.
26+
* Create a one-use hosted checkout after the user confirms $10-$250 USD. The request creates no
27+
* charge. It returns a paid-read API key without an Xquik account. Replays return the same key.
3028
*/
3129
class GuestWalletCreateParams
3230
private constructor(

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

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private constructor(
3434
private val credentialNotice: JsonValue,
3535
private val credits: JsonField<String>,
3636
private val expiresAt: JsonField<OffsetDateTime>,
37-
private val instructions: JsonValue,
37+
private val instructions: JsonField<String>,
3838
private val pollAfterSeconds: JsonValue,
3939
private val purchaseId: JsonField<String>,
4040
private val requiresUserInteraction: JsonValue,
@@ -66,7 +66,9 @@ private constructor(
6666
@JsonProperty("expires_at")
6767
@ExcludeMissing
6868
expiresAt: JsonField<OffsetDateTime> = JsonMissing.of(),
69-
@JsonProperty("instructions") @ExcludeMissing instructions: JsonValue = JsonMissing.of(),
69+
@JsonProperty("instructions")
70+
@ExcludeMissing
71+
instructions: JsonField<String> = JsonMissing.of(),
7072
@JsonProperty("poll_after_seconds")
7173
@ExcludeMissing
7274
pollAfterSeconds: JsonValue = JsonMissing.of(),
@@ -135,7 +137,7 @@ private constructor(
135137
fun authorization(): Authorization = authorization.getRequired("authorization")
136138

137139
/**
138-
* Raw Stripe-hosted checkout URL for user interaction.
140+
* Hosted checkout URL for user interaction.
139141
*
140142
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
141143
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
@@ -172,15 +174,12 @@ private constructor(
172174
fun expiresAt(): OffsetDateTime = expiresAt.getRequired("expires_at")
173175

174176
/**
175-
* Expected to always return the following:
176-
* ```java
177-
* JsonValue.from("Give checkout_url to the user. They must complete payment on Stripe. Never submit payment for them. After payment, poll status_url every poll_after_seconds until latest_purchase.status is no longer pending.")
178-
* ```
177+
* Hosted checkout and status polling instructions.
179178
*
180-
* However, this method can be useful for debugging and logging (e.g. if the server responded
181-
* with an unexpected value).
179+
* @throws XTwitterScraperInvalidDataException if the JSON field has an unexpected type or is
180+
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
182181
*/
183-
@JsonProperty("instructions") @ExcludeMissing fun _instructions(): JsonValue = instructions
182+
fun instructions(): String = instructions.getRequired("instructions")
184183

185184
/**
186185
* Wait at least this long before polling status_url.
@@ -287,6 +286,15 @@ private constructor(
287286
@ExcludeMissing
288287
fun _expiresAt(): JsonField<OffsetDateTime> = expiresAt
289288

289+
/**
290+
* Returns the raw JSON value of [instructions].
291+
*
292+
* Unlike [instructions], this method doesn't throw if the JSON field has an unexpected type.
293+
*/
294+
@JsonProperty("instructions")
295+
@ExcludeMissing
296+
fun _instructions(): JsonField<String> = instructions
297+
290298
/**
291299
* Returns the raw JSON value of [purchaseId].
292300
*
@@ -333,6 +341,7 @@ private constructor(
333341
* .checkoutUrl()
334342
* .credits()
335343
* .expiresAt()
344+
* .instructions()
336345
* .purchaseId()
337346
* .status()
338347
* .walletId()
@@ -355,10 +364,7 @@ private constructor(
355364
)
356365
private var credits: JsonField<String>? = null
357366
private var expiresAt: JsonField<OffsetDateTime>? = null
358-
private var instructions: JsonValue =
359-
JsonValue.from(
360-
"Give checkout_url to the user. They must complete payment on Stripe. Never submit payment for them. After payment, poll status_url every poll_after_seconds until latest_purchase.status is no longer pending."
361-
)
367+
private var instructions: JsonField<String>? = null
362368
private var pollAfterSeconds: JsonValue = JsonValue.from(2)
363369
private var purchaseId: JsonField<String>? = null
364370
private var requiresUserInteraction: JsonValue = JsonValue.from(true)
@@ -443,7 +449,7 @@ private constructor(
443449
this.authorization = authorization
444450
}
445451

446-
/** Raw Stripe-hosted checkout URL for user interaction. */
452+
/** Hosted checkout URL for user interaction. */
447453
fun checkoutUrl(checkoutUrl: String) = checkoutUrl(JsonField.of(checkoutUrl))
448454

449455
/**
@@ -494,19 +500,19 @@ private constructor(
494500
*/
495501
fun expiresAt(expiresAt: JsonField<OffsetDateTime>) = apply { this.expiresAt = expiresAt }
496502

503+
/** Hosted checkout and status polling instructions. */
504+
fun instructions(instructions: String) = instructions(JsonField.of(instructions))
505+
497506
/**
498-
* Sets the field to an arbitrary JSON value.
499-
*
500-
* It is usually unnecessary to call this method because the field defaults to the
501-
* following:
502-
* ```java
503-
* JsonValue.from("Give checkout_url to the user. They must complete payment on Stripe. Never submit payment for them. After payment, poll status_url every poll_after_seconds until latest_purchase.status is no longer pending.")
504-
* ```
507+
* Sets [Builder.instructions] to an arbitrary JSON value.
505508
*
509+
* You should usually call [Builder.instructions] with a well-typed [String] value instead.
506510
* This method is primarily for setting the field to an undocumented or not yet supported
507511
* value.
508512
*/
509-
fun instructions(instructions: JsonValue) = apply { this.instructions = instructions }
513+
fun instructions(instructions: JsonField<String>) = apply {
514+
this.instructions = instructions
515+
}
510516

511517
/**
512518
* Sets the field to an arbitrary JSON value.
@@ -617,6 +623,7 @@ private constructor(
617623
* .checkoutUrl()
618624
* .credits()
619625
* .expiresAt()
626+
* .instructions()
620627
* .purchaseId()
621628
* .status()
622629
* .walletId()
@@ -634,7 +641,7 @@ private constructor(
634641
credentialNotice,
635642
checkRequired("credits", credits),
636643
checkRequired("expiresAt", expiresAt),
637-
instructions,
644+
checkRequired("instructions", instructions),
638645
pollAfterSeconds,
639646
checkRequired("purchaseId", purchaseId),
640647
requiresUserInteraction,
@@ -685,16 +692,7 @@ private constructor(
685692
}
686693
credits()
687694
expiresAt()
688-
_instructions().let {
689-
if (
690-
it !=
691-
JsonValue.from(
692-
"Give checkout_url to the user. They must complete payment on Stripe. Never submit payment for them. After payment, poll status_url every poll_after_seconds until latest_purchase.status is no longer pending."
693-
)
694-
) {
695-
throw XTwitterScraperInvalidDataException("'instructions' is invalid, received $it")
696-
}
697-
}
695+
instructions()
698696
_pollAfterSeconds().let {
699697
if (it != JsonValue.from(2)) {
700698
throw XTwitterScraperInvalidDataException(
@@ -752,16 +750,7 @@ private constructor(
752750
} +
753751
(if (credits.asKnown().isPresent) 1 else 0) +
754752
(if (expiresAt.asKnown().isPresent) 1 else 0) +
755-
instructions.let {
756-
if (
757-
it ==
758-
JsonValue.from(
759-
"Give checkout_url to the user. They must complete payment on Stripe. Never submit payment for them. After payment, poll status_url every poll_after_seconds until latest_purchase.status is no longer pending."
760-
)
761-
)
762-
1
763-
else 0
764-
} +
753+
(if (instructions.asKnown().isPresent) 1 else 0) +
765754
pollAfterSeconds.let { if (it == JsonValue.from(2)) 1 else 0 } +
766755
(if (purchaseId.asKnown().isPresent) 1 else 0) +
767756
requiresUserInteraction.let { if (it == JsonValue.from(true)) 1 else 0 } +

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import com.x_twitter_scraper.api.core.http.QueryParams
1212
import java.util.Objects
1313

1414
/**
15-
* Poll after Stripe payment. Use usable to decide whether paid reads can run. An active wallet can
16-
* remain usable while a top-up is pending. A new wallet becomes usable only after verified webhook
17-
* fulfillment. Send the guest key as Authorization: Bearer.
15+
* Poll after payment. Use usable to decide whether paid reads can run. An active wallet can remain
16+
* usable while a top-up is pending. A new wallet becomes usable only after payment is verified.
17+
* Send the guest key as Authorization: Bearer.
1818
*/
1919
class GuestWalletRetrieveStatusParams
2020
private constructor(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import java.util.Collections
2323
import java.util.Objects
2424

2525
/**
26-
* Create a one-use Stripe-hosted checkout for an existing paid-read guest key after the user
27-
* explicitly confirms a $10-$250 USD amount. The key remains the same. This request creates no
28-
* charge by itself and never redirects through an Xquik web page.
26+
* Create a one-use hosted checkout after the user confirms a $10-$250 USD amount for an existing
27+
* paid-read guest key. The key remains the same. This request creates no charge and never redirects
28+
* through Xquik.
2929
*/
3030
class GuestWalletTopupParams
3131
private constructor(

0 commit comments

Comments
 (0)