padron 0.1.9 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7840f9d3ce5ea14c49af907d251b654a77899e4a0f537f7b175cc367e516dc3
4
- data.tar.gz: 0fdb6b937f4e4af3448494c0eb25b0e7d2a66e8df4597e3034e60bfef3bcf0b7
3
+ metadata.gz: 724ee007843b14b278beaf9890850bbf3af521d2fa72477e684582a8cb20466f
4
+ data.tar.gz: 12c3dfb4be37d464ff543ee2b29be471fcb28c410245719cdcda6c736a3bd874
5
5
  SHA512:
6
- metadata.gz: 49024a74e3a73de7432ec6a5ff619dba24dd24d8d33b1d44645890723c622d9d52d0891f7c0977ce66fe31842985a28eb131368933a60f70189719f86528859d
7
- data.tar.gz: e4522818f4d5bb7752be5225ff2fc8b9920e800af606807ffdef7d8240eab83e4403f661359d15954149bf9098edd0801a77f3b2b5b34c7c277f080d737b4c6e
6
+ metadata.gz: 993b9de60d1770bdc2d53051bae4a18e58effa9ab6f8290d4296656716193190a704c5631e2b82a917c90b242a57cd1a75cd3ec60a321fbd2dde0d42ec46a37f
7
+ data.tar.gz: 64b664837d860a0cb4f1c42220f02b15b2786043fc30ef9a64132c573292cee2712d13b178b019bfeab3b08ed84d69952a18c19a1a6af7cdc7073310b284b85b
data/lib/padron/call.rb CHANGED
@@ -49,11 +49,11 @@ module Padron
49
49
  end
50
50
 
51
51
  def set_body
52
- ids = Padron::IdPersona.new(id).return_cuits
52
+ ids = id.is_a?(Array) ? id : Padron::IdPersona.new(id).return_cuits
53
53
  body = Padron.auth_hash
54
54
  id_personas = []
55
55
  ids.map do |cuit|
56
- id_personas << cuit
56
+ id_personas << cuit.tr('^0-9', '')
57
57
  end
58
58
  @body = body.merge({"idPersona" => id_personas})
59
59
  end
@@ -64,24 +64,37 @@ module Padron
64
64
 
65
65
  def set_data
66
66
  personas = data.body[:get_persona_list_response][:persona_list_return][:persona]
67
- personas.map do |persona|
68
- unless persona[:error_constancia] && persona[:error_constancia].try(:[],:apellido).nil?
69
- if !persona[:error_constancia].nil?
70
- {:name => set_name(persona[:error_constancia]),
71
- :cuit => persona[:error_constancia][:id_persona]}
72
- else
73
- {:name => set_name(persona[:datos_generales]),
74
- :cuit => persona[:datos_generales][:id_persona],
75
- :cp => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :cod_postal),
76
- :address => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :direccion),
77
- :city_id => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :id_provincia),
78
- :city => Padron::PROVINCIAS[persona[:datos_generales].try(:[],:domicilio_fiscal).try(:[], :id_provincia)],
79
- :locality => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :localidad)}
80
- end
81
- end
67
+ if personas.is_a? Array
68
+ set_multiple(personas)
69
+ else
70
+ set_single(personas)
71
+ end
72
+
73
+ end
74
+
75
+ def set_multiple(personas)
76
+ personas.map do |persona|
77
+ set_single(persona)
82
78
  end
83
79
  end
84
80
 
81
+ def set_single(persona)
82
+ unless persona[:error_constancia] && persona[:error_constancia].try(:[],:apellido).nil?
83
+ if !persona[:error_constancia].nil?
84
+ {:name => set_name(persona[:error_constancia]),
85
+ :cuit => persona[:error_constancia][:id_persona]}
86
+ else
87
+ {:name => set_name(persona[:datos_generales]),
88
+ :cuit => persona[:datos_generales][:id_persona],
89
+ :cp => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :cod_postal),
90
+ :address => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :direccion),
91
+ :city_id => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :id_provincia),
92
+ :city => Padron::PROVINCIAS[persona[:datos_generales].try(:[],:domicilio_fiscal).try(:[], :id_provincia)],
93
+ :locality => persona[:datos_generales].try(:[], :domicilio_fiscal).try(:[], :localidad)}
94
+ end
95
+ end
96
+ end
97
+
85
98
  def set_name(persona)
86
99
  return "#{persona.try(:[], :nombre)} #{persona.try(:[], :apellido)}"
87
100
  end
@@ -7,7 +7,7 @@ module Padron
7
7
  end
8
8
 
9
9
  def return_cuits
10
- return id if id.length == 11
10
+ return [id] if id.length == 11
11
11
  return calculate_cuits
12
12
  end
13
13
 
@@ -1,3 +1,3 @@
1
1
  module Padron
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Facundo Diaz Martinez