Module: Octokit::Client::Users
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/users.rb
Constant Summary collapse
- EMAIL_RE =
/[\w.!#\$%+-]+@[\w-]+(?:\.[\w-]+)+/
Instance Method Summary collapse
- #add_email(email, options = {}) ⇒ Object
- #add_key(title, key, options = {}) ⇒ Object
- #emails(options = {}) ⇒ Object
- #follow(user, options = {}) ⇒ Object
- #followers(user = login, options = {}) ⇒ Object
- #following(user = login, options = {}) ⇒ Object
- #follows?(*args) ⇒ Boolean
-
#keys(options = {}) ⇒ Object
Not yet supported: get a single key, update an existing key.
- #remove_email(email, options = {}) ⇒ Object
- #remove_key(id, options = {}) ⇒ Object
-
#search_users(search, options = {}) ⇒ Object
Depreciated: V3 of the API does not allow searching users.
- #unfollow(user, options = {}) ⇒ Object
-
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user.
-
#user(user = nil) ⇒ Hashie::Mash
Get a single user.
- #watched(user = login, options = {}) ⇒ Object
Instance Method Details
#add_email(email, options = {}) ⇒ Object
93 94 95 |
# File 'lib/octokit/client/users.rb', line 93 def add_email(email, ={}) post("/user/emails", .merge({:email => email}), 3) end |
#add_key(title, key, options = {}) ⇒ Object
81 82 83 |
# File 'lib/octokit/client/users.rb', line 81 def add_key(title, key, ={}) post("/user/keys", .merge({:title => title, :key => key}), 3) end |
#emails(options = {}) ⇒ Object
89 90 91 |
# File 'lib/octokit/client/users.rb', line 89 def emails(={}) get("/user/emails", , 3) end |
#follow(user, options = {}) ⇒ Object
63 64 65 |
# File 'lib/octokit/client/users.rb', line 63 def follow(user, ={}) put("/user/following/#{user}", , 3, true, raw=true).status == 204 end |
#followers(user = login, options = {}) ⇒ Object
45 46 47 |
# File 'lib/octokit/client/users.rb', line 45 def followers(user=login, ={}) get("/users/#{user}/followers", , 3) end |
#following(user = login, options = {}) ⇒ Object
49 50 51 |
# File 'lib/octokit/client/users.rb', line 49 def following(user=login, ={}) get("/users/#{user}/following", , 3) end |
#follows?(*args) ⇒ Boolean
53 54 55 56 57 58 59 60 61 |
# File 'lib/octokit/client/users.rb', line 53 def follows?(*args) target = args.pop user = args.first user ||= login return if user.nil? get("/user/following/#{target}", {}, 3, true, raw=true).status == 204 rescue Octokit::NotFound false end |
#keys(options = {}) ⇒ Object
Not yet supported: get a single key, update an existing key
77 78 79 |
# File 'lib/octokit/client/users.rb', line 77 def keys(={}) get("/user/keys", , 3) end |
#remove_email(email, options = {}) ⇒ Object
97 98 99 |
# File 'lib/octokit/client/users.rb', line 97 def remove_email(email, ={}) delete("/user/emails", .merge({:email => email}), 3, true, raw=true).status == 204 end |
#remove_key(id, options = {}) ⇒ Object
85 86 87 |
# File 'lib/octokit/client/users.rb', line 85 def remove_key(id, ={}) delete("/user/keys/#{id}", , 3, true, raw=true) end |
#search_users(search, options = {}) ⇒ Object
Depreciated: V3 of the API does not allow searching users
6 7 8 9 10 11 12 |
# File 'lib/octokit/client/users.rb', line 6 def search_users(search, ={}) if search.match(EMAIL_RE) get("/api/v2/json/user/email/#{search}", , 2)['user'] else get("/api/v2/json/user/search/#{search}", , 2)['users'] end end |
#unfollow(user, options = {}) ⇒ Object
67 68 69 |
# File 'lib/octokit/client/users.rb', line 67 def unfollow(user, ={}) delete("/user/following/#{user}", , 3, true, raw=true).status == 204 end |
#update_user(options) ⇒ Hashie::Mash
Update the authenticated user
41 42 43 |
# File 'lib/octokit/client/users.rb', line 41 def update_user() patch("/user", , 3) end |
#user(user = nil) ⇒ Hashie::Mash
Get a single user
20 21 22 23 24 25 26 |
# File 'lib/octokit/client/users.rb', line 20 def user(user=nil) if user get("/users/#{user}", {}, 3) else get("/user", {}, 3) end end |
#watched(user = login, options = {}) ⇒ Object
71 72 73 |
# File 'lib/octokit/client/users.rb', line 71 def watched(user=login, ={}) get("/users/#{user}/watched", , 3) end |