Class: Auth::Lh::Api
Instance Attribute Summary collapse
-
#application_code ⇒ Object
Returns the value of attribute application_code.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#return_url ⇒ Object
Returns the value of attribute return_url.
Class Method Summary collapse
Instance Method Summary collapse
- #get_user(code_or_login) ⇒ Object
- #get_users(filters = {}) ⇒ Object
- #logged_user(session_token, remote_ip) ⇒ Object
- #login_url ⇒ Object
- #logout_url ⇒ Object
Instance Attribute Details
#application_code ⇒ Object
Returns the value of attribute application_code.
6 7 8 |
# File 'lib/auth/lh/api.rb', line 6 def application_code @application_code end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/auth/lh/api.rb', line 6 def endpoint @endpoint end |
#return_url ⇒ Object
Returns the value of attribute return_url.
6 7 8 |
# File 'lib/auth/lh/api.rb', line 6 def return_url @return_url end |
Class Method Details
.configure(args = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/auth/lh/api.rb', line 8 def self.configure(args={}) instance.endpoint = (args[:endpoint] || 'https://auth.lhconfort.com.ar') instance.return_url = args[:return_url] instance.application_code = args[:application_code] end |
Instance Method Details
#get_user(code_or_login) ⇒ Object
33 34 35 |
# File 'lib/auth/lh/api.rb', line 33 def get_user(code_or_login) User.new(get_request("/api/user/#{code_or_login}")) end |
#get_users(filters = {}) ⇒ Object
37 38 39 40 |
# File 'lib/auth/lh/api.rb', line 37 def get_users(filters={}) results = get_request("/api/users", filters) results.map { |r| User.new(r) } end |
#logged_user(session_token, remote_ip) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/auth/lh/api.rb', line 14 def logged_user(session_token, remote_ip) result = get_request '/logged_user', { app_code: @application_code, session_token: session_token, remote_ip: remote_ip } SessionResponse.new(result) end |
#login_url ⇒ Object
24 25 26 27 |
# File 'lib/auth/lh/api.rb', line 24 def login_url login_attempt = create_login_attempt "#{@endpoint}/login?attempt=#{login_attempt.token}" end |
#logout_url ⇒ Object
29 30 31 |
# File 'lib/auth/lh/api.rb', line 29 def logout_url "#{@endpoint}/logout?return=#{CGI::escape(@return_url)}" end |