portal_scraper 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1939dee0f771654ced16cfc0b9df2d7fad0e95028579bf47fb0ec75216a437b1
4
- data.tar.gz: 5ee3c84ca36f19d1684b23b0929975d7210e5bb2f3f002e700fd61e5a1e2bd7f
3
+ metadata.gz: 1645a898b4d02cea25387829c4aa64cbba4079548e4a3071c2dd36e38890e3a8
4
+ data.tar.gz: 8d5ef9cc5da93c985773a63de9fcfdf196909357bcd69db414ccec45daab864d
5
5
  SHA512:
6
- metadata.gz: c2a171f87a5463ac205e4c7bd6f4140d1a2db0e84a6a3f2cddbf381010708f8013cb03803d277e3e41692120ccb3409b10fece235b82b6a6c9fc81055849a24d
7
- data.tar.gz: 462c1a675eec28ec90f1089987305cbb3a25d2add2cea43425ba5bdd7010d24c78c37d7b2b6f4e5ebc1cd0d1b191ba7914df293a4a719d96a0b8f2d98e58ffa5
6
+ metadata.gz: bd9db17c4112d4247fe21cd37d71acde3da046ec54be8fd91d2977a14f55312ff1117b2f20c12eb20be5caa6dffc4c31f3e4d0ef2863bbc4e0336a2606700736
7
+ data.tar.gz: 276da5c4531e01f87149e8e703658a9a0140c2808ec4c27e112445dd91e0556a88f3250048499c73d37bc012bc2b00d0fc6709d0f8360cf08eaa708478c1e571
@@ -1,11 +1,13 @@
1
1
  require 'mechanize'
2
2
  require 'active_support/all'
3
3
  require_relative '../city_names_helper'
4
+ require_relative '../number_helper'
4
5
 
5
6
  module PortalScraper
6
7
  module Accounts
7
8
  class Client
8
9
  include CityNamesHelper
10
+ include NumberHelper
9
11
  attr_accessor :app_id, :secret
10
12
 
11
13
  CODE_TO_COUNTRY_MAPPING = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'code_to_country.json')))
@@ -24,11 +26,25 @@ module PortalScraper
24
26
  results = app.post(url_for('/appRecherche.do'), { nom: '', prenom: '', chercher: 'Chercher' })
25
27
  loop do
26
28
  results.links_with(href: /appTiersDetail.do/).each do |link|
27
- account = link.click
29
+ account = link.click
30
+ transfers = []
31
+ account.links_with(css: 'table#contrat td a').each do |transfer|
32
+ result = transfer.click
33
+ result.search('table#operation tbody tr').each do |row|
34
+ transfers << {
35
+ operation_date: row.search('td[1]').text.strip.match(/\d{2}\/\d{2}\/\d{4}/).to_s,
36
+ nature: row.search('td[2]').text.strip.gsub(/[\n,\t,'']/, ''),
37
+ value_date: row.search('td[3]').text.strip.match(/\d{2}\/\d{2}\/\d{4}/).to_s,
38
+ debit: format_number(row.search('td[4]')),
39
+ credit: format_number(row.search('td[5]')),
40
+ }
41
+ end
42
+ end
28
43
  accounts_data[:accounts] << {
29
44
  client_ref: find_table_value(account, 'Identifiant tiers'),
30
- balance: account.search('table#contrat th.n').text.gsub(/[[:space:]]+/, '').tr('.,', ',.').to_f,
31
- opened_on: account.search('table#contrat td').text.gsub(/\d{2}\/\d{2}\/\d{4}/)&.max
45
+ balance: format_number(account.search('table#contrat th.n')),
46
+ opened_on: account.search('table#contrat td').text.gsub(/\d{2}\/\d{2}\/\d{4}/)&.max,
47
+ transfers: transfers
32
48
  }
33
49
  end
34
50
 
@@ -0,0 +1,8 @@
1
+ module PortalScraper
2
+ module NumberHelper
3
+
4
+ def format_number(number)
5
+ number.text.strip.gsub(/[[:space:]]+/, '').tr(',', '.').to_d
6
+ end
7
+ end
8
+ end
@@ -1,7 +1,7 @@
1
1
  module PortalScraper
2
2
  class Version
3
3
  MAJOR = 1
4
- MINOR = 8
4
+ MINOR = 9
5
5
  PATCH = 0
6
6
 
7
7
  def self.to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portal_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armand Mégrot
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-12-18 00:00:00.000000000 Z
12
+ date: 2019-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
@@ -123,6 +123,7 @@ files:
123
123
  - lib/portal_scraper/bad_login_url.rb
124
124
  - lib/portal_scraper/bad_root_url.rb
125
125
  - lib/portal_scraper/city_names_helper.rb
126
+ - lib/portal_scraper/number_helper.rb
126
127
  - lib/portal_scraper/portal_scraper_error.rb
127
128
  - lib/portal_scraper/version.rb
128
129
  - portal-scraper.gemspec