vat_payer_cz 0.0.3 → 0.0.4

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: 807e334a32d9d296115c356a28f12aa21aec3397
4
- data.tar.gz: f5420d9d49965329a2a97941de66d19f01ac85e8
3
+ metadata.gz: 5d57e420c66d207f6f0e161655d2b31f6aff236e
4
+ data.tar.gz: d2216b9183c903bab7deb0b5a68f95ccf032ea9b
5
5
  SHA512:
6
- metadata.gz: a9407c571506ee198838e31d539dda02d2cb5139efccb54670040021ac4764f4bacb8ba25b151c9632f1c737bae6e4aff18bb383716b3f9af1aa68f2926d2aca
7
- data.tar.gz: 7730a090a5cc510c1de40ea11eecc719ff19b4a16a80433b45e9b286b3d124060afc5ccbe7bdc32fdb6c6bcdc0ab16b25472e6b4dafad870cad6b9ec6e9dfb98
6
+ metadata.gz: 8d135b33db2365972b85e730f8477e15ed8f125ec8e8b1562668714ef776dd4c9fb82d24fa4b8e8b3d8a7d65d09560a9662ea6c7c43ccbdb40c147bf2bc3a8ec
7
+ data.tar.gz: a261dbf1213afb8ced159c571afe36962d26908e50fdd1696229728eab50d8a47ba82faf7e4670ccf3fa31f7f6032cb8a2fa5c02c9b6dc64127bf98b2981a91d
@@ -4,9 +4,11 @@ module VatInfo
4
4
  class SchemaError < StandardError; end
5
5
 
6
6
  class Query
7
- DOCS = 'https://adisspr.mfcr.cz/adistc/adis/idpr_pub/dpr_info/ws_spdph.faces'
7
+ DOCS = 'https://adisspr.mfcr.cz/adistc/adis/idpr_pub/dpr_info/ws_spdph.faces'.freeze
8
8
  WSDL = 'http://adisrws.mfcr.cz/adistc/axis2/services/rozhraniCRPDPH.rozhraniCRPDPHSOAP?wsdl'.freeze
9
- TIMEOUT = 2
9
+ TIMEOUT = 2
10
+ SERVICE_UNAVAILABLE = 503
11
+ REQUEST_TIME_OUT = 408
10
12
 
11
13
  def self.call(request, endpoint, wsdl = WSDL, timeout = TIMEOUT)
12
14
  client = Savon.client(wsdl: wsdl, open_timeout: timeout)
@@ -16,10 +18,16 @@ module VatInfo
16
18
  if response.success?
17
19
  VatInfo::Response.new(status_code: 200, raw: response.body)
18
20
  else
19
- VatInfo::Response.new(status_code: 503)
21
+ VatInfo::Response.new(status_code: SERVICE_UNAVAILABLE)
22
+ end
23
+ rescue Savon::HTTPError => e
24
+ if e.to_s.include?('sorry-page.html')
25
+ VatInfo::Response.new(status_code: SERVICE_UNAVAILABLE)
26
+ else
27
+ raise e
20
28
  end
21
29
  rescue Net::OpenTimeout
22
- VatInfo::Response.new(status_code: 408)
30
+ VatInfo::Response.new(status_code: REQUEST_TIME_OUT)
23
31
  rescue Savon::SOAPFault => e
24
32
  raise SchemaError, 'The SOAP schema of VAT service may have changed. Go to '\
25
33
  "#{DOCS} to verify. Original error: #{e}"
@@ -1,3 +1,3 @@
1
1
  module VatInfo
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vat_payer_cz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Landovsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-27 00:00:00.000000000 Z
11
+ date: 2018-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon