Skip to content

Users calls

Rashmi Yadav edited this page Oct 25, 2013 · 19 revisions

####To call /users

RubyStackoverflow.users(options = {})

Example

response = RubyStackoverflow.users({inname: 'raysrashmi', sort: 'reputation'})
response.data.first.display_name
#=> 'raysrashmi'

response.data is an array of users. If there is any error then you can access it

response.error

####To call /users/{ids}

RubyStackoverflow.users_by_ids([ids], options = {})

Example

response = RubyStackoverflow.users_by_ids(['1363236'])
response.data.first.display_name 
#=> 'raysrashmi'

####To call /users/{ids}/answers (answers of users in {ids})

response = RubyStackoverflow.users_with_answers([ids], options)

Example

response = RubyStackoverflow.users_with_answers(['1363236'],{min: '2013-10-01', max: '2013-10-24'})
response.data.first.answers 
#=> [#<RubyStackoverflow::Client::Answer:0x007fcee5ac6668 @question_id=19551247, @answer_id=19551539, @creation_date="2013-10-23 20:21:50 UTC", @last_activity_date="2013-10-23 20:21:50 UTC", @score=0,...]

####To call /users/{ids}/badges (badges of users in {ids}

RubyStackoverflow.users_with_badges([ids], options={})

Example

response = RubyStackoverflow.users_with_badges(['1363236'],{order: 'asc'})
response.data.first.badges
#=> [#<RubyStackoverflow::Client::Badge:0x007ff635164d50 @badge_id=1, @rank="bronze", @name="Teacher", @award_count=1,..]

####To call /users/{ids}/comments (comments of users in {ids})

RubyStackoverflow.users_with_comments([ids], options={})

Example

response = RubyStackoverflow.users_with_comments(['1363236'],{sort: 'votes'})
response.data.first.comments
#=> [#<RubyStackoverflow::Client::Comment:0x007fb8140d8698 @comment_id=28886246, @post_id=19476854, @creation_date="2013-10-20 12:49:58 UTC"...]

####To call /users/{ids}/comments/{toid} (comments that the users in {ids} have posted in reply to the single user identified in {toid})

RubyStackoverflow.users_with_replied_comments(ids, toid, options = {})

Example

response = RubyStackoverflow.users_with_replied_comments(['707894','1004415'], '1300151')
response.data.first.comments.first.score
#=> 2

####To call /users/{ids}/favorites (questions favorited by users in ids)

RubyStackoverflow.users_with_favorites_questions([ids], options = {})

Example

response = RubyStackoverflow.users_with_favorites_questions(['1363236'])
response.data.first.questions.first.view_count
#=> 10

####To call /users/{ids}/mentioned (comments that the users in {ids} were mentioned in)

RubyStackoverflow.users_with_mentioned_comments([ids], options={})

Example

response = RubyStackoverflow.users_with_mentioned_comments(['707894','1004415'])
response.data.first.comments.first.score
#=> 2

####To call /users/{id}/notifications (notifications of user) To make this request you should have access_token otherwise it wont success

RubyStackoverflow.users_notifications(id, options={})

Example

response = RubyStackoverflow.users_notifications(1363236)
response.data
#=> [#<RubyStackoverflow::Client::Notification:0x007fa27c1fe908 @notification_type="new_privilege",.....]

####To call /users/{id}/notifications (notifications of user) To make this request also you should have access_token otherwise it wont success

RubyStackoverflow.users_unread_notifications(id, options={})

Example

response = RubyStackoverflow.users_unread_notifications(1363236)
response.data
#=> [#<RubyStackoverflow::Client::Notification:0x007fa27c1fe908 @notification_type="new_privilege",.....]

####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids}) ####To call /users/{ids}/answers(answers of users in {ids})

Clone this wiki locally