Module: LiveEnsure

Includes:
Configure
Defined in:
lib/live_ensure.rb,
lib/live_ensure/errors.rb,
lib/live_ensure/version.rb,
lib/live_ensure/response.rb,
lib/live_ensure/configure.rb,
lib/live_ensure/setup_response.rb,
lib/live_ensure/session_status_response.rb

Defined Under Namespace

Modules: Configure Classes: AuthSessionError, ConnectionError, InvalidResponse, Response, ServiceDown, SessionStatusResponse, SetupResponse

Constant Summary collapse

HOST =
"https://app.liveensure.com/live-identity"
VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.get(url, base_url = '') ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/live_ensure.rb', line 25

def get(url, base_url = '')
  connection = Patron::Session.new
  connection.connect_timeout = 5
  connection.timeout = 10
  connection.base_url = base_url unless base_url.empty?
  response = connection.get(url)

  if response.status < 400
    response.body
  else
    raise ConnectionError, response.status
  end
end

.request_launch(email) ⇒ Object



17
18
19
# File 'lib/live_ensure.rb', line 17

def request_launch(email)
  SetupResponse.new(get(start_url(email)))
end

.session_status(token, base_url) ⇒ Object



21
22
23
# File 'lib/live_ensure.rb', line 21

def session_status(token, base_url)
  SessionStatusResponse.new(get(session_status_url(token), base_url))
end

.session_status_url(token) ⇒ Object



43
44
45
# File 'lib/live_ensure.rb', line 43

def session_status_url(token)
  "/idr/sessionStatus/4/#{token}/#{configuration.api_key}/#{configuration.api_password}"
end

.start_url(email) ⇒ Object



39
40
41
# File 'lib/live_ensure.rb', line 39

def start_url(email)
  "#{HOST}/idr/sessionStart/4/#{email}/#{configuration.api_agent_id}/#{configuration.api_key}/#{configuration.api_password}"
end