portal_scraper 1.4.1 → 1.4.2

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: 528699b1216ea500430d60e2c094d1338e27a2541bd58d2913829da810b70ef5
4
- data.tar.gz: ce9ba88cf06971c5cf3999c87bb0b981e126922ed457950ca29937acbc33650a
3
+ metadata.gz: ae3df4443de4498950c6211977813f29b8797bdccea1f0bb7fddff3b81ce4e7a
4
+ data.tar.gz: 47f4c80cf69c069c17077723621910a4c3b1a79217376bbc334939c7d6ccffc7
5
5
  SHA512:
6
- metadata.gz: 6bd226eddbf651b826a0c209fb546cdf4d603000fc216b0c35c191679e6fc9976ba83b209482203a248dd0488639ddc8fcca913f017efa997ea8fa7846516654
7
- data.tar.gz: 2a556200ae1fad277e399351928a2b0be6f5fef24794ac39bb6a2c0c28d1ae4ce68d9d2ac648ca14afd259020294aea1914d78610a31837b17c792fffd813c7f
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( File.dirname(__FILE__), 'code_to_country.json')))
9
- MINIMUM_AMOUNT = 10
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
- fill_commune(app, form, user[:codePostal], user[:ville].gsub('-', ' ').upcase.sub('SAINT', 'ST'))
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 = form.click_button
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 = confirmation_page.search('td.ZMSG').text.strip
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
@@ -2,7 +2,7 @@ module PortalScraper
2
2
  class Version
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].compact.join('.')
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.1
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-05-20 00:00:00.000000000 Z
12
+ date: 2019-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize