Module: Twitter::REST::AccountActivity
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#check_subscription(env_name) ⇒ nil
Provides a way to determine if a webhook configuration is subscribed to the provided user's events.
-
#create_subscription(env_name) ⇒ nil
Subscribes the provided application to all events for the provided environment for all message types.
-
#create_webhook(env_name, url) ⇒ Hash
Registers a webhook URL for all event types.
-
#deactivate_subscription(env_name) ⇒ nil
Deactivates subscription(s) for the provided user context and application for all activities.
-
#delete_webhook(env_name, webhook_id) ⇒ nil
Removes the webhook from the provided application's all activities configuration.
-
#list_webhooks(env_name) ⇒ Hash
Returns all environments, webhook URLs and their statuses for the authenticating app.
-
#trigger_crc_check(env_name, webhook_id) ⇒ nil
Triggers the challenge response check (CRC) for the given enviroments webhook for all activites.
Methods included from Utils
Instance Method Details
#check_subscription(env_name) ⇒ nil
Check if the user is subscribed to the given app
Provides a way to determine if a webhook configuration is subscribed to the provided user's events. If the provided user context has an active subscription with provided application, returns 204 OK.
82 83 84 |
# File 'lib/twitter/rest/account_activity.rb', line 82 def check_subscription(env_name) perform_request(:get, "/1.1/account_activity/all/#{env_name}/subscriptions.json") end |
#create_subscription(env_name) ⇒ nil
Subscribe the user(whose credentials are provided) to the app so that the webhook can receive all types of events from user
Subscribes the provided application to all events for the provided environment for all message types. After activation, all events for the requesting user will be sent to the application's webhook via POST request.
70 71 72 |
# File 'lib/twitter/rest/account_activity.rb', line 70 def create_subscription(env_name) perform_request(:json_post, "/1.1/account_activity/all/#{env_name}/subscriptions.json") end |
#create_webhook(env_name, url) ⇒ Hash
Create a webhook
Registers a webhook URL for all event types. The URL will be validated via CRC request before saving. In case the validation failed, returns comprehensive error message to the requester.
21 22 23 |
# File 'lib/twitter/rest/account_activity.rb', line 21 def create_webhook(env_name, url) perform_request(:json_post, "/1.1/account_activity/all/#{env_name}/webhooks.json?url=#{url}") end |
#deactivate_subscription(env_name) ⇒ nil
Deactivate a subscription, Users events will not be sent to the app
Deactivates subscription(s) for the provided user context and application for all activities. After deactivation, all events for the requesting user will no longer be sent to the webhook URL.
94 95 96 |
# File 'lib/twitter/rest/account_activity.rb', line 94 def deactivate_subscription(env_name) perform_request(:delete, "/1.1/account_activity/all/#{env_name}/subscriptions.json") end |
#delete_webhook(env_name, webhook_id) ⇒ nil
Delete a webhook
Removes the webhook from the provided application's all activities configuration. The webhook ID can be accessed by making a call to GET /1.1/account_activity/all/webhooks.
45 46 47 |
# File 'lib/twitter/rest/account_activity.rb', line 45 def delete_webhook(env_name, webhook_id) perform_request(:delete, "/1.1/account_activity/all/#{env_name}/webhooks/#{webhook_id}.json") end |
#list_webhooks(env_name) ⇒ Hash
List webhooks
Returns all environments, webhook URLs and their statuses for the authenticating app. Currently, only one webhook URL can be registered to each environment.
33 34 35 |
# File 'lib/twitter/rest/account_activity.rb', line 33 def list_webhooks(env_name) perform_request(:get, "/1.1/account_activity/all/#{env_name}/webhooks.json") end |
#trigger_crc_check(env_name, webhook_id) ⇒ nil
Trigger CRC check to a webhook
Triggers the challenge response check (CRC) for the given enviroments webhook for all activites. If the check is successful, returns 204 and reenables the webhook by setting its status to valid.
58 59 60 |
# File 'lib/twitter/rest/account_activity.rb', line 58 def trigger_crc_check(env_name, webhook_id) perform_request(:json_put, "/1.1/account_activity/all/#{env_name}/webhooks/#{webhook_id}.json") end |