Class: XTwitterScraper::Resources::Credits

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/credits.rb

Overview

Subscription & billing

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Credits

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 Credits.

Parameters:



50
51
52
# File 'lib/x_twitter_scraper/resources/credits.rb', line 50

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve_balance(request_options: {}) ⇒ XTwitterScraper::Models::CreditRetrieveBalanceResponse

Get credits balance

Parameters:

Returns:

See Also:



16
17
18
19
20
21
22
23
# File 'lib/x_twitter_scraper/resources/credits.rb', line 16

def retrieve_balance(params = {})
  @client.request(
    method: :get,
    path: "credits",
    model: XTwitterScraper::Models::CreditRetrieveBalanceResponse,
    options: params[:request_options]
  )
end

#topup_balance(amount:, request_options: {}) ⇒ XTwitterScraper::Models::CreditTopupBalanceResponse

Top up credits balance

Parameters:

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
# File 'lib/x_twitter_scraper/resources/credits.rb', line 36

def topup_balance(params)
  parsed, options = XTwitterScraper::CreditTopupBalanceParams.dump_request(params)
  @client.request(
    method: :post,
    path: "credits/topup",
    body: parsed,
    model: XTwitterScraper::Models::CreditTopupBalanceResponse,
    options: options
  )
end