Class: XTwitterScraper::Resources::APIKeys

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

Overview

API key management (session auth only)

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ APIKeys

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

Parameters:



72
73
74
# File 'lib/x_twitter_scraper/resources/api_keys.rb', line 72

def initialize(client:)
  @client = client
end

Instance Method Details

#create(name: nil, request_options: {}) ⇒ XTwitterScraper::Models::APIKeyCreateResponse

Create API key

Parameters:

Returns:

See Also:



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/x_twitter_scraper/resources/api_keys.rb', line 17

def create(params = {})
  parsed, options = XTwitterScraper::APIKeyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api-keys",
    body: parsed,
    model: XTwitterScraper::Models::APIKeyCreateResponse,
    security: {auth_api_key: true},
    options: options
  )
end

#list(request_options: {}) ⇒ XTwitterScraper::Models::APIKeyListResponse

List API keys

Parameters:

Returns:

See Also:



38
39
40
41
42
43
44
45
46
# File 'lib/x_twitter_scraper/resources/api_keys.rb', line 38

def list(params = {})
  @client.request(
    method: :get,
    path: "api-keys",
    model: XTwitterScraper::Models::APIKeyListResponse,
    security: {auth_api_key: true},
    options: params[:request_options]
  )
end

#revoke(id, request_options: {}) ⇒ XTwitterScraper::Models::APIKeyRevokeResponse

Revoke API key

Parameters:

Returns:

See Also:



59
60
61
62
63
64
65
66
67
# File 'lib/x_twitter_scraper/resources/api_keys.rb', line 59

def revoke(id, params = {})
  @client.request(
    method: :delete,
    path: ["api-keys/%1$s", id],
    model: XTwitterScraper::Models::APIKeyRevokeResponse,
    security: {auth_api_key: true},
    options: params[:request_options]
  )
end