Class: Auth::Lh::Api

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/auth/lh/api.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_codeObject

Returns the value of attribute application_code.



6
7
8
# File 'lib/auth/lh/api.rb', line 6

def application_code
  @application_code
end

#endpointObject

Returns the value of attribute endpoint.



6
7
8
# File 'lib/auth/lh/api.rb', line 6

def endpoint
  @endpoint
end

#return_urlObject

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()
  User.new(get_request("/api/user/#{}"))
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_urlObject



24
25
26
27
# File 'lib/auth/lh/api.rb', line 24

def 
   = 
  "#{@endpoint}/login?attempt=#{.token}"
end

#logout_urlObject



29
30
31
# File 'lib/auth/lh/api.rb', line 29

def logout_url
  "#{@endpoint}/logout?return=#{CGI::escape(@return_url)}"
end