forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorgs.rb
More file actions
101 lines (89 loc) · 2.41 KB
/
Copy pathorgs.rb
File metadata and controls
101 lines (89 loc) · 2.41 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# encoding: utf-8
module Github
class Orgs < API
extend AutoloadHelper
autoload_all 'github_api/orgs',
:Members => 'members',
:Teams => 'teams'
VALID_ORG_PARAM_NAMES = %w[
billing_email
company
email
location
name
].freeze
# Creates new Orgs API
def initialize(options = {})
super(options)
end
# Access to Orgs::Members API
def members
@members ||= ApiFactory.new 'Orgs::Members'
end
# Access to Orgs::Teams API
def teams
@teams ||= ApiFactory.new 'Orgs::Teams'
end
# List all public organizations for a user.
#
# = Examples
# github = Github.new
# github.orgs.list user: 'user-name'
#
# List public and private organizations for the authenticated user.
#
# github = Github.new oauth_token: '..'
# github.orgs.list
#
def list(*args)
params = args.extract_options!
normalize! params
response = if (user_name = params.delete("user"))
get_request("/users/#{user_name}/orgs", params)
else
# For the authenticated user
get_request("/user/orgs", params)
end
return response unless block_given?
response.each { |el| yield el }
end
alias :all :list
# Get properties for a single organization
#
# = Examples
# github = Github.new
# github.orgs.get 'github'
#
def get(org_name, params={})
assert_presence_of org_name
normalize! params
get_request("/orgs/#{org_name}", params)
end
alias :find :get
# Edit organization
#
# = Parameters
# <tt>:billing_email</tt> - Optional string - Billing email address. This address is not publicized.
# <tt>:company</tt> - Optional string
# <tt>:email</tt> - Optional string
# <tt>:location</tt> - Optional string
# <tt>:name</tt> - Optional string
#
# = Examples
# github = Github.new oauth_token: '...'
# github.orgs.edit 'github',
# "billing_email": "[email protected]",
# "blog": "https://github.com/blog",
# "company": "GitHub",
# "email": "[email protected]",
# "location": "San Francisco",
# "name": "github"
#
def edit(org_name, params={})
assert_presence_of org_name
normalize! params
filter! VALID_ORG_PARAM_NAMES, params
patch_request("/orgs/#{org_name}", params)
end
end # Orgs
end # Github