class AfipWsfe::AuthData

Attributes

todays_data_file_name[RW]

Public Class Methods

auth_hash() click to toggle source
# File lib/afip_wsfe/auth_data.rb, line 9
def auth_hash
  fetch unless AfipWsfe.constants.include?(:TOKEN) && AfipWsfe.constants.include?(:SIGN)
  
  {
    auth: {
      token: AfipWsfe::TOKEN,
      sign: AfipWsfe::SIGN,
      cuit: AfipWsfe.cuit,
    }
  }
end

Private Class Methods

fetch() click to toggle source
# File lib/afip_wsfe/auth_data.rb, line 27
def fetch
  unless File.exists?(todays_data_file_name)
    wsaa = AfipWsfe::Wsaa.new
    wsaa.login
  end

  YAML.load_file(todays_data_file_name).each do |k, v|
    AfipWsfe.const_set(k.to_s.upcase, v)
  end
end
remove() click to toggle source
# File lib/afip_wsfe/auth_data.rb, line 38
def remove
  AfipWsfe.remove_const(:TOKEN)
  AfipWsfe.remove_const(:SIGN)
  File.delete(@todays_data_file)
end