A corporation manager and dashboard for EVE Online
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

29 lignes
620 B

  1. module Calefaction::EVE
  2. extend self
  3. def corp_ticker(corp_id)
  4. cache_key = "calefaction/eve/corp_ticker/#{corp_id}"
  5. existing = Rails.cache.read(cache_key)
  6. return existing unless existing.nil?
  7. ticker = get_corp_ticker_from_api(corp_id)
  8. return '?' if ticker.nil?
  9. Rails.cache.write(cache_key, ticker)
  10. ticker
  11. end
  12. private
  13. def get_corp_ticker_from_api(corp_id)
  14. ensure_api
  15. @@api.scope = 'corp'
  16. begin
  17. @@api.CorporationSheet(corporationID: corp_id).ticker
  18. rescue EAAL::EAALError
  19. nil
  20. end
  21. end
  22. def ensure_api
  23. @@api ||= EAAL::API.new(nil, nil)
  24. end
  25. end