Class: AuthOpenApi::AuthSession
- Inherits:
-
Object
- Object
- AuthOpenApi::AuthSession
- Defined in:
- lib/cdnetworks-client/auth_open_api.rb
Instance Method Summary collapse
-
#initialize(user, pass, client) ⇒ AuthSession
constructor
A new instance of AuthSession.
- #login ⇒ Object
- #logout ⇒ Object
- #raise_handled_error(code, desc) ⇒ Object
- #session ⇒ Object
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
#login ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cdnetworks-client/auth_open_api.rb', line 20 def login params = { user: @user, pass: @pass, output: "json" } resp = @client.call(LOGIN_URL, params) resp[:body]['loginResponse']['session'] end |
#logout ⇒ Object
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 |
#session ⇒ Object
16 17 18 |
# File 'lib/cdnetworks-client/auth_open_api.rb', line 16 def session @session ||= login end |