github_api 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +159 -0
  3. data/Rakefile +52 -0
  4. data/features/github.feature +9 -0
  5. data/features/step_definitions/github_steps.rb +0 -0
  6. data/features/support/env.rb +13 -0
  7. data/lib/github_api.rb +55 -0
  8. data/lib/github_api/api.rb +133 -0
  9. data/lib/github_api/api/extract_options.rb +17 -0
  10. data/lib/github_api/api/mime.rb +5 -0
  11. data/lib/github_api/api/utils.rb +9 -0
  12. data/lib/github_api/client.rb +35 -0
  13. data/lib/github_api/configuration.rb +84 -0
  14. data/lib/github_api/connection.rb +91 -0
  15. data/lib/github_api/error.rb +35 -0
  16. data/lib/github_api/gists.rb +199 -0
  17. data/lib/github_api/gists/comments.rb +74 -0
  18. data/lib/github_api/git_data.rb +26 -0
  19. data/lib/github_api/git_data/blobs.rb +9 -0
  20. data/lib/github_api/git_data/commits.rb +9 -0
  21. data/lib/github_api/git_data/references.rb +9 -0
  22. data/lib/github_api/git_data/tags.rb +9 -0
  23. data/lib/github_api/git_data/trees.rb +9 -0
  24. data/lib/github_api/issues.rb +201 -0
  25. data/lib/github_api/issues/comments.rb +98 -0
  26. data/lib/github_api/issues/events.rb +50 -0
  27. data/lib/github_api/issues/labels.rb +191 -0
  28. data/lib/github_api/issues/milestones.rb +119 -0
  29. data/lib/github_api/orgs.rb +90 -0
  30. data/lib/github_api/orgs/members.rb +109 -0
  31. data/lib/github_api/orgs/teams.rb +236 -0
  32. data/lib/github_api/pull_requests.rb +210 -0
  33. data/lib/github_api/pull_requests/comments.rb +134 -0
  34. data/lib/github_api/repos.rb +256 -0
  35. data/lib/github_api/repos/collaborators.rb +59 -0
  36. data/lib/github_api/repos/commits.rb +115 -0
  37. data/lib/github_api/repos/downloads.rb +77 -0
  38. data/lib/github_api/repos/forks.rb +29 -0
  39. data/lib/github_api/repos/hooks.rb +67 -0
  40. data/lib/github_api/repos/keys.rb +53 -0
  41. data/lib/github_api/repos/watching.rb +50 -0
  42. data/lib/github_api/request.rb +75 -0
  43. data/lib/github_api/request/oauth2.rb +33 -0
  44. data/lib/github_api/response.rb +10 -0
  45. data/lib/github_api/response/jsonize.rb +22 -0
  46. data/lib/github_api/response/mashify.rb +26 -0
  47. data/lib/github_api/response/raise_error.rb +33 -0
  48. data/lib/github_api/users.rb +82 -0
  49. data/lib/github_api/users/emails.rb +49 -0
  50. data/lib/github_api/users/followers.rb +98 -0
  51. data/lib/github_api/users/keys.rb +84 -0
  52. data/lib/github_api/version.rb +12 -0
  53. data/spec/fixtures/collaborators_list.json +6 -0
  54. data/spec/fixtures/commits_list.json +25 -0
  55. data/spec/fixtures/repos_branches_list.json +7 -0
  56. data/spec/fixtures/repos_list.json +27 -0
  57. data/spec/github/api_spec.rb +6 -0
  58. data/spec/github/client_spec.rb +6 -0
  59. data/spec/github/gists/comments_spec.rb +5 -0
  60. data/spec/github/gists_spec.rb +5 -0
  61. data/spec/github/git_data/blobs_spec.rb +5 -0
  62. data/spec/github/git_data/commits_spec.rb +5 -0
  63. data/spec/github/git_data/references_spec.rb +5 -0
  64. data/spec/github/git_data/tags_spec.rb +5 -0
  65. data/spec/github/git_data/trees_spec.rb +5 -0
  66. data/spec/github/git_data_spec.rb +5 -0
  67. data/spec/github/issues/comments_spec.rb +5 -0
  68. data/spec/github/issues/events_spec.rb +5 -0
  69. data/spec/github/issues/labels_spec.rb +5 -0
  70. data/spec/github/issues/milestones_spec.rb +5 -0
  71. data/spec/github/issues_spec.rb +5 -0
  72. data/spec/github/orgs/members_spec.rb +5 -0
  73. data/spec/github/orgs/teams_spec.rb +5 -0
  74. data/spec/github/orgs_spec.rb +5 -0
  75. data/spec/github/repos/collaborators_spec.rb +6 -0
  76. data/spec/github/repos/commits_spec.rb +5 -0
  77. data/spec/github/repos/downloads_spec.rb +5 -0
  78. data/spec/github/repos/forks_spec.rb +5 -0
  79. data/spec/github/repos/hooks_spec.rb +5 -0
  80. data/spec/github/repos/keys_spec.rb +5 -0
  81. data/spec/github/repos/watching_spec.rb +5 -0
  82. data/spec/github/repos_spec.rb +35 -0
  83. data/spec/github_spec.rb +5 -0
  84. data/spec/spec_helper.rb +15 -0
  85. metadata +284 -0
@@ -0,0 +1,109 @@
1
+ # encoding: utf-8
2
+
3
+ module Github
4
+ class Orgs
5
+ module Members
6
+
7
+ # List members
8
+ # List all users who are members of an organization. A member is a user
9
+ # that belongs to at least 1 team in the organization.
10
+ # If the authenticated user is also a member of this organization then
11
+ # both concealed and public members will be returned.
12
+ # Otherwise only public members are returned.
13
+ #
14
+ # = Examples
15
+ # @github = Github.new
16
+ # @github.orgs.members 'org-name'
17
+ #
18
+ def members(org_name, params={})
19
+ _validate_presence_of org_name
20
+ _normalize_params_keys(params)
21
+ response = get("/orgs/#{org_name}/members", params)
22
+ return response unless block_given?
23
+ response.each { |el| yield el }
24
+ end
25
+
26
+ # Check if user is a member of an organization
27
+ #
28
+ # = Examples
29
+ # @github = Github.new
30
+ # @github.orgs.member? 'org-name', 'member-name'
31
+ #
32
+ def member?(org_name, member_name, params={})
33
+ _validate_presence_of org_name, member_name
34
+ _normalize_params_keys(params)
35
+ get("/orgs/#{org_name}/members/#{member_name}", params)
36
+ true
37
+ rescue Github::ResourceNotFound
38
+ false
39
+ end
40
+
41
+ # Remove a member
42
+ # Removing a user from this list will remove them from all teams and
43
+ # they will no longer have any access to the organization’s repositories.
44
+ #
45
+ # = Examples
46
+ # @github = Github.new
47
+ # @github.orgs.delete_member 'org-name', 'member-name'
48
+ #
49
+ def delete_member(org_name, member_name, params={})
50
+ _validate_presence_of org_name, member_name
51
+ _normalize_params_keys(params)
52
+ delete("/orgs/#{org_name}/members/#{member_name}", params)
53
+ end
54
+
55
+ # List public members
56
+ # Members of an organization can choose to have their membership publicized or not.
57
+ # = Examples
58
+ # @github = Github.new
59
+ # @github.orgs.public_members 'org-name'
60
+ #
61
+ def public_members(org_name, params={})
62
+ _validate_presence_of org_name
63
+ _normalize_params_keys(params)
64
+ response = get("/orgs/#{org_name}/public_members")
65
+ return response unless block_given?
66
+ response.each { |el| yield el }
67
+ end
68
+ # Get if a user is a public member of an organization
69
+ #
70
+ # = Examples
71
+ # @github = Github.new
72
+ # @github.orgs.public_member? 'org-name', 'member-name'
73
+ #
74
+ def public_member?(org_name, member_name, params={})
75
+ _validate_presence_of org_name, member_name
76
+ _normalize_params_keys(params)
77
+ get("/orgs/#{org_name}/public_members/#{member_name}", params)
78
+ true
79
+ rescue Github::ResourceNotFound
80
+ false
81
+ end
82
+
83
+ # Publicize a user’s membership
84
+ #
85
+ # = Examples
86
+ # @github = Github.new :oauth_token => '...'
87
+ # @github.orgs.publicize 'org-name', 'member-name'
88
+ #
89
+ def publicize(org_name, member_name, params={})
90
+ _validate_presence_of org_name, member_name
91
+ _normalize_params_keys(params)
92
+ put("/orgs/#{org_name}/public_members/#{member_name}", params)
93
+ end
94
+
95
+ # Conceal a user’s membership
96
+ #
97
+ # = Examples
98
+ # @github = Github.new :oauth_token => '...'
99
+ # @github.orgs.conceal 'org-name', 'member-name'
100
+ #
101
+ def conceal(org_name, member_name, params={})
102
+ _validate_presence_of org_name, member_name
103
+ _normalize_params_keys(params)
104
+ delete("/orgs/#{org_name}/public_members/#{member_name}", params)
105
+ end
106
+
107
+ end # Members
108
+ end # Orgs
109
+ end # Github
@@ -0,0 +1,236 @@
1
+ # encoding: utf-8
2
+
3
+ module Github
4
+ class Orgs
5
+ # All actions against teams require at a minimum an authenticated user
6
+ # who is a member of the owner’s team in the :org being managed.
7
+ # Api calls that require explicit permissions are noted.
8
+ module Teams
9
+
10
+ VALID_TEAM_PARAM_NAMES = %w[ name repo_names permission ]
11
+ VALID_TEAM_PARAM_VALUES = {
12
+ 'permission' => %w[ pull push admin ]
13
+ }
14
+
15
+ # List teams
16
+ #
17
+ # = Examples
18
+ # @github = Github.new :oauth_token => '...'
19
+ # @github.orgs.teams 'org-name'
20
+ #
21
+ def teams(org_name, params={})
22
+ _validate_presence_of org_name
23
+ _normalize_params_keys(params)
24
+
25
+ get("/orgs/#{org_name}/teams", params)
26
+ return response unless block_given?
27
+ response.each { |el| yield el }
28
+ end
29
+
30
+ # Get a team
31
+ #
32
+ # = Examples
33
+ # @github = Github.new :oauth_token => '...'
34
+ # @github.orgs.team 'team-name'
35
+ #
36
+ def team(team_name, params={})
37
+ _validate_presence_of team_name
38
+ _normalize_params_keys(params)
39
+
40
+ get("/teams/#{team_name}", params)
41
+ end
42
+
43
+ # Create a team
44
+ #
45
+ # In order to create a team, the authenticated user must be an owner of<tt>:org</tt>.
46
+ # = Inputs
47
+ # <tt>:name</tt> - Required string
48
+ # <tt>:repo_names</tt> - Optional array of strings
49
+ # <tt>:permission</tt> - Optional string
50
+ # * <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
51
+ # * <tt>push</tt> - team members can pull and push, but not administor this repositores.
52
+ # * <tt>admin</tt> - team members can pull, push and administor these repositories.
53
+ #
54
+ # = Examples
55
+ # @github = Github.new :oauth_token => '...'
56
+ # @github.orgs.create_team 'org-name',
57
+ # "name" => "new team",
58
+ # "permission" => "push",
59
+ # "repo_names" => [
60
+ # "github/dotfiles"
61
+ # ]
62
+ #
63
+ def create_team(org_name, params={})
64
+ _validate_presence_of org_name
65
+ _normalize_params_keys(params)
66
+ _filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
67
+ _validate_params_values(VALID_TEAM_PARAM_VALUES, params)
68
+
69
+ raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
70
+
71
+ post("/orgs/#{org_name}/teams", params)
72
+ end
73
+
74
+ # Create a team
75
+ # In order to edit a team, the authenticated user must be an owner of the org that the team is associated with.
76
+ #
77
+ # = Inputs
78
+ # <tt>:name</tt> - Required string
79
+ # <tt>:permission</tt> - Optional string
80
+ # * <tt>pull</tt> - team members can pull, but not push or administor this repositories. Default
81
+ # * <tt>push</tt> - team members can pull and push, but not administor this repositores.
82
+ # * <tt>admin</tt> - team members can pull, push and administor these repositories.
83
+ #
84
+ # = Examples
85
+ # @github = Github.new :oauth_token => '...'
86
+ # @github.orgs.edit_team 'team-name',
87
+ # "name" => "new team name",
88
+ # "permission" => "push"
89
+ #
90
+ def edit_team(team_name, params={})
91
+ _validate_presence_of team_name
92
+ _normalize_params_keys(params)
93
+ _filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
94
+ _validate_params_values(VALID_TEAM_PARAM_VALUES, params)
95
+
96
+ raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
97
+
98
+ patch("/teams/#{team_name}", params)
99
+ end
100
+
101
+ # Delete a team
102
+ # In order to delete a team, the authenticated user must be an owner of the org that the team is associated with
103
+ #
104
+ # = Examples
105
+ # @github = Github.new :oauth_token => '...'
106
+ # @github.orgs.delete_team 'team-name'
107
+ #
108
+ def delete_team(team_name, params={})
109
+ _validate_presence_of team_name
110
+ _normalize_params_keys(params)
111
+ delete("/teams/#{team_name}", params)
112
+ end
113
+
114
+ # List team members
115
+ # In order to list members in a team, the authenticated user must be a member of the team.
116
+ #
117
+ # = Examples
118
+ # @github = Github.new :oauth_token => '...'
119
+ # @github.orgs.team_members 'team-name'
120
+ # @github.orgs.team_members 'team-name' { |member| ... }
121
+ #
122
+ def team_members(team_name, params={})
123
+ _validate_presence_of team_name
124
+ _normalize_params_keys(params)
125
+
126
+ response = get("/teams/:id/members", params)
127
+ return response unless block_given?
128
+ response.each { |el| yield el }
129
+ end
130
+
131
+ # Check if a user is a member of a team
132
+ #
133
+ # = Examples
134
+ # @github = Github.new :oauth_token => '...'
135
+ # @github.orgs.team_member? 'team-name', 'user-name'
136
+ #
137
+ def team_member?(team_name, member_name, params={})
138
+ _validate_presence_of team_name, member_name
139
+ _normalize_params_keys(params)
140
+ get("/teams/#{team_name}/members/#{member_name}", params)
141
+ true
142
+ rescue Github::ResourceNotFound
143
+ false
144
+ end
145
+
146
+ # Add a team member
147
+ # In order to add a user to a team, the authenticated user must have ‘admin’ permissions to the team or be an owner of the org that the team is associated with.
148
+ #
149
+ # = Examples
150
+ # @github = Github.new :oauth_token => '...'
151
+ # @github.orgs.add_team_member 'team-name', 'user-name'
152
+ #
153
+ def add_team_member(team_name, member_name, params={})
154
+ _validate_presence_of team_name, member_name
155
+ _normalize_params_keys(params)
156
+ put("/teams/#{team_name}/members/#{member_name}", params)
157
+ end
158
+
159
+ # Remove a team member
160
+ # In order to remove a user from a team, the authenticated user must
161
+ # have ‘admin’ permissions to the team or be an owner of the org that
162
+ # the team is associated with.
163
+ # note: This does not delete the user, it just remove them from the team.
164
+ #
165
+ # = Examples
166
+ # @github = Github.new :oauth_token => '...'
167
+ # @github.orgs.remove_team_member 'team-name', 'member-name'
168
+ #
169
+ def remove_team_member(team_name, member_name, params={})
170
+ _validate_presence_of team_name, member_name
171
+ _normalize_params_keys(params)
172
+ delete("/teams/#{team_name}/members/#{member_name}", params)
173
+ end
174
+
175
+ # List team repositories
176
+ #
177
+ # = Examples
178
+ # @github = Github.new :oauth_token => '...'
179
+ # @github.orgs.team_repos 'team-name'
180
+ #
181
+ def team_repos(team_name, params={})
182
+ _validate_presence_of team_name, member_name
183
+ _normalize_params_keys(params)
184
+
185
+ response = get("/teams/#{team_name}/repos", params)
186
+ return response unless block_given?
187
+ response.each { |el| yield el }
188
+ end
189
+
190
+ # Check if a repository belongs to a team
191
+ #
192
+ # = Examples
193
+ # @github = Github.new :oauth_token => '...'
194
+ # @github.orgs.team_repo? 'team-name'
195
+ #
196
+ def team_repo?(team_name, user_name, repo_name, params={})
197
+ _validate_presence_of team_name, user_name, repo_name
198
+ _normalize_params_keys(params)
199
+ get("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
200
+ true
201
+ rescue Github::ResourceNotFound
202
+ false
203
+ end
204
+
205
+ # Add a team repository
206
+ # In order to add a repo to a team, the authenticated user must be
207
+ # an owner of the org that the team is associated with.
208
+ #
209
+ # = Examples
210
+ # @github = Github.new :oauth_token => '...'
211
+ # @github.orgs.add_team_repo 'team-name', 'user-name', 'repo-name'
212
+ #
213
+ def add_team_repo(team_name, user_name, repo_name, params={})
214
+ _validate_presence_of team_name, user_name, repo_name
215
+ _normalize_params_keys(params)
216
+ put("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
217
+ end
218
+
219
+ # Remove a team repository
220
+ # In order to add a repo to a team, the authenticated user must be
221
+ # an owner of the org that the team is associated with.
222
+ # note: This does not delete the repo, it just removes it from the team.
223
+ #
224
+ # = Examples
225
+ # @github = Github.new :oauth_token => '...'
226
+ # @github.orgs.remove_team_repo 'team-name', 'user-name', 'repo-name'
227
+ #
228
+ def remove_team_repo(team_name, user_name, repo_name, params={})
229
+ _validate_presence_of team_name, user_name, repo_name
230
+ _normalize_params_keys(params)
231
+ delete("/teams/#{team_name}/repos/#{user_name}/#{repo_name}", params)
232
+ end
233
+
234
+ end # Teams
235
+ end # Orgs
236
+ end # Github
@@ -0,0 +1,210 @@
1
+ # encoding: utf-8
2
+
3
+ module Github
4
+ class PullRequests < API
5
+ extend AutoloadHelper
6
+
7
+ autoload_all 'github_api/pull_requests',
8
+ :Comments => 'comments'
9
+
10
+ include Github::PullRequests::Comments
11
+
12
+ VALID_REQUEST_PARAM_NAMES = %w[
13
+ title
14
+ body
15
+ base
16
+ head
17
+ state
18
+ issue
19
+ commit_message
20
+ ].freeze
21
+
22
+ VALID_REQUEST_PARAM_VALUES = {
23
+ 'state' => %w[ open closed ]
24
+ }
25
+
26
+ # Creates new Gists API
27
+ def initialize(options = {})
28
+ super(options)
29
+ end
30
+
31
+ # List pull requests
32
+ #
33
+ # = Examples
34
+ # @github = Github.new :user => 'user-name', :repo => 'repo-name'
35
+ # @github.pull_requests.pull_requests
36
+ # @github.pull_requests.pull_requests { |req| ... }
37
+ #
38
+ # @pull_reqs = Github::PullRequests.new
39
+ # @pull_reqs.pull_requests 'user-name', 'repo-name'
40
+ #
41
+ def pull_requests(user_name=nil, repo_name=nil, params={})
42
+ _update_user_repo_params(user_name, repo_name)
43
+ _validate_user_repo_params(user, repo) unless (user? && repo?)
44
+
45
+ _normalize_params_keys(params)
46
+ _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
47
+ _validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
48
+
49
+ response = get("/repos/#{user}/#{repo}/pulls", params)
50
+ return response unless block_given?
51
+ response.each { |el| yield el }
52
+ end
53
+
54
+ # Get a single pull request
55
+ #
56
+ # = Examples
57
+ # @github = Github.new
58
+ # @github.pull_requests.pull_request 'user-name', 'repo-name', 'request-id'
59
+ #
60
+ # @pull_reqs = Github::PullRequests.new
61
+ # @pull_reqs.pull_request 'user-name', 'repo-name', 'request-id'
62
+ #
63
+ def pull_request(user_name, repo_name, request_id, params={})
64
+ _update_user_repo_params(user_name, repo_name)
65
+ _validate_user_repo_params(user, repo) unless user? && repo?
66
+ _validate_presence_of request_id
67
+ _normalize_params_keys(params)
68
+
69
+ get("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
70
+ end
71
+
72
+ # Create a pull request
73
+ #
74
+ # = Inputs
75
+ # * <tt>:title</tt> - Required string
76
+ # * <tt>:body</tt> - Optional string
77
+ # * <tt>:base</tt> - Required string - The branch you want your changes pulled into.
78
+ # * <tt>:head</tt> - Required string - The branch where your changes are implemented.
79
+ # note: head and base can be either a sha or a branch name.
80
+ # Typically you would namespace head with a user like this: username:branch.
81
+ # = Alternative Input
82
+ # You can also create a Pull Request from an existing Issue by passing
83
+ # an Issue number instead of <tt>title</tt> and <tt>body</tt>.
84
+ # * <tt>issue</tt> - Required number - Issue number in this repository to turn into a Pull Request.
85
+ #
86
+ # = Examples
87
+ # @github = Github.new :oauth_token => '...'
88
+ # @github.pull_requests.create_request 'user-name', 'repo-name',
89
+ # "title" => "Amazing new feature",
90
+ # "body" => "Please pull this in!",
91
+ # "head" => "octocat:new-feature",
92
+ # "base" => "master"
93
+ #
94
+ # alternatively
95
+ #
96
+ # @github.pull_requests.create_request 'user-name', 'repo-name',
97
+ # "issue" => "5",
98
+ # "head" => "octocat:new-feature",
99
+ # "base" => "master"
100
+ #
101
+ def create_request(user_name=nil, repo_name=nil, params={})
102
+ _update_user_repo_params(user_name, repo_name)
103
+ _validate_user_repo_params(user, repo) unless user? && repo?
104
+
105
+ _normalize_params_keys(params)
106
+ _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
107
+
108
+ post("/repos/#{user}/#{repo}/pulls", params)
109
+ end
110
+
111
+ # Update a pull request
112
+ #
113
+ # = Inputs
114
+ # * <tt>:title</tt> - Optional string
115
+ # * <tt>:body</tt> - Optional string
116
+ # * <tt>:state</tt> - Optional string - State of this Pull Request. Valid values are <tt>open</tt> and <tt>closed</tt>.
117
+ #
118
+ # = Examples
119
+ # @github = Github.new :oauth_token => '...'
120
+ # @github.pull_requests.update_request 'user-name', 'repo-name', 'request-id'
121
+ # "title" => "Amazing new title",
122
+ # "body" => "Update body",
123
+ # "state" => "open",
124
+ #
125
+ def update_request(user_name, repo_name, request_id, params={})
126
+ _update_user_repo_params(user_name, repo_name)
127
+ _validate_user_repo_params(user, repo) unless user? && repo?
128
+ _validate_presence_of request_id
129
+
130
+ _normalize_params_keys(params)
131
+ _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
132
+ _validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
133
+
134
+ patch("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
135
+ end
136
+
137
+ # List commits on a pull request
138
+ #
139
+ # = Examples
140
+ # @github = Github.new
141
+ # @github.pull_requests.request_commits 'user-name', 'repo-name', 'request-id'
142
+ #
143
+ def request_commits(user_name, repo_name, request_id, params={})
144
+ _update_user_repo_params(user_name, repo_name)
145
+ _validate_user_repo_params(user, repo) unless user? && repo?
146
+ _validate_presence_of request_id
147
+ _normalize_params_keys(params)
148
+
149
+ response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/commits", params)
150
+ return response unless block_given?
151
+ response.each { |el| yield el }
152
+ end
153
+
154
+ # List pull requests files
155
+ #
156
+ # = Examples
157
+ # @github = Github.new
158
+ # @github.pull_requests.request_files 'user-name', 'repo-name', 'request-id'
159
+ #
160
+ def request_files(user_name, repo_name, request_id, params={})
161
+ _update_user_repo_params(user_name, repo_name)
162
+ _validate_user_repo_params(user, repo) unless user? && repo?
163
+ _validate_presence_of request_id
164
+ _normalize_params_keys(params)
165
+
166
+ response = get("/repos/#{user}/#{repo}/pulls/#{request_id}/files", params)
167
+ return response unless block_given?
168
+ response.each { |el| yield el }
169
+ end
170
+
171
+ # Check if pull request has been merged
172
+ #
173
+ # = Examples
174
+ # @github = Github.new
175
+ # @github.pull_requests.merged? 'user-name', 'repo-name', 'request-id'
176
+ #
177
+ def merged?(user_name, repo_name, request_id, params={})
178
+ _update_user_repo_params(user_name, repo_name)
179
+ _validate_user_repo_params(user, repo) unless user? && repo?
180
+ _validate_presence_of request_id
181
+ _normalize_params_keys(params)
182
+
183
+ get("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
184
+ true
185
+ rescue Github::ResourceNotFound
186
+ false
187
+ end
188
+
189
+ # Merge a pull request(Merge Button)
190
+ #
191
+ # = Inputs
192
+ # <tt>:commit_message</tt> - Optional string - The message that will be used for the merge commit
193
+ #
194
+ # = Examples
195
+ # @github = Github.new
196
+ # @github.pull_requests.request_files 'user-name', 'repo-name', 'request-id'
197
+ #
198
+ def merge(user_name, repo_name, request_id, params={})
199
+ _update_user_repo_params(user_name, repo_name)
200
+ _validate_user_repo_params(user, repo) unless user? && repo?
201
+ _validate_presence_of request_id
202
+
203
+ _normalize_params_keys(params)
204
+ _filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
205
+
206
+ put("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
207
+ end
208
+
209
+ end # PullRequests
210
+ end # Github