Class: Arca::PersonaServiceA5

Inherits:
Object
  • Object
show all
Defined in:
lib/arca/persona_service_a5.rb

Constant Summary collapse

WSDL =
{
  development: "https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
  production: "https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL",
  test: "#{Root}/test/fixtures/ws_sr_padron_a5.wsdl"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PersonaServiceA5

Returns a new instance of PersonaServiceA5.



13
14
15
16
17
# File 'lib/arca/persona_service_a5.rb', line 13

def initialize(options = {})
  @cuit = options[:cuit]
  @wsaa = WSAA.new options.merge(service: "ws_sr_padron_a5")
  @client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@wsaa.env], soap_version: 1)
end

Instance Attribute Details

#wsaaObject (readonly)

Returns the value of attribute wsaa.



11
12
13
# File 'lib/arca/persona_service_a5.rb', line 11

def wsaa
  @wsaa
end

Instance Method Details

#dummyObject



19
20
21
# File 'lib/arca/persona_service_a5.rb', line 19

def dummy
  request(:dummy)[:return]
end

#get_persona(id) ⇒ Object



23
24
25
26
# File 'lib/arca/persona_service_a5.rb', line 23

def get_persona(id)
  message = @wsaa.auth.merge(cuitRepresentada: @cuit, idPersona: id)
  request(:get_persona, message)[:persona_return]
end

#get_persona_list(ids) ⇒ Object

Request many personas in one SOAP call. ids: array of CUIT/id_persona. Returns array of persona_return hashes (same shape as get_persona per element).



30
31
32
33
34
35
36
37
38
# File 'lib/arca/persona_service_a5.rb', line 30

def get_persona_list(ids)
  ids = Array(ids)
  return [] if ids.empty?

  message = @wsaa.auth.merge(cuitRepresentada: @cuit, idPersona: ids.map(&:to_s))
  raw = request(:get_persona_list, message)[:persona_list_return]
  personas = raw[:persona]
  Array.wrap(personas).compact
end