portal_scraper 1.3.0 → 1.4.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: c4df187d3c6821bbb51afe75a0b0facff3e37789221ef19f5916ff365ae5c513
4
- data.tar.gz: 741723003ad4428b8219d6eeda4fdd8471bf1b0977fdcd494e105f3de79e4776
3
+ metadata.gz: 2d955f16ec3fc0d202a414fb9bffe2056ccbc9e6ab89a17e39074c9b72672b75
4
+ data.tar.gz: 5666f797c7c73c0d36a1f8f5435b855103ec3a1ebfe7b2918cc081a2d4d4b94e
5
5
  SHA512:
6
- metadata.gz: 040bacec63c67e59b5ac8aef874bb90557a8e4f19ec9ff16f9ef4f4bdedd270df67ae2d72c23b02aca6deaabfba9f63fc074c9ba8d4bc37b79e26bf711bdfcdc
7
- data.tar.gz: 3ae49e0387465e4208dbcb67d9c530f8209d30198098ca9a9d2cd9ef6d9b70f1e091d2e450c9267b5f8ff1cdc5c786fa9074eb4b60239d3414bf278d9b3131bb
6
+ metadata.gz: d660fa624051947f57a56599f1c1304309f5af7bd78755c0117d2f38480040d56bff11bd873f35d2671f4bb6e16c070a63626923af3dc24fcea51d2c84a305ab
7
+ data.tar.gz: a4204632ed78023b53cc626184d86ce24b4fb823533f55e2fea74ce18a82604f36be8c90fd2d26eab37db77d817955984a1821fe1d885bc68e9d95aa621dcce4
@@ -43,7 +43,6 @@ module PortalScraper
43
43
  return { error: 'Missing data' }
44
44
  else
45
45
  ref = result_page.search('td.ZMSG').text.split(':')[1].strip
46
- proposition result_page
47
46
  return { client_ref: ref }
48
47
  end
49
48
  end
@@ -51,6 +50,20 @@ module PortalScraper
51
50
  nil
52
51
  end
53
52
 
53
+ def create_proposition(client_ref)
54
+ login
55
+ app.get(url_for('/appRecherche.do')) do |search_user_page|
56
+ search_user_page.form_with(name: /(frmCritRech)/i) do |form|
57
+ form['idTiers'] = client_ref
58
+ result_page = form.click_button
59
+ result_page.links.find { |l| l.text.strip == client_ref }.click
60
+ app.get(url_for('/propositionList.do'))
61
+ return { proposition_ref: proposition }
62
+ end
63
+ end
64
+ nil
65
+ end
66
+
54
67
  private
55
68
 
56
69
  def app
@@ -72,9 +85,7 @@ module PortalScraper
72
85
  app.get(url_for(config.token_url)) unless config.token_url.nil?
73
86
  end
74
87
 
75
- def proposition(creation_page)
76
- form = creation_page.form_with(name: /succes/i) || creation_page.forms[0]
77
- form.click_button
88
+ def proposition
78
89
  proposition_page = app.get(url_for('/propositionDetail.do'), {idx: 3})
79
90
  proposition_form = proposition_page.form_with(name: /proposition/i)
80
91
  try_form_fields(proposition_form, %w(montant amount), MINIMUM_AMOUNT)
@@ -85,7 +96,10 @@ module PortalScraper
85
96
  if confirmation_page.uri.path =~ /error.do/
86
97
  return { error: 'Missing data' }
87
98
  end
99
+ text = confirmation_page.search('td.ZMSG').text.strip
100
+ proposition_ref = text.match('\d{9}')[0]
88
101
  app.get(url_for('/propositionImprimer.do'))
102
+ proposition_ref
89
103
  end
90
104
 
91
105
  def try_form_fields(form, fields, value)
@@ -1,7 +1,7 @@
1
1
  module PortalScraper
2
2
  class Version
3
3
  MAJOR = 1
4
- MINOR = 3
4
+ MINOR = 4
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.3.0
4
+ version: 1.4.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-05-14 00:00:00.000000000 Z
12
+ date: 2019-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize