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.
 
 
 
 
 

55 lines
1.1 KiB

  1. require 'eaal'
  2. module Calefaction::EVE
  3. extend self
  4. class APIUser
  5. def initialize(key_id, vcode)
  6. @api = EAAL::API.new(key_id, vcode)
  7. end
  8. def character_sheet(char_id)
  9. @api.scope = 'char'
  10. begin
  11. @api.CharacterSheet(characterID: char_id)
  12. rescue EAAL::Exception::EAALError
  13. nil
  14. end
  15. end
  16. def characters
  17. @api.scope = 'account'
  18. begin
  19. @api.Characters.characters
  20. rescue EAAL::Exception::EAALError
  21. nil
  22. end
  23. end
  24. end
  25. def corp_ticker(corp_id)
  26. cache_key = "calefaction/eve/corp_ticker/#{corp_id}"
  27. existing = Rails.cache.read(cache_key)
  28. return existing unless existing.nil?
  29. sheet = corporation_sheet(corp_id)
  30. return '?' if sheet.nil?
  31. Rails.cache.write(cache_key, sheet.ticker)
  32. sheet.ticker
  33. end
  34. private
  35. def corporation_sheet(corp_id)
  36. ensure_basic_api
  37. @@api.scope = 'corp'
  38. begin
  39. @@api.CorporationSheet(corporationID: corp_id)
  40. rescue EAAL::Exception::EAALError
  41. nil
  42. end
  43. end
  44. def ensure_basic_api
  45. @@api ||= EAAL::API.new(nil, nil)
  46. end
  47. end