afipws 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: c62722b5dadabc183a975922b0177b63d8bce82c24fafdd35e74240856b25d8e
4
- data.tar.gz: b1a0f1ce2a252d730fee01a0830fc3d2142b50df33c13864b95854bdffa856ca
3
+ metadata.gz: 35d82abb92bacac0765fa6ff1165144285d88b6de45ffb84ae70fa99a8c5bd34
4
+ data.tar.gz: 5dfb329baf6446010559789d0afbcf24b1de9dbe8a5c7121f5b3dec932ef1d4e
5
5
  SHA512:
6
- metadata.gz: 969630cf2f9cb2b9ae629a61f0c0cdfe79832825ea6a6fe43745d341b5b29b1117ce230567ed0e9fd27ff22f73936135bf1c4cfc6aed856fb5090ec1eeadd9eb
7
- data.tar.gz: 4601ea842fcd9d84ed968fd6e8a0d11e7304353b92782dfe79ad18d6894d8c8eada013b893d8ea0f424ac004722cee6edd9e879513204d7cb354321dfb16ad75
6
+ metadata.gz: 9c3a00c50955d67e1a4c5bf53965a5b5d2b5ec305c0d4fff28beb8f54339d7d0bd2e9d17145dccdf101f1608f4a0c0420da2e75e2ab8ef8fdfaae7163d142547
7
+ data.tar.gz: e3cfc5f3648b0ab30686f6a7848557b42f332eb12e38216a7b2ee9da69cc3a2d0dfc437477b80d35e2f9b003f699ea3fdd988cbdf9dfd23f85f7c980df3fca17
@@ -0,0 +1,13 @@
1
+ name: CI
2
+ on: push
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v3
8
+ - name: Set up Ruby
9
+ uses: ruby/setup-ruby@v1
10
+ - name: Install dependencies
11
+ run: bundle install
12
+ - name: Run tests
13
+ run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afipws (2.1.0)
4
+ afipws (2.2.0)
5
5
  activesupport
6
6
  builder
7
7
  httpclient
@@ -11,7 +11,7 @@ PATH
11
11
  GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
- activesupport (7.0.2.2)
14
+ activesupport (7.0.4.3)
15
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
16
  i18n (>= 1.6, < 2)
17
17
  minitest (>= 5.1)
@@ -24,7 +24,7 @@ GEM
24
24
  ast (2.4.2)
25
25
  builder (3.2.4)
26
26
  coderay (1.1.3)
27
- concurrent-ruby (1.1.9)
27
+ concurrent-ruby (1.2.2)
28
28
  diff-lcs (1.3)
29
29
  ffi (1.15.5)
30
30
  formatador (1.1.0)
@@ -48,7 +48,7 @@ GEM
48
48
  httpi (2.5.0)
49
49
  rack
50
50
  socksify
51
- i18n (1.10.0)
51
+ i18n (1.12.0)
52
52
  concurrent-ruby (~> 1.0)
53
53
  jaro_winkler (1.5.4)
54
54
  listen (3.7.1)
@@ -56,11 +56,11 @@ GEM
56
56
  rb-inotify (~> 0.9, >= 0.9.10)
57
57
  lumberjack (1.2.8)
58
58
  method_source (1.0.0)
59
- minitest (5.15.0)
59
+ minitest (5.18.0)
60
60
  mocha (0.9.10)
61
61
  rake
62
62
  nenv (0.3.0)
63
- nokogiri (1.13.1-arm64-darwin)
63
+ nokogiri (1.13.10-arm64-darwin)
64
64
  racc (~> 1.4)
65
65
  nori (2.6.0)
66
66
  notiffany (0.1.3)
@@ -73,8 +73,8 @@ GEM
73
73
  coderay (~> 1.1)
74
74
  method_source (~> 1.0)
75
75
  public_suffix (4.0.6)
76
- racc (1.6.0)
77
- rack (2.2.3)
76
+ racc (1.6.1)
77
+ rack (3.0.7)
78
78
  rainbow (3.1.1)
79
79
  rake (13.0.1)
80
80
  rb-fsevent (0.11.1)
@@ -114,7 +114,7 @@ GEM
114
114
  shellany (0.0.1)
115
115
  socksify (1.7.1)
116
116
  thor (1.2.1)
117
- tzinfo (2.0.4)
117
+ tzinfo (2.0.6)
118
118
  concurrent-ruby (~> 1.0)
119
119
  unicode-display_width (1.6.1)
120
120
  wasabi (3.7.0)
data/README.md CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Ruby client para los web services de la AFIP.
4
4
 
5
- [![Build Status](https://app.travis-ci.com/eeng/afipws.svg?branch=master)](https://app.travis-ci.com/eeng/afipws)
5
+ [![Build Status](https://github.com/eeng/afipws/actions/workflows/ci.yml/badge.svg)](https://github.com/eeng/afipws/actions/workflows/ci.yml)
6
6
 
7
7
  ## Servicios Disponibles
8
8
 
9
- * wsaa (WSAA)
10
- * wsfe (WSFE)
11
- * ws_sr_constancia_inscripcion (WSConstanciaInscripcion)
12
- * ws_sr_padron_a100 (PersonaServiceA100)
13
- * ws_sr_padron_a4 (PersonaServiceA4)
14
- * ws_sr_padron_a5 (PersonaServiceA5)
15
- * wconsdeclaracion (WConsDeclaracion)
9
+ - wsaa (WSAA)
10
+ - wsfe (WSFE)
11
+ - ws_sr_constancia_inscripcion (WSConstanciaInscripcion)
12
+ - ws_sr_padron_a100 (PersonaServiceA100)
13
+ - ws_sr_padron_a4 (PersonaServiceA4)
14
+ - ws_sr_padron_a5 (PersonaServiceA5)
15
+ - wconsdeclaracion (WConsDeclaracion)
16
16
 
17
17
  ## Uso
18
18
 
data/lib/afipws/client.rb CHANGED
@@ -6,8 +6,10 @@ module Afipws
6
6
 
7
7
  def request action, body = nil
8
8
  @savon.call action, message: body
9
- rescue Savon::SOAPFault => e
9
+ rescue Savon::SOAPFault, Savon::HTTPError => e
10
10
  raise ServerError, e
11
+ rescue HTTPClient::ConnectTimeoutError => e
12
+ raise NetworkError.new(e, retriable: true)
11
13
  rescue HTTPClient::TimeoutError => e
12
14
  raise NetworkError, e
13
15
  end
@@ -3,5 +3,9 @@ module Afipws
3
3
  def code? _code
4
4
  false
5
5
  end
6
+
7
+ def retriable?
8
+ false
9
+ end
6
10
  end
7
11
  end
@@ -1,4 +1,13 @@
1
1
  module Afipws
2
2
  class NetworkError < Error
3
+ def initialize e, retriable: false
4
+ super e
5
+
6
+ @retriable = retriable
7
+ end
8
+
9
+ def retriable?
10
+ @retriable
11
+ end
3
12
  end
4
13
  end
@@ -1,3 +1,3 @@
1
1
  module Afipws
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module Afipws
4
4
  describe Client do
5
- context 'manejo de errores' do
5
+ context 'errores' do
6
6
  subject { Client.new(wsdl: Afipws::WSFE::WSDL[:test]) }
7
7
 
8
8
  it 'Savon::SOAPFault se encapsulan en ServerError' do
@@ -10,10 +10,32 @@ module Afipws
10
10
  -> { subject.request :fe_dummy }.should raise_error ServerError, /CMS no es valido/
11
11
  end
12
12
 
13
- it 'HTTPClient::TimeoutError se encapsulan en NetworkError' do
13
+ it 'Savon::HTTPError se encapsulan en ServerError' do
14
+ expect_savon_to_raise Savon::HTTPError, stub(code: 503, body: 'Service Unavailable')
15
+ -> { subject.request :fe_dummy }.should raise_error ServerError, /Service Unavailable/
16
+ end
17
+
18
+ it 'HTTPClient::TimeoutError se encapsulan en NetworkError y no es retriable' do
19
+ expect_savon_to_raise HTTPClient::ReceiveTimeoutError, 'execution expired'
20
+ -> { subject.request :fe_dummy }.should raise_error { |error|
21
+ error.should be_a NetworkError
22
+ error.message.should match /execution expired/
23
+ error.retriable?.should be false
24
+ }
25
+ end
26
+
27
+ it 'HTTPClient::ConnectTimeoutError se encapsulan en NetworkError y es retriable' do
28
+ expect_savon_to_raise HTTPClient::ConnectTimeoutError, 'execution expired'
29
+ -> { subject.request :fe_dummy }.should raise_error { |error|
30
+ error.should be_a NetworkError
31
+ error.message.should match /execution expired/
32
+ error.retriable?.should be true
33
+ }
34
+ end
35
+
36
+ def expect_savon_to_raise error_class, message
14
37
  # Hack to mock exceptions on Savon
15
- subject.instance_eval('@savon').expects(:call).raises(HTTPClient::ReceiveTimeoutError, 'execution expired')
16
- -> { subject.request :fe_dummy }.should raise_error NetworkError, /execution expired/
38
+ subject.instance_eval('@savon', __FILE__, __LINE__).expects(:call).raises(error_class, message)
17
39
  end
18
40
  end
19
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afipws
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Nicolau
@@ -159,11 +159,11 @@ extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
161
  - ".envrc"
162
+ - ".github/workflows/ci.yml"
162
163
  - ".gitignore"
163
164
  - ".rspec"
164
165
  - ".rubocop.yml"
165
166
  - ".ruby-version"
166
- - ".travis.yml"
167
167
  - CHANGELOG.md
168
168
  - Gemfile
169
169
  - Gemfile.lock
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- before_install: gem install bundler -v 2.1.4