lib/soaspec/o_auth2.rb in soaspec-0.3.2 vs lib/soaspec/o_auth2.rb in soaspec-0.3.3

- old
+ new

@@ -130,13 +130,23 @@ def payload payload = { client_id: params[:client_id], client_secret: params[:client_secret] } payload.merge(if params[:password] && params[:username] { grant_type: 'password', username: params[:username], - password: password, multipart: true - } + password: password + }.merge multipart true else - { grant_type: 'client_credentials' } + { grant_type: 'client_credentials' }.merge multipart false end) + end + + private + + # @param [Boolean] default Default value for multipart + # @return [Hash] Multipart set to true if not set and is grant_type password + def multipart(default) + return { multipart: true } if (params[:multipart].nil? && default) || params[:multipart] + + {} end end end