dsander-reve 0.0.131 → 0.0.132

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/reve/classes.rb +18 -0
  2. data/lib/reve.rb +23 -5
  3. data/test/test_reve.rb +20 -0
  4. metadata +3 -3
data/lib/reve/classes.rb CHANGED
@@ -159,6 +159,24 @@ module Reve #:nodoc:
159
159
  end
160
160
  end
161
161
 
162
+ # Represents a single Contact
163
+ # Attributes:
164
+ # * contact_id ( Fixnum ) - ID of the Contact.
165
+ # * contact_name ( String ) - Name of the belligerant Contact.
166
+ # * in_watchlist ( Fixnum ) - Whether or not the Contact is in the watchlist.
167
+ # * standing ( String ) - The standing of the Contact.
168
+ class PersonalContact
169
+ attr_reader :contact_id, :contact_name, :in_watchlist, :standing
170
+ def initialize(elem) #:nodoc:
171
+ @contact_id = elem['contactID'].to_i
172
+ @contact_name = elem['contactName']
173
+ @in_watchlist = elem['inWatchlist'] == 'True' ? true : false
174
+ @standing = elem['standing'].to_i
175
+ end
176
+ end
177
+
178
+ class CorporateContact < PersonalContact; end
179
+
162
180
  # The status of a System with regards to a FactionWar. Who controls what
163
181
  # and what System is contested
164
182
  # Attributes:
data/lib/reve.rb CHANGED
@@ -89,9 +89,11 @@ module Reve
89
89
  @@corp_member_medals_url = 'http://api.eve-online.com/corp/MemberMedals.xml.aspx'
90
90
  @@server_status_url = 'http://api.eve-online.com/Server/ServerStatus.xml.aspx'
91
91
  @@research_url = 'http://api.eve-online.com/char/Research.xml.aspx'
92
- @@personal_notification_url = 'http://api.eve-online.com/char/Notifications.xml.aspx'
93
- @@personal_mailing_lists_url = 'http://api.eve-online.com/char/mailinglists.xml.aspx'
94
- @@personal_mail_messages_url = 'http://api.eve-online.com/char/MailMessages.xml.aspx'
92
+ @@personal_notification_url = 'http://api.eve-online.com/char/Notifications.xml.aspx'
93
+ @@personal_mailing_lists_url = 'http://api.eve-online.com/char/mailinglists.xml.aspx'
94
+ @@personal_mail_messages_url = 'http://api.eve-online.com/char/MailMessages.xml.aspx'
95
+ @@personal_contacts_url = 'http://api.eve-online.com/char/ContactList.xml.aspx'
96
+ @@corporate_contacts_url = 'http://api.eve-online.com/corp/ContactList.xml.aspx'
95
97
 
96
98
  cattr_accessor :character_sheet_url, :training_skill_url, :characters_url, :personal_wallet_journal_url,
97
99
  :corporate_wallet_journal_url, :personal_wallet_trans_url, :corporate_wallet_trans_url,
@@ -106,7 +108,7 @@ module Reve
106
108
  :certificate_tree_url, :character_medals_url, :corporate_medals_url,
107
109
  :corp_member_medals_url, :server_status_url, :skill_queue_url, :corporation_member_security_url,
108
110
  :personal_notification_url, :personal_mailing_lists_url, :personal_mail_messages_url,
109
- :research_url
111
+ :research_url, :personal_contacts_url, :corporate_contacts_url
110
112
 
111
113
 
112
114
  attr_accessor :key, :userid, :charid
@@ -291,7 +293,23 @@ module Reve
291
293
  return h if h
292
294
  process_query(Reve::Classes::CorporateIndustryJob, opts[:url] || @@corporate_industry_jobs_url,false,args)
293
295
  end
294
-
296
+
297
+ # Returns a list of Reve::Classes::PersonalContact objects.
298
+ def personal_contacts(opts = {:characterid => nil})
299
+ args = postfields(opts)
300
+ h = compute_hash(args.merge(:url => @@personal_contacts_url))
301
+ return h if h
302
+ process_query(Reve::Classes::PersonalContact, opts[:url] || @@personal_contacts_url,false,args)
303
+ end
304
+
305
+ # Returns a list of Reve::Classes::CorporateContact objects.
306
+ def corporate_contacts(opts = {:characterid => nil})
307
+ args = postfields(opts)
308
+ h = compute_hash(args.merge(:url => @@corporate_contacts_url))
309
+ return h if h
310
+ process_query(Reve::Classes::PersonalContact, opts[:url] || @@corporate_contacts_url,false,args)
311
+ end
312
+
295
313
  # Returns the SkillTree from
296
314
  # http://api.eve-online.com/eve/SkillTree.xml.aspx
297
315
  # See also: Reve::Classes::SkillTree
data/test/test_reve.rb CHANGED
@@ -295,6 +295,26 @@ class TestReve < Test::Unit::TestCase
295
295
  end
296
296
  end
297
297
 
298
+ def test_personal_contacts_clean
299
+ Reve::API.personal_contacts_url = XML_BASE + 'char_contacts.xml'
300
+ contacts = @api.personal_contacts
301
+ assert_equal(2, contacts.length)
302
+ assert_equal("Hirento Raikkanen", contacts.first.contact_name )
303
+ assert_equal(3010913, contacts.first.contact_id )
304
+ assert_equal(false, contacts.first.in_watchlist )
305
+ assert_equal(0, contacts.first.standing )
306
+ end
307
+
308
+ def test_corporate_contacts_clean
309
+ Reve::API.corporate_contacts_url = XML_BASE + 'char_contacts.xml'
310
+ contacts = @api.corporate_contacts
311
+ assert_equal(2, contacts.length)
312
+ assert_equal("Hirento Raikkanen", contacts.first.contact_name )
313
+ assert_equal(3010913, contacts.first.contact_id )
314
+ assert_equal(false, contacts.first.in_watchlist )
315
+ assert_equal(0, contacts.first.standing )
316
+ end
317
+
298
318
  def test_faction_war_system_stats_clean(skip_preamble = false,stats = nil)
299
319
  Reve::API.faction_war_occupancy_url = XML_BASE + 'map_facwarsystems.xml'
300
320
  unless skip_preamble # not best practice but will get the job done!
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 131
9
- version: 0.0.131
8
+ - 132
9
+ version: 0.0.132
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lisa Seelye
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2009-12-04 00:00:00 +00:00
17
+ date: 2010-09-07 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency