twttr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fe60301d1d17eb4a2904de32bbd649364bb864e13cbe9c56c5151d987c34ec4
4
- data.tar.gz: c7c28b855390fe720ce157d49e8d6f7525ae14ad797bc1a1fbdda77ed4efabfb
3
+ metadata.gz: e199840acca6799e8d3e0e5624510cf9f1a0ba060177dad0b24d9b37b57fb0d9
4
+ data.tar.gz: 29a188421066cf6de970656874f8cc36d238f5aba1b51430c7d6a019618597bf
5
5
  SHA512:
6
- metadata.gz: aa537df933312dea3e75e86dcf6828b7d8ca2cc81138ec46f7b3e867b81dcaa01c542c601306f26f8c8d68590762071bb80d04dd88ef155c5df0798abf568e3d
7
- data.tar.gz: fe96a4b38af080331a25a6be5a31d9e5cfc98d0b95b54faabfd1b45dce89bdb1e16e37635eace45bb7a8ef9c63983f295024ebe1fd82c4e7ad15a14c9b823795
6
+ metadata.gz: 4bd17869256489e6c5878173cab9251b10bdce1332442cc4d35da4cbc566a8948171ae4bfcc953e368dc85180afe36753468ffa2ec808b25ec34b8e3f51aee2d
7
+ data.tar.gz: e291aa2e6bdbfe2fd7b350e092e729c33f0e342eb4f2091f62b1ce2ac51cec35fb3b7467e2b57b3fdd5b658a740c31a0debae7b750d84c9c8166d2aef1a8cb69
@@ -13,13 +13,15 @@ module Twttr
13
13
  # GET /2/users/:id/following
14
14
  # https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following
15
15
  #
16
+ # Returns paginated list of users followed by user_id.
17
+ #
16
18
  # @param user_id [String] The user ID whose following you would like to retrieve.
17
19
  # @param max_results [Integer] Max number of results per peage.
18
20
  # @param pagination_token [String] Initial page pagination token.
19
21
  # @yield [Array<Twttr::Model::User>] Users followed by page.
22
+ # @yield [String,NilClass] Pagination token.
20
23
  # @return [Array<Twttr::Model::User>] Users followed.
21
- # @return [String,NilClass] Pagination token.
22
- def following(user_id, max_results: nil, pagination_token: nil, &block) # rubocop:disable Metrics/MethodLength
24
+ def following(user_id, max_results: nil, pagination_token: nil, &block) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
23
25
  response = get(FOLLOWING_PATH, params: { user_id: user_id },
24
26
  query_params: {
25
27
  'user.fields': config.user_fields,
@@ -33,11 +35,11 @@ module Twttr
33
35
 
34
36
  pagination_token = response['meta']['pagination_token']
35
37
 
36
- return users, pagination_token unless block_given?
38
+ yield users, pagination_token if block_given?
37
39
 
38
- yield users, pagination_token
40
+ return users if pagination_token.nil?
39
41
 
40
- following(user_id, pagination_token, &block) unless pagination_token.nil?
42
+ users + following(user_id, pagination_token: pagination_token, &block)
41
43
  end
42
44
  end
43
45
  end
@@ -12,23 +12,62 @@ module Twttr
12
12
  USER_BY_USERNAME_PATH = "#{V2::V2_PATH}/users/by/username/%<username>s"
13
13
  USER_PATH = "#{V2::V2_PATH}/users/%<user_id>s"
14
14
 
15
+ # GET /2/users/:id/following
16
+ # https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following
17
+ #
18
+ # Returns paginated list of users followed by user_id.
19
+ #
20
+ # @param user_id [String] The user ID whose following you would like to retrieve.
21
+ # @param max_results [Integer] Max number of results per peage.
22
+ # @param pagination_token [String] Initial page pagination token.
23
+ # @yield [Array<Twttr::Model::User>] Users followed by page.
24
+ # @yield [String,NilClass] Pagination token.
25
+ # @return [Array<Twttr::Model::User>] Users followed.
26
+
27
+ # GET /2/users/me
28
+ # https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-me
29
+ #
30
+ # Returns current authenticated user
31
+ #
32
+ # @return [Twttr::Model::User] Current user.
15
33
  def me
16
34
  response = get(ME_PATH, query_params: { 'user.fields': config.user_fields })
17
35
  Model::User.new(response['data'], self)
18
36
  end
19
37
 
38
+ # GET /2/users/:id
39
+ # https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-id
40
+ #
41
+ # Returns target user by id
42
+ #
43
+ # @param user_id [String] Traget user id.
44
+ # @return [Twttr::Model::User] Target user.
20
45
  def user(user_id)
21
46
  response = get(USER_PATH, params: { user_id: user_id },
22
47
  query_params: { 'user.fields': config.user_fields })
23
48
  Model::User.new(response['data'], self)
24
49
  end
25
50
 
51
+ # GET /2/users/by/username/:username
52
+ # https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users-by-username-username
53
+ #
54
+ # Returns target user by username
55
+ #
56
+ # @param username [String] Traget username.
57
+ # @return [Twttr::Model::User] Target user.
26
58
  def user_by_username(username)
27
59
  response = get(USER_BY_USERNAME_PATH, params: { username: username },
28
60
  query_params: { 'user.fields': config.user_fields })
29
61
  Model::User.new(response['data'], self)
30
62
  end
31
63
 
64
+ # GET /2/users
65
+ # https://developer.twitter.com/en/docs/twitter-api/users/lookup/api-reference/get-users
66
+ #
67
+ # Returns target users by id
68
+ #
69
+ # @param user_ids [Array<String>] Traget user ids.
70
+ # @return [Array<Twttr::Model::User>] Target users.
32
71
  def users(user_ids)
33
72
  response = get(USERS_PATH,
34
73
  query_params: { ids: user_ids.join(','), 'user.fields': config.user_fields })
@@ -15,6 +15,18 @@ module Twttr
15
15
  @client = client
16
16
  end
17
17
 
18
+ # Forwards to Follows#following setting user_id to current user's id.
19
+ #
20
+ # GET /2/users/:id/following
21
+ # https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following
22
+ #
23
+ # Returns paginated list of users followed by user_id.
24
+ #
25
+ # @param max_results [Integer] Max number of results per peage.
26
+ # @param pagination_token [String] Initial page pagination token.
27
+ # @yield [Array<Twttr::Model::User>] Users followed by page.
28
+ # @yield [String,NilClass] Pagination token.
29
+ # @return [Array<Twttr::Model::User>] Users followed.
18
30
  def following(max_results: nil, pagination_token: nil, &block)
19
31
  client.following(id, max_results: max_results, pagination_token: pagination_token, &block)
20
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twttr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Decurnex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-08 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth