Class: Padron::AuthData

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.environmentObject

Returns the value of attribute environment.



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

def environment
  @environment
end

.todays_data_file_nameObject

Returns the value of attribute todays_data_file_name.



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

def todays_data_file_name
  @todays_data_file_name
end

Class Method Details

.auth_hashObject



27
28
29
30
# File 'lib/padron/auth_data.rb', line 27

def auth_hash
  fetch unless Padron.constants.include?(:TOKEN) && Padron.constants.include?(:SIGN)
  { 'token' => Padron::TOKEN, 'sign'  => Padron::SIGN, 'cuitRepresentado'  => Padron.cuit }
end

.fetchObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/padron/auth_data.rb', line 9

def fetch
  unless File.exists?(Padron.pkey)
    raise "Archivo de llave privada no encontrado en #{ Padron.pkey }"
  end

  unless File.exists?(Padron.cert)
    raise "Archivo certificado no encontrado en #{ Padron.cert }"
  end

  unless File.exists?(todays_data_file_name)
    Padron::Wsaa.
  end

  YAML.load_file(todays_data_file_name).each do |k, v|
    Padron.const_set(k.to_s.upcase, v) #unless Padron.const_defined?(k.to_s.upcase)
  end
end

.wsaa_urlObject



33
34
35
# File 'lib/padron/auth_data.rb', line 33

def wsaa_url
  Padron::URLS[Padron.environment][:wsaa]
end

.wsfe_urlObject



37
38
39
40
# File 'lib/padron/auth_data.rb', line 37

def wsfe_url
  raise 'Environment not sent to either :test or :production' unless Padron::URLS.keys.include? environment
  Padron::URLS[Padron.environment][:wsfe]
end