Class: FineAnts::Adapters::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/fine_ants/adapters/target.rb

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Target

Returns a new instance of Target.



6
7
8
9
# File 'lib/fine_ants/adapters/target.rb', line 6

def initialize(credentials)
  @user = credentials[:user]
  @password = credentials[:password]
end

Instance Method Details

#downloadObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fine_ants/adapters/target.rb', line 21

def download
  balance = find("#AcctSummaryRCAM_AcctTbl_CrntBal").text
  available_balance = find("#AcctSummaryRCAM_AcctTbl_CredAvail").text
  next_due_date = find("#AcctSummaryRCAM_AcctTbl_PmtDueDt").text
  card_number = find("#AccountAcctNum").text.delete("For your REDcard ending in: ")

  [
    {
      adapter: :target,
      user: @user,
      id: "REDcard #{card_number}",
      name: "REDcard #{card_number}",
      type: :credit_card,
      amount: -1 * parse_currency(balance),
      available_amount: parse_currency(available_balance),
      next_due_date: parse_due_date(next_due_date)
    }
  ]
end

#loginObject



11
12
13
14
15
16
17
18
19
# File 'lib/fine_ants/adapters/target.rb', line 11

def 
  visit "https://rcam.target.com/default.aspx"

  fill_in "Login_UserName", with: @user
  fill_in "Login_Password", with: @password
  find("#Login_btnSignIn_btnSignIn").click

  verify_login!
end