Class: Reve::API

Inherits:
Object show all
Defined in:
lib/reve.rb

Overview

API Class. Basic Usage: api = Reve::API.new(‘my_UserID’, ‘my_apiKey’) alliances = api.alliances # Returns an array of Reve::Classes::Alliance

api.personal_wallet_blanace(:characterid => 892008733) # Returns an array of Reve::Classes::WalletBalance. Note that the CharacterID Number is required here.

api.sovereignty :just_hash => true # Returns the hash for this call with no Alliance data with it.

As of Revision 22 (28 August 2007) all API calls take a parameter, :just_hash, to just get the hash that represents that particular API call; No data related to the call is returned if :just_hash is present

All API methods have the functionality to read XML from an arbitrary location. This could be another webserver, or a XML file on disk. To use this pass the hash option :url => location where location is a String or URI class. See format_url_request documentation for more details.

Constant Summary collapse

@@alliances_url =
'http://api.eve-online.com/eve/AllianceList.xml.aspx'
@@sovereignty_url =
'http://api.eve-online.com/map/Sovereignty.xml.aspx'
@@reftypes_url =
'http://api.eve-online.com/eve/RefTypes.xml.aspx'
@@skill_tree_url =
'http://api.eve-online.com/eve/SkillTree.xml.aspx'
@@member_tracking_url =
'http://api.eve-online.com/corp/MemberTracking.xml.aspx'
@@corporate_wallet_balance_url =
'http://api.eve-online.com/corp/AccountBalance.xml.aspx'
@@personal_wallet_balance_url =
'http://api.eve-online.com/char/AccountBalance.xml.aspx'
@@corporate_wallet_trans_url =
'http://api.eve-online.com/corp/WalletTransactions.xml.aspx'
@@personal_wallet_trans_url =
'http://api.eve-online.com/char/WalletTransactions.xml.aspx'
@@corporate_wallet_journal_url =
'http://api.eve-online.com/corp/WalletJournal.xml.aspx'
@@personal_wallet_journal_url =
'http://api.eve-online.com/char/WalletJournal.xml.aspx'
@@characters_url =
'http://api.eve-online.com/account/Characters.xml.aspx'
@@training_skill_url =
'http://api.eve-online.com/char/SkillInTraining.xml.aspx'
@@skill_queue_url =
'http://api.eve-online.com/char/SkillQueue.xml.aspx'
@@character_sheet_url =
'http://api.eve-online.com/char/CharacterSheet.xml.aspx'
@@starbases_url =
'http://api.eve-online.com/corp/StarbaseList.xml.aspx'
@@starbasedetail_url =
'http://api.eve-online.com/corp/StarbaseDetail.xml.aspx'
@@conqurable_outposts_url =
'http://api.eve-online.com/eve/ConquerableStationList.xml.aspx'
@@corporation_sheet_url =
'http://api.eve-online.com/corp/CorporationSheet.xml.aspx'
@@corporation_member_security_url =
'http://api.eve-online.com/corp/MemberSecurity.xml.aspx'
@@errors_url =
'http://api.eve-online.com/eve/ErrorList.xml.aspx'
@@map_jumps_url =
'http://api.eve-online.com/map/Jumps.xml.aspx'
@@map_kills_url =
'http://api.eve-online.com/map/Kills.xml.aspx'
@@personal_market_orders_url =
'http://api.eve-online.com/char/MarketOrders.xml.aspx'
@@corporate_market_orders_url =
'http://api.eve-online.com/corp/MarketOrders.xml.aspx'
@@personal_industry_jobs_url =
'http://api.eve-online.com/char/IndustryJobs.xml.aspx'
@@corporate_industry_jobs_url =
'http://api.eve-online.com/corp/IndustryJobs.xml.aspx'
@@personal_assets_url =
'http://api.eve-online.com/char/AssetList.xml.aspx'
@@corporate_assets_url =
'http://api.eve-online.com/corp/AssetList.xml.aspx'
@@personal_kills_url =
'http://api.eve-online.com/char/KillLog.xml.aspx'
@@corporate_kills_url =
'http://api.eve-online.com/corp/KillLog.xml.aspx'
@@character_id_url =

?names=CCP%20Garthagk,Raquel%20Smith

'http://api.eve-online.com/eve/CharacterID.xml.aspx'
@@character_name_url =

?ids=797400947,892008733

'http://api.eve-online.com/eve/CharacterName.xml.aspx'
@@personal_faction_war_stats_url =
'http://api.eve-online.com/char/FacWarStats.xml.aspx'
@@corporate_faction_war_stats_url =
'http://api.eve-online.com/corp/FacWarStats.xml.aspx'
@@general_faction_war_stats_url =
'http://api.eve-online.com/eve/FacWarStats.xml.aspx'
@@top_faction_war_stats_url =
'http://api.eve-online.com/eve/FacWarTopStats.xml.aspx'
@@faction_war_occupancy_url =
'http://api.eve-online.com/map/FacWarSystems.xml.aspx'
@@certificate_tree_url =
'http://api.eve-online.com/eve/CertificateTree.xml.aspx'
@@character_medals_url =
'http://api.eve-online.com/char/Medals.xml.aspx'
@@corporate_medals_url =
'http://api.eve-online.com/corp/Medals.xml.aspx'
@@corp_member_medals_url =
'http://api.eve-online.com/corp/MemberMedals.xml.aspx'
@@server_status_url =
'http://api.eve-online.com/Server/ServerStatus.xml.aspx'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(userid = "", key = "", charid = "") ⇒ API

Create a new API instance. current_time and cached_until are meaningful only for the LAST call made. Expects:

  • userid ( Integer | String ) - Your API userID

  • key ( String ) - Your API key (Full key or restricted key)

  • charid ( Integer | String ) - Default characterID for calls requiring it.

NOTE: All values passed to the constructor are typecasted to a String for safety.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/reve.rb', line 116

def initialize(userid = "", key = "", charid = "")
  @userid = (userid || "").to_s
  @key    = (key    || "").to_s
  @charid = (charid || "").to_s
  
  @save_path = nil

  @http_user_agent = "Reve"
  @max_tries = 3

  @current_time = nil
  @cached_until = nil
  @last_hash = nil
end

Instance Attribute Details

#cached_untilObject (readonly)

Returns the value of attribute cached_until.



107
108
109
# File 'lib/reve.rb', line 107

def cached_until
  @cached_until
end

#charidObject

Returns the value of attribute charid.



105
106
107
# File 'lib/reve.rb', line 105

def charid
  @charid
end

#current_timeObject (readonly)

Returns the value of attribute current_time.



107
108
109
# File 'lib/reve.rb', line 107

def current_time
  @current_time
end

#http_user_agentObject

Returns the value of attribute http_user_agent.



106
107
108
# File 'lib/reve.rb', line 106

def http_user_agent
  @http_user_agent
end

#keyObject

Returns the value of attribute key.



105
106
107
# File 'lib/reve.rb', line 105

def key
  @key
end

#last_hashObject (readonly)

Returns the value of attribute last_hash.



107
108
109
# File 'lib/reve.rb', line 107

def last_hash
  @last_hash
end

#save_pathObject

Returns the value of attribute save_path.



106
107
108
# File 'lib/reve.rb', line 106

def save_path
  @save_path
end

#useridObject

Returns the value of attribute userid.



105
106
107
# File 'lib/reve.rb', line 105

def userid
  @userid
end

Instance Method Details

#alliances(opts = {}) ⇒ Object

Return a list of Alliances and member Corporations from api.eve-online.com/eve/AllianceList.xml.aspx Use the corporation_sheet method to get information for each member Corporation See also: Reve::Classes::Alliance, Reve::Classes::Corporation and corporation_sheet



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/reve.rb', line 192

def alliances(opts = {})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@alliances_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@alliances_url,true,args)
  alliances = []
  xml.search("/eveapi/result/rowset[@name='alliances']/row").each do |alliance|
    alliance_obj = Reve::Classes::Alliance.new(alliance)
    alliance.search("rowset[@name='memberCorporations']/row").each do |corporation|
      alliance_obj.member_corporations << Reve::Classes::Corporation.new(corporation)
    end
    alliances << alliance_obj
  end
  alliances
end

#certificate_tree(opts = {}) ⇒ Object

Returns a Reve::Classes::CertificateTree object that contains the Certificate tree structure. See the rdoc for Reve::Classes::CertificateTree for details. See also: Reve::Classes::CertificateTree



780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
# File 'lib/reve.rb', line 780

def certificate_tree(opts = {})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@certificate_tree_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@certificate_tree_url,true,args)
  
  tree = Reve::Classes::CertificateTree.new
  xml.search("/eveapi/result/rowset[@name=categories]/row").each do |category|
    cat = Reve::Classes::CertificateCategory.new(category)
    category.search("rowset[@name=classes]/row").each do |klass|
      kl = Reve::Classes::CertificateClass.new(klass)
      klass.search("rowset[@name=certificates]/row").each do |certificate|
        cert = Reve::Classes::Certificate.new(certificate)
        certificate.search("rowset[@name=requiredSkills]/row").each do |skill|
          cert.required_skills << Reve::Classes::CertificateRequiredSkill.new(skill)
        end
        certificate.search("rowset[@name=requiredCertificates]/row").each do |requiredcert|
          cert.required_certificates << Reve::Classes::CertificateRequiredCertificate.new(requiredcert)
        end
        kl.certificates << cert
      end
      cat.classes << kl
    end
    tree.categories << cat
  end
  tree
end

#character_medals(opts = { :characterid => nil }) ⇒ Object

Gets the list of Medals awarded to a Character. Returns a Reve::Classes::CharacterMedals object.



447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/reve.rb', line 447

def character_medals(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@character_medals_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@character_medals_url,true,args)
  current = xml.search("/eveapi/result/rowset[@name=currentCorporation]/row").inject([]) do |cur,elem|
    cur << Reve::Classes::CharacterMedal.new(elem)
  end
  other = xml.search("/eveapi/result/rowset[@name=otherCorporations]/row").inject([]) do |cur,elem|
    cur << Reve::Classes::CharacterMedal.new(elem)
  end
  Reve::Classes::CharacterMedals.new(current,other)
end

#character_name(opts = {}) ⇒ Object

Convert ids to Character names. Expects a Hash as a parameter with these keys:

  • ids ( Array ) - An Array of Character IDs to fetch the names of.

See Also: character_name, Reve::Classes::Character, character_sheet



178
179
180
181
182
183
184
# File 'lib/reve.rb', line 178

def character_name(opts = {})
  ids = opts[:ids] || []
  return [] if ids.empty?
  opts[:ids] = ids.join(',')
  compute_hash(  opts.merge(:url => @@character_name_url) ) ||
    process_query(Reve::Classes::Character,opts[:url] || @@character_name_url,false,opts)
end

#character_sheet(opts = { :characterid => nil }) ⇒ Object

Gets the CharacterSheet from api.eve-online.com/char/CharacterSheet.xml.aspx Expects:

  • characterid ( Fixnum ) - Get the CharacterSheet for this Character

See also: Reve::Classes::CharacterSheet



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/reve.rb', line 813

def character_sheet(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@character_sheet_url))
  return h if h
  
  xml = process_query(nil,opts[:url] || @@character_sheet_url,true,args)
  cs = Reve::Classes::CharacterSheet.new

  [ Reve::Classes::IntelligenceEnhancer, Reve::Classes::MemoryEnhancer, Reve::Classes::CharismaEnhancer,
    Reve::Classes::PerceptionEnhancer, Reve::Classes::WillpowerEnhancer
  ].each do |klass|
    xml_attr = klass.to_s.split("::").last.sub("Enhancer",'').downcase + "Bonus"
    i = klass.new(xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorName/").first.to_s,
                  xml.search("/eveapi/result/attributeEnhancers/#{xml_attr}").search("augmentatorValue/").first.to_s.to_i)
    cs.enhancers << i
  end

  [ 'characterID', 'name', 'race', 'bloodLine', 'gender','corporationName',
    'corporationID','balance', 'cloneName', 'cloneSkillPoints' 
  ].each do |field|
    cs.send("#{field.downcase}=",xml.search("/eveapi/result/#{field}/").first.to_s)
  end
  
  [ 'intelligence','memory','charisma','perception','willpower' ].each do |attrib|
    cs.send("#{attrib}=",xml.search("/eveapi/result/attributes/#{attrib}/").first.to_s.to_i) 
  end
  xml.search("rowset[@name=skills]/row").each do |elem|
    cs.skills << Reve::Classes::Skill.new(elem)
  end
  
  xml.search("rowset[@name=certificates]/row").each do |elem|
    cs.certificate_ids << elem['certificateID'].to_i
  end
  [ :corporationRolesAtHQ, :corporationRoles, :corporationRolesAtBase, :corporationRolesAtOther ].each do |role_kind|
    xml.search("rowset[@name=#{role_kind.to_s}]/row").each do |elem|
      cs.rsend(["#{role_kind}"], [:push,Reve::Classes::CorporateRole.new(elem)])
    end
  end
  
  xml.search("rowset[@name=corporationTitles]/row").each do |elem|
    cs.corporate_titles << Reve::Classes::CorporateTitle.new(elem)
  end
  
  cs
end

#characters(opts = {}) ⇒ Object

Returns a Character list for the associated key and userid from api.eve-online.com/account/Characters.xml.aspx See also: Reve::Classes::Character



596
597
598
599
600
601
# File 'lib/reve.rb', line 596

def characters(opts = {})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@characters_url))
  return h if h
  process_query(Reve::Classes::Character,opts[:url] || @@characters_url,false,args)
end

#conquerable_stations(opts = {}) ⇒ Object Also known as: conqurable_stations

Returns a list of ConqurableStations and outposts from api.eve-online.com/eve/ConquerableStationList.xml.aspx See also: Reve::Classes::ConqurableStation



247
248
249
250
# File 'lib/reve.rb', line 247

def conquerable_stations(opts = {})
  compute_hash(  opts.merge(:url => @@conqurable_outposts_url) ) ||
      process_query(Reve::Classes::ConquerableStation, opts[:url] || @@conqurable_outposts_url, false)
end

#corporate_assets_list(opts = { :characterid => nil}) ⇒ Object

Get a list of the Corporate Assets. Pass the characterid of the Corporate member See also assets_list method



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/reve.rb', line 577

def corporate_assets_list(opts = { :characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_assets_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@corporate_assets_url,true,args)
  assets = []
  xml.search("/eveapi/result/rowset/row").each do |container|
    asset_container = Reve::Classes::AssetContainer.new(container)
    container.search("rowset[@name='contents']/row").each do |asset|
      asset_container.assets << Reve::Classes::Asset.new(asset)
    end
    assets << asset_container
  end
  assets
end

#corporate_faction_war_stats(opts = { :characterid => nil }) ⇒ Object

Gets the CorporateFactionWarStat for the Corporation a Character belongs to. Expects:

  • characterid ( Integer | String ) - Get this character’s corp’s CorporateFactionWarStat.

See Also Reve::Classes::CorporateFactionWarStat and personal_faction_war_stats



483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/reve.rb', line 483

def corporate_faction_war_stats(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_faction_war_stats_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@corporate_faction_war_stats_url,true,args)    
  elems = {}
  [ :factionID, :factionName, :enlisted, :pilots,
    :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday,
    :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem|
      elems[elem.to_s] = xml.search("/eveapi/result/" + elem.to_s).first.inner_html
    end
  Reve::Classes::CorporateFactionWarParticpant.new(elems)
end

#corporate_industry_jobs(opts = {:characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::CorporateIndustryJob objects.



281
282
283
284
285
286
# File 'lib/reve.rb', line 281

def corporate_industry_jobs(opts = {:characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_industry_jobs_url))
  return h if h
  process_query(Reve::Classes::CorporateIndustryJob, opts[:url] || @@corporate_industry_jobs_url,false,args)
end

#corporate_kills(opts = { :characterid => nil }) ⇒ Object

See the options for personal_kills



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/reve.rb', line 693

def corporate_kills(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_kills_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@corporate_kills_url,true,args)
  kills = []
  xml.search("/eveapi/result/rowset/row").each do |e|
    victim = Reve::Classes::KillVictim.new(e.search("victim").first) rescue next # cant find victim
    attackers = []
    losses = []
    e.search("rowset[@name='attackers']/row").each do |attacker|
      attackers << Reve::Classes::KillAttacker.new(attacker)
    end
    e.search("rowset[@name='items']/row").each do |lost_item|
      lost = Reve::Classes::KillLoss.new(lost_item)
      lost_item.search("rowset[@name='items']/row").each do |contained|
        lost.contained_losses << Reve::Classes::KillLoss.new(contained)
      end
      losses << lost
    end
    kills << Reve::Classes::Kill.new(e, victim, attackers, losses)      
  end
  kills
end

#corporate_market_orders(opts = {:characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::MarketOrder objects for market orders that are up on behalf of a Corporation Pass the characterid of the Character of whose corporation to check for



265
266
267
268
269
270
# File 'lib/reve.rb', line 265

def corporate_market_orders(opts = {:characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_market_orders_url))
  return h if h
  process_query(Reve::Classes::CorporateMarketOrder, opts[:url] || @@corporate_market_orders_url, false, args)
end

#corporate_medals(opts = { :characterid => nil }) ⇒ Object

Get the medals a Corporation can give out. Returns a list of Reve::Classes::CorporateMedal objects. Expects:

  • characterid ( Integer | String ) - Get this Medals this Character’s Corporation can give out

See also: Reve::Classes::CorporateMedal, Reve::Classes::Medal



424
425
426
427
428
429
# File 'lib/reve.rb', line 424

def corporate_medals(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_medals_url))
  return h if h
  process_query(Reve::Classes::CorporateMedal, opts[:url] || @@corporate_medals_url,false,args)
end

#corporate_member_medals(opts = { :characterid => nil }) ⇒ Object

Gets the medals the Corporation has given out. Returns a list of Reve::Classes::CorporateMemberMedal Expects:

  • characterid ( Integer | String ) - Get this Medals this Character’s Corporation has given out

See also: Reve::Classes::CorporateMedal, Reve::Classes::Medal



437
438
439
440
441
442
# File 'lib/reve.rb', line 437

def corporate_member_medals(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corp_member_medals_url))
  return h if h
  process_query(Reve::Classes::CorporateMemberMedal, opts[:url] || @@corp_member_medals_url,false,args)
end

#corporate_member_security(opts = { :characterid => nil }) ⇒ Object



754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/reve.rb', line 754

def corporate_member_security(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporation_member_security_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@corporation_member_security_url,true,args)

  cmc = Reve::Classes::CorporationMemberSecurity.new
  xml.search("/eveapi/result/member").each do |member|
    mem = Reve::Classes::CorporationMember.new(member)
    cmc.members << mem
    [:roles, :grantableRoles, :rolesAtHQ, :grantableRolesAtHQ, :rolesAtBase, :grantableRolesAtBase, :rolesAtOther, :grantableRolesAtOther].each do |rowset|
      member.search("/rowset[@name=#{rowset.to_s}]/row").each do |row|
        mem.rsend(["#{rowset}"], [:push,Reve::Classes::CorporateRole.new(row)])
      end
    end
    member.search("/rowset[@name=titles]/row").each do |row|
      mem.rsend([:titles], [:push,Reve::Classes::CorporateTitle.new(row)])
    end
  end
  cmc
end

#corporate_wallet_balance(opts = { :characterd => nil }) ⇒ Object

Gets one’s corporate WalletBalance from api.eve-online.com/corp/AccountBalance.xml.aspx Expects:

  • characterid ( Integer | String ) - Look at WalletBalance objects from this Character’s Corporation

See also: Reve::Classes::WalletBalance and personal_wallet_balance



356
357
358
359
360
361
# File 'lib/reve.rb', line 356

def corporate_wallet_balance(opts = { :characterd => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_wallet_balance_url))
  return h if h
  process_query(Reve::Classes::WalletBalance,opts[:url] || @@corporate_wallet_balance_url,false,args)
end

#corporate_wallet_journal(opts = {:accountkey => nil, :characterid => nil, :beforerefid => nil}) ⇒ Object

Gets one’s own corporate WalletJournal list from api.eve-online.com/corp/WalletJournal.xml.aspx Expects:

  • account_key ( Integer | String ) - Account key (1000-1006) to look at.

  • characterid ( Integer | String ) - Look at WalletJournal objects from this Character’s Corporation

  • beforerefid ( Integer | String ) - Gets a list of WalletTransaction objects from before this RefID.

See also: Reve::Classes::WalletJournal and personal_wallet_journal



399
400
401
402
403
404
# File 'lib/reve.rb', line 399

def corporate_wallet_journal(opts = {:accountkey => nil, :characterid => nil, :beforerefid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_wallet_journal_url))
  return h if h
  process_query(Reve::Classes::WalletJournal,opts[:url] || @@corporate_wallet_journal_url,false,args)
end

#corporate_wallet_transactions(opts = {:accountkey => nil, :characterid => nil, :beforerefid => nil}) ⇒ Object

Gets one’s corporate WalletTransaction list from api.eve-online.com/corp/WalletTransactions.xml.aspx Expects:

  • account_key ( Integer | String ) - Account key (1000-1006) to look at.

  • characterid ( Integer | String ) - Look at WalletTransaction objects from this Character’s Corporation

  • beforetransid ( Integer | String ) - Gets a list of WalletTransaction objects from before this Transaction ID.

See also: Reve::Classes::WalletTransaction and personal_wallet_transactions



385
386
387
388
389
390
# File 'lib/reve.rb', line 385

def corporate_wallet_transactions(opts = {:accountkey => nil, :characterid => nil, :beforerefid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporate_wallet_trans_url))
  return h if h
  process_query(Reve::Classes::CorporateWalletTransaction,opts[:url] || @@corporate_wallet_trans_url,false,args)
end

#corporation_sheet(opts = { :characterid => nil }) ⇒ Object

Gets the CorporationSheet from api.eve-online.com/corp/CorporationSheet.xml.aspx Expects:

  • Hash of arguments:

    • characterid ( Integer | String ) - Gets the CorporationSheet for this Character

    • corporationid ( Integer ) - If the characterid isn’t passed then send the corporation’s id

(See the alliances method for a list) to get the details of a Corporation that belongs to an Alliance. See also: Reve::Classes::CorporationSheet



725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
# File 'lib/reve.rb', line 725

def corporation_sheet(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@corporation_sheet_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@corporation_sheet_url,true,args)

  h = { 'graphicid' => 0, 'shape1' => 0, 'shape2' => 0, 'shape3' => 0, 'color1' => 0, 'color2' => 0, 'color3' => 0,  }
  h.keys.each { |k| h[k] = xml.search("//result/logo/" + k + "/").to_s.to_i }
   = Reve::Classes::CorporateLogo.new h
  
  wallet_divisions = xml.search("//result/rowset[@name='walletDivisions']/").collect { |k| k if k.kind_of? Hpricot::Elem } - [ nil ]
  divisions = xml.search("//result/rowset[@name='divisions']/").collect { |k| k if k.kind_of? Hpricot::Elem } - [ nil ]
  divisions.collect! { |d| Reve::Classes::CorporateDivision.new(d) }
  wallet_divisions.collect! { |w| Reve::Classes::WalletDivision.new(w) }
  
  # Map the XML names to our own names and assign them to the temporary 
  # hash +res+ to pass to Reve::Classes::CorporationSheet#new
  res = Hash.new
  { :corporationid => :id, :corporationname => :name, :ticker => :ticker, :ceoid => :ceo_id,
    :ceoname => :ceo_name, :stationid => :station_id, :stationname => :station_name,
    :description => :description, :url => :url, :allianceid => :alliance_id,
    :alliancename => :alliance_name, :taxrate => :tax_rate, :membercount => :member_count,
    :memberlimit => :member_limit, :shares => :shares }.each do |k,v|
    res[v] = xml.search("//result/#{k.to_s}/").first.to_s.strip
  end

  Reve::Classes::CorporationSheet.new res, divisions, wallet_divisions,   
end

#errors(opts = {}) ⇒ Object

Returns a list of API Errors



223
224
225
226
# File 'lib/reve.rb', line 223

def errors(opts = {})
  compute_hash(  opts.merge(:url => @@errors_url) ) || 
    process_query(Reve::Classes::APIError,opts[:url] || @@errors_url,false)
end

#faction_war_stats(opts = {}) ⇒ Object

Gets Faction-wide war stats. See also: Reve::Classes::EveFactionWarStat, Reve::Classes::FactionwideFactionWarParticpant, Reve::Classes::FactionWar



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/reve.rb', line 500

def faction_war_stats(opts = {} )
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@general_faction_war_stats_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@general_faction_war_stats_url,true,args)
  participants = xml.search("/eveapi/result/rowset[@name='factions']/row").collect do |faction|
    Reve::Classes::FactionwideFactionWarParticpant.new(faction)
  end
  wars = xml.search("/eveapi/result/rowset[@name='factionWars']/row").collect do |faction_war|
    Reve::Classes::FactionWar.new(faction_war)
  end
  totals = {}
  [ :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday,
    :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem|
    totals[elem.to_s] = xml.search("/eveapi/result/totals/" + elem.to_s).first.inner_html
  end
  Reve::Classes::EveFactionWarStat.new(totals, wars, participants)
end

#faction_war_system_stats(opts = {}) ⇒ Object Also known as: faction_war_occupancy

Returns the occupancy data for each System. See also: Reve::Classes::FactionWarSystemStatus



521
522
523
524
525
526
# File 'lib/reve.rb', line 521

def faction_war_system_stats(opts = {})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@faction_war_occupancy_url))
  return h if h
  process_query(Reve::Classes::FactionWarSystemStatus,opts[:url] || @@faction_war_occupancy_url,false,args)
end

#faction_war_top_stats(opts = {}) ⇒ Object

Gets a list of the top 10 statistics for Characters, Corporations and Factions in factional warfare. Read the notes on Reve::Classes::FactionWarTopStats.



531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/reve.rb', line 531

def faction_war_top_stats(opts = {})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@top_faction_war_stats_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@top_faction_war_stats_url,true,args)
  template = { :yesterday_kills => "KillsYesterday", :last_week_kills => "KillsLastWeek", :total_kills => "KillsTotal",
               :yesterday_victory_points => 'VictoryPointsYesterday', :last_week_victory_points => 'VictoryPointsLastWeek', :total_victory_points => 'VictoryPointsTotal' }
  # Inject here to save 60 lines.
  characters = template.inject({}) do |h,(key,val)|
    klass = key.to_s =~ /kills/ ? Reve::Classes::CharacterFactionKills : Reve::Classes::CharacterFactionVictoryPoints
    h[key] = pull_out_top_10_data(xml,klass,'characters',val)
    h
  end
  corporations = template.inject({}) do |h,(key,val)|
    klass = key.to_s =~ /kills/ ? Reve::Classes::CorporationFactionKills : Reve::Classes::CorporationFactionVictoryPoints
    h[key] = pull_out_top_10_data(xml,klass,'corporations',val)
    h
  end
  factions = template.inject({}) do |h,(key,val)|
    klass = key.to_s =~ /kills/ ? Reve::Classes::FactionKills : Reve::Classes::FactionVictoryPoints
    h[key] = pull_out_top_10_data(xml,klass,'factions',val)
    h
  end
  Reve::Classes::FactionWarTopStats.new(characters,corporations,factions)
end

#map_jumps(opts = {}) ⇒ Object

Returns a list of the number of jumps for each system. If there are no jumps for a system it will not be included. See also Reve::Classes::MapJump



210
211
212
213
# File 'lib/reve.rb', line 210

def map_jumps(opts = {})
  compute_hash(  opts.merge(:url => @@map_jumps_url) ) ||
    process_query(Reve::Classes::MapJump,opts[:url] || @@map_jumps_url,false)
end

#map_kills(opts = {}) ⇒ Object

Returns a list of the number of kills for each system. If there are no kills for a system it will not be included. See also Reve::Classes::MapKill



217
218
219
220
# File 'lib/reve.rb', line 217

def map_kills(opts = {})
  compute_hash(  opts.merge(:url => @@map_kills_url) ) ||
    process_query(Reve::Classes::MapKill,opts[:url] || @@map_kills_url,false)
end

#member_tracking(opts = {:characterid => nil}) ⇒ Object

Does big brother tracking from api.eve-online.com/corp/MemberTracking.xml.aspx Expects:

  • characterid ( Integer | String ) - Look at players in this Character’s Corporation

See also: Reve::Classes::MemberTracking



332
333
334
335
336
337
# File 'lib/reve.rb', line 332

def member_tracking(opts = {:characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@member_tracking_url))
  return h if h
  process_query(Reve::Classes::MemberTracking,opts[:url] || @@member_tracking_url,false,args)
end

#names_to_ids(opts = {}) ⇒ Object Also known as: character_id

Convert a list of names to their ids. Expects a Hash as a parameter with these keys:

  • names ( Array ) - An Array of Names to fetch the IDs of.

See Also: character_name, Reve::Classes::Character, character_sheet



157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/reve.rb', line 157

def names_to_ids(opts = {} )
  names = opts[:names] || []
  return [] if names.empty? # No names were passed.
  opts[:names] = names.join(',')
  args = postfields(opts)
  h = compute_hash(  opts.merge(:url => @@character_id_url) )
  return h if h
  xml = process_query(nil,opts[:url] || @@character_id_url, true,opts)
  ret = []
  xml.search("//rowset/row").each do |elem|
    ret << Reve::Classes::Character.new(elem)
  end
  ret
end

#personal_assets_list(opts = { :characterid => nil }) ⇒ Object

Get a list of personal assets for the characterid. See the Reve::Classes::Asset and Reve::Classes::AssetContainer classes for attributes available.



560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
# File 'lib/reve.rb', line 560

def personal_assets_list(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_assets_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@personal_assets_url,true,args)
  assets = []
  xml.search("/eveapi/result/rowset[@name='assets']/row").each do |container|
    asset_container = Reve::Classes::AssetContainer.new(container)
    container.search("rowset[@name='contents']/row").each do |asset|
      asset_container.assets << Reve::Classes::Asset.new(asset)
    end
    assets << asset_container
  end
  assets
end

#personal_faction_war_stats(opts = { :characterid => nil }) ⇒ Object

Gets the Reve::Classes::PersonalFactionWarStat for a character. Expects:

  • characterid ( Integer | String ) - Get this character’s PersonalFactionWarStat.

See Also Reve::Classes::PersonalFactionWarStat and corporate_faction_war_stats



465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/reve.rb', line 465

def personal_faction_war_stats(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_faction_war_stats_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@personal_faction_war_stats_url,true,args)    
  elems = {}
  [ :factionID, :factionName, :enlisted, :currentRank, :highestRank, 
    :killsYesterday, :killsLastWeek, :killsTotal, :victoryPointsYesterday,
    :victoryPointsLastWeek, :victoryPointsTotal ].each do |elem|
      elems[elem.to_s] = xml.search("/eveapi/result/" + elem.to_s).first.inner_html
    end
  Reve::Classes::PersonalFactionWarParticpant.new(elems)
end

#personal_industry_jobs(opts = {:characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::PersonalIndustryJob objects.



273
274
275
276
277
278
# File 'lib/reve.rb', line 273

def personal_industry_jobs(opts = {:characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_industry_jobs_url))
  return h if h
  process_query(Reve::Classes::PersonalIndustryJob, opts[:url] || @@personal_industry_jobs_url,false,args)
end

#personal_kills(opts = { :characterid => nil }) ⇒ Object

Get the last kills for the characterid passed. Expects:

  • Hash of arguments

    • characterid ( Integer ) - The Character whose Kills to retrieve

    • beforekillid ( Integer ) - (Optional) - Return the most recent kills before this killid.



667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/reve.rb', line 667

def personal_kills(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_kills_url))
  return h if h
  xml = process_query(nil,opts[:url] || @@personal_kills_url,true,args)
  kills = []
  xml.search("/eveapi/result/rowset/row").each do |e|
    victim = Reve::Classes::KillVictim.new(e.search("victim").first) rescue next # cant find victim
    attackers = []
    losses = []
    e.search("rowset[@name='attackers']/row").each do |attacker|
      attackers << Reve::Classes::KillAttacker.new(attacker)
    end
    e.search("rowset[@name='items']/row").each do |lost_item|
      lost = Reve::Classes::KillLoss.new(lost_item)
      lost_item.search("rowset[@name='items']/row").each do |contained|
        lost.contained_losses << Reve::Classes::KillLoss.new(contained)
      end
      losses << lost
    end
    kills << Reve::Classes::Kill.new(e, victim, attackers, losses)      
  end
  kills
end

#personal_market_orders(opts = {:characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::MarketOrder objects for market orders that are up Pass the characterid of the Character to check for



256
257
258
259
260
261
# File 'lib/reve.rb', line 256

def personal_market_orders(opts = {:characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_market_orders_url))
  return h if h
  process_query(Reve::Classes::PersonalMarketOrder, opts[:url] || @@personal_market_orders_url, false, args)
end

#personal_wallet_balance(opts = { :characterid => nil }) ⇒ Object

Gets one’s own personal WalletBalance from api.eve-online.com/char/AccountBalance.xml.aspx Expects:

  • characterid ( Integer | String ) - Look at this player’s WalletBalance

See also: Reve::Classes::WalletBalance and corporate_wallet_balance



344
345
346
347
348
349
# File 'lib/reve.rb', line 344

def personal_wallet_balance(opts = { :characterid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_wallet_balance_url))
  return h if h
  process_query(Reve::Classes::WalletBalance,opts[:url] || @@personal_wallet_balance_url,false,args)
end

#personal_wallet_journal(opts = { :characterid => nil, :beforerefid => nil}) ⇒ Object

Gets one’s own personal WalletJournal list from api.eve-online.com/char/WalletJournal.xml.aspx Expects:

  • characterid ( Integer | String ) - Look at this player’s WalletJournal list

  • beforerefid ( Integer | String ) - Gets a list of WalletJournal objects from before this RefID.

See also: Reve::Classes::WalletJournal and corporate_wallet_journal



412
413
414
415
416
417
# File 'lib/reve.rb', line 412

def personal_wallet_journal(opts = { :characterid => nil, :beforerefid => nil} )
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_wallet_journal_url))
  return h if h
  process_query(Reve::Classes::WalletJournal,opts[:url] || @@personal_wallet_journal_url,false,args)
end

#personal_wallet_transactions(opts = { :characterid => nil, :beforetransid => nil }) ⇒ Object

Gets one’s own personal WalletTransaction list from api.eve-online.com/char/WalletTransactions.xml.aspx Expects:

  • characterid ( Integer | String ) - Look at this player’s WalletTransaction list

  • beforetransid ( Integer | String ) - Gets a list of WalletTransaction objects from before this Transaction ID.

See also: Reve::Classes::WalletTransaction and corporate_wallet_transactions



370
371
372
373
374
375
# File 'lib/reve.rb', line 370

def personal_wallet_transactions(opts = { :characterid => nil, :beforetransid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@personal_wallet_trans_url) )
  return h if h
  process_query(Reve::Classes::PersonalWalletTransaction,opts[:url] || @@personal_wallet_trans_url,false,args)
end

#ref_types(opts = {}) ⇒ Object

Returns a RefType list (whatever they are) from api.eve-online.com/eve/RefTypes.xml.aspx See also: Reve::Classes::RefType



239
240
241
242
# File 'lib/reve.rb', line 239

def ref_types(opts = {})
  compute_hash(  opts.merge(:url => @@reftypes_url) ) || 
      process_query(Reve::Classes::RefType,opts[:url] || @@reftypes_url,false)
end

#server_status(opts = {}) ⇒ Object

Get the server status of Tranquility as a Reve::Classes::ServerStatus object. See Also: Reve::Classes::ServerStatus



142
143
144
145
146
147
148
149
150
151
# File 'lib/reve.rb', line 142

def server_status(opts = {})
  args = postfields(opts)
  h = compute_hash(  opts.merge(:url => @@server_status_url) )
  return h if h
  xml = process_query(nil,opts[:url] || @@server_status_url,true,opts)
  Reve::Classes::ServerStatus.new(
    xml.search("/eveapi/result/serverOpen/").first.to_s,
    xml.search("/eveapi/result/onlinePlayers/").first.to_s
  )
end

#skill_in_training(opts = {:characterid => nil}) ⇒ Object

Gets the SkillInTraining from api.eve-online.com/char/SkillInTraining.xml.aspx Expects:

  • characterid ( Integer | String ) - Get the SkillInTraining for this Character

See also: Reve::Classes::SkillInTraining



608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/reve.rb', line 608

def skill_in_training(opts = {:characterid => nil})
  args = postfields(opts)
  ch = compute_hash(args.merge(:url => @@training_skill_url))
  return ch if ch
  h = {}
  xml = process_query(nil,opts[:url] || @@training_skill_url,true,args)
  xml.search("//result").each do |elem|
    for field in [ 'currentTQTime', 'trainingEndTime','trainingStartTime','trainingTypeID','trainingStartSP','trainingDestinationSP','trainingToLevel','skillInTraining' ]
      h[field] = (elem/field.intern).inner_html
    end
  end
  Reve::Classes::SkillInTraining.new(h)
end

#skill_queue(opts = {:characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::QueuedSkill for characterid api.eve-online.com/char/SkillQueue.xml.aspx Expects:

  • characterid ( Integer | String ) - Get the QueuedSkill list for this character

See also Reve::Classes::QueuedSkill



627
628
629
630
631
632
# File 'lib/reve.rb', line 627

def skill_queue(opts = {:characterid => nil})
  args = postfields(opts)
  ch = compute_hash(args.merge(:url => @@skill_queue_url))
  return ch if ch
  process_query(Reve::Classes::QueuedSkill,opts[:url] || @@skill_queue_url,false,args)
end

#skill_tree(opts = {}) ⇒ Object

Returns the SkillTree from api.eve-online.com/eve/SkillTree.xml.aspx See also: Reve::Classes::SkillTree NOTE: This doesn’t actually return a ‘tree’ yet.



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/reve.rb', line 292

def skill_tree(opts = {})
  h = compute_hash(opts.merge(:url => @@skill_tree_url) )
  return h if h
  doc = process_query(nil,opts[:url] || @@skill_tree_url,true)
  skills = []
  (doc/'rowset[@name=skills]/row').each do |skill|
    name = skill['typeName']
    type_id = skill['typeID']
    group_id = skill['groupID']
    rank = (skill/:rank).inner_html
    desc = (skill/:description).inner_html
    required_skills = []
    reqs = (skill/'rowset@name=[requiredskills]/row')
    reqs.each do |required|
      next if required.kind_of? Hpricot::Text # why is this needed? Why is this returned? How can I only get stuff with typeid and skilllevel?
      required_skills << Reve::Classes::SkillRequirement.new(required) if required['typeID'] && required['skillLevel']
    end
    required_attribs = []
    (skill/'requiredAttributes').each do |req|
      pri = doc.at(req.xpath + "/primaryAttribute")
      sec = doc.at(req.xpath + "/secondaryAttribute")
      required_attribs << Reve::Classes::PrimaryAttribute.new(pri.inner_html)
      required_attribs << Reve::Classes::SecondaryAttribute.new(sec.inner_html)
    end
    bonuses = []
    res = (skill/'rowset@name=[skillBonusCollection]/row')
    res.each do |bonus|
      next if bonus.kind_of? Hpricot::Text
      bonuses << Reve::Classes::SkillBonus.new(bonus) if bonus['bonusType'] && bonus['bonusValue']
    end
    skills << Reve::Classes::SkillTree.new(name,type_id,group_id,desc,rank,required_attribs,required_skills,bonuses)
  end
  skills
end

#sovereignty(opts = {}) ⇒ Object

Returns the Sovereignty list from api.eve-online.com/map/Sovereignty.xml.aspx See also: Reve::Classes::Sovereignty



231
232
233
234
# File 'lib/reve.rb', line 231

def sovereignty(opts = {})
  compute_hash(  opts.merge(:url => @@sovereignty_url) ) || 
    process_query(Reve::Classes::Sovereignty,opts[:url] || @@sovereignty_url,false)
end

#starbase_fuel(opts = { :characterid => nil, :starbaseid => nil }) ⇒ Object

Returns the fuel status for the Starbase whose item id is starbase_id api.eve-online.com/corp/StarbaseDetail.xml.aspx Expects:

  • characterid ( Integer | String ) - Get the Starbase associated wih this character’s Corporation

  • starbase_id ( Integer ) - Get the fuel for this Starbase. This is the Starbase’s itemid.

See also Reve::Classes::StarbaseFuel



652
653
654
655
656
657
658
659
# File 'lib/reve.rb', line 652

def starbase_fuel(opts = { :characterid => nil, :starbaseid => nil })
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@starbasedetail_url))
  return h if h
  ret = process_query(Reve::Classes::StarbaseFuel,opts[:url] || @@starbasedetail_url, false, args)
  ret.each { |r| r.starbase_id = opts[:starbaseid] }
  ret
end

#starbases(opts = { :characterid => nil}) ⇒ Object

Returns a list of Reve::Classes::Starbase for characterid’s Corporation. api.eve-online.com/corp/StarbaseList.xml.aspx Expects:

  • characterid ( Integer | String ) - Get the Starbase list for this character’s Corporation

See also Reve::Classes::Starbase



639
640
641
642
643
644
# File 'lib/reve.rb', line 639

def starbases(opts = { :characterid => nil})
  args = postfields(opts)
  h = compute_hash(args.merge(:url => @@starbases_url))
  return h if h
  process_query(Reve::Classes::Starbase,opts[:url] || @@starbases_url,false,args)
end