Class: ChatSDK::X::ApiClient
- Inherits:
-
ApiClient::Base
- Object
- ApiClient::Base
- ChatSDK::X::ApiClient
- Defined in:
- lib/chat_sdk/x/api_client.rb
Constant Summary collapse
- BASE_URL =
"https://api.x.com"
Instance Method Summary collapse
- #create_tweet(text:, reply: nil) ⇒ Object
-
#initialize(access_token) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #like_tweet(user_id:, tweet_id:) ⇒ Object
- #send_dm(participant_id:, text:) ⇒ Object
- #unlike_tweet(user_id:, tweet_id:) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ ApiClient
Returns a new instance of ApiClient.
8 9 10 |
# File 'lib/chat_sdk/x/api_client.rb', line 8 def initialize(access_token) @access_token = access_token end |
Instance Method Details
#create_tweet(text:, reply: nil) ⇒ Object
12 13 14 15 16 |
# File 'lib/chat_sdk/x/api_client.rb', line 12 def create_tweet(text:, reply: nil) body = {"text" => text} body["reply"] = reply if reply request(:post, "/2/tweets", body) end |
#like_tweet(user_id:, tweet_id:) ⇒ Object
22 23 24 |
# File 'lib/chat_sdk/x/api_client.rb', line 22 def like_tweet(user_id:, tweet_id:) request(:post, "/2/users/#{user_id}/likes", {"tweet_id" => tweet_id}) end |
#send_dm(participant_id:, text:) ⇒ Object
18 19 20 |
# File 'lib/chat_sdk/x/api_client.rb', line 18 def send_dm(participant_id:, text:) request(:post, "/2/dm_conversations/with/#{participant_id}/messages", {"text" => text}) end |
#unlike_tweet(user_id:, tweet_id:) ⇒ Object
26 27 28 |
# File 'lib/chat_sdk/x/api_client.rb', line 26 def unlike_tweet(user_id:, tweet_id:) request(:delete, "/2/users/#{user_id}/likes/#{tweet_id}") end |