forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.rb
More file actions
82 lines (74 loc) · 2 KB
/
Copy pathusers.rb
File metadata and controls
82 lines (74 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# encoding: utf-8
module Github
class Users < API
extend AutoloadHelper
# Load all the modules after initializing Repos to avoid superclass mismatch
autoload_all 'github/users',
:Emails => 'emails',
:Followers => 'followers',
:Keys => 'keys'
include Github::Users::Emails
include Github::Users::Followers
include Github::Users::Keys
VALID_USER_PARAMS_NAMES = %w[
name
email
blog
company
location
hireable
bio
].freeze
# Creates new Repos API
def initialize(options = {})
super(options)
end
# Get a single unauthenticated user
#
# = Examples
# @github = Github.new
# @github.users.get_user 'user-name'
#
# Get the authenticated user
#
# = Examples
# @github = Github.new :oauth_token => '...'
# @github.users.get_user
#
def get_user(user_name=nil, params={})
_normalize_params_keys(params)
if user_name
get("/users/#{user}", params)
else
get("/user", params)
end
end
# Update the authenticated user
#
# = Inputs
# * <tt>:name</tt> - Optional string
# * <tt>:email</tt> - Optional string - publically visible email address
# * <tt>:blog</tt> - Optional string
# * <tt>:company</tt> - Optional string
# * <tt>:location</tt> - Optional string
# * <tt>:hireable</tt> - Optional boolean
# * <tt>:bio</tt> - Optional string
#
# = Examples
# @github = Github.new :oauth_token => '..'
# @github.users.update_user
# "name" => "monalisa octocat",
# "email" => "[email protected]",
# "blog" => "https://github.com/blog",
# "company" => "GitHub",
# "location" => "San Francisco",
# "hireable" => true,
# "bio" => "There once..."
#
def update_user(params={})
_normalize_params_keys(params)
_filter_params_keys(VALID_USER_PARAMS_NAMES, params)
patch("/user", params)
end
end # Users
end # Github