Class: XTwitterScraper::Resources::GuestWallets

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/guest_wallets.rb,
sig/x_twitter_scraper/resources/guest_wallets.rbs

Overview

Accountless prepaid access for paid read endpoints

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ GuestWallets

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GuestWallets.

Parameters:



103
104
105
# File 'lib/x_twitter_scraper/resources/guest_wallets.rb', line 103

def initialize(client:)
  @client = client
end

Instance Method Details

#create(amount_minor:, idempotency_key:, currency: :usd, request_options: {}) ⇒ XTwitterScraper::Models::GuestWalletCreateResponse

Some parameter documentations has been truncated, see Models::GuestWalletCreateParams for more details.

Create a one-use Stripe-hosted checkout after the user explicitly confirms a $10-$250 USD amount. This request creates no charge by itself. The user opens checkout_url on Stripe. This endpoint returns the paid-read API key without requiring an Xquik account, email, dashboard, or Xquik web page. An idempotent replay returns the same key.

Parameters:

  • amount_minor (Integer)

    Body param: Confirmed USD amount in cents.

  • idempotency_key (String)

    Header param: Generate a cryptographically random UUID v4. Reuse it only to retr

  • currency (Symbol, :usd)

    Body param

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/x_twitter_scraper/resources/guest_wallets.rb', line 29

def create(params)
  parsed, options = XTwitterScraper::GuestWalletCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "guest-wallets",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::GuestWalletCreateResponse,
    security: {},
    options: options
  )
end

#retrieve_status(request_options: {}) ⇒ XTwitterScraper::Models::GuestWalletRetrieveStatusResponse

Poll after Stripe payment. Use usable to decide whether paid reads can run. An active wallet can remain usable while a top-up is pending. A new wallet becomes usable only after verified webhook fulfillment. Send the guest key as Authorization: Bearer.



55
56
57
58
59
60
61
62
63
# File 'lib/x_twitter_scraper/resources/guest_wallets.rb', line 55

def retrieve_status(params = {})
  @client.request(
    method: :get,
    path: "guest-wallets/status",
    model: XTwitterScraper::Models::GuestWalletRetrieveStatusResponse,
    security: {auth_api_key: true},
    options: params[:request_options]
  )
end

#topup(amount_minor:, idempotency_key:, currency: :usd, request_options: {}) ⇒ XTwitterScraper::Models::GuestWalletTopupResponse

Some parameter documentations has been truncated, see Models::GuestWalletTopupParams for more details.

Create a one-use Stripe-hosted checkout for an existing paid-read guest key after the user explicitly confirms a $10-$250 USD amount. The key remains the same. This request creates no charge by itself and never redirects through an Xquik web page.

Parameters:

  • amount_minor (Integer)

    Body param: Confirmed USD amount in cents.

  • idempotency_key (String)

    Header param: Generate a cryptographically random UUID v4. Reuse it only to retr

  • currency (Symbol, :usd)

    Body param

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/x_twitter_scraper/resources/guest_wallets.rb', line 86

def topup(params)
  parsed, options = XTwitterScraper::GuestWalletTopupParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: "guest-wallets/topups",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::GuestWalletTopupResponse,
    security: {auth_api_key: true},
    options: options
  )
end