Class: Scottrade::Session
- Includes:
- Helpers
- Defined in:
- lib/scottrade/session.rb
Instance Attribute Summary collapse
-
#encrypted_id ⇒ Object
readonly
Returns the value of attribute encrypted_id.
-
#mask_id ⇒ Object
readonly
Returns the value of attribute mask_id.
Attributes inherited from Base
Instance Method Summary collapse
- #authenticate ⇒ Object
- #authenticated? ⇒ Boolean
-
#initialize(account, password) ⇒ Session
constructor
A new instance of Session.
Methods included from Helpers
Methods inherited from Base
Constructor Details
#initialize(account, password) ⇒ Session
Returns a new instance of Session.
13 14 15 16 17 |
# File 'lib/scottrade/session.rb', line 13 def initialize(account, password) @account = account @password = password @cookies = nil end |
Instance Attribute Details
#encrypted_id ⇒ Object (readonly)
Returns the value of attribute encrypted_id.
11 12 13 |
# File 'lib/scottrade/session.rb', line 11 def encrypted_id @encrypted_id end |
#mask_id ⇒ Object (readonly)
Returns the value of attribute mask_id.
11 12 13 |
# File 'lib/scottrade/session.rb', line 11 def mask_id @mask_id end |
Instance Method Details
#authenticate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scottrade/session.rb', line 21 def authenticate params = request_parameters("VerifyLogin") params["appName"] = "ScottradeMobileApplication" params["appVer"] = "1.1.4" params["isRemAcc"] = "true" params["page"] = "LogIn" params["langId"] = "English" params["acc"] = @account params["pwd"] = @password params["isEncrypted"] = "false" response = authentication_post(params) = response.get_fields('set-cookie') # only cookies are set on valid credentials parsed_response = JSON.parse(response.body) @cookies = [] .each { | | @cookies.push(.split('; ')[0]) } @encrypted_dd = parsed_response["encryptedId"] @mask_id = parsed_response["maskId"] return self end |
#authenticated? ⇒ Boolean
18 19 20 |
# File 'lib/scottrade/session.rb', line 18 def authenticated? return (@cookies != nil) end |