Class: XTwitterScraper::Resources::Events

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

Overview

Activity events from monitored accounts

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Events

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

Parameters:



60
61
62
# File 'lib/x_twitter_scraper/resources/events.rb', line 60

def initialize(client:)
  @client = client
end

Instance Method Details

#list(after: nil, event_type: nil, limit: nil, monitor_id: nil, request_options: {}) ⇒ XTwitterScraper::Models::EventListResponse

List events

Parameters:

  • after (String)

    Cursor for keyset pagination

  • event_type (Symbol, XTwitterScraper::Models::EventType)

    Filter events by type

  • limit (Integer)

    Maximum number of items to return (1-100, default 50)

  • monitor_id (String)

    Filter events by monitor ID

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

Returns:

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/x_twitter_scraper/resources/events.rb', line 44

def list(params = {})
  parsed, options = XTwitterScraper::EventListParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "events",
    query: query.transform_keys(event_type: "eventType", monitor_id: "monitorId"),
    model: XTwitterScraper::Models::EventListResponse,
    security: {auth_api_key: true},
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::EventDetail

Get event

Parameters:

Returns:

See Also:



18
19
20
21
22
23
24
25
# File 'lib/x_twitter_scraper/resources/events.rb', line 18

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["events/%1$s", id],
    model: XTwitterScraper::EventDetail,
    options: params[:request_options]
  )
end