fiscalizer 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 5439e82bdd0f32d49e0074f573d9128e4eced208
4
- data.tar.gz: 931cf25940e68ea5bcd81ebfc78ac2e27eca42ca
3
+ metadata.gz: b454d2d045c0dacee3673dc33b7ba9ef313a467c
4
+ data.tar.gz: 0404c3903032076ba7f10ddf1e0a5ecfa519e54b
5
5
  SHA512:
6
- metadata.gz: 21acba55748c02761bab6d55d71b469bae68f36a3995c7af211fba3b0cf51988407c083c62ae497c8b0e02e8e624ae981e55b15d626d2db369f7311ceacfae8a
7
- data.tar.gz: ce83a88e9d79a4a0984436308ff67284be71d5f4b37961641104bc07c7922788c5778f7a09637c9902316b8d4c7ad779621502889dd591be39c6e03294755845
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.use_ssl = true
31
- http.cert_store = OpenSSL::X509::Store.new
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 = Net::HTTP::Post.new(uri.request_uri)
42
- request.content_type = 'application/xml'
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 # send_echo
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 # send_office
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
@@ -1,3 +1,3 @@
1
1
  class Fiscalizer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
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.7
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-10 00:00:00.000000000 Z
11
+ date: 2014-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri