portal_scraper 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/portal_scraper/accounts/client.rb +11 -6
- data/lib/portal_scraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3df4443de4498950c6211977813f29b8797bdccea1f0bb7fddff3b81ce4e7a
|
4
|
+
data.tar.gz: 47f4c80cf69c069c17077723621910a4c3b1a79217376bbc334939c7d6ccffc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d8e011c675a99778e34b675331cfd27978695a37234261065ba214b29df4614028bf3d7eac3b04b8796936bf64839712e953479fde94520983c8ca9e2aba3e
|
7
|
+
data.tar.gz: 3cfe35a13f40355287c021d93ace48f65762cc9d9af00e80d69ab60adba5d87c13718bda87861628770b0ae414361c92469f394c1833e7023f19fe40ee19e048
|
@@ -5,8 +5,8 @@ module PortalScraper
|
|
5
5
|
class Client
|
6
6
|
attr_accessor :app_id, :secret
|
7
7
|
|
8
|
-
CODE_TO_COUNTRY_MAPPING = JSON.parse(File.read(File.join(
|
9
|
-
MINIMUM_AMOUNT
|
8
|
+
CODE_TO_COUNTRY_MAPPING = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'code_to_country.json')))
|
9
|
+
MINIMUM_AMOUNT = 10
|
10
10
|
|
11
11
|
def initialize(app_id = nil, secret = nil)
|
12
12
|
@app_id = app_id || config.app_id
|
@@ -33,7 +33,12 @@ module PortalScraper
|
|
33
33
|
app.get(url_for('/appTiersCreation.do')) do |create_page|
|
34
34
|
create_page.form_with(name: /(create|creation)/i) do |form|
|
35
35
|
form.fields.each { |f| try_form_fields(form, [f.name], user[f.name.to_sym]) }
|
36
|
-
|
36
|
+
if user[:codeInsee].present?
|
37
|
+
form['commune'] = user[:codeInsee]
|
38
|
+
form['libCommune'] = user[:ville]
|
39
|
+
else
|
40
|
+
fill_commune(app, form, user[:codePostal], user[:ville].gsub('-', ' ').upcase.sub('SAINT', 'ST'))
|
41
|
+
end
|
37
42
|
fill_birth_place(form, user[:paysNaissance])
|
38
43
|
form['modeContact'] = ''
|
39
44
|
form['creerTiers'] = 'Créer'
|
@@ -55,7 +60,7 @@ module PortalScraper
|
|
55
60
|
app.get(url_for('/appRecherche.do')) do |search_user_page|
|
56
61
|
search_user_page.form_with(name: /(frmCritRech)/i) do |form|
|
57
62
|
form['idTiers'] = client_ref
|
58
|
-
result_page
|
63
|
+
result_page = form.click_button
|
59
64
|
result_page.links.find { |l| l.text.strip == client_ref }.click
|
60
65
|
app.get(url_for('/propositionList.do'))
|
61
66
|
return { proposition_ref: proposition }
|
@@ -86,7 +91,7 @@ module PortalScraper
|
|
86
91
|
end
|
87
92
|
|
88
93
|
def proposition
|
89
|
-
proposition_page = app.get(url_for('/propositionDetail.do'), {idx: 3})
|
94
|
+
proposition_page = app.get(url_for('/propositionDetail.do'), { idx: 3 })
|
90
95
|
proposition_form = proposition_page.form_with(name: /proposition/i)
|
91
96
|
try_form_fields(proposition_form, %w(montant amount), MINIMUM_AMOUNT)
|
92
97
|
proposition_form['regimeFiscal'] = 'I'
|
@@ -96,7 +101,7 @@ module PortalScraper
|
|
96
101
|
if confirmation_page.uri.path =~ /error.do/
|
97
102
|
return { error: 'Missing data' }
|
98
103
|
end
|
99
|
-
text
|
104
|
+
text = confirmation_page.search('td.ZMSG').text.strip
|
100
105
|
proposition_ref = text.match('\d{9}')[0]
|
101
106
|
app.get(url_for('/propositionImprimer.do'))
|
102
107
|
proposition_ref
|
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.4.
|
4
|
+
version: 1.4.2
|
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
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|