sferik / twitter-ruby

A Ruby interface to the Twitter API.
http://www.rubydoc.info/gems/twitter
MIT License
4.58k stars 1.31k forks source link

Support AccountActivityAPIs #978

Closed tadao closed 1 year ago

tadao commented 4 years ago

How about the rest Premium Account Activity APIs? https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/subscribe-account-activity/api-reference/aaa-premium#post-account-activity-all-env-name-webhooks

I created the API list which is supported, unsupported and deprecated below.

Any thoughts?

Ref: https://github.com/sferik/twitter/issues/883

tadao commented 4 years ago

I coded a monkeypatch.

module AccountActivityPatch
  # GET account_activity/all/subscriptions/count
  def count_subscriptions
    perform_request(:get, "/1.1/account_activity/all/subscriptions/count.json")
  end

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

  # DELETE /account_activity/all/:env_name/subscriptions/:user_id.json
  def delete_subscription(env_name, user_id)
    perform_request(:delete, "/1.1/account_activity/all/#{env_name}/subscriptions/#{user_id}.json")
  end
end

Thanks :)