Class: XTwitterScraper::Resources::Webhooks

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

Overview

Webhook endpoint management and delivery

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

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

Parameters:



164
165
166
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 164

def initialize(client:)
  @client = client
end

Instance Method Details

#create(event_types:, url:, request_options: {}) ⇒ XTwitterScraper::Models::WebhookCreateResponse

Create webhook

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 24

def create(params)
  parsed, options = XTwitterScraper::WebhookCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "webhooks",
    body: parsed,
    model: XTwitterScraper::Models::WebhookCreateResponse,
    options: options
  )
end

#deactivate(id, request_options: {}) ⇒ XTwitterScraper::Models::WebhookDeactivateResponse

Deactivate webhook

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



92
93
94
95
96
97
98
99
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 92

def deactivate(id, params = {})
  @client.request(
    method: :delete,
    path: ["webhooks/%1$s", id],
    model: XTwitterScraper::Models::WebhookDeactivateResponse,
    options: params[:request_options]
  )
end

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

List webhooks

Parameters:

Returns:

See Also:



72
73
74
75
76
77
78
79
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 72

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

#list_deliveries(id, request_options: {}) ⇒ XTwitterScraper::Models::WebhookListDeliveriesResponse

List webhook deliveries

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



112
113
114
115
116
117
118
119
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 112

def list_deliveries(id, params = {})
  @client.request(
    method: :get,
    path: ["webhooks/%1$s/deliveries", id],
    model: XTwitterScraper::Models::WebhookListDeliveriesResponse,
    options: params[:request_options]
  )
end

#resume(id, request_options: {}) ⇒ XTwitterScraper::Models::WebhookResumeResponse

Test and resume webhook endpoint

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



132
133
134
135
136
137
138
139
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 132

def resume(id, params = {})
  @client.request(
    method: :post,
    path: ["webhooks/%1$s/resume", id],
    model: XTwitterScraper::Models::WebhookResumeResponse,
    options: params[:request_options]
  )
end

#test_(id, request_options: {}) ⇒ XTwitterScraper::Models::WebhookTestResponse

Test webhook endpoint

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



152
153
154
155
156
157
158
159
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 152

def test_(id, params = {})
  @client.request(
    method: :post,
    path: ["webhooks/%1$s/test", id],
    model: XTwitterScraper::Models::WebhookTestResponse,
    options: params[:request_options]
  )
end

#update(id, event_types: nil, is_active: nil, url: nil, request_options: {}) ⇒ XTwitterScraper::Models::Webhook

Update webhook

Parameters:

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
# File 'lib/x_twitter_scraper/resources/webhooks.rb', line 52

def update(id, params = {})
  parsed, options = XTwitterScraper::WebhookUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["webhooks/%1$s", id],
    body: parsed,
    model: XTwitterScraper::Webhook,
    options: options
  )
end