A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
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