-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.rb
44 lines (36 loc) · 1001 Bytes
/
base.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'curb'
require 'nokogiri'
module GetARoom
class Base
def initialize(email, password)
@email = email
@password = password
login
end
def finalize
logout
end
def logged_in?
return true
end
def login
@curb = Curl::Easy.new('http://ga.getaroomapp.com/login')
@curb.headers["User-Agent"] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2"
@curb.follow_location = true
@curb.enable_cookies = true
#@curb.verbose = true
@curb.perform
@curb.http_post([
Curl::PostField.content('email', @email),
Curl::PostField.content('password', @password)
])
raise("Could not login to service!") if @curb.response_code != 200
@curb
end
def logout
@curb.url = "http://ga.getaroomapp.com/logout"
@curb.perform
@curb = nil
end
end
end