portal_scraper 1.2.3 → 1.3.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: 5652460df11dd2c25bd5628b991eb3b0f2e62d02b2c4717c966b23d6bb4885ca
4
- data.tar.gz: 83d7985aa78c0ead3a8fbedd939a48a052667dd2e94b42f420cc1f02b27ce6af
3
+ metadata.gz: c4df187d3c6821bbb51afe75a0b0facff3e37789221ef19f5916ff365ae5c513
4
+ data.tar.gz: 741723003ad4428b8219d6eeda4fdd8471bf1b0977fdcd494e105f3de79e4776
5
5
  SHA512:
6
- metadata.gz: 3912e4709b6076e71e4c510be4b558a8ca6814fec5fc3c0aa1b82742b6c4b17307a362f9c908ff79c9dfe3600e3a17f6c55016ab2416ce452e1ab6ee212b8fc9
7
- data.tar.gz: c1d94dd080fe873a7892b9f81d63b447f4a8a8d66f990c5bfe14ff0d892a9667098f575e1fb38d15829e48c185a0143c5631f902a1b08ecdab55e07543af71ba
6
+ metadata.gz: 040bacec63c67e59b5ac8aef874bb90557a8e4f19ec9ff16f9ef4f4bdedd270df67ae2d72c23b02aca6deaabfba9f63fc074c9ba8d4bc37b79e26bf711bdfcdc
7
+ data.tar.gz: 3ae49e0387465e4208dbcb67d9c530f8209d30198098ca9a9d2cd9ef6d9b70f1e091d2e450c9267b5f8ff1cdc5c786fa9074eb4b60239d3414bf278d9b3131bb
@@ -6,6 +6,7 @@ module PortalScraper
6
6
  attr_accessor :app_id, :secret
7
7
 
8
8
  CODE_TO_COUNTRY_MAPPING = JSON.parse(File.read(File.join( File.dirname(__FILE__), 'code_to_country.json')))
9
+ MINIMUM_AMOUNT = 10
9
10
 
10
11
  def initialize(app_id = nil, secret = nil)
11
12
  @app_id = app_id || config.app_id
@@ -41,7 +42,9 @@ module PortalScraper
41
42
  if result_page.uri.path =~ /error.do/
42
43
  return { error: 'Missing data' }
43
44
  else
44
- return { client_ref: result_page.search('td.ZMSG').text.split(':')[1].strip }
45
+ ref = result_page.search('td.ZMSG').text.split(':')[1].strip
46
+ proposition result_page
47
+ return { client_ref: ref }
45
48
  end
46
49
  end
47
50
  end
@@ -69,6 +72,22 @@ module PortalScraper
69
72
  app.get(url_for(config.token_url)) unless config.token_url.nil?
70
73
  end
71
74
 
75
+ def proposition(creation_page)
76
+ form = creation_page.form_with(name: /succes/i) || creation_page.forms[0]
77
+ form.click_button
78
+ proposition_page = app.get(url_for('/propositionDetail.do'), {idx: 3})
79
+ proposition_form = proposition_page.form_with(name: /proposition/i)
80
+ try_form_fields(proposition_form, %w(montant amount), MINIMUM_AMOUNT)
81
+ proposition_form['regimeFiscal'] = 'I'
82
+ proposition_form.click_button
83
+ app.get(url_for('/propositionCreate.do'))
84
+ confirmation_page = app.get(url_for('/propositionConfirm.do'))
85
+ if confirmation_page.uri.path =~ /error.do/
86
+ return { error: 'Missing data' }
87
+ end
88
+ app.get(url_for('/propositionImprimer.do'))
89
+ end
90
+
72
91
  def try_form_fields(form, fields, value)
73
92
  fields.each do |field|
74
93
  if form.has_field?(field)
@@ -1,8 +1,8 @@
1
1
  module PortalScraper
2
2
  class Version
3
3
  MAJOR = 1
4
- MINOR = 2
5
- PATCH = 3
4
+ MINOR = 3
5
+ PATCH = 0
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].compact.join('.')
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.name = 'portal_scraper'
10
10
  spec.version = PortalScraper::Version
11
- spec.authors = ['Armand Mégrot']
12
- spec.email = ['armand.megrot@gmail.com']
11
+ spec.authors = ['Armand Mégrot', 'Thomas Burgaud']
12
+ spec.email = %w(armand.megrot@gmail.com thomasburgaud98@gmail.com)
13
13
  spec.summary = 'Ruby portal scraper'
14
14
  spec.description = 'Scrapping client for extranet portals.'
15
15
  spec.license = 'Apache-2.0'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portal_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armand Mégrot
8
+ - Thomas Burgaud
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-04-25 00:00:00.000000000 Z
12
+ date: 2019-05-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: mechanize
@@ -97,6 +98,7 @@ dependencies:
97
98
  description: Scrapping client for extranet portals.
98
99
  email:
99
100
  - armand.megrot@gmail.com
101
+ - thomasburgaud98@gmail.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []