module OnSIP::Session::ClassMethods

Public Instance Methods

create(username, password) { |response| ... } click to toggle source
# File lib/onsip/session.rb, line 37
def create(username, password)
  response = OnSIP.connection.get('/api', {'Action' => 'SessionCreate', 'Username' => username, 'Password' => password, 'Output' => 'json'}, {})
  yield response if block_given?
  process_create_session_response response
end
destroy!(session_id) { |response| ... } click to toggle source
# File lib/onsip/session.rb, line 53
def destroy!(session_id)
  response = OnSIP.connection.get('/api', {'Action' => 'SessionDestroy', 'SessionId' => session_id, 'Output' => 'json'}, {})
  yield response if block_given?
  process_destroy_session_response response
end
process_create_session_response(response) click to toggle source
# File lib/onsip/session.rb, line 43
def process_create_session_response(response)
  session = nil

  key_path = %w(Response Context Session)
  a = ResponseParser.parse_response response, key_path
  session = (a.map { |h| new h }).first if a

  session
end
process_destroy_session_response(response) click to toggle source
# File lib/onsip/session.rb, line 59
def process_destroy_session_response(response)
  session = nil

  key_path = %w(Response Context Session)
  a = ResponseParser.parse_response response, key_path
  session = (a.map { |h| new h }).first if a

  session
end