Class: AuthOpenApi::AuthSession

Inherits:
Object
  • Object
show all
Defined in:
lib/cdnetworks-client/auth_open_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, pass, client) ⇒ AuthSession

Returns a new instance of AuthSession.



10
11
12
13
14
# File 'lib/cdnetworks-client/auth_open_api.rb', line 10

def initialize(user, pass, client)
  @user = user
  @pass = pass
  @client = client
end

Instance Method Details

#loginObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/cdnetworks-client/auth_open_api.rb', line 20

def 
  params = {
    user: @user,
    pass: @pass,
    output: "json"
  }
  resp = @client.call(LOGIN_URL, params)

  resp[:body]['loginResponse']['session']
end

#logoutObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/cdnetworks-client/auth_open_api.rb', line 31

def logout
  params = {
    user: @user,
    pass: @pass,
    output: "json"
  }

  resp = @client.call(LOGOUT_URL, params)
  resp[:body]['logoutResponse']
end

#raise_handled_error(code, desc) ⇒ Object



6
7
8
# File 'lib/cdnetworks-client/auth_open_api.rb', line 6

def raise_handled_error(code, desc)
  raise OpenApiError::ApiError.new("Auth error: #{code} - #{desc}")
end

#sessionObject



16
17
18
# File 'lib/cdnetworks-client/auth_open_api.rb', line 16

def session
  @session ||= 
end