Module: TwitterLabsAPI::Resources::User
- Included in:
- Client
- Defined in:
- lib/twitter_labs_api/resources/user.rb
Constant Summary collapse
- DEFAULT_USER_FIELDS =
%w[id name username].freeze
- DEFAULT_FIELDS =
{ user: DEFAULT_USER_FIELDS }.freeze
Instance Method Summary collapse
-
#get_user(id:, fields: DEFAULT_FIELDS) ⇒ Object
Returns a variety of information about a single more user specified by the requested ID.
-
#get_users(ids:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about one or more Users specified by the requested IDs.
-
#get_users_by_usernames(usernames:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about one or more Users specified by the requested usernames.
Instance Method Details
#get_user(id:, fields: DEFAULT_FIELDS) ⇒ Object
Returns a variety of information about a single more user specified by the requested ID.
13 14 15 16 17 18 |
# File 'lib/twitter_labs_api/resources/user.rb', line 13 def get_user(id:, fields: DEFAULT_FIELDS) url = "https://api.twitter.com/labs/2/users/#{id}" params = ParamsService.from_fields(fields) make_request(url: url, params: params) end |
#get_users(ids:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about one or more Users specified by the requested IDs.
26 27 28 29 30 31 32 |
# File 'lib/twitter_labs_api/resources/user.rb', line 26 def get_users(ids:, fields: DEFAULT_FIELDS) url = 'https://api.twitter.com/labs/2/users' params = ParamsService.from_fields(fields) params.merge!({ ids: ids.join(',') }) make_request(url: url, params: params, is_collection: true) end |
#get_users_by_usernames(usernames:, fields: DEFAULT_FIELDS) ⇒ Array<Hash>
Returns a variety of information about one or more Users specified by the requested usernames.
40 41 42 43 44 45 46 |
# File 'lib/twitter_labs_api/resources/user.rb', line 40 def get_users_by_usernames(usernames:, fields: DEFAULT_FIELDS) url = 'https://api.twitter.com/labs/2/users/by' params = ParamsService.from_fields(fields) params.merge!({ usernames: usernames.join(',') }) make_request(url: url, params: params, is_collection: true) end |