Afip 1.4.6 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +4 -27
- data/.gitignore +0 -8
- data/Afip-1.2.1.gem +0 -0
- data/Afip-1.4.gem +0 -0
- data/Afip.gemspec +0 -41
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -49
- data/LICENSE.txt +0 -21
- data/README.md +0 -39
- data/Rakefile +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/Afip.rb +0 -59
- data/lib/Afip/auth_data.rb +0 -71
- data/lib/Afip/authorizer.rb +0 -10
- data/lib/Afip/bill.rb +0 -274
- data/lib/Afip/constants.rb +0 -115
- data/lib/Afip/core_ext/float.rb +0 -8
- data/lib/Afip/core_ext/hash.rb +0 -23
- data/lib/Afip/core_ext/string.rb +0 -12
- data/lib/Afip/ctg.rb +0 -234
- data/lib/Afip/padron.rb +0 -184
- data/lib/Afip/version.rb +0 -3
- data/lib/Afip/wsaa.rb +0 -94
data/lib/Afip/version.rb
DELETED
data/lib/Afip/wsaa.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
module Afip
|
2
|
-
# Authorization class. Handles interactions wiht the WSAA, to provide
|
3
|
-
# valid key and signature that will last for a day.
|
4
|
-
#
|
5
|
-
class Wsaa
|
6
|
-
# Main method for authentication and authorization.
|
7
|
-
# When successful, produces the yaml file with auth data.
|
8
|
-
#
|
9
|
-
def self.login(service = "wsfe")
|
10
|
-
tra = build_tra(service)
|
11
|
-
cms = build_cms(tra)
|
12
|
-
req = build_request(cms)
|
13
|
-
auth = call_wsaa(req)
|
14
|
-
|
15
|
-
write_yaml(auth)
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
# Builds the xml for the 'Ticket de Requerimiento de Acceso'
|
20
|
-
# @return [String] containing the request body
|
21
|
-
#
|
22
|
-
def self.build_tra service
|
23
|
-
@now = (Time.now) - 120
|
24
|
-
@from = @now.strftime('%FT%T%:z')
|
25
|
-
@to = (@from.to_time.end_of_day).strftime('%FT%T%:z')
|
26
|
-
@id = @now.strftime('%s')
|
27
|
-
tra = <<-EOF
|
28
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
29
|
-
<loginTicketRequest version="1.0">
|
30
|
-
<header>
|
31
|
-
<uniqueId>#{ @id }</uniqueId>
|
32
|
-
<generationTime>#{ @from }</generationTime>
|
33
|
-
<expirationTime>#{ @to }</expirationTime>
|
34
|
-
</header>
|
35
|
-
<service>#{service}</service>
|
36
|
-
</loginTicketRequest>
|
37
|
-
EOF
|
38
|
-
return tra
|
39
|
-
end
|
40
|
-
|
41
|
-
# Builds the CMS
|
42
|
-
# @return [String] cms
|
43
|
-
#
|
44
|
-
def self.build_cms(tra)
|
45
|
-
cms = `echo '#{ tra }' |
|
46
|
-
#{ Afip.openssl_bin } cms -sign -in /dev/stdin -signer #{ Afip.cert } -inkey #{ Afip.pkey } -nodetach \
|
47
|
-
-outform der |
|
48
|
-
#{ Afip.openssl_bin } base64 -e`
|
49
|
-
return cms
|
50
|
-
end
|
51
|
-
|
52
|
-
# Builds the CMS request to log in to the server
|
53
|
-
# @return [String] the cms body
|
54
|
-
#
|
55
|
-
def self.build_request(cms)
|
56
|
-
request = <<-XML
|
57
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
58
|
-
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://wsaa.view.sua.dvadac.desein.afip.gov">
|
59
|
-
<SOAP-ENV:Body>
|
60
|
-
<ns1:loginCms>
|
61
|
-
<ns1:in0>
|
62
|
-
#{ cms }
|
63
|
-
</ns1:in0>
|
64
|
-
</ns1:loginCms>
|
65
|
-
</SOAP-ENV:Body>
|
66
|
-
</SOAP-ENV:Envelope>
|
67
|
-
XML
|
68
|
-
return request
|
69
|
-
end
|
70
|
-
|
71
|
-
# Calls the WSAA with the request built by build_request
|
72
|
-
# @return [Array] with the token and signature
|
73
|
-
#
|
74
|
-
def self.call_wsaa(req)
|
75
|
-
response = `echo '#{ req }' | curl -k -s -H 'Content-Type: application/soap+xml; action=""' -d @- #{ Afip::AuthData.wsaa_url }`
|
76
|
-
pp response
|
77
|
-
response = CGI::unescapeHTML(response)
|
78
|
-
token = response.scan(/\<token\>(.+)\<\/token\>/).first.first
|
79
|
-
sign = response.scan(/\<sign\>(.+)\<\/sign\>/).first.first
|
80
|
-
return [token, sign]
|
81
|
-
end
|
82
|
-
|
83
|
-
# Writes the token and signature to a YAML file in the /tmp directory
|
84
|
-
#
|
85
|
-
def self.write_yaml(certs)
|
86
|
-
yml = <<-YML
|
87
|
-
token: #{certs[0]}
|
88
|
-
sign: #{certs[1]}
|
89
|
-
YML
|
90
|
-
`echo '#{ yml }' > /tmp/#{Afip::AuthData.environment.to_s}_Afip_#{ Afip.cuit }_#{ Time.new.strftime('%Y_%m_%d') }.yml`
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|