Class: Txbr::BrazeSession
- Inherits:
-
Object
- Object
- Txbr::BrazeSession
- Defined in:
- lib/txbr/braze_session.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#email_address ⇒ Object
readonly
Returns the value of attribute email_address.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(api_url, email_address, password) ⇒ BrazeSession
constructor
A new instance of BrazeSession.
- #reset! ⇒ Object
- #session_id ⇒ Object
Constructor Details
#initialize(api_url, email_address, password) ⇒ BrazeSession
Returns a new instance of BrazeSession.
8 9 10 11 12 13 14 |
# File 'lib/txbr/braze_session.rb', line 8 def initialize(api_url, email_address, password) @api_url = api_url @email_address = email_address @password = password reset! end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
6 7 8 |
# File 'lib/txbr/braze_session.rb', line 6 def api_url @api_url end |
#email_address ⇒ Object (readonly)
Returns the value of attribute email_address.
6 7 8 |
# File 'lib/txbr/braze_session.rb', line 6 def email_address @email_address end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/txbr/braze_session.rb', line 6 def password @password end |
Instance Method Details
#reset! ⇒ Object
35 36 37 |
# File 'lib/txbr/braze_session.rb', line 35 def reset! @session_id = nil end |
#session_id ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/txbr/braze_session.rb', line 16 def session_id @session_id ||= begin agent = Mechanize.new url = Txbr::Utils.url_join(api_url, "auth?email=#{CGI.escape(email_address)}") agent.get(url) do |page| page.form_with(id: 'developer_signin').tap do |form| form['developer[password]'] = password form.submit end end agent . .find { || .name == '_session_id' } .value end end |