Class: Padron::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/padron/call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Call

Returns a new instance of Call.



6
7
8
9
# File 'lib/padron/call.rb', line 6

def initialize(args={})
  @environment = args[:environment] || :test
  @id = args[:id] || raise(NullOrInvalidAttribute.new, "Por favor ingrese el documento.")
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/padron/call.rb', line 4

def body
  @body
end

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/padron/call.rb', line 4

def client
  @client
end

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/padron/call.rb', line 4

def data
  @data
end

#environmentObject (readonly)

Returns the value of attribute environment.



4
5
6
# File 'lib/padron/call.rb', line 4

def environment
  @environment
end

#fault_codeObject (readonly)

Returns the value of attribute fault_code.



4
5
6
# File 'lib/padron/call.rb', line 4

def fault_code
  @fault_code
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/padron/call.rb', line 4

def id
  @id
end

Instance Method Details

#dummyObject



11
12
13
14
# File 'lib/padron/call.rb', line 11

def dummy
  set_client
  pp reponse = client.call(:dummy)
end

#get_dataObject



16
17
18
19
20
# File 'lib/padron/call.rb', line 16

def get_data
  @data = get_personas
  return nil unless fault_code.nil?
  set_data
end

#get_personasObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/padron/call.rb', line 22

def get_personas
  set_client
  set_body
  response = client.call(:get_persona_list, message: body)
  rescue Savon::SOAPFault => error
    if !error.blank?
      @fault_code = error.to_hash[:fault][:faultstring]
    else
      @fault_code = nil
    end
    return response
end