afipws 1.0.0 → 1.0.1

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: f0430f1994cf2d6f6afe098bda447441df15f7bb
4
- data.tar.gz: 519d1e3e5ea15497d131905c9b1e37e2959b26b0
3
+ metadata.gz: 844da5760c94b36dc705a95c99a5c69d75a517c2
4
+ data.tar.gz: c3ca012f55bc89c325c69c9c7c18a3941f7445f9
5
5
  SHA512:
6
- metadata.gz: 3fa823ccd4f74a535dce9893b9df3277a82f944789e8c75be937c4fc277afc32fdc6e9136359b13fab08c839b063a0bc71b34a89053eb448c3bc654babc5f756
7
- data.tar.gz: 9a40c8d4855d4b0d5eb3ea0112c38f282213ecf727f1a3963026670fcd3f76f2fd433a535140eb7ae0a9d53b7011e20fad172e812e83095195c630608d3969f4
6
+ metadata.gz: d51c1dfbcf92f3f9d7fe548f236a69cbdef1179995c2c02bc37ab81c7ee034413f3ae71b8439182692aa0901ff82b1a4030019be66638225f55b3478e2ba8b61
7
+ data.tar.gz: d85ac1c15ff84b0781d2831c432c66f6678bf47ad79320b20779d7696ed32d955644d54206e2c10fc49a075c2e776a5addf2c44e944687e2d439d49b53e9c4ce
data/.travis.yml ADDED
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile.lock CHANGED
@@ -1,96 +1,90 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afipws (1.0.0)
4
+ afipws (1.0.1)
5
5
  activesupport
6
6
  builder
7
- httpclient
8
- i18n
9
7
  nokogiri
10
8
  savon (~> 2.11.0)
11
9
 
12
10
  GEM
13
11
  remote: http://rubygems.org/
14
12
  specs:
15
- activesupport (5.0.0.1)
13
+ activesupport (5.2.0)
16
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (~> 0.7)
15
+ i18n (>= 0.7, < 2)
18
16
  minitest (~> 5.1)
19
17
  tzinfo (~> 1.1)
20
18
  akami (1.3.1)
21
19
  gyoku (>= 0.4.0)
22
20
  nokogiri
23
- builder (3.2.2)
24
- byebug (1.1.1)
25
- columnize (~> 0.3.6)
26
- debugger-linecache (~> 1.2.0)
27
- coderay (1.1.1)
28
- columnize (0.3.6)
29
- concurrent-ruby (1.0.2)
30
- debugger-linecache (1.2.0)
31
- diff-lcs (1.2.5)
32
- ffi (1.9.14)
21
+ builder (3.2.3)
22
+ coderay (1.1.2)
23
+ concurrent-ruby (1.0.5)
24
+ diff-lcs (1.3)
25
+ ffi (1.9.25)
33
26
  formatador (0.2.5)
34
- guard (2.14.0)
27
+ guard (2.14.2)
35
28
  formatador (>= 0.2.4)
36
29
  listen (>= 2.7, < 4.0)
37
- lumberjack (~> 1.0)
30
+ lumberjack (>= 1.0.12, < 2.0)
38
31
  nenv (~> 0.1)
39
32
  notiffany (~> 0.0)
40
33
  pry (>= 0.9.12)
41
34
  shellany (~> 0.0)
42
35
  thor (>= 0.18.1)
43
- guard-rspec (4.3.1)
36
+ guard-compat (1.2.1)
37
+ guard-rspec (4.7.3)
44
38
  guard (~> 2.1)
45
- rspec (>= 2.14, < 4.0)
39
+ guard-compat (~> 1.1)
40
+ rspec (>= 2.99.0, < 4.0)
46
41
  gyoku (1.3.1)
47
42
  builder (>= 2.1.2)
48
- httpclient (2.8.2.4)
49
- httpi (2.4.2)
43
+ httpi (2.4.3)
50
44
  rack
51
45
  socksify
52
- i18n (0.7.0)
46
+ i18n (1.0.1)
47
+ concurrent-ruby (~> 1.0)
53
48
  listen (3.1.5)
54
49
  rb-fsevent (~> 0.9, >= 0.9.4)
55
50
  rb-inotify (~> 0.9, >= 0.9.7)
56
51
  ruby_dep (~> 1.2)
57
- lumberjack (1.0.10)
58
- method_source (0.8.2)
59
- mini_portile2 (2.1.0)
60
- minitest (5.9.1)
52
+ lumberjack (1.0.13)
53
+ method_source (0.9.0)
54
+ mini_portile2 (2.3.0)
55
+ minitest (5.11.3)
61
56
  mocha (0.9.10)
62
57
  rake
63
58
  nenv (0.3.0)
64
- nokogiri (1.6.8)
65
- mini_portile2 (~> 2.1.0)
66
- pkg-config (~> 1.1.7)
59
+ nokogiri (1.8.4)
60
+ mini_portile2 (~> 2.3.0)
67
61
  nori (2.6.0)
68
62
  notiffany (0.1.1)
69
63
  nenv (~> 0.1)
70
64
  shellany (~> 0.0)
71
- pkg-config (1.1.7)
72
- pry (0.10.4)
65
+ pry (0.11.3)
73
66
  coderay (~> 1.1.0)
74
- method_source (~> 0.8.1)
75
- slop (~> 3.4)
76
- pry-byebug (1.0.1)
77
- byebug (~> 1.1.1)
78
- pry (>= 0.9.10)
79
- rack (2.0.1)
67
+ method_source (~> 0.9.0)
68
+ rack (2.0.5)
80
69
  rake (10.4.2)
81
- rb-fsevent (0.9.7)
82
- rb-inotify (0.9.7)
83
- ffi (>= 0.5.0)
84
- rspec (2.14.1)
85
- rspec-core (~> 2.14.0)
86
- rspec-expectations (~> 2.14.0)
87
- rspec-mocks (~> 2.14.0)
88
- rspec-core (2.14.8)
89
- rspec-expectations (2.14.5)
90
- diff-lcs (>= 1.1.3, < 2.0)
91
- rspec-mocks (2.14.6)
92
- ruby_dep (1.4.0)
93
- savon (2.11.1)
70
+ rb-fsevent (0.10.3)
71
+ rb-inotify (0.9.10)
72
+ ffi (>= 0.5.0, < 2)
73
+ rspec (3.7.0)
74
+ rspec-core (~> 3.7.0)
75
+ rspec-expectations (~> 3.7.0)
76
+ rspec-mocks (~> 3.7.0)
77
+ rspec-core (3.7.1)
78
+ rspec-support (~> 3.7.0)
79
+ rspec-expectations (3.7.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.7.0)
82
+ rspec-mocks (3.7.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.7.0)
85
+ rspec-support (3.7.1)
86
+ ruby_dep (1.5.0)
87
+ savon (2.11.2)
94
88
  akami (~> 1.2)
95
89
  builder (>= 2.1.2)
96
90
  gyoku (~> 1.2)
@@ -99,11 +93,10 @@ GEM
99
93
  nori (~> 2.4)
100
94
  wasabi (~> 3.4)
101
95
  shellany (0.0.1)
102
- slop (3.6.0)
103
- socksify (1.7.0)
104
- thor (0.19.1)
105
- thread_safe (0.3.5)
106
- tzinfo (1.2.2)
96
+ socksify (1.7.1)
97
+ thor (0.20.0)
98
+ thread_safe (0.3.6)
99
+ tzinfo (1.2.5)
107
100
  thread_safe (~> 0.1)
108
101
  wasabi (3.5.0)
109
102
  httpi (~> 2.0)
@@ -114,11 +107,10 @@ PLATFORMS
114
107
 
115
108
  DEPENDENCIES
116
109
  afipws!
117
- guard-rspec (~> 4.3.1)
118
- mocha (~> 0.9.10)
119
- pry-byebug
120
- rake (~> 10.4.2)
121
- rspec (~> 2.14.1)
110
+ guard-rspec
111
+ mocha
112
+ rake
113
+ rspec
122
114
 
123
115
  BUNDLED WITH
124
- 1.12.3
116
+ 1.16.1
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
- guard :rspec, cmd: 'rspec' do
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
5
5
  end
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Afipws
2
+
3
+ Ruby client para los web services de la AFIP.
4
+
5
+ [![Build Status](https://travis-ci.org/eeng/afipws.svg?branch=master)](https://travis-ci.org/eeng/afipws)
6
+
7
+ ## Uso
8
+
9
+ Primero hay que crear la clave privada y obtener el certificado correspondiente según los pasos indicados [aquí](http://www.afip.gov.ar/ws/WSAA/cert-req-howto.txt).
10
+
11
+ Luego hay que instalar la librería:
12
+
13
+ ```ruby
14
+ gem install afipws
15
+ ```
16
+
17
+ Y por último usamos el web service de esta forma:
18
+
19
+ ```ruby
20
+ require 'afipws'
21
+ ws = Afipws::WSFE.new env: :development, cuit: '...', key: File.read('test.key'), cert: File.read('test.crt')
22
+ puts ws.cotizacion 'DOL'
23
+ ```
24
+
25
+ De momento sólo están soportados los servicios WSAA y WSFEv1.
26
+ Ver specs para más ejemplos.
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/afipws.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Emmanuel Nicolau"]
9
9
  s.email = ["emmanicolau@gmail.com"]
10
- s.homepage = ""
11
- s.summary = %q{Ruby wrapper para los servicios web de la AFIP}
10
+ s.homepage = "https://github.com/eeng/afipws"
11
+ s.summary = %q{Ruby client para los web services de la AFIP}
12
12
  s.description = ""
13
13
 
14
14
  s.rubyforge_project = "afipws"
@@ -17,16 +17,13 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
-
21
- s.add_development_dependency 'rspec', '~> 2.14.1'
22
- s.add_development_dependency 'rake', '~> 10.4.2'
23
- s.add_development_dependency 'mocha', '~> 0.9.10'
24
- s.add_development_dependency 'guard-rspec', '~> 4.3.1'
25
- s.add_development_dependency 'pry-byebug'
20
+
21
+ s.add_development_dependency 'rspec'
22
+ s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'mocha'
24
+ s.add_development_dependency 'guard-rspec'
26
25
  s.add_dependency "builder"
27
26
  s.add_dependency "savon", '~> 2.11.0'
28
27
  s.add_dependency "nokogiri"
29
28
  s.add_dependency "activesupport"
30
- s.add_dependency "i18n"
31
- s.add_dependency "httpclient"
32
29
  end
@@ -1,3 +1,3 @@
1
1
  module Afipws
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/afipws/wsaa.rb CHANGED
@@ -7,7 +7,7 @@ module Afipws
7
7
  production: "https://wsaa.afip.gov.ar/ws/services/LoginCms?wsdl",
8
8
  test: Root + "/spec/fixtures/wsaa.wsdl"
9
9
  }
10
-
10
+
11
11
  def initialize options = {}
12
12
  @env = (options[:env] || :test).to_sym
13
13
  @key = options[:key]
@@ -17,7 +17,7 @@ module Afipws
17
17
  @cuit = options[:cuit]
18
18
  @client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@env])
19
19
  end
20
-
20
+
21
21
  def generar_tra service, ttl
22
22
  xml = Builder::XmlMarkup.new indent: 2
23
23
  xml.instruct!
@@ -31,47 +31,47 @@ module Afipws
31
31
  xml.service service
32
32
  end
33
33
  end
34
-
34
+
35
35
  def firmar_tra tra, key, crt
36
36
  key = OpenSSL::PKey::RSA.new key
37
37
  crt = OpenSSL::X509::Certificate.new crt
38
38
  OpenSSL::PKCS7::sign crt, key, tra
39
39
  end
40
-
40
+
41
41
  def codificar_tra pkcs7
42
42
  pkcs7.to_pem.lines.to_a[1..-2].join
43
43
  end
44
-
44
+
45
45
  def tra key, cert, service, ttl
46
46
  codificar_tra firmar_tra(generar_tra(service, ttl), key, cert)
47
47
  end
48
-
48
+
49
49
  def login
50
50
  response = @client.raw_request :login_cms, in0: tra(@key, @cert, @service, @ttl)
51
51
  ta = Nokogiri::XML(Nokogiri::XML(response.to_xml).text)
52
- { token: ta.css('token').text, sign: ta.css('sign').text,
52
+ { token: ta.css('token').text, sign: ta.css('sign').text,
53
53
  generation_time: from_xsd_datetime(ta.css('generationTime').text),
54
54
  expiration_time: from_xsd_datetime(ta.css('expirationTime').text) }
55
55
  rescue Savon::SOAPFault => f
56
56
  raise WSError, f.message
57
57
  end
58
-
58
+
59
59
  # Obtiene un TA, lo cachea hasta que expire, y devuelve el hash Auth listo para pasarle al Client
60
60
  # en los otros WS.
61
61
  def auth
62
62
  @ta = login if ta_expirado?
63
63
  { auth: { token: @ta[:token], sign: @ta[:sign], cuit: @cuit } }
64
64
  end
65
-
65
+
66
66
  private
67
67
  def ta_expirado?
68
68
  @ta.nil? or @ta[:expiration_time] <= Time.now
69
69
  end
70
-
70
+
71
71
  def xsd_datetime time
72
72
  time.strftime('%Y-%m-%dT%H:%M:%S%z').sub /(\d{2})(\d{2})$/, '\1:\2'
73
73
  end
74
-
74
+
75
75
  def from_xsd_datetime str
76
76
  Time.parse(str) rescue nil
77
77
  end
data/lib/afipws/wsfe.rb CHANGED
@@ -11,52 +11,52 @@ module Afipws
11
11
  production: Root + "/lib/afipws/wsfev1.wsdl",
12
12
  test: Root + "/spec/fixtures/wsfe.wsdl"
13
13
  }
14
-
14
+
15
15
  def initialize options = {}
16
16
  @env = (options[:env] || :test).to_sym
17
17
  @wsaa = options[:wsaa] || WSAA.new(options.merge(service: 'wsfe'))
18
18
  ssl_version = env == :development || Date.today >= Date.new(2016,11,1) ? :SSLv3 : :TLSv1
19
19
  @client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@env], ssl_version: ssl_version, convert_request_keys_to: :camelcase)
20
20
  end
21
-
21
+
22
22
  def dummy
23
23
  @client.fe_dummy
24
24
  end
25
-
25
+
26
26
  def tipos_comprobantes
27
27
  r = @client.fe_param_get_tipos_cbte auth
28
28
  x2r get_array(r, :cbte_tipo), id: :integer, fch_desde: :date, fch_hasta: :date
29
29
  end
30
-
30
+
31
31
  def tipos_documentos
32
32
  r = @client.fe_param_get_tipos_doc auth
33
33
  x2r get_array(r, :doc_tipo), id: :integer, fch_desde: :date, fch_hasta: :date
34
34
  end
35
-
35
+
36
36
  def tipos_monedas
37
37
  r = @client.fe_param_get_tipos_monedas auth
38
38
  x2r get_array(r, :moneda), fch_desde: :date, fch_hasta: :date
39
39
  end
40
-
40
+
41
41
  def tipos_iva
42
42
  r = @client.fe_param_get_tipos_iva auth
43
43
  x2r get_array(r, :iva_tipo), id: :integer, fch_desde: :date, fch_hasta: :date
44
44
  end
45
-
45
+
46
46
  def tipos_tributos
47
47
  r = @client.fe_param_get_tipos_tributos auth
48
- x2r get_array(r, :tributo_tipo), id: :integer, fch_desde: :date, fch_hasta: :date
48
+ x2r get_array(r, :tributo_tipo), id: :integer, fch_desde: :date, fch_hasta: :date
49
49
  end
50
50
 
51
51
  def puntos_venta
52
52
  r = @client.fe_param_get_ptos_venta auth
53
53
  x2r get_array(r, :pto_venta), nro: :integer, fch_baja: :date, bloqueado: :boolean
54
54
  end
55
-
55
+
56
56
  def cotizacion moneda_id
57
57
  @client.fe_param_get_cotizacion(auth.merge(mon_id: moneda_id))[:result_get][:mon_cotiz].to_f
58
58
  end
59
-
59
+
60
60
  def autorizar_comprobantes opciones
61
61
  comprobantes = opciones[:comprobantes]
62
62
  request = { 'FeCAEReq' => {
@@ -64,20 +64,20 @@ module Afipws
64
64
  'FeDetReq' => { 'FECAEDetRequest' => comprobantes.map { |comprobante| comprobante_to_request comprobante }
65
65
  }}}
66
66
  r = @client.fecae_solicitar auth.merge r2x(request, cbte_fch: :date)
67
- r = Array.wrap(r[:fe_det_resp][:fecae_det_response]).map do |h|
67
+ r = Array.wrap(r[:fe_det_resp][:fecae_det_response]).map do |h|
68
68
  obs = Array.wrap(h[:observaciones] ? h[:observaciones][:obs] : nil)
69
69
  h.select_keys(:cae, :cae_fch_vto, :resultado).merge(cbte_nro: h[:cbte_desde], observaciones: obs)
70
70
  end
71
71
  x2r r, cae_fch_vto: :date, cbte_nro: :integer, code: :integer
72
72
  end
73
-
73
+
74
74
  def comprobante_to_request comprobante
75
75
  nro = comprobante.delete :cbte_nro
76
76
  iva = comprobante.delete :imp_iva
77
77
  comprobante.delete :tributos if comprobante[:imp_trib] == 0
78
78
  comprobante.merge cbte_desde: nro, cbte_hasta: nro, 'ImpIVA' => iva
79
79
  end
80
-
80
+
81
81
  def solicitar_caea
82
82
  convertir_rta_caea @client.fecaea_solicitar auth.merge(periodo_para_solicitud_caea)
83
83
  rescue Afipws::WSError => e
@@ -87,11 +87,11 @@ module Afipws
87
87
  raise
88
88
  end
89
89
  end
90
-
90
+
91
91
  def consultar_caea fecha
92
92
  convertir_rta_caea @client.fecaea_consultar auth.merge(periodo_para_consulta_caea(fecha))
93
93
  end
94
-
94
+
95
95
  def informar_comprobantes_caea opciones
96
96
  comprobantes = opciones[:comprobantes]
97
97
  request = { 'FeCAEARegInfReq' => {
@@ -101,17 +101,17 @@ module Afipws
101
101
  end
102
102
  }}}
103
103
  r = @client.fecaea_reg_informativo auth.merge r2x(request, cbte_fch: :date)
104
- r = Array.wrap(r[:fe_det_resp][:fecaea_det_response]).map do |h|
104
+ r = Array.wrap(r[:fe_det_resp][:fecaea_det_response]).map do |h|
105
105
  obs = Array.wrap(h[:observaciones] ? h[:observaciones][:obs] : nil)
106
106
  h.select_keys(:caea, :resultado).merge(cbte_nro: h[:cbte_desde], observaciones: obs)
107
107
  end
108
108
  x2r r, cbte_nro: :integer, code: :integer
109
109
  end
110
-
110
+
111
111
  def informar_caea_sin_movimientos caea, pto_vta
112
112
  @client.fecaea_sin_movimiento_informar(auth.merge('CAEA' => caea, 'PtoVta' => pto_vta))
113
113
  end
114
-
114
+
115
115
  def ultimo_comprobante_autorizado opciones
116
116
  @client.fe_comp_ultimo_autorizado(auth.merge(opciones))[:cbte_nro].to_i
117
117
  end
@@ -119,30 +119,30 @@ module Afipws
119
119
  def consultar_comprobante opciones
120
120
  @client.fe_comp_consultar(auth.merge(fe_comp_cons_req: opciones))[:result_get]
121
121
  end
122
-
122
+
123
123
  def cant_max_registros_x_lote
124
124
  @client.fe_comp_tot_x_request(auth)[:reg_x_req].to_i
125
125
  end
126
-
126
+
127
127
  def periodo_para_solicitud_caea
128
128
  periodo_para_consulta_caea fecha_inicio_quincena_siguiente
129
129
  end
130
-
130
+
131
131
  def periodo_para_consulta_caea fecha
132
132
  orden = fecha.day <= 15 ? 1 : 2
133
133
  { orden: orden, periodo: fecha.strftime('%Y%m') }
134
134
  end
135
-
135
+
136
136
  def fecha_inicio_quincena_siguiente
137
137
  hoy = Date.today
138
- hoy.day <= 15 ? hoy.change(day: 16) : hoy.next_month.change(day: 1)
138
+ hoy.day <= 15 ? hoy.change(day: 16) : hoy.next_month.change(day: 1)
139
139
  end
140
-
140
+
141
141
  private
142
142
  def get_array response, array_element
143
143
  Array.wrap response[:result_get][array_element]
144
144
  end
145
-
145
+
146
146
  def convertir_rta_caea r
147
147
  x2r r[:result_get], fch_tope_inf: :date, fch_vig_desde: :date, fch_vig_hasta: :date
148
148
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Afipws::WSAA do
4
4
  context "generación documento tra" do
5
5
  it "debería generar xml" do
6
- Time.stubs(:now).returns Time.local(2001, 12, 31, 12, 00)
6
+ Time.stubs(:now).returns Time.new(2001, 12, 31, 12, 0, 0, '-03:00')
7
7
  xml = subject.generar_tra 'wsfe', 2400
8
8
  xml.should match_xpath "/loginTicketRequest/header/uniqueId", Time.now.to_i.to_s
9
9
  xml.should match_xpath "/loginTicketRequest/header/generationTime", "2001-12-31T11:20:00-03:00"
@@ -11,7 +11,7 @@ describe Afipws::WSAA do
11
11
  xml.should match_xpath "/loginTicketRequest/service", "wsfe"
12
12
  end
13
13
  end
14
-
14
+
15
15
  context "firmado del tra" do
16
16
  it "debería firmar el tra usando el certificado y la clave privada" do
17
17
  key = File.read(File.dirname(__FILE__) + '/test.key')
@@ -20,13 +20,13 @@ describe Afipws::WSAA do
20
20
  subject.firmar_tra(tra, key, crt).to_s.should =~ /BEGIN PKCS7/
21
21
  end
22
22
  end
23
-
23
+
24
24
  context "codificación del tra" do
25
25
  it "debería quitarle el header y footer" do
26
- subject.codificar_tra(OpenSSL::PKCS7.new).should == "MAIGAA==\n"
26
+ subject.codificar_tra(OpenSSL::PKCS7.new).should_not include 'BEGIN', 'END'
27
27
  end
28
28
  end
29
-
29
+
30
30
  context "login" do
31
31
  it "debería mandar el TRA al WS y obtener el TA" do
32
32
  ws = Afipws::WSAA.new key: 'key', cert: 'cert'
@@ -35,27 +35,27 @@ describe Afipws::WSAA do
35
35
  ta = ws.login
36
36
  ta[:token].should == 'PD94='
37
37
  ta[:sign].should == 'i9xDN='
38
- ta[:generation_time].should == Time.local(2011,01,12,18,57,04)
39
- ta[:expiration_time].should == Time.local(2011,01,13,06,57,04)
38
+ ta[:generation_time].should == Time.new(2011, 1, 12, 18, 57, 4, '-03:00')
39
+ ta[:expiration_time].should == Time.new(2011, 1, 13, 6, 57, 4, '-03:00')
40
40
  end
41
-
41
+
42
42
  it "debería encapsular SOAP Faults" do
43
43
  subject.stubs(:tra).returns('')
44
44
  savon.expects(:login_cms).with(message: :any).returns(fixture('login_cms/fault'))
45
45
  lambda { subject.login }.should raise_error Afipws::WSError, /CMS no es valido/
46
46
  end
47
47
  end
48
-
48
+
49
49
  context "auth" do
50
50
  before { Time.stubs(:now).returns(now = Time.local(2010,1,1)) }
51
-
51
+
52
52
  it "debería cachear TA" do
53
53
  subject.expects(:login).once.returns(ta = {token: 'token', sign: 'sign', expiration_time: Time.now + 60})
54
54
  subject.auth
55
55
  subject.auth
56
56
  subject.ta.should equal ta
57
57
  end
58
-
58
+
59
59
  it "si el TA expiró debería ejecutar solicitar uno nuevo" do
60
60
  subject.expects(:login).twice.returns(token: 't1', expiration_time: Time.now - 2).then.returns(token: 't2')
61
61
  subject.auth
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require 'rspec'
2
2
  require 'afipws'
3
3
  require 'savon/mock/spec_helper'
4
4
  require 'mocha'
5
- require 'pry-byebug'
6
5
 
7
6
  Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
8
7
 
@@ -5,7 +5,7 @@ RSpec::Matchers.define :match_xpath do |xpath, expected_value|
5
5
  @xml.xpath(xpath).text.should == expected_value.to_s
6
6
  end
7
7
 
8
- failure_message_for_should do |actual|
8
+ failure_message do |actual|
9
9
  "expected xpath '#{xpath}' with value '#{expected_value}' in doc:\n#{@xml}"
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,73 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afipws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Nicolau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-26 00:00:00.000000000 Z
11
+ date: 2018-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.1
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.14.1
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 10.4.2
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 10.4.2
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.9.10
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.10
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 4.3.1
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 4.3.1
69
- - !ruby/object:Gem::Dependency
70
- name: pry-byebug
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -136,34 +122,6 @@ dependencies:
136
122
  - - ">="
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: i18n
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: httpclient
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :runtime
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
125
  description: ''
168
126
  email:
169
127
  - emmanicolau@gmail.com
@@ -175,10 +133,11 @@ files:
175
133
  - ".gitignore"
176
134
  - ".rspec"
177
135
  - ".ruby-version"
136
+ - ".travis.yml"
178
137
  - Gemfile
179
138
  - Gemfile.lock
180
139
  - Guardfile
181
- - README.rdoc
140
+ - README.md
182
141
  - Rakefile
183
142
  - afipws.gemspec
184
143
  - autotest/discover.rb
@@ -231,7 +190,7 @@ files:
231
190
  - spec/spec_helper.rb
232
191
  - spec/support/matchers.rb
233
192
  - spec/support/savon_extensions.rb
234
- homepage: ''
193
+ homepage: https://github.com/eeng/afipws
235
194
  licenses: []
236
195
  metadata: {}
237
196
  post_install_message:
@@ -250,10 +209,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
209
  version: '0'
251
210
  requirements: []
252
211
  rubyforge_project: afipws
253
- rubygems_version: 2.6.6
212
+ rubygems_version: 2.5.1
254
213
  signing_key:
255
214
  specification_version: 4
256
- summary: Ruby wrapper para los servicios web de la AFIP
215
+ summary: Ruby client para los web services de la AFIP
257
216
  test_files:
258
217
  - spec/afipws/core_ext/hash_spec.rb
259
218
  - spec/afipws/test.crt
data/README.rdoc DELETED
@@ -1,35 +0,0 @@
1
- = Afipws
2
-
3
- == Uso
4
-
5
- Primero hay que crear la clave privada y obtener el certificado correspondiente según los pasos indicados {aquí}[http://www.afip.gov.ar/ws/WSAA/cert-req-howto.txt].
6
-
7
- Luego hay que instalar la librería:
8
-
9
- gem install afipws
10
-
11
- Y por último usamos el web service de esta forma:
12
-
13
- require 'afipws'
14
- ws = Afipws::WSFE.new :env => :development, :cuit => '...', :key => File.read('test.key') , :cert => File.read('test.crt')
15
- puts ws.cotizacion 'DOL'
16
-
17
- De momento sólo están soportados los servicios WSAA y WSFEv1.
18
- Ver specs para más ejemplos.
19
-
20
- == Testing
21
-
22
- git clone git://github.com/eeng/afipws.git
23
- cd afipws
24
- bundle
25
- rake
26
-
27
- == Note on Patches/Pull Requests
28
-
29
- * Fork the project.
30
- * Make your feature addition or bug fix.
31
- * Add tests for it. This is important so I don't break it in a
32
- future version unintentionally.
33
- * Commit, do not mess with rakefile, version, or history.
34
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
35
- * Send me a pull request. Bonus points for topic branches.