twitter_labs_api 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec82ff15b22f8a14b4dc1ad25721f80f2b24b3765015a57153b23cd08682eee8
4
- data.tar.gz: d4b233244f69b5f8c32de63f80b5ad3f1e78c126b4cf7d6cd45331f7dcab8eb4
3
+ metadata.gz: 697a03319c55056717774438db0f412e52df2337e52452bfecc0c9f5f00c99f2
4
+ data.tar.gz: d841c0f5c73763593663180cae40f1528b21037708fbc9b05f0c4fcc89d83720
5
5
  SHA512:
6
- metadata.gz: b3b8f6f74db6c566164f33694844f8b06a49d50cd4a2d6707cb3896ef7243eddd771cfef300b9028599f5c817283829ec3731241296de203edb32a75f89ba9ca
7
- data.tar.gz: e039b095549909701d0a8fd9dfff4e622c398de4111718acbf0327e247d8e3cb449d45689b36cc7e939ece61c54b490e6b85664c473fa3ba6c665fbcfee93590
6
+ metadata.gz: d4f956e69a646de92cd9c79139bae452091603630da9e6596e004d0a6f084c8be362bb083a01aa2ccb66cb4385dcfdc099d35dd8f2b91c291f9a19b93395f774
7
+ data.tar.gz: 88bb52e555879a7c003f4006f3d4f10c34bd509dfd083ac06856006a3e2a9d2f3b57dcd1a0e5d5e93df3c15a92bd8b723c0b362a40b0a287c639cfe234b68aa1
@@ -1,3 +1,8 @@
1
+ # 0.5.2 - 28 July 2020
2
+
3
+ - Add `search`
4
+ - Finish `rdoc` coverage
5
+
1
6
  # 0.5.1 - 28 July 2020
2
7
 
3
8
  - Add `User-Agent` request header
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twitter_labs_api (0.5.1)
4
+ twitter_labs_api (0.5.2)
5
5
  activesupport (~> 6.0)
6
6
  httplog (~> 1.4)
7
7
 
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 = {
@@ -1,3 +1,3 @@
1
1
  module TwitterLabsAPI
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.5.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_labs_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomholford