fiscalizer 0.0.7 → 0.0.8
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/fiscalizer/communication.rb +10 -8
- data/lib/fiscalizer/fiscalizer.rb +10 -5
- data/lib/fiscalizer/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: b454d2d045c0dacee3673dc33b7ba9ef313a467c
|
4
|
+
data.tar.gz: 0404c3903032076ba7f10ddf1e0a5ecfa519e54b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec7e6577ab49d8b0dadc8155da38f9c686e5a21cf4af435e3d8780d04aafe9955fc0fc8e998fbe095964a49fac63f5e00eaf6ecc86605da6e9c0ca5274767024
|
7
|
+
data.tar.gz: 800e3560a62ef699841e25e69a8bdeedc66a5635f6161468158aff16868e298ce04e3c362cd05fb40ba485b8908b7bad583ddb019b749d3d70224d97e415a7ac
|
@@ -2,13 +2,13 @@ class Fiscalizer
|
|
2
2
|
class Communication
|
3
3
|
attr_accessor :url, :tns, :schemaLocation,
|
4
4
|
:key_public, :key_private, :certificate,
|
5
|
-
:certificate_issued_by
|
5
|
+
:certificate_issued_by, :timeout
|
6
6
|
|
7
7
|
def initialize( tns: "http://www.apis-it.hr/fin/2012/types/f73",
|
8
8
|
url: "https://cis.porezna-uprava.hr:8449/FiskalizacijaService",
|
9
9
|
schemaLocation: "http://www.apis-it.hr/fin/2012/types/f73 FiskalizacijaSchema.xsd",
|
10
10
|
key_public: nil, key_private: nil, certificate: nil,
|
11
|
-
certificate_issued_by: "OU=RDC,O=FINA,C=HR" )
|
11
|
+
certificate_issued_by: "OU=RDC,O=FINA,C=HR", timeout:3 )
|
12
12
|
@tns = tns
|
13
13
|
@url = url
|
14
14
|
@schemaLocation = schemaLocation
|
@@ -16,6 +16,7 @@ class Fiscalizer
|
|
16
16
|
@key_private = key_private
|
17
17
|
@certificate = certificate
|
18
18
|
@certificate_issued_by = certificate_issued_by
|
19
|
+
@timeout = timeout
|
19
20
|
end # initialize
|
20
21
|
|
21
22
|
def send object
|
@@ -27,8 +28,9 @@ class Fiscalizer
|
|
27
28
|
# Prepare data
|
28
29
|
uri = URI.parse(@url)
|
29
30
|
http = Net::HTTP.new(uri.host, uri.port)
|
30
|
-
http.
|
31
|
-
http.
|
31
|
+
http.read_timeout = @timeout
|
32
|
+
http.use_ssl = true
|
33
|
+
http.cert_store = OpenSSL::X509::Store.new
|
32
34
|
http.cert_store.set_default_paths
|
33
35
|
http.cert_store.add_cert(@certificate)
|
34
36
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
@@ -38,8 +40,8 @@ class Fiscalizer
|
|
38
40
|
return false if encoded_object.nil?
|
39
41
|
|
40
42
|
# Send it
|
41
|
-
request
|
42
|
-
request.content_type
|
43
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
44
|
+
request.content_type = 'application/xml'
|
43
45
|
request.body = encoded_object
|
44
46
|
response = http.request(request)
|
45
47
|
|
@@ -89,7 +91,7 @@ class Fiscalizer
|
|
89
91
|
xml = soap_envelope(echo_xml).to_xml
|
90
92
|
object.generated_xml = soap_envelope(echo_xml).to_xml
|
91
93
|
return xml
|
92
|
-
end #
|
94
|
+
end # encode_echo
|
93
95
|
|
94
96
|
def encode_office object
|
95
97
|
office_request_xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
@@ -162,7 +164,7 @@ class Fiscalizer
|
|
162
164
|
object.generated_xml = signed_xml
|
163
165
|
|
164
166
|
return signed_xml
|
165
|
-
end #
|
167
|
+
end # encode_office
|
166
168
|
|
167
169
|
def encode_invoice object
|
168
170
|
generate_security_code object
|
@@ -9,14 +9,15 @@ class Fiscalizer
|
|
9
9
|
# Accessible attributes
|
10
10
|
attr_accessor :url, :key_public_path, :key_private_path, :certificate_path,
|
11
11
|
:key_private, :key_public, :certificate,
|
12
|
-
:tns, :schemaLocation, :certificate_issued_by
|
12
|
+
:tns, :schemaLocation, :certificate_issued_by,
|
13
|
+
:timeout
|
13
14
|
|
14
15
|
# Public methods
|
15
16
|
def initialize( url: "https://cis.porezna-uprava.hr:8449/FiskalizacijaService",
|
16
17
|
key_public_path: nil, key_private_path: nil, certificate_path: nil,
|
17
18
|
tns: "http://www.apis-it.hr/fin/2012/types/f73",
|
18
19
|
schemaLocation: "http://www.apis-it.hr/fin/2012/types/f73 FiskalizacijaSchema.xsd",
|
19
|
-
certificate_issued_by: "OU=RDC,O=FINA,C=HR", certificate_p12_path: nil, password: nil)
|
20
|
+
certificate_issued_by: "OU=RDC,O=FINA,C=HR", certificate_p12_path: nil, password: nil, timeout:3)
|
20
21
|
@url = url
|
21
22
|
@key_public_path = key_public_path
|
22
23
|
@key_private_path = key_private_path
|
@@ -24,6 +25,7 @@ class Fiscalizer
|
|
24
25
|
@certificate_p12_path = certificate_p12_path
|
25
26
|
@tns = tns
|
26
27
|
@schemaLocation = schemaLocation
|
28
|
+
@timeout = timeout
|
27
29
|
|
28
30
|
# Import certificates
|
29
31
|
export_keys password
|
@@ -47,7 +49,8 @@ class Fiscalizer
|
|
47
49
|
# Send it
|
48
50
|
comm = Fiscalizer::Communication.new url: @url, tns: @tns, schemaLocation: @schemaLocation,
|
49
51
|
key_public: @key_public, key_private: @key_private,
|
50
|
-
certificate: @certificate, certificate_issued_by: @certificate_issued_by
|
52
|
+
certificate: @certificate, certificate_issued_by: @certificate_issued_by,
|
53
|
+
timeout:@timeout
|
51
54
|
raw_response = comm.send echo
|
52
55
|
response = Fiscalizer::Response.new object: echo, html_response: raw_response, tns: @tns
|
53
56
|
return response
|
@@ -80,7 +83,8 @@ class Fiscalizer
|
|
80
83
|
# Send it
|
81
84
|
comm = Fiscalizer::Communication.new url: @url, tns: @tns, schemaLocation: @schemaLocation,
|
82
85
|
key_public: @key_public, key_private: @key_private,
|
83
|
-
certificate: @certificate, certificate_issued_by: @certificate_issued_by
|
86
|
+
certificate: @certificate, certificate_issued_by: @certificate_issued_by,
|
87
|
+
timeout:@timeout
|
84
88
|
raw_response = comm.send office
|
85
89
|
response = Fiscalizer::Response.new object: office, html_response: raw_response, tns: @tns
|
86
90
|
return response
|
@@ -123,7 +127,8 @@ class Fiscalizer
|
|
123
127
|
# Send it
|
124
128
|
comm = Fiscalizer::Communication.new url: @url, tns: @tns, schemaLocation: @schemaLocation,
|
125
129
|
key_public: @key_public, key_private: @key_private,
|
126
|
-
certificate: @certificate, certificate_issued_by: @certificate_issued_by
|
130
|
+
certificate: @certificate, certificate_issued_by: @certificate_issued_by,
|
131
|
+
timeout:@timeout
|
127
132
|
raw_response = comm.send invoice
|
128
133
|
response = Fiscalizer::Response.new object: invoice, html_response: raw_response, tns: @tns
|
129
134
|
return response
|
data/lib/fiscalizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fiscalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanko Krtalić Rusendić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|