twitter_labs_api 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/twitter_labs_api/resources/tweet.rb +17 -0
- data/lib/twitter_labs_api/resources/user.rb +6 -0
- data/lib/twitter_labs_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 697a03319c55056717774438db0f412e52df2337e52452bfecc0c9f5f00c99f2
|
4
|
+
data.tar.gz: d841c0f5c73763593663180cae40f1528b21037708fbc9b05f0c4fcc89d83720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4f956e69a646de92cd9c79139bae452091603630da9e6596e004d0a6f084c8be362bb083a01aa2ccb66cb4385dcfdc099d35dd8f2b91c291f9a19b93395f774
|
7
|
+
data.tar.gz: 88bb52e555879a7c003f4006f3d4f10c34bd509dfd083ac06856006a3e2a9d2f3b57dcd1a0e5d5e93df3c15a92bd8b723c0b362a40b0a287c639cfe234b68aa1
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,7 @@ Currently, the following endpoints are implemented:
|
|
63
63
|
- `TwitterLabsAPI#get_tweet` ([docs](https://developer.twitter.com/en/docs/labs/tweets-and-users/api-reference/get-tweets-id)) - Retrieve a single Tweet object with an `id`
|
64
64
|
- `TwitterLabsAPI#get_tweets` ([docs](https://developer.twitter.com/en/docs/labs/tweets-and-users/api-reference/get-tweets)) - Retrieve multiple Tweets with a collection of `ids`
|
65
65
|
- `TwitterLabsAPI#hide_reply` ([docs](https://developer.twitter.com/en/docs/labs/hide-replies/api-reference/put-hidden)) - Hide a reply by referencing it's `id`; must be in a conversation belonging to the authenticating user
|
66
|
+
- `TwitterLabsAPI#search` ([docs](https://developer.twitter.com/en/docs/labs/recent-search/api-reference/get-recent-search)) - Returns Tweets from the last 7 days that match a search query.
|
66
67
|
|
67
68
|
#### Users
|
68
69
|
|
@@ -3,6 +3,7 @@ module TwitterLabsAPI
|
|
3
3
|
module Tweet
|
4
4
|
DEFAULT_TWEET_FIELDS = %w[id author_id created_at lang public_metrics].freeze
|
5
5
|
|
6
|
+
# Returns a variety of information about a single Tweet specified by the requested ID.
|
6
7
|
# @param [String] :id the ID of the requested Tweet
|
7
8
|
# @param [Array<String>] :tweet_fields (["id", "author_id", "created_at", "lang", "public_metrics"]) the list of fields to retrieve for the given tweet
|
8
9
|
# @return Hash an object with requested tweet fields
|
@@ -15,6 +16,7 @@ module TwitterLabsAPI
|
|
15
16
|
make_request(url: url, params: params)
|
16
17
|
end
|
17
18
|
|
19
|
+
# Returns a variety of information about the Tweet specified by the requested ID or list of IDs.
|
18
20
|
# @param [Array<String>] :ids the collection of requested Tweet IDs
|
19
21
|
# @param [Array<String>] :tweet_fields (["id", "author_id", "created_at", "lang", "public_metrics"]) the list of fields to retrieve for the given tweet
|
20
22
|
# @return [Array<Hash>] of tweet objects with the requested tweet fields
|
@@ -28,6 +30,7 @@ module TwitterLabsAPI
|
|
28
30
|
make_request(url: url, params: params, is_collection: true)
|
29
31
|
end
|
30
32
|
|
33
|
+
# Hides or unhides a reply to a Tweet.
|
31
34
|
# @param [String] :id the ID of the requested Tweet; must belong to a conversation by the authenticated user
|
32
35
|
# @return boolean indicating the hidden status of the requested tweet
|
33
36
|
def hide_reply(id:)
|
@@ -35,6 +38,20 @@ module TwitterLabsAPI
|
|
35
38
|
|
36
39
|
make_request(url: url, method: :put)[:hidden]
|
37
40
|
end
|
41
|
+
|
42
|
+
# The Labs recent search endpoint returns Tweets from the last 7 days that match a search query.
|
43
|
+
# @param [String] :query the search query
|
44
|
+
# @param [Array<String>] :tweet_fields (["id", "author_id", "created_at", "lang", "public_metrics"]) the list of fields to retrieve for the given tweet
|
45
|
+
# @param [Array<String>] :tweet_fields (["id", "author_id", "created_at", "lang", "public_metrics"]) the list of fields to retrieve for the given tweet
|
46
|
+
def search(query:, tweet_fields: DEFAULT_TWEET_FIELDS)
|
47
|
+
url = "https://api.twitter.com/labs/2/tweets/search"
|
48
|
+
params = {
|
49
|
+
'query' => query,
|
50
|
+
'tweet.fields' => tweet_fields.join(',')
|
51
|
+
}.compact
|
52
|
+
|
53
|
+
make_request(url: url, params: params, is_collection: true)
|
54
|
+
end
|
38
55
|
end
|
39
56
|
end
|
40
57
|
end
|
@@ -3,8 +3,10 @@ module TwitterLabsAPI
|
|
3
3
|
module User
|
4
4
|
DEFAULT_USER_FIELDS = %w[id name username].freeze
|
5
5
|
|
6
|
+
# Returns a variety of information about a single more user specified by the requested ID.
|
6
7
|
# @param [String] :id the ID of the requested User
|
7
8
|
# @param [Array<String>] :user_fields (["name", "username"]) the list of fields to retrieve for the given User
|
9
|
+
# @return Hash an object with requested user fields
|
8
10
|
def get_user(id:, user_fields: DEFAULT_USER_FIELDS)
|
9
11
|
url = "https://api.twitter.com/labs/2/users/#{id}"
|
10
12
|
params = {
|
@@ -14,8 +16,10 @@ module TwitterLabsAPI
|
|
14
16
|
make_request(url: url, params: params)
|
15
17
|
end
|
16
18
|
|
19
|
+
# Returns a variety of information about one or more Users specified by the requested IDs.
|
17
20
|
# @param [Array<String>] :ids the collection of requested User IDs
|
18
21
|
# @param [Array<String>] :user_fields (["name", "username"]) the list of fields to retrieve for the given User
|
22
|
+
# @return [Array<Hash>] of user objects with the requested user fields
|
19
23
|
def get_users(ids:, user_fields: DEFAULT_USER_FIELDS)
|
20
24
|
url = 'https://api.twitter.com/labs/2/users'
|
21
25
|
params = {
|
@@ -26,8 +30,10 @@ module TwitterLabsAPI
|
|
26
30
|
make_request(url: url, params: params, is_collection: true)
|
27
31
|
end
|
28
32
|
|
33
|
+
# Returns a variety of information about one or more Users specified by the requested usernames.
|
29
34
|
# @param [Array<String>] :usernames the collection of requested Usernames
|
30
35
|
# @param [Array<String>] :user_fields (["name", "username"]) the list of fields to retrieve for the given User
|
36
|
+
# @return [Array<Hash>] of user objects with the requested user fields
|
31
37
|
def get_users_by_usernames(usernames:, user_fields: DEFAULT_USER_FIELDS)
|
32
38
|
url = 'https://api.twitter.com/labs/2/users/by'
|
33
39
|
params = {
|