lib/redd.rb in redd-0.4.1 vs lib/redd.rb in redd-0.4.2
- old
+ new
@@ -1,14 +1,15 @@
require "redd/client/unauthenticated"
require "redd/client/authenticated"
require "redd/client/oauth2"
module Redd
- def self.client(username = nil, password = nil)
- client = Redd::Client::Unauthenticated.new
- if username.nil? || password.nil?
- client
+ def self.client(username = nil, password = nil, redirect_uri = nil, options = {})
+ if redirect_uri
+ Redd::Client::OAuth2.new(username, password, redirect_uri, options)
+ elsif username && password
+ Redd::Client::Authenticated.new_from_credentials(username, password, options)
else
- client.login(username, password)
+ Redd::Client::Unauthenticated.new
end
end
end