Module: Twitter::REST::AccountActivity

Includes:
Utils, Utils
Included in:
API
Defined in:
lib/twitter/rest/account_activity.rb

Overview

Methods for interacting with the Account Activity API

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#check_subscription(env_name) ⇒ nil

Note:

Check if the user is subscribed to the given app

Checks if the user is subscribed to the webhook

Examples:

client.check_subscription("production")

Parameters:

  • env_name (String)

    Environment Name

Returns:

  • (nil)

Raises:

See Also:



107
108
109
# File 'lib/twitter/rest/account_activity.rb', line 107

def check_subscription(env_name)
  perform_request(:get, "/1.1/account_activity/all/#{env_name}/subscriptions.json")
end

#create_subscription(env_name) ⇒ nil

Note:

Subscribe the user to receive webhook events

Subscribes the application to all events for the environment

Examples:

client.create_subscription("production")

Parameters:

  • env_name (String)

    Environment Name

Returns:

  • (nil)

Raises:

See Also:



91
92
93
# File 'lib/twitter/rest/account_activity.rb', line 91

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

Note:

Create a webhook

Registers a webhook URL for all event types

Examples:

client.create_webhook("production", "https://example.com/webhook")

Parameters:

  • env_name (String)

    Environment Name

  • url (String)

    Encoded URL for the callback endpoint

Returns:

  • (Hash)

Raises:

See Also:



26
27
28
# File 'lib/twitter/rest/account_activity.rb', line 26

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

Note:

Deactivate a subscription

Deactivates subscription for the user and application

Examples:

client.deactivate_subscription("production")

Parameters:

  • env_name (String)

    Environment Name

Returns:

  • (nil)

Raises:

See Also:



123
124
125
# File 'lib/twitter/rest/account_activity.rb', line 123

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

Note:

Delete a webhook

Removes the webhook from the application’s configuration

Examples:

client.delete_webhook("production", "12345")

Parameters:

  • env_name (String)

    Environment Name

  • webhook_id (String)

    Webhook ID

Returns:

  • (nil)

Raises:

See Also:



58
59
60
# File 'lib/twitter/rest/account_activity.rb', line 58

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

Note:

List webhooks

Returns all environments and webhook URLs for the app

Examples:

client.list_webhooks("production")

Parameters:

  • env_name (String)

    Environment Name

Returns:

  • (Hash)

Raises:

See Also:



42
43
44
# File 'lib/twitter/rest/account_activity.rb', line 42

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

Note:

Trigger CRC check to a webhook

Triggers the challenge response check (CRC) for a webhook

Examples:

client.trigger_crc_check("production", "12345")

Parameters:

  • env_name (String)

    Environment Name

  • webhook_id (String)

    Webhook ID

Returns:

  • (nil)

Raises:

See Also:



75
76
77
# File 'lib/twitter/rest/account_activity.rb', line 75

def trigger_crc_check(env_name, webhook_id)
  perform_request(:json_put, "/1.1/account_activity/all/#{env_name}/webhooks/#{webhook_id}.json")
end