sii_chile 0.1.2 → 0.1.4
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 +4 -4
- data/lib/sii_chile/consulta.rb +21 -2
- data/lib/sii_chile/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f526c5f522c2cb71f7f367df7449af50239abf9
|
|
4
|
+
data.tar.gz: 1e0f09e39921b4f5a02250b0c8ee4a071a7093b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0430abf164c28dc7d73932a3bd277bd471a80eb020c27370024048614067b0ed35ca6addf21ec6c992661c39731ebb08f2ba462e6777844c4889493ca618437a
|
|
7
|
+
data.tar.gz: 73b3bbc3d52307702bc8f337695eabda1e969f4db1449289375ff96100c9ab641dd6bd4c4b2e0088899d5f7c58278b7a8d608625d67266438281b261382f3ac6
|
data/lib/sii_chile/consulta.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
require 'base64'
|
|
3
|
+
|
|
1
4
|
module SIIChile
|
|
2
5
|
class Consulta
|
|
3
6
|
attr_reader :rut
|
|
@@ -17,11 +20,14 @@ module SIIChile
|
|
|
17
20
|
def fetch!
|
|
18
21
|
raise 'Rut invalido' unless @rut.valid?
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
captcha = fetch_captcha!
|
|
24
|
+
response = Faraday.post('https://zeus.sii.cl/cvc_cgi/stc/getstc', {
|
|
21
25
|
'RUT' => @rut.number,
|
|
22
26
|
'DV' => @rut.code,
|
|
23
27
|
'PRG' => 'STC',
|
|
24
|
-
'
|
|
28
|
+
'OPC' => 'NOR',
|
|
29
|
+
'txt_code' => captcha[:code],
|
|
30
|
+
'txt_captcha' => captcha[:captcha]
|
|
25
31
|
})
|
|
26
32
|
|
|
27
33
|
data = Nokogiri::HTML(response.body)
|
|
@@ -46,5 +52,18 @@ module SIIChile
|
|
|
46
52
|
:error => e.message
|
|
47
53
|
}
|
|
48
54
|
end
|
|
55
|
+
|
|
56
|
+
def fetch_captcha!
|
|
57
|
+
response = Faraday.post('https://zeus.sii.cl/cvc_cgi/stc/CViewCaptcha.cgi', {
|
|
58
|
+
oper: 0
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
data = JSON.parse(response.body)
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
code: Base64.decode64(data["txtCaptcha"])[36..39],
|
|
65
|
+
captcha: data["txtCaptcha"]
|
|
66
|
+
}
|
|
67
|
+
end
|
|
49
68
|
end
|
|
50
69
|
end
|
data/lib/sii_chile/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sii_chile
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Seba Gamboa
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-12-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|