github_api 0.1.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +20 -0
- data/README.rdoc +159 -0
- data/Rakefile +52 -0
- data/features/github.feature +9 -0
- data/features/step_definitions/github_steps.rb +0 -0
- data/features/support/env.rb +13 -0
- data/lib/github_api.rb +55 -0
- data/lib/github_api/api.rb +133 -0
- data/lib/github_api/api/extract_options.rb +17 -0
- data/lib/github_api/api/mime.rb +5 -0
- data/lib/github_api/api/utils.rb +9 -0
- data/lib/github_api/client.rb +35 -0
- data/lib/github_api/configuration.rb +84 -0
- data/lib/github_api/connection.rb +91 -0
- data/lib/github_api/error.rb +35 -0
- data/lib/github_api/gists.rb +199 -0
- data/lib/github_api/gists/comments.rb +74 -0
- data/lib/github_api/git_data.rb +26 -0
- data/lib/github_api/git_data/blobs.rb +9 -0
- data/lib/github_api/git_data/commits.rb +9 -0
- data/lib/github_api/git_data/references.rb +9 -0
- data/lib/github_api/git_data/tags.rb +9 -0
- data/lib/github_api/git_data/trees.rb +9 -0
- data/lib/github_api/issues.rb +201 -0
- data/lib/github_api/issues/comments.rb +98 -0
- data/lib/github_api/issues/events.rb +50 -0
- data/lib/github_api/issues/labels.rb +191 -0
- data/lib/github_api/issues/milestones.rb +119 -0
- data/lib/github_api/orgs.rb +90 -0
- data/lib/github_api/orgs/members.rb +109 -0
- data/lib/github_api/orgs/teams.rb +236 -0
- data/lib/github_api/pull_requests.rb +210 -0
- data/lib/github_api/pull_requests/comments.rb +134 -0
- data/lib/github_api/repos.rb +256 -0
- data/lib/github_api/repos/collaborators.rb +59 -0
- data/lib/github_api/repos/commits.rb +115 -0
- data/lib/github_api/repos/downloads.rb +77 -0
- data/lib/github_api/repos/forks.rb +29 -0
- data/lib/github_api/repos/hooks.rb +67 -0
- data/lib/github_api/repos/keys.rb +53 -0
- data/lib/github_api/repos/watching.rb +50 -0
- data/lib/github_api/request.rb +75 -0
- data/lib/github_api/request/oauth2.rb +33 -0
- data/lib/github_api/response.rb +10 -0
- data/lib/github_api/response/jsonize.rb +22 -0
- data/lib/github_api/response/mashify.rb +26 -0
- data/lib/github_api/response/raise_error.rb +33 -0
- data/lib/github_api/users.rb +82 -0
- data/lib/github_api/users/emails.rb +49 -0
- data/lib/github_api/users/followers.rb +98 -0
- data/lib/github_api/users/keys.rb +84 -0
- data/lib/github_api/version.rb +12 -0
- data/spec/fixtures/collaborators_list.json +6 -0
- data/spec/fixtures/commits_list.json +25 -0
- data/spec/fixtures/repos_branches_list.json +7 -0
- data/spec/fixtures/repos_list.json +27 -0
- data/spec/github/api_spec.rb +6 -0
- data/spec/github/client_spec.rb +6 -0
- data/spec/github/gists/comments_spec.rb +5 -0
- data/spec/github/gists_spec.rb +5 -0
- data/spec/github/git_data/blobs_spec.rb +5 -0
- data/spec/github/git_data/commits_spec.rb +5 -0
- data/spec/github/git_data/references_spec.rb +5 -0
- data/spec/github/git_data/tags_spec.rb +5 -0
- data/spec/github/git_data/trees_spec.rb +5 -0
- data/spec/github/git_data_spec.rb +5 -0
- data/spec/github/issues/comments_spec.rb +5 -0
- data/spec/github/issues/events_spec.rb +5 -0
- data/spec/github/issues/labels_spec.rb +5 -0
- data/spec/github/issues/milestones_spec.rb +5 -0
- data/spec/github/issues_spec.rb +5 -0
- data/spec/github/orgs/members_spec.rb +5 -0
- data/spec/github/orgs/teams_spec.rb +5 -0
- data/spec/github/orgs_spec.rb +5 -0
- data/spec/github/repos/collaborators_spec.rb +6 -0
- data/spec/github/repos/commits_spec.rb +5 -0
- data/spec/github/repos/downloads_spec.rb +5 -0
- data/spec/github/repos/forks_spec.rb +5 -0
- data/spec/github/repos/hooks_spec.rb +5 -0
- data/spec/github/repos/keys_spec.rb +5 -0
- data/spec/github/repos/watching_spec.rb +5 -0
- data/spec/github/repos_spec.rb +35 -0
- data/spec/github_spec.rb +5 -0
- data/spec/spec_helper.rb +15 -0
- metadata +284 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Issues
|
5
|
+
module Events
|
6
|
+
|
7
|
+
# List events for an issue
|
8
|
+
#
|
9
|
+
# = Examples
|
10
|
+
# @github = Github.new
|
11
|
+
# @github.issues.events 'user-name', 'repo-name', 'issue-id'
|
12
|
+
#
|
13
|
+
# List events for a repository
|
14
|
+
#
|
15
|
+
# = Examples
|
16
|
+
# @github = Github.new
|
17
|
+
# @github.issues.events 'user-name', 'repo-name'
|
18
|
+
#
|
19
|
+
def events(user_name=nil, repo_name=nil, issue_id=nil, params={})
|
20
|
+
_update_user_repo_params(user_name, repo_name)
|
21
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
22
|
+
_normalize_params_keys(params)
|
23
|
+
|
24
|
+
response = if issue_id
|
25
|
+
get("/repos/#{user}/#{repo}/issues/#{issue_id}/events", params)
|
26
|
+
else
|
27
|
+
get("/repos/#{user}/#{repo}/issues/events", params)
|
28
|
+
end
|
29
|
+
return response unless block_given?
|
30
|
+
response.each { |el| yield el }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get a single event
|
34
|
+
#
|
35
|
+
# = Examples
|
36
|
+
# @github = Github.new
|
37
|
+
# @github.issues.event 'user-name', 'repo-name', 'event-id'
|
38
|
+
#
|
39
|
+
def event(user_name, repo_name, event_id, params={})
|
40
|
+
_update_user_repo_params(user_name, repo_name)
|
41
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
42
|
+
_validate_presence_of event_id
|
43
|
+
_normalize_params_keys(params)
|
44
|
+
|
45
|
+
get("/repos/#{user}/#{repo}/issues/events/#{event_id}")
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Events
|
49
|
+
end # Issues
|
50
|
+
end # Github
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Issues
|
5
|
+
module Labels
|
6
|
+
|
7
|
+
VALID_LABEL_INPUTS = %w[ name color ]
|
8
|
+
|
9
|
+
# List all labels for a repository
|
10
|
+
#
|
11
|
+
# = Examples
|
12
|
+
# @github = Github.new :user => 'user-name', :repo => 'repo-name'
|
13
|
+
# @github.issues.labels
|
14
|
+
# @github.issues.labels { |label| ... }
|
15
|
+
#
|
16
|
+
def labels(user_name=nil, repo_name=nil, params={})
|
17
|
+
_update_user_repo_params(user_name, repo_name)
|
18
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
19
|
+
_normalize_params_keys(params)
|
20
|
+
|
21
|
+
response = get("/repos/#{user}/#{repo}/labels", params)
|
22
|
+
return response unless block_given?
|
23
|
+
response.each { |el| yield el }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get a single label
|
27
|
+
#
|
28
|
+
# = Examples
|
29
|
+
# @github = Github.new
|
30
|
+
# @github.issues.label 'user-name', 'repo-name', 'label-id'
|
31
|
+
#
|
32
|
+
def label(user_name, repo_name, label_id, params={})
|
33
|
+
_update_user_repo_params(user_name, repo_name)
|
34
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
35
|
+
_normalize_params_keys(params)
|
36
|
+
|
37
|
+
get("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Create a label
|
41
|
+
#
|
42
|
+
# = Inputs
|
43
|
+
# <tt>:name</tt> - Required string
|
44
|
+
# <tt>:color</tt> - Required string - 6 character hex code, without leading #
|
45
|
+
#
|
46
|
+
# = Examples
|
47
|
+
# @github = Github.new :user => 'user-name', :repo => 'repo-name'
|
48
|
+
# @github.issues.create_label :name => 'API', :color => 'FFFFFF'
|
49
|
+
#
|
50
|
+
def create_label(user_name=nil, repo_name=nil, params={})
|
51
|
+
_update_user_repo_params(user_name, repo_name)
|
52
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
53
|
+
|
54
|
+
_normalize_params_keys(params)
|
55
|
+
_filter_params_keys(VALID_LABEL_INPUTS, params)
|
56
|
+
|
57
|
+
raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
|
58
|
+
|
59
|
+
post("/repos/#{user}/#{repo}/labels", params)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Update a label
|
63
|
+
#
|
64
|
+
# = Inputs
|
65
|
+
# <tt>:name</tt> - Required string
|
66
|
+
# <tt>:color</tt> - Required string - 6 character hex code, without leading #
|
67
|
+
#
|
68
|
+
# = Examples
|
69
|
+
# @github = Github.new
|
70
|
+
# @github.issues.update_label 'user-name', 'repo-name', 'label-id', :name => 'API', :color => "FFFFFF"
|
71
|
+
#
|
72
|
+
def update_label(user_name, repo_name, label_id, params={})
|
73
|
+
_update_user_repo_params(user_name, repo_name)
|
74
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
75
|
+
_validate_presence_of label_id
|
76
|
+
|
77
|
+
_normalize_params_keys(params)
|
78
|
+
_filter_params_keys(VALID_LABEL_INPUTS, params)
|
79
|
+
|
80
|
+
raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
|
81
|
+
|
82
|
+
patch("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Delete a label
|
86
|
+
#
|
87
|
+
# = Examples
|
88
|
+
# @github = Github.new
|
89
|
+
# @github.issues.delete_label 'user-name', 'repo-name', 'label-id'
|
90
|
+
#
|
91
|
+
def delete_label(user_name, repo_name, label_id, params={})
|
92
|
+
_update_user_repo_params(user_name, repo_name)
|
93
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
94
|
+
_validate_presence_of milestone_id
|
95
|
+
_normalize_params_keys(params)
|
96
|
+
|
97
|
+
delete("/repos/#{user}/#{repo}/labels/#{label_id}", params)
|
98
|
+
end
|
99
|
+
|
100
|
+
# List labels on an issue
|
101
|
+
#
|
102
|
+
# = Examples
|
103
|
+
# @github = Github.new
|
104
|
+
# @github.issues.labels_for 'user-name', 'repo-name', 'issue-id'
|
105
|
+
#
|
106
|
+
def labels_for(user_name, repo_name, issue_id, params={})
|
107
|
+
_update_user_repo_params(user_name, repo_name)
|
108
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
109
|
+
_validate_presence_of(issue_id)
|
110
|
+
_normalize_params_keys(params)
|
111
|
+
|
112
|
+
get("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Add labels to an issue
|
116
|
+
#
|
117
|
+
# = Examples
|
118
|
+
# @github = Github.new
|
119
|
+
# @github.issues.add_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
120
|
+
#
|
121
|
+
def add_labels(user_name, repo_name, issue_id, *args)
|
122
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
123
|
+
params['data'] = [args].flatten unless args.nil?
|
124
|
+
_update_user_repo_params(user_name, repo_name)
|
125
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
126
|
+
_validate_presence_of(issue_id)
|
127
|
+
_normalize_params_keys(params)
|
128
|
+
|
129
|
+
post("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Remove a label from an issue
|
133
|
+
#
|
134
|
+
# = Examples
|
135
|
+
# @github = Github.new
|
136
|
+
# @github.issues.remove_label 'user-name', 'repo-name', 'issue-id', 'label-id'
|
137
|
+
#
|
138
|
+
# Remove all labels from an issue
|
139
|
+
# = Examples
|
140
|
+
# @github = Github.new
|
141
|
+
# @github.issues.remove_label 'user-name', 'repo-name', 'issue-id'
|
142
|
+
#
|
143
|
+
def remove_label(user_name, repo_name, issue_id, label_id=nil, params={})
|
144
|
+
_update_user_repo_params(user_name, repo_name)
|
145
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
146
|
+
_validate_presence_of(issue_id)
|
147
|
+
_normalize_params_keys(params)
|
148
|
+
|
149
|
+
if label_id
|
150
|
+
delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels/#{label_id}", params)
|
151
|
+
else
|
152
|
+
delete("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Replace all labels for an issue
|
157
|
+
#
|
158
|
+
# Sending an empty array ([]) will remove all Labels from the Issue.
|
159
|
+
#
|
160
|
+
# = Examples
|
161
|
+
# @github = Github.new
|
162
|
+
# @github.issues.replace_labels 'user-name', 'repo-name', 'issue-id', 'label1', 'label2', ...
|
163
|
+
#
|
164
|
+
def replace_labels(user_name, repo_name, issue_id, *args)
|
165
|
+
params = args.last.is_a?(Hash) ? args.pop : {}
|
166
|
+
params['data'] = [args].flatten unless args.nil?
|
167
|
+
_update_user_repo_params(user_name, repo_name)
|
168
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
169
|
+
_validate_presence_of(issue_id)
|
170
|
+
_normalize_params_keys(params)
|
171
|
+
|
172
|
+
put("/repos/#{user}/#{repo}/issues/#{issue_id}/labels", params)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Get labels for every issue in a milestone
|
176
|
+
#
|
177
|
+
# = Examples
|
178
|
+
# @github = Github.new
|
179
|
+
# @github.issues.get_label 'user-name', 'repo-name', 'milestone-id'
|
180
|
+
#
|
181
|
+
def get_label(user_name, repo_name, milestone_id, params={})
|
182
|
+
_update_user_repo_params(user_name, repo_name)
|
183
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
184
|
+
_validate_presence_of(issue_id)
|
185
|
+
|
186
|
+
get("/repos/#{user}/#{repo}/milestones/#{milestone_id}/labels", params)
|
187
|
+
end
|
188
|
+
|
189
|
+
end # Labels
|
190
|
+
end # Issues
|
191
|
+
end # Github
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Issues
|
5
|
+
module Milestones
|
6
|
+
|
7
|
+
VALID_MILSTONE_OPTIONS = {
|
8
|
+
'state' => %w[ open closed ],
|
9
|
+
'sort' => %w[ due_date completeness ],
|
10
|
+
'direction' => %w[ desc asc ]
|
11
|
+
}
|
12
|
+
|
13
|
+
VALID_MILESTONE_INPUTS = %w[ title state description due_on ]
|
14
|
+
|
15
|
+
# List milestones for a repository
|
16
|
+
#
|
17
|
+
# = Parameters
|
18
|
+
# <tt>:state</tt> - <tt>open</tt>, <tt>closed</tt>, default: <tt>open</tt>
|
19
|
+
# <tt>:sort</tt> - <tt>due_date</tt>, <tt>completeness</tt>, default: <tt>due_date</tt>
|
20
|
+
# <tt>:direction</tt> - <tt>asc</tt>, <tt>desc</tt>, default: <tt>desc</tt>
|
21
|
+
#
|
22
|
+
# = Examples
|
23
|
+
# @github = Github.new :user => 'user-name', :repo => 'repo-name'
|
24
|
+
# @github.issues.milestones
|
25
|
+
#
|
26
|
+
def milestones(user_name=nil, repo_name=nil, params={})
|
27
|
+
_update_user_repo_params(user_name, repo_name)
|
28
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
29
|
+
|
30
|
+
_normalize_params_keys(params)
|
31
|
+
_filter_params_keys(VALID_MILSTONE_OPTIONS.keys, params)
|
32
|
+
_validate_params_values(VALID_MILSTONE_OPTIONS, params)
|
33
|
+
|
34
|
+
response = get("/repos/#{user}/#{repo}/milestones", params)
|
35
|
+
return response unless block_given?
|
36
|
+
response.each { |el| yield el }
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get a single milestone
|
40
|
+
#
|
41
|
+
# = Examples
|
42
|
+
# @github = Github.new
|
43
|
+
# @github.issues.milestone 'user-name', 'repo-name', 'milestone-id'
|
44
|
+
#
|
45
|
+
def milestone(user_name, repo_name, milestone_id, params={})
|
46
|
+
_update_user_repo_params(user_name, repo_name)
|
47
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
48
|
+
_normalize_params_keys(params)
|
49
|
+
|
50
|
+
get("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Create a milestone
|
54
|
+
#
|
55
|
+
# = Inputs
|
56
|
+
# <tt>:title</tt> - Required string
|
57
|
+
# <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
|
58
|
+
# <tt>:description</tt> - Optional string
|
59
|
+
# <tt>:due_on</tt> - Optional string - ISO 8601 time
|
60
|
+
#
|
61
|
+
# = Examples
|
62
|
+
# @github = Github.new :user => 'user-name', :repo => 'repo-name'
|
63
|
+
# @github.issues.create_milestone :title => 'hello-world'
|
64
|
+
#
|
65
|
+
def create_milestone(user_name=nil, repo_name=nil, params={})
|
66
|
+
_update_user_repo_params(user_name, repo_name)
|
67
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
68
|
+
|
69
|
+
_normalize_params_keys(params)
|
70
|
+
_filter_params_keys(VALID_MILESTONE_INPUTS, params)
|
71
|
+
|
72
|
+
raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
|
73
|
+
|
74
|
+
post("/repos/#{user}/#{repo}/milestones", params)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Update a milestone
|
78
|
+
#
|
79
|
+
# = Inputs
|
80
|
+
# <tt>:title</tt> - Required string
|
81
|
+
# <tt>:state</tt> - Optional string - <tt>open</tt> or <tt>closed</tt>
|
82
|
+
# <tt>:description</tt> - Optional string
|
83
|
+
# <tt>:due_on</tt> - Optional string - ISO 8601 time
|
84
|
+
#
|
85
|
+
# = Examples
|
86
|
+
# @github = Github.new
|
87
|
+
# @github.issues.update_milestone 'user-name', 'repo-name', 'milestone-id', :title => 'hello-world'
|
88
|
+
#
|
89
|
+
def update_milestone(user_name, repo_name, milestone_id, params={})
|
90
|
+
_update_user_repo_params(user_name, repo_name)
|
91
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
92
|
+
_validate_presence_of milestone_id
|
93
|
+
|
94
|
+
_normalize_params_keys(params)
|
95
|
+
_filter_params_keys(VALID_MILESTONE_INPUTS, params)
|
96
|
+
|
97
|
+
raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
|
98
|
+
|
99
|
+
patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Delete a milestone
|
103
|
+
#
|
104
|
+
# = Examples
|
105
|
+
# @github = Github.new
|
106
|
+
# @github.issues.delete_milestone 'user-name', 'repo-name', 'milestone-id'
|
107
|
+
#
|
108
|
+
def delete_milestone(user_name, repo_name, milestone_id, params={})
|
109
|
+
_update_user_repo_params(user_name, repo_name)
|
110
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
111
|
+
_validate_presence_of milestone_id
|
112
|
+
_normalize_params_keys(params)
|
113
|
+
|
114
|
+
delete("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
|
115
|
+
end
|
116
|
+
|
117
|
+
end # Milestones
|
118
|
+
end # Issues
|
119
|
+
end # Github
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Orgs < API
|
5
|
+
extend AutoloadHelper
|
6
|
+
|
7
|
+
autoload_all 'github_api/orgs',
|
8
|
+
:Members => 'members',
|
9
|
+
:Teams => 'teams'
|
10
|
+
|
11
|
+
include Github::Orgs::Members
|
12
|
+
include Github::Orgs::Teams
|
13
|
+
|
14
|
+
VALID_ORG_PARAM_NAMES = %w[
|
15
|
+
billing_email
|
16
|
+
company
|
17
|
+
email
|
18
|
+
location
|
19
|
+
name
|
20
|
+
]
|
21
|
+
|
22
|
+
# Creates new Orgs API
|
23
|
+
def initialize(options = {})
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# List all public organizations for a user.
|
28
|
+
#
|
29
|
+
# = Examples
|
30
|
+
# @github = Github.new :user => 'user-name'
|
31
|
+
# @github.orgs.orgs
|
32
|
+
#
|
33
|
+
# List public and private organizations for the authenticated user.
|
34
|
+
#
|
35
|
+
# @github = Github.new :oauth_token => '..'
|
36
|
+
# @github.orgs.org 'github'
|
37
|
+
#
|
38
|
+
def orgs(user_name=nil, params={})
|
39
|
+
_update_user_repo_params(user_name)
|
40
|
+
_normalize_params_keys(params)
|
41
|
+
|
42
|
+
response = if user?
|
43
|
+
get("/users/#{user}/orgs", params)
|
44
|
+
else
|
45
|
+
get("/user/orgs", params)
|
46
|
+
end
|
47
|
+
return response unless block_given?
|
48
|
+
response.each { |el| yield el }
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get properties for a single organization
|
52
|
+
#
|
53
|
+
# = Examples
|
54
|
+
# @github = Github.new
|
55
|
+
# @github.orgs.org 'github'
|
56
|
+
#
|
57
|
+
def org(org_name, params={})
|
58
|
+
_validate_presence_of org_name
|
59
|
+
get("/orgs/#{org_name}")
|
60
|
+
end
|
61
|
+
|
62
|
+
# Edit organization
|
63
|
+
#
|
64
|
+
# = Parameters
|
65
|
+
# <tt>:billing_email</tt> - Optional string - Billing email address. This address is not publicized.
|
66
|
+
# <tt>:company</tt> - Optional string
|
67
|
+
# <tt>:email</tt> - Optional string
|
68
|
+
# <tt>:location</tt> - Optional string
|
69
|
+
# <tt>:name</tt> - Optional string
|
70
|
+
#
|
71
|
+
# = Examples
|
72
|
+
# @github = Github.new :oauth_token => '...'
|
73
|
+
# @github.orgs.edit_org 'github',
|
74
|
+
# "billing_email" => "support@github.com",
|
75
|
+
# "blog" => "https://github.com/blog",
|
76
|
+
# "company" => "GitHub",
|
77
|
+
# "email" => "support@github.com",
|
78
|
+
# "location" => "San Francisco",
|
79
|
+
# "name" => "github"
|
80
|
+
#
|
81
|
+
def edit_org(org_name, params={})
|
82
|
+
_validate_presence_of org_name
|
83
|
+
_normalize_params_keys(params)
|
84
|
+
_filter_params_keys(VALID_ORG_PARAM_NAMES, params)
|
85
|
+
|
86
|
+
patch("/orgs/#{org_name}", params)
|
87
|
+
end
|
88
|
+
|
89
|
+
end # Orgs
|
90
|
+
end # Github
|