boq_com_au 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 169a4211f870a165121c2ac49ec27b58346c7f28b0ecc24bcafbb9d494c74877
4
- data.tar.gz: fecb838576a38a082066462790e4167a6d58eaaf252389a5d75849130a8c66f9
3
+ metadata.gz: 7dbfa387d610f682d7da5ac4cc759933199a95e07fa2a3ed59a371a81b8fb14c
4
+ data.tar.gz: 5fb79aa2173d74a2a5bc5caed23aa36d877fd4addd817625e81637ac1b3eef67
5
5
  SHA512:
6
- metadata.gz: 4951d8080e25d20cc968437cd2009e39fb87b22b961bb44c7442742ab32d2c84e7dcf1a0bb14b0363a3b8076eb85bbcf87b6276ec7a46ffa96fbb9c3f396aca4
7
- data.tar.gz: 58615e334a814d0ac6a32c226d78c6cde168cce65e3fcc1bc97e9ead3af68f0d6bfa6bbf4477cdad633aeb6fe8a147ac631915640b37d680188dbaae921884a5
6
+ metadata.gz: d73852294ffd68b289400f939be9046d7d45037646c0ace02aaab989b92b46097d4d6a84a8bc9857740d7ac06056a8dbf20ab76aa90f0fc3535bf82170d62a5e
7
+ data.tar.gz: 36866d193c771d928993c5f9b1000624b827c4ed400470baf57ccadfc8faff4c4d54a4c8ec34afc0c8c9b400652601f08a37b4a35175a6ee276e2d7350814d5f
data/CHANGELOG CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## 20261115
4
4
 
5
+ 0.4.1: ~ BoqComAu::Account#login and #download_transactions name every argument missing at once, as an ArgumentError.
6
+
7
+ 1. + BoqComAu::Account#validate_args
8
+ 2. + BoqComAu::Account#login: Calls validate_args(username:, password:), then WebAccount#login.
9
+ 3. - BoqComAu::Account#username, #password: WebAccount's readers are used, nil where not given.
10
+ 4. ~ BoqComAu::Account#download_transactions: Calls validate_args(account_number:).
11
+ 5. ~ test/BoqComAu/Account_test.rb: One missing and both missing are named by login, given to new or to login itself; a nil account_number is named by download_transactions; username and password are nil where not given.
12
+ 6. ~ README.md, Account.rb's notes: login raises ArgumentError naming every one missing.
13
+ 7. ~ Account.rb's notes: Chosen, which draws BOQ's dropdowns, is said to be a JavaScript library, as otherwise it reads as the word "chosen".
14
+ 8. ~ BoqComAu::VERSION: /0.4.0/0.4.1/
15
+
5
16
  0.4.0: - BoqComAu::Account#initialize: Now uses superclass WebAccount.
6
17
 
7
18
  1. ~ boq_com_au.gemspec: webaccount /'~> 0.7'/'~> 0.8'/
data/README.md CHANGED
@@ -58,7 +58,7 @@ The username is the Customer Access Number. It and the password are given, or se
58
58
  boq_account = BoqComAu::Account.new(username: customer_access_number, password: password)
59
59
  boq_account.username, boq_account.password = customer_access_number, password
60
60
  ```
61
- Where either is missing, `login` stops, saying which.
61
+ Where either is missing, `login` raises ArgumentError before starting the browser, naming every one missing.
62
62
 
63
63
  ### The browser
64
64
 
@@ -5,10 +5,10 @@
5
5
  # 1. The login page's ids and names (id4, 8, ...) appear to be generated, so the fields are found by their labels.
6
6
  # 2. The ids and names after login (id121, 74, ...) appear to be generated too, so TRANSACTIONS_SELECTORS find things by their text.
7
7
  # 3. BankFast's links are javascript:void(0) where they aren't the session's key and a callback number, and some, such as Transaction History, are in a menu which is closed. A link which isn't displayed is clicked by JavaScript.
8
- # 4. Dropdowns are Chosen's, which hides the select and draws its own: <select id>_chosen, opened by its a.chosen-single and chosen from its li.active-result. A select which is displayed is used as it is.
8
+ # 4. Dropdowns are drawn by Chosen, a JavaScript library, which hides the select and draws its own: <select id>_chosen, opened by its a.chosen-single and chosen from its li.active-result. A select which is displayed is used as it is.
9
9
  # 5. Where a one-time code is asked for after logging on, login() waits default_wait_timeout seconds for it to be entered by hand.
10
10
  # 6. The browser, Chrome or Firefox, is WebAccount's: given a profile_directory, it's started with that profile, kept between runs, so as the bank sees a returning browser rather than a fresh automated one. It downloads into download_directory without asking, and opens nothing it downloads.
11
- # 7. A username or password not given stops login, saying which is missing.
11
+ # 7. A username or password not given stops login before the browser is started, naming every one missing.
12
12
  # 8. BOQ names the exported file after the account number and the date, as 12345678_20261103.csv, and the browser numbers a second download of the same name; so the newest finished CSV file to appear in download_directory once Download is clicked is taken to be it.
13
13
  # 9. Dates are BOQ's own, as shown on choosing the account, unless a period or a date is given; then they're set under Advanced Search and searched on before exporting.
14
14
 
@@ -37,16 +37,14 @@ module BoqComAu
37
37
  download_button: {xpath: '//*[self::a or self::button][normalize-space()="Download"] | //input[@value="Download"]'}
38
38
  }
39
39
 
40
- def username
41
- @username || raise("No username: it's given as username:.")
42
- end
43
-
44
- def password
45
- @password || raise("No password: it's given as password:.")
40
+ def login(username: nil, password: nil)
41
+ validate_args(username: username || self.username, password: password || self.password)
42
+ super
46
43
  end
47
44
 
48
45
  # period is :all, the last year, or :last_month. Without it, from_date and to_date, either of which defaults to a year ago and today respectively where the other is given. Returns the name of the CSV file downloaded.
49
46
  def download_transactions(account_number:, period: nil, from_date: nil, to_date: nil)
47
+ validate_args(account_number: account_number)
50
48
  from_date, to_date = dates(period: period, from_date: from_date, to_date: to_date)
51
49
  get_transactions_page
52
50
  select_bank_account(account_number)
@@ -59,6 +57,17 @@ module BoqComAu
59
57
 
60
58
  private
61
59
 
60
+ def validate_args(args)
61
+ missing_args = []
62
+ args.each do |arg_name, value|
63
+ missing_args << arg_name unless value
64
+ end
65
+ return if missing_args.empty?
66
+ aggregate_error = missing_args.join(', ')
67
+ copula = missing_args.count > 1 ? 'are' : 'is'
68
+ raise ArgumentError, "#{aggregate_error} #{copula} missing."
69
+ end
70
+
62
71
  # page interaction
63
72
 
64
73
  def chosen_list(select_element)
@@ -2,5 +2,5 @@
2
2
  # BoqComAu::VERSION
3
3
 
4
4
  module BoqComAu
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
@@ -81,17 +81,34 @@ describe BoqComAu::Account do
81
81
  _(account.password).must_equal('secret')
82
82
  end
83
83
 
84
- it "say which is missing where they're not given, rather than reading the environment" do
84
+ it "are nil where they're not given, rather than read from the environment" do
85
85
  ENV['BOQ_USERNAME'], ENV['BOQ_PASSWORD'] = 'customer', 'secret'
86
86
  account = BoqComAu::Account.new
87
- _(_{account.username}.must_raise(RuntimeError).message).must_include('No username')
88
- _(_{account.password}.must_raise(RuntimeError).message).must_include('No password')
87
+ _(account.username).must_be_nil
88
+ _(account.password).must_be_nil
89
89
  ensure
90
90
  ENV.delete('BOQ_USERNAME')
91
91
  ENV.delete('BOQ_PASSWORD')
92
92
  end
93
93
  end
94
94
 
95
+ describe "#login" do
96
+ it "names the one missing, before starting the browser" do
97
+ account = BoqComAu::Account.new(username: 'customer')
98
+ _(_{account.login}.must_raise(ArgumentError).message).must_equal('password is missing.')
99
+ _(account.instance_variable_get(:@driver)).must_be_nil
100
+ end
101
+
102
+ it "names both where both are missing" do
103
+ _(_{BoqComAu::Account.new.login}.must_raise(ArgumentError).message).must_equal('username, password are missing.')
104
+ end
105
+
106
+ it "takes either given to login itself as given" do
107
+ _(_{BoqComAu::Account.new(username: 'customer').login(password: nil)}.must_raise(ArgumentError).message).must_equal('password is missing.')
108
+ _(_{BoqComAu::Account.new.login(username: 'customer')}.must_raise(ArgumentError).message).must_equal('password is missing.')
109
+ end
110
+ end
111
+
95
112
  describe "#download_transactions" do
96
113
  def account_recording_steps
97
114
  account = account_with_driver(stand_in_driver)
@@ -112,6 +129,12 @@ describe BoqComAu::Account do
112
129
  account.download_transactions(account_number: '12345678', from_date: '2026-10-01', to_date: '2026-10-31')
113
130
  _(steps).must_equal([:get_transactions_page, :select_bank_account, [:enter_dates, '2026-10-01', '2026-10-31'], :search, :export_csv])
114
131
  end
132
+
133
+ it "names a missing account number, before going to the transactions page" do
134
+ account, steps = account_recording_steps
135
+ _(_{account.download_transactions(account_number: nil)}.must_raise(ArgumentError).message).must_equal('account_number is missing.')
136
+ _(steps).must_be_empty
137
+ end
115
138
  end
116
139
 
117
140
  describe "the browser" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boq_com_au
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoran