github_api 0.4.6 → 0.4.7

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.
Files changed (97) hide show
  1. data/features/cassettes/errors/repos/create.yml +33 -23
  2. data/features/cassettes/gists/comments/all.yml +116 -106
  3. data/features/cassettes/gists/comments/first.yml +41 -31
  4. data/features/cassettes/gists/gist.yml +61 -50
  5. data/features/cassettes/gists/gists/public_all.yml +31 -58
  6. data/features/cassettes/gists/gists/user_all.yml +44 -34
  7. data/features/cassettes/pagination/repos.yml +161 -287
  8. data/features/cassettes/pagination/repos/commits.yml +174 -299
  9. data/features/cassettes/pagination/repos/commits/next.yml +166 -161
  10. data/features/cassettes/pagination/repos/commits/sha.yml +127 -121
  11. data/features/cassettes/pagination/repos/commits/sha/next.yml +130 -250
  12. data/features/cassettes/pagination/repos/diff.yml +126 -154
  13. data/features/cassettes/pagination/repos/diff/next.yml +123 -246
  14. data/features/cassettes/pagination/repos/next.yml +162 -157
  15. data/features/cassettes/pagination/repos/per_page/each_page.yml +370 -352
  16. data/features/cassettes/pagination/repos/per_page/first.yml +127 -121
  17. data/features/cassettes/repos/branches.yml +38 -65
  18. data/features/cassettes/repos/tags.yml +127 -175
  19. data/features/support/vcr.rb +2 -2
  20. data/lib/github_api/authorization.rb +3 -3
  21. data/lib/github_api/error.rb +3 -0
  22. data/lib/github_api/error/client_error.rb +20 -0
  23. data/lib/github_api/error/invalid_options.rb +18 -0
  24. data/lib/github_api/error/required_params.rb +18 -0
  25. data/lib/github_api/error/service_error.rb +1 -1
  26. data/lib/github_api/error/validations.rb +18 -0
  27. data/lib/github_api/gists.rb +1 -5
  28. data/lib/github_api/gists/comments.rb +2 -8
  29. data/lib/github_api/git_data/blobs.rb +1 -2
  30. data/lib/github_api/git_data/commits.rb +1 -2
  31. data/lib/github_api/git_data/references.rb +2 -4
  32. data/lib/github_api/git_data/trees.rb +1 -1
  33. data/lib/github_api/issues.rb +1 -2
  34. data/lib/github_api/issues/comments.rb +2 -2
  35. data/lib/github_api/issues/labels.rb +2 -4
  36. data/lib/github_api/issues/milestones.rb +2 -4
  37. data/lib/github_api/orgs/teams.rb +3 -4
  38. data/lib/github_api/repos.rb +9 -3
  39. data/lib/github_api/repos/commits.rb +2 -2
  40. data/lib/github_api/repos/downloads.rb +1 -2
  41. data/lib/github_api/repos/hooks.rb +2 -8
  42. data/lib/github_api/repos/keys.rb +2 -3
  43. data/lib/github_api/validation.rb +5 -1
  44. data/lib/github_api/version.rb +1 -1
  45. data/spec/github/api_factory_spec.rb +2 -1
  46. data/spec/github/api_spec.rb +4 -2
  47. data/spec/github/authorization_spec.rb +19 -28
  48. data/spec/github/authorizations_spec.rb +2 -1
  49. data/spec/github/client_spec.rb +4 -1
  50. data/spec/github/deprecation_spec.rb +2 -1
  51. data/spec/github/error/client_error_spec.rb +28 -0
  52. data/spec/github/error/invalid_options_spec.rb +21 -0
  53. data/spec/github/error/required_params_spec.rb +21 -0
  54. data/spec/github/events_spec.rb +4 -4
  55. data/spec/github/filter_spec.rb +2 -2
  56. data/spec/github/gists/comments_spec.rb +8 -4
  57. data/spec/github/gists_spec.rb +19 -14
  58. data/spec/github/git_data/blobs_spec.rb +10 -4
  59. data/spec/github/git_data/commits_spec.rb +13 -6
  60. data/spec/github/git_data/references_spec.rb +13 -8
  61. data/spec/github/git_data/tags_spec.rb +8 -3
  62. data/spec/github/git_data/trees_spec.rb +9 -3
  63. data/spec/github/issues/comments_spec.rb +10 -3
  64. data/spec/github/issues/events_spec.rb +8 -3
  65. data/spec/github/issues/labels_spec.rb +13 -7
  66. data/spec/github/issues/milestones_spec.rb +10 -3
  67. data/spec/github/issues_spec.rb +3 -3
  68. data/spec/github/mime_type_spec.rb +64 -64
  69. data/spec/github/orgs/members_spec.rb +2 -11
  70. data/spec/github/orgs/teams_spec.rb +9 -9
  71. data/spec/github/orgs_spec.rb +22 -8
  72. data/spec/github/page_iterator_spec.rb +2 -1
  73. data/spec/github/page_links_spec.rb +2 -1
  74. data/spec/github/paged_request_spec.rb +2 -1
  75. data/spec/github/pull_requests/comments_spec.rb +9 -3
  76. data/spec/github/pull_requests_spec.rb +6 -2
  77. data/spec/github/repos/collaborators_spec.rb +12 -7
  78. data/spec/github/repos/commits_spec.rb +20 -14
  79. data/spec/github/repos/downloads_spec.rb +19 -8
  80. data/spec/github/repos/forks_spec.rb +6 -3
  81. data/spec/github/repos/hooks_spec.rb +14 -8
  82. data/spec/github/repos/keys_spec.rb +8 -6
  83. data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -11
  84. data/spec/github/repos/watching_spec.rb +15 -38
  85. data/spec/github/repos_spec.rb +35 -39
  86. data/spec/github/request_spec.rb +4 -0
  87. data/spec/github/response/helpers_spec.rb +0 -2
  88. data/spec/github/result_spec.rb +2 -3
  89. data/spec/github/users/followers_spec.rb +6 -8
  90. data/spec/github/users_spec.rb +123 -123
  91. data/spec/github/validation_spec.rb +8 -7
  92. data/spec/github_spec.rb +6 -7
  93. data/spec/spec_helper.rb +2 -2
  94. metadata +36 -21
  95. data/features/cassettes/gists/star.yml +0 -34
  96. data/features/cassettes/pagination/repos/per_page/1.yml +0 -134
  97. data/features/cassettes/repos/teams.yml +0 -38
@@ -1,7 +1,7 @@
1
1
  require 'vcr'
2
2
 
3
- VCR.config do |conf|
4
- conf.stub_with :webmock
3
+ VCR.configure do |conf|
4
+ conf.hook_into :webmock
5
5
  conf.cassette_library_dir = 'features/cassettes'
6
6
  conf.default_cassette_options = { :record => :new_episodes }
7
7
  conf.filter_sensitive_data('<***>') { ''}
@@ -17,7 +17,7 @@ module Github
17
17
  # Strategy token
18
18
  def auth_code
19
19
  _verify_client
20
- @client.auth_code
20
+ client.auth_code
21
21
  end
22
22
 
23
23
  # Sends authorization request to GitHub.
@@ -33,13 +33,13 @@ module Github
33
33
  #
34
34
  def authorize_url(params = {})
35
35
  _verify_client
36
- @client.auth_code.authorize_url(params)
36
+ client.auth_code.authorize_url(params)
37
37
  end
38
38
 
39
39
  # Makes request to token endpoint and retrieves access token value
40
40
  def get_token(authorization_code, params = {})
41
41
  _verify_client
42
- @client.auth_code.get_token(authorization_code, params)
42
+ client.auth_code.get_token(authorization_code, params)
43
43
  end
44
44
 
45
45
  # Check whether authentication credentials are present
@@ -26,6 +26,9 @@ end # Github
26
26
  service_unavailable
27
27
  internal_server_error
28
28
  unprocessable_entity
29
+ client_error
30
+ invalid_options
31
+ required_params
29
32
  ].each do |error|
30
33
  require "github_api/error/#{error}"
31
34
  end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ module Github #:nodoc
4
+ # Raised when Github returns the HTTP status code 404
5
+ module Error
6
+ class ClientError < GithubError
7
+ attr_reader :problem, :summary, :resolution
8
+
9
+ def initialize(message)
10
+ super(message)
11
+ end
12
+
13
+ def generate_message(attributes)
14
+ "\nProblem:\n #{attributes[:problem]}"+
15
+ "\nSummary:\n #{attributes[:summary]}"+
16
+ "\nResolution:\n #{attributes[:resolution]}"
17
+ end
18
+ end
19
+ end # Error
20
+ end # Github
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module Github #:nodoc
4
+ # Raised when invalid options are passed to a request body
5
+ module Error
6
+ class InvalidOptions < ClientError
7
+ def initialize(invalid, valid)
8
+ super(
9
+ generate_message(
10
+ :problem => "Invalid option #{invalid.keys.join(', ')} provided for this request.",
11
+ :summary => "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
12
+ :resolution => "Valid options are: #{valid.join(', ')}, make sure these are the ones you are using"
13
+ )
14
+ )
15
+ end
16
+ end
17
+ end # Error
18
+ end # Github
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module Github #:nodoc
4
+ # Raised when invalid options are passed to a request body
5
+ module Error
6
+ class RequiredParams < ClientError
7
+ def initialize(provided, required)
8
+ super(
9
+ generate_message(
10
+ :problem => "Missing required parameters: #{provided.keys.join(', ')} provided for this request.",
11
+ :summary => "Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.",
12
+ :resolution => "Required parameters are: #{required.join(', ')}, make sure these are the ones you are using"
13
+ )
14
+ )
15
+ end
16
+ end
17
+ end # Error
18
+ end # Github
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Github #:nodoc
4
- # Raised when Github returns the HTTP status code 404
4
+ # Raised when Github returns any of the HTTP status codes
5
5
  module Error
6
6
  class ServiceError < GithubError
7
7
  attr_accessor :http_headers
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ module Github #:nodoc
4
+ # Raised when passed parameters are missing or contain wrong values.
5
+ module Error
6
+ class Validations < ClientError
7
+ def initialize(errors)
8
+ super(
9
+ generate_message(
10
+ :problem => '',
11
+ :summary => '',
12
+ :resolution => ''
13
+ )
14
+ )
15
+ end
16
+ end
17
+ end # Error
18
+ end # Github
@@ -105,11 +105,7 @@ module Github
105
105
  #
106
106
  def create_gist(params={})
107
107
  _normalize_params_keys(params)
108
-
109
- unless _validate_inputs(REQUIRED_GIST_INPUTS, params)
110
- raise ArgumentError,
111
- "Required parameters are: #{REQUIRED_GIST_INPUTS.join(', ')}"
112
- end
108
+ _validate_inputs(REQUIRED_GIST_INPUTS, params)
113
109
 
114
110
  post("/gists", params)
115
111
  end
@@ -58,10 +58,7 @@ module Github
58
58
  _normalize_params_keys(params)
59
59
  # _merge_mime_type(:gist_comment, params)
60
60
  _filter_params_keys(ALLOWED_GIST_COMMENT_INPUTS, params)
61
-
62
- unless _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)
63
- raise ArgumentError, "Required inputs are: :body"
64
- end
61
+ _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)
65
62
 
66
63
  post("/gists/#{gist_id}/comments", params)
67
64
  end
@@ -78,10 +75,7 @@ module Github
78
75
  _validate_presence_of(comment_id)
79
76
  # _merge_mime_type(:gist_comment, params)
80
77
  _filter_params_keys(ALLOWED_GIST_COMMENT_INPUTS, params)
81
-
82
- unless _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)
83
- raise ArgumentError, "Required inputs are: :body"
84
- end
78
+ _validate_inputs(REQUIRED_GIST_COMMENT_INPUTS, params)
85
79
 
86
80
  patch("/gists/comments/#{comment_id}", params)
87
81
  end
@@ -42,8 +42,7 @@ module Github
42
42
 
43
43
  _normalize_params_keys(params)
44
44
  _filter_params_keys(VALID_BLOB_PARAM_NAMES, params)
45
-
46
- raise ArgumentError, "Required params are: #{VALID_BLOB_PARAM_NAMES.join(', ')}" unless _validate_inputs(VALID_BLOB_PARAM_NAMES, params)
45
+ _validate_inputs(VALID_BLOB_PARAM_NAMES, params)
47
46
 
48
47
  post("/repos/#{user}/#{repo}/git/blobs", params)
49
48
  end
@@ -74,8 +74,7 @@ module Github
74
74
  _validate_user_repo_params(user, repo) unless user? && repo?
75
75
  _normalize_params_keys(params)
76
76
  _filter_params_keys(VALID_COMMIT_PARAM_NAMES, params)
77
-
78
- raise ArgumentError, "Required params are: message, tree, parents" unless _validate_inputs(REQUIRED_COMMIT_PARAMS, params)
77
+ _validate_inputs(REQUIRED_COMMIT_PARAMS, params)
79
78
 
80
79
  post("/repos/#{user}/#{repo}/git/commits", params)
81
80
  end
@@ -83,8 +83,7 @@ module Github
83
83
  _normalize_params_keys params
84
84
  _filter_params_keys VALID_REF_PARAM_NAMES, params
85
85
  _validate_reference params['ref']
86
-
87
- raise ArgumentError, "Required params are: ref, sha" unless _validate_inputs(%w[ ref sha ], params)
86
+ _validate_inputs(%w[ ref sha ], params)
88
87
 
89
88
  post("/repos/#{user}/#{repo}/git/refs", params)
90
89
  end
@@ -109,8 +108,7 @@ module Github
109
108
  _validate_reference ref
110
109
  _normalize_params_keys(params)
111
110
  _filter_params_keys(VALID_REF_PARAM_NAMES, params)
112
-
113
- raise ArgumentError, "Required params are: sha" unless _validate_inputs(%w[ sha ], params)
111
+ _validate_inputs(%w[ sha ], params)
114
112
 
115
113
  patch("/repos/#{user}/#{repo}/git/refs/#{ref}", params)
116
114
  end
@@ -86,7 +86,7 @@ module Github
86
86
  _validate_user_repo_params(user, repo) unless user? && repo?
87
87
  _normalize_params_keys(params)
88
88
 
89
- raise ArgumentError, "Required param: 'tree'" unless _validate_inputs(%w[ tree ], params)
89
+ _validate_inputs(%w[ tree ], params)
90
90
 
91
91
  _filter_params_keys(VALID_TREE_PARAM_NAMES, params['tree'])
92
92
  _validate_params_values(VALID_TREE_PARAM_VALUES, params['tree'])
@@ -171,8 +171,7 @@ module Github
171
171
  _normalize_params_keys(params)
172
172
  # _merge_mime_type(:issue, params)
173
173
  _filter_params_keys(VALID_ISSUE_PARAM_NAMES, params)
174
-
175
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
174
+ _validate_inputs(%w[ title ], params)
176
175
 
177
176
  post("/repos/#{user}/#{repo}/issues", params)
178
177
  end
@@ -70,7 +70,7 @@ module Github
70
70
  _normalize_params_keys(params)
71
71
  # _merge_mime_type(:issue_comment, params)
72
72
  _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
73
- raise ArgumentError, "Required params are: :body" unless _validate_inputs(%w[ body ], params)
73
+ _validate_inputs(%w[ body ], params)
74
74
 
75
75
  post("/repos/#{user}/#{repo}/issues/#{issue_id}/comments", params)
76
76
  end
@@ -94,7 +94,7 @@ module Github
94
94
  _normalize_params_keys(params)
95
95
  # _merge_mime_type(:issue_comment, params)
96
96
  _filter_params_keys(VALID_ISSUE_COMMENT_PARAM_NAME, params)
97
- raise ArgumentError, "Required params are: :body" unless _validate_inputs(%w[ body ], params)
97
+ _validate_inputs(%w[ body ], params)
98
98
 
99
99
  patch("/repos/#{user}/#{repo}/issues/comments/#{comment_id}")
100
100
  end
@@ -56,8 +56,7 @@ module Github
56
56
 
57
57
  _normalize_params_keys(params)
58
58
  _filter_params_keys(VALID_LABEL_INPUTS, params)
59
-
60
- raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
59
+ _validate_inputs(VALID_LABEL_INPUTS, params)
61
60
 
62
61
  post("/repos/#{user}/#{repo}/labels", params)
63
62
  end
@@ -79,8 +78,7 @@ module Github
79
78
 
80
79
  _normalize_params_keys(params)
81
80
  _filter_params_keys(VALID_LABEL_INPUTS, params)
82
-
83
- raise ArgumentError, "Required params are: :name, :color" unless _validate_inputs(VALID_LABEL_INPUTS, params)
81
+ _validate_inputs(VALID_LABEL_INPUTS, params)
84
82
 
85
83
  patch("/repos/#{user}/#{repo}/labels/#{label_id}", params)
86
84
  end
@@ -85,8 +85,7 @@ module Github
85
85
 
86
86
  _normalize_params_keys(params)
87
87
  _filter_params_keys(VALID_MILESTONE_INPUTS, params)
88
-
89
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
88
+ _validate_inputs(%w[ title ], params)
90
89
 
91
90
  post("/repos/#{user}/#{repo}/milestones", params)
92
91
  end
@@ -114,8 +113,7 @@ module Github
114
113
 
115
114
  _normalize_params_keys(params)
116
115
  _filter_params_keys(VALID_MILESTONE_INPUTS, params)
117
-
118
- raise ArgumentError, "Required params are: :title" unless _validate_inputs(%w[ title ], params)
116
+ _validate_inputs(%w[ title ], params)
119
117
 
120
118
  patch("/repos/#{user}/#{repo}/milestones/#{milestone_id}", params)
121
119
  end
@@ -67,8 +67,7 @@ module Github
67
67
  _normalize_params_keys(params)
68
68
  _filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
69
69
  _validate_params_values(VALID_TEAM_PARAM_VALUES, params)
70
-
71
- raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
70
+ _validate_inputs(%w[ name ], params)
72
71
 
73
72
  post("/orgs/#{org_name}/teams", params)
74
73
  end
@@ -92,10 +91,10 @@ module Github
92
91
  def edit_team(team_name, params={})
93
92
  _validate_presence_of team_name
94
93
  _normalize_params_keys(params)
94
+
95
95
  _filter_params_keys(VALID_TEAM_PARAM_NAMES, params)
96
96
  _validate_params_values(VALID_TEAM_PARAM_VALUES, params)
97
-
98
- raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
97
+ _validate_inputs(%w[ name ], params)
99
98
 
100
99
  patch("/teams/#{team_name}", params)
101
100
  end
@@ -59,7 +59,7 @@ module Github
59
59
  # @repos = Github::Repos.new
60
60
  # @repos.branches 'user-name', 'repo-name'
61
61
  #
62
- def branches(user_name=nil, repo_name=nil, params={})
62
+ def branches(user_name, repo_name, params={})
63
63
  _update_user_repo_params(user_name, repo_name)
64
64
  _validate_user_repo_params(user, repo) unless (user? && repo?)
65
65
  _normalize_params_keys(params)
@@ -103,7 +103,11 @@ module Github
103
103
  _normalize_params_keys(params)
104
104
  _filter_params_keys(VALID_REPO_OPTIONS + %w[ org ], params)
105
105
 
106
- raise ArgumentError, "Required params are: :name" unless _validate_inputs(%w[ name ], params)
106
+ # if !_validate_inputs(%w[ name ], params)
107
+ # raise ArgumentError, "Required params are: :name"
108
+ # end
109
+
110
+ _validate_inputs(%w[ name ], params)
107
111
 
108
112
  # Requires authenticated user
109
113
  if (org = params.delete("org"))
@@ -161,7 +165,9 @@ module Github
161
165
  _normalize_params_keys(params)
162
166
  _filter_params_keys(VALID_REPO_OPTIONS, params)
163
167
 
164
- raise ArgumentError, "Required params are: #{%w[ :name ] }" unless _validate_inputs(%w[ name ], params)
168
+ unless _validate_inputs(%w[ name ], params)
169
+ raise ArgumentError, "Required params are: #{%w[ :name ] }"
170
+ end
165
171
 
166
172
  patch("/repos/#{user}/#{repo}", DEFAULT_REPO_OPTIONS.merge(params))
167
173
  end
@@ -38,7 +38,7 @@ module Github
38
38
  _normalize_params_keys(params)
39
39
  _filter_params_keys(REQUIRED_COMMENT_PARAMS, params)
40
40
 
41
- raise ArgumentError, "Expected following inputs to the method: #{REQUIRED_COMMENT_PARAMS.join(', ')}" unless _validate_inputs(REQUIRED_COMMENT_PARAMS, params)
41
+ _validate_inputs(REQUIRED_COMMENT_PARAMS, params)
42
42
 
43
43
  post("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
44
44
  end
@@ -170,7 +170,7 @@ module Github
170
170
  _validate_presence_of comment_id
171
171
 
172
172
  _normalize_params_keys(params)
173
- raise ArgumentError, "expected following inputs to the method: 'body'" unless _validate_inputs(["body"], params)
173
+ _validate_inputs(%w[ body ], params)
174
174
 
175
175
  patch("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
176
176
  end
@@ -100,8 +100,7 @@ module Github
100
100
 
101
101
  _normalize_params_keys(params)
102
102
  _filter_params_keys(VALID_DOWNLOAD_PARAM_NAMES, params)
103
-
104
- raise ArgumentError, "Required parameters are: #{REQUIRED_PARAMS.join(', ')}" unless _validate_inputs(REQUIRED_PARAMS, params)
103
+ _validate_inputs(REQUIRED_PARAMS, params)
105
104
 
106
105
  post("/repos/#{user}/#{repo}/downloads", params)
107
106
  end
@@ -97,10 +97,7 @@ module Github
97
97
 
98
98
  _normalize_params_keys(params)
99
99
  _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
100
-
101
- unless _validate_inputs(REQUIRED_PARAMS, params)
102
- raise ArgumentError, "Required parameters are: name, config"
103
- end
100
+ _validate_inputs(REQUIRED_PARAMS, params)
104
101
 
105
102
  post("/repos/#{user}/#{repo}/hooks", params)
106
103
  end
@@ -133,10 +130,7 @@ module Github
133
130
 
134
131
  _normalize_params_keys(params)
135
132
  _filter_params_keys(VALID_HOOK_PARAM_NAMES, params, :recursive => false)
136
-
137
- unless _validate_inputs(REQUIRED_PARAMS, params)
138
- raise ArgumentError, "Required parameters are: name, config"
139
- end
133
+ _validate_inputs(REQUIRED_PARAMS, params)
140
134
 
141
135
  patch("/repos/#{user}/#{repo}/hooks/#{hook_id}", params)
142
136
  end
@@ -50,13 +50,12 @@ module Github
50
50
  # "title" => "octocat@octomac",
51
51
  # "key" => "ssh-rsa AAA..."
52
52
  #
53
- def create_key(user_name=nil, repo_name=nil, params={})
53
+ def create_key(user_name, repo_name, params={})
54
54
  _update_user_repo_params(user_name, repo_name)
55
55
  _validate_user_repo_params(user, repo) unless user? && repo?
56
56
  _normalize_params_keys(params)
57
57
  _filter_params_keys(VALID_KEY_PARAM_NAMES, params)
58
-
59
- raise ArgumentError, "Required params are: #{VALID_KEY_PARAM_NAMES.join(', ')}" unless _validate_inputs(VALID_KEY_PARAM_NAMES, params)
58
+ _validate_inputs(VALID_KEY_PARAM_NAMES, params)
60
59
 
61
60
  post("/repos/#{user}/#{repo}/keys", params)
62
61
  end
@@ -12,9 +12,13 @@ module Github
12
12
  # Ensures that esential input parameters are present before request is made
13
13
  #
14
14
  def _validate_inputs(required, provided)
15
- required.all? do |key|
15
+ result = required.all? do |key|
16
16
  provided.has_deep_key? key
17
17
  end
18
+ if !result
19
+ raise Github::Error::RequiredParams.new(provided, required)
20
+ end
21
+ result
18
22
  end
19
23
 
20
24
  # Ensures that esential arguments are present before request is made