Class: ThreeUsage::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/three_usage/fetcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, pin) ⇒ Fetcher

Returns a new instance of Fetcher.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/three_usage/fetcher.rb', line 7

def initialize(username,password,pin)
  agent = WWW::Mechanize.new
  page = agent.get('https://www.my.three.com.au/My3/jfn')
   = page.form('login')
  . = username
  .password = password
  page = agent.submit(, .buttons.first)
  pin_form = page.form('myForm')
  if pin_form.nil?
    puts "Authentication failure"
    exit(1)
  end
  pin_form.pin = pin
  @page = agent.submit(pin_form, pin_form.buttons.first)
end

Instance Attribute Details

#pageObject

Returns the value of attribute page.



6
7
8
# File 'lib/three_usage/fetcher.rb', line 6

def page
  @page
end