Class: WigleApi::Connection
- Inherits:
-
Object
- Object
- WigleApi::Connection
- Defined in:
- lib/wigle_api/connection.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #login(username, password) ⇒ Object
- #search(data) ⇒ Object
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 14 15 16 |
# File 'lib/wigle_api/connection.rb', line 9 def initialize @connection = Net::HTTP.new(WIGLE_URI.host, WIGLE_URI.port) @connection.ca_file = "/etc/pki/tls/certs/ca-bundle.crt" @connection.use_ssl = true @connection.verify_mode = OpenSSL::SSL::VERIFY_PEER @logged_in = false end |
Class Method Details
.new(*args) ⇒ Object
5 6 7 |
# File 'lib/wigle_api/connection.rb', line 5 def self.new(*args) @@instance ||= super end |
Instance Method Details
#login(username, password) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wigle_api/connection.rb', line 18 def login(username, password) return true if @logged_in login_form_data = { "credential_0" => username, "credential_1" => password, "destination" => "/gps/gps/main", "noexpire" => "on", } response = post(WIGLE_LOGIN_URL, login_form_data) if response["Set-Cookie"].nil? return false end @auth_cookie = response["Set-Cookie"] @logged_in = true end |
#search(data) ⇒ Object
38 39 40 41 42 |
# File 'lib/wigle_api/connection.rb', line 38 def search(data) raise NotLoggedIn unless @logged_in response = post(WIGLE_QUERY_URL, data) end |