Class: BptScraper::Login

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/bpt_scraper/login.rb

Overview

Handles the scraping of the home page for CSRF token from username input. Additionally handles the POSTing of login info to create a session

Constant Summary collapse

BASE_URL =
'https://www.brownpapertickets.com/login.html'.freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#failed_login_fetch, #failed_login_post, #missing_options_error, #missing_parameters_error, #no_developer_id_error

Constructor Details

#initialize(base_url: nil, email: nil, password: nil) ⇒ Login

Returns a new instance of Login.



13
14
15
16
17
18
# File 'lib/bpt_scraper/login.rb', line 13

def initialize(base_url: nil, email: nil, password: nil)
  self.base_url = base_url || self.class.base_url || BASE_URL
  self.email = email || self.class.email
  self.password = password || self.class.password
  missing_options_error('Login') if (self.email.nil? || self.password.nil?)
end

Class Attribute Details

.base_urlObject

Returns the value of attribute base_url.



26
27
28
# File 'lib/bpt_scraper/login.rb', line 26

def base_url
  @base_url
end

.emailObject

Returns the value of attribute email.



26
27
28
# File 'lib/bpt_scraper/login.rb', line 26

def email
  @email
end

.fieldsObject

Returns the value of attribute fields.



26
27
28
# File 'lib/bpt_scraper/login.rb', line 26

def fields
  @fields
end

.passwordObject

Returns the value of attribute password.



26
27
28
# File 'lib/bpt_scraper/login.rb', line 26

def password
  @password
end

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url.



9
10
11
# File 'lib/bpt_scraper/login.rb', line 9

def base_url
  @base_url
end

#emailObject

Returns the value of attribute email.



9
10
11
# File 'lib/bpt_scraper/login.rb', line 9

def email
  @email
end

#fieldsObject

Returns the value of attribute fields.



9
10
11
# File 'lib/bpt_scraper/login.rb', line 9

def fields
  @fields
end

#passwordObject

Returns the value of attribute password.



9
10
11
# File 'lib/bpt_scraper/login.rb', line 9

def password
  @password
end

Class Method Details

.resetObject



29
30
31
32
33
34
# File 'lib/bpt_scraper/login.rb', line 29

def self.reset
  self.base_url = nil
  self.fields = nil
  self.email = nil
  self.password = nil
end

Instance Method Details

#create_sessionObject



20
21
22
23
# File 'lib/bpt_scraper/login.rb', line 20

def create_session
  self.fields = 
  
end