Module: OnSIP::Session::ClassMethods

Included in:
OnSIP::Session
Defined in:
lib/onsip/session.rb

Instance Method Summary collapse

Instance Method Details

#create(username, password) {|response| ... } ⇒ Object

Yields:

  • (response)


37
38
39
40
41
# 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| ... } ⇒ Object

Yields:

  • (response)


53
54
55
56
57
# 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) ⇒ Object



43
44
45
46
47
48
49
50
51
# 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) ⇒ Object



59
60
61
62
63
64
65
66
67
# 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