Module: TwitterLabsAPI::Resources::Tweet
- Included in:
- Client
- Defined in:
- lib/twitter_labs_api/resources/tweet.rb
Constant Summary collapse
- DEFAULT_TWEET_FIELDS =
%w[id author_id created_at lang public_metrics].freeze
- DEFAULT_FIELDS =
{ tweet: DEFAULT_TWEET_FIELDS }.freeze
Instance Method Summary collapse
-
#get_tweet(id:, fields: DEFAULT_FIELDS) ⇒ Object
Returns a variety of information about a single Tweet specified by the requested ID.
-
#get_tweets(ids:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about the Tweet specified by the requested ID or list of IDs.
-
#hide_reply(id:) ⇒ Object
Hides or unhides a reply to a Tweet.
-
#search(query:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
The Labs recent search endpoint returns Tweets from the last 7 days that match a search query.
Instance Method Details
#get_tweet(id:, fields: DEFAULT_FIELDS) ⇒ Object
Returns a variety of information about a single Tweet specified by the requested ID.
13 14 15 16 17 18 |
# File 'lib/twitter_labs_api/resources/tweet.rb', line 13 def get_tweet(id:, fields: DEFAULT_FIELDS) url = "https://api.twitter.com/labs/2/tweets/#{id}" params = ParamsService.from_fields(fields) make_request(url: url, params: params) end |
#get_tweets(ids:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about the Tweet specified by the requested ID or list of IDs.
26 27 28 29 30 31 32 |
# File 'lib/twitter_labs_api/resources/tweet.rb', line 26 def get_tweets(ids:, fields: DEFAULT_FIELDS) url = 'https://api.twitter.com/labs/2/tweets' params = ParamsService.from_fields(fields) params.merge!({ ids: ids.join(',') }) make_request(url: url, params: params, is_collection: true) end |
#hide_reply(id:) ⇒ Object
Hides or unhides a reply to a Tweet.
37 38 39 40 41 |
# File 'lib/twitter_labs_api/resources/tweet.rb', line 37 def hide_reply(id:) url = "https://api.twitter.com/labs/2/tweets/#{id}/hidden" make_request(url: url, method: :put)[:hidden] end |
#search(query:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
The Labs recent search endpoint returns Tweets from the last 7 days that match a search query.
49 50 51 52 53 54 55 |
# File 'lib/twitter_labs_api/resources/tweet.rb', line 49 def search(query:, fields: DEFAULT_FIELDS) url = 'https://api.twitter.com/labs/2/tweets/search' params = ParamsService.from_fields(fields) params.merge!({ query: query }) make_request(url: url, params: params, is_collection: true) end |