@@ -6,16 +6,6 @@ class Client::Authorizations < API
66
77 require_all 'github_api/client/authorizations' , 'app'
88
9- VALID_AUTH_PARAM_NAMES = %w[
10- scopes
11- add_scopes
12- remove_scopes
13- note
14- note_url
15- client_id
16- client_secret
17- ] . freeze
18-
199 # Access to Authorizations::App API
2010 namespace :app
2111
@@ -24,9 +14,9 @@ class Client::Authorizations < API
2414 # @see https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
2515 #
2616 # @example
27- # github = Github.new basic_auth: 'login:password'
28- # github.oauth.list
29- # github.oauth.list { |auth| ... }
17+ # github = Github.new basic_auth: 'login:password'
18+ # github.oauth.list
19+ # github.oauth.list { |auth| ... }
3020 #
3121 # @api public
3222 def list ( *args )
@@ -37,7 +27,7 @@ def list(*args)
3727 return response unless block_given?
3828 response . each { |el | yield el }
3929 end
40- alias :all :list
30+ alias_method :all , :list
4131
4232 # Get a single authorization
4333 #
@@ -56,39 +46,45 @@ def get(*args)
5646
5747 get_request ( "/authorizations/#{ arguments . id } " , arguments . params )
5848 end
59- alias :find :get
49+ alias_method :find , :get
6050
6151 # Create a new authorization
6252 #
53+ # @see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
54+ #
6355 # @param [Hash] params
6456 # @option params [Array[String]] :scopes
6557 # A list of scopes that this authorization is in.
6658 # @option params [String] :note
67- # A note to remind you what the OAuth token is for.
59+ # Required. A note to remind you what the OAuth token is for.
6860 # @option params [String] :note_url
6961 # A URL to remind you what the OAuth token is for.
7062 # @option params [String] :client_id
7163 # The 20 character OAuth app client key for which to create the token.
7264 # @option params [String] :client_secret
7365 # The 40 character OAuth app client secret for which to create the token.
66+ # @option params [String] :fingerprint
67+ # A unique string to distinguish an authorization from others
68+ # created for the same client ID and user.
7469 #
7570 # @example
76- # github = Github.new basic_auth: 'login:password'
77- # github.oauth.create
78- # "scopes" => ["public_repo"]
71+ # github = Github.new basic_auth: 'login:password'
72+ # github.oauth.create scopes: ["public_repo"], note: 'amdmin script'
7973 #
8074 # @api public
8175 def create ( *args )
8276 raise_authentication_error unless authenticated?
8377 arguments ( args ) do
84- permit VALID_AUTH_PARAM_NAMES
78+ assert_required :note , :scopes
8579 end
8680
8781 post_request ( '/authorizations' , arguments . params )
8882 end
8983
9084 # Update an existing authorization
9185 #
86+ # @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
87+ #
9288 # @param [Hash] inputs
9389 # @option inputs [Array] :scopes
9490 # Optional array - A list of scopes that this authorization is in.
@@ -100,28 +96,30 @@ def create(*args)
10096 # Optional string - A note to remind you what the OAuth token is for.
10197 # @optoin inputs [String] :note_url
10298 # Optional string - A URL to remind you what the OAuth token is for.
99+ # @option params [String] :fingerprint
100+ # A unique string to distinguish an authorization from others
101+ # created for the same client ID and user.
103102 #
104103 # @example
105- # github = Github.new basic_auth: 'login:password'
106- # github.oauth.update "authorization-id", add_scopes: ["repo"]
104+ # github = Github.new basic_auth: 'login:password'
105+ # github.oauth.update "authorization-id", add_scopes: ["repo"]
107106 #
108107 # @api public
109108 def update ( *args )
110109 raise_authentication_error unless authenticated?
111- arguments ( args , required : [ :id ] ) do
112- permit VALID_AUTH_PARAM_NAMES
113- end
110+ arguments ( args , required : [ :id ] )
114111
115112 patch_request ( "/authorizations/#{ arguments . id } " , arguments . params )
116113 end
117- alias :edit :update
114+ alias_method :edit , :update
118115
119116 # Delete an authorization
120117 #
121118 # @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
122119 #
123120 # @example
124- # github.oauth.delete 'authorization-id'
121+ # github = Github.new
122+ # github.oauth.delete 'authorization-id'
125123 #
126124 # @api public
127125 def delete ( *args )
@@ -130,14 +128,13 @@ def delete(*args)
130128
131129 delete_request ( "/authorizations/#{ arguments . id } " , arguments . params )
132130 end
133- alias :remove :delete
131+ alias_method :remove , :delete
134132
135133 protected
136134
137135 def raise_authentication_error
138- raise ArgumentError , 'You can only access your own tokens' +
139- ' via Basic Authentication'
136+ raise ArgumentError , 'You can only access your own tokens' \
137+ ' via Basic Authentication'
140138 end
141-
142139 end # Client::Authorizations
143140end # Github
0 commit comments