Class: Rnfse::API

Inherits:
Object
  • Object
show all
Defined in:
lib/rnfse/api.rb

Defined Under Namespace

Modules: Abrasf10, IssNet10, SpeedGov10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rnfse/api.rb', line 15

def initialize(options = {})
  options = load_options(options)
        
  case
  when has_options(options, 'provedor', 'homologacao')
    provedor = provedores['homologacao'][options['provedor'].to_s]
    raise ArgumentError, 'provedor de homologação inexistente', caller if provedor.nil?
    self.api = provedor['api']
    load_options_method = :load_options_for_staging

  when has_options(options, 'provedor', 'municipio')
    provedor = provedores['producao'][options['provedor'].to_s]
    raise ArgumentError, 'provedor inexistente', caller if provedor.nil?
    self.api = provedor['api']
    load_options_method = :load_options_for_production

  when has_options(options, 'padrao', 'namespace', 'endpoint')
    self.api = options['padrao'].to_s
    load_options_method = :load_options_for_custom

  else
    raise ArgumentError, 'opções inválidas', caller
  end

  extend self.class.const_get(String.camelize(self.api))

  self.send(load_options_method, options)
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



8
9
10
# File 'lib/rnfse/api.rb', line 8

def api
  @api
end

#certificateObject

Returns the value of attribute certificate.



9
10
11
# File 'lib/rnfse/api.rb', line 9

def certificate
  @certificate
end

#endpointObject

Returns the value of attribute endpoint.



7
8
9
# File 'lib/rnfse/api.rb', line 7

def endpoint
  @endpoint
end

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/rnfse/api.rb', line 10

def key
  @key
end

#namespaceObject

Returns the value of attribute namespace.



6
7
8
# File 'lib/rnfse/api.rb', line 6

def namespace
  @namespace
end

#soap_clientObject

Returns the value of attribute soap_client.



12
13
14
# File 'lib/rnfse/api.rb', line 12

def soap_client
  @soap_client
end

#verboseObject

Returns the value of attribute verbose.



13
14
15
# File 'lib/rnfse/api.rb', line 13

def verbose
  @verbose
end

#xml_builderObject

Returns the value of attribute xml_builder.



11
12
13
# File 'lib/rnfse/api.rb', line 11

def xml_builder
  @xml_builder
end