the-city-admin 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.rvmrc +1 -1
  3. data/examples/city_keys.rb +2 -2
  4. data/examples/donations.rb +33 -0
  5. data/lib/api/address_list.rb +4 -5
  6. data/lib/api/api_list.rb +50 -0
  7. data/lib/api/checkin_list.rb +4 -5
  8. data/lib/api/donation.rb +36 -18
  9. data/lib/api/donation_export_list.rb +4 -5
  10. data/lib/api/donation_list.rb +5 -7
  11. data/lib/api/fund_list.rb +5 -7
  12. data/lib/api/group_address_list.rb +4 -5
  13. data/lib/api/group_checkin_list.rb +4 -5
  14. data/lib/api/group_event_attendance_list.rb +4 -5
  15. data/lib/api/group_export.rb +1 -0
  16. data/lib/api/group_export_list.rb +4 -5
  17. data/lib/api/group_invitation_list.rb +4 -5
  18. data/lib/api/group_list.rb +5 -7
  19. data/lib/api/group_role_list.rb +4 -5
  20. data/lib/api/group_tag_list.rb +4 -5
  21. data/lib/api/invitation_list.rb +4 -5
  22. data/lib/api/metric_list.rb +5 -6
  23. data/lib/api/metric_measurement_list.rb +5 -6
  24. data/lib/api/pledge_list.rb +5 -7
  25. data/lib/api/role_list.rb +5 -6
  26. data/lib/api/skill_list.rb +5 -6
  27. data/lib/api/skilled_user_id_list.rb +5 -6
  28. data/lib/api/skilled_user_list.rb +5 -6
  29. data/lib/api/tag_group_list.rb +5 -6
  30. data/lib/api/tag_list.rb +5 -6
  31. data/lib/api/terminology_list.rb +5 -6
  32. data/lib/api/user.rb +24 -23
  33. data/lib/api/user_address.rb +17 -12
  34. data/lib/api/user_address_list.rb +4 -5
  35. data/lib/api/user_admin_privilege_list.rb +5 -6
  36. data/lib/api/user_family_list.rb +5 -4
  37. data/lib/api/user_invitation_list.rb +5 -6
  38. data/lib/api/user_list.rb +5 -6
  39. data/lib/api/user_note_list.rb +5 -6
  40. data/lib/api/user_process_answer_list.rb +5 -6
  41. data/lib/api/user_process_list.rb +5 -6
  42. data/lib/api/user_role_list.rb +5 -6
  43. data/lib/api/user_skill_list.rb +5 -6
  44. data/lib/api/web_hook_list.rb +5 -6
  45. data/lib/auto_load.rb +1 -0
  46. data/lib/readers/address_list_reader.rb +6 -2
  47. data/lib/readers/checkin_list_reader.rb +7 -2
  48. data/lib/readers/donation_export_list_reader.rb +7 -2
  49. data/lib/readers/donation_list_reader.rb +6 -1
  50. data/lib/readers/fund_list_reader.rb +6 -1
  51. data/lib/readers/group_address_list_reader.rb +8 -3
  52. data/lib/readers/group_checkin_list_reader.rb +8 -3
  53. data/lib/readers/group_event_attendance_list_reader.rb +8 -3
  54. data/lib/readers/group_export_list_reader.rb +8 -3
  55. data/lib/readers/group_invitation_list_reader.rb +8 -3
  56. data/lib/readers/group_list_reader.rb +6 -1
  57. data/lib/readers/group_role_list_reader.rb +8 -3
  58. data/lib/readers/group_tag_list_reader.rb +8 -3
  59. data/lib/readers/invitation_list_reader.rb +7 -2
  60. data/lib/readers/metric_list_reader.rb +7 -2
  61. data/lib/readers/metric_measurement_list_reader.rb +10 -3
  62. data/lib/readers/pledge_list_reader.rb +6 -1
  63. data/lib/readers/role_list_reader.rb +8 -3
  64. data/lib/readers/skill_list_reader.rb +7 -2
  65. data/lib/readers/skilled_user_id_list_reader.rb +10 -4
  66. data/lib/readers/skilled_user_list_reader.rb +10 -4
  67. data/lib/readers/tag_group_list_reader.rb +9 -4
  68. data/lib/readers/tag_list_reader.rb +7 -2
  69. data/lib/readers/terminology_list_reader.rb +7 -2
  70. data/lib/readers/user_address_list_reader.rb +8 -3
  71. data/lib/readers/user_admin_privilege_list_reader.rb +8 -3
  72. data/lib/readers/user_family_list_reader.rb +8 -2
  73. data/lib/readers/user_invitation_list_reader.rb +8 -3
  74. data/lib/readers/user_list_reader.rb +8 -6
  75. data/lib/readers/user_note_list_reader.rb +8 -3
  76. data/lib/readers/user_process_answer_list_reader.rb +9 -4
  77. data/lib/readers/user_process_list_reader.rb +8 -3
  78. data/lib/readers/user_reader.rb +1 -1
  79. data/lib/readers/user_role_list_reader.rb +8 -3
  80. data/lib/readers/user_skill_list_reader.rb +8 -3
  81. data/lib/readers/web_hook_list_reader.rb +7 -2
  82. data/thecity_admin_api.gemspec +1 -1
  83. metadata +7 -9
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9aedbac713fcae49330b49c38fecdf4aaa92b354
4
+ data.tar.gz: f444b6444d42e4aae42bbbf7e6969f0357faa9e3
5
+ SHA512:
6
+ metadata.gz: 676155448c9e815bb08fc898124024dbb703b9692133418e63b8b3c48190a589bc60335f1fffa552cfb8c32876deaff6578da1c0f45846cf046e88ef01d49ac3
7
+ data.tar.gz: c92561c0a923239e26f1586ebd82054ce5573c0065a35bee269b1413d5c52ae534c0ce614312b9d2822d52a36be34d3878b2e2aa5eda451b7f688aa600f5df2b
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm ruby-1.9.2-p320@admin-api
1
+ rvm ruby-1.9.2-p320@admin-api --create
@@ -1,6 +1,6 @@
1
1
  module CityKeys
2
2
 
3
- KEY = '66c59e2ee24553e7237259e30b4c17365681b95c'
4
- TOKEN = 'a9ae4af3c3e80102'
3
+ KEY = '**** YOUR CITY API KEY ****'
4
+ TOKEN = '**** YOUR CITY API TOKEN ****'
5
5
 
6
6
  end
@@ -0,0 +1,33 @@
1
+ # *******************************************
2
+ # This is a demo file to show usage.
3
+ #
4
+ # @package TheCity::Admin
5
+ # @authors Robbie Lieb <robbie@onthecity.org>, Wes Hays <wes@onthecity.org>
6
+ # *******************************************
7
+
8
+ TCA_ENV = 'development'
9
+ THE_CITY_ADMIN_PATH = 'http://api.devthecity.org:9292'
10
+ key = '6910f0d2654c7704ceb3af054f52294db67b23ee'
11
+ token = '3eaf0b8b967dde78'
12
+
13
+
14
+ require 'ruby-debug'
15
+ require File.dirname(__FILE__) + '/../lib/the_city_admin.rb'
16
+
17
+ require File.dirname(__FILE__) + '/city_keys.rb'
18
+ include CityKeys
19
+
20
+ TheCity::AdminApi.connect(KEY, TOKEN)
21
+
22
+
23
+ de_list = TheCity::DonationList.new
24
+ de_list.each do |item|
25
+ puts "DonationExport: #{item.inspect}"
26
+ end
27
+
28
+
29
+ puts "------------------------------------"
30
+
31
+ puts "####################################"
32
+
33
+
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class AddressList
3
+ class AddressList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -21,8 +19,9 @@ module TheCity
21
19
  # AddressList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- reader = options[:reader] || TheCity::AddressListReader.new(options)
25
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:reader] = TheCity::AddressListReader.new(@options) if @options[:reader].nil?
24
+ @json_data = @options[:reader].load_feed
26
25
 
27
26
  @total_entries = @json_data['total_entries']
28
27
  @total_pages = @json_data['total_pages']
@@ -0,0 +1,50 @@
1
+ module TheCity
2
+
3
+ # This class is the base class for all TheCity objects and is meant to be inherited.
4
+ #
5
+ class ApiList
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ def self.load(options = {})
10
+ self.new(options)
11
+ end
12
+
13
+ # Checks if there is a next page.
14
+ #
15
+ # @return true for yes, false for no.
16
+ def next_page?
17
+ @current_page < @total_pages
18
+ end
19
+
20
+ # Gets the next page of results.
21
+ #
22
+ # @return [UserList] or nil if there are no more pages.
23
+ def next_page
24
+ return nil unless next_page?
25
+ self.class.new( @options.merge({:page => @options[:page]+1}) )
26
+ end
27
+
28
+ # Loads the next page of results and replaces self with the results.
29
+ #
30
+ # @return true on success or otherwise false.
31
+ def next_page!
32
+ return false unless next_page?
33
+
34
+ @options[:page] += 1
35
+ @options[:reader] = @options[:reader].class.new(@options)
36
+ @json_data = @options[:reader].load_feed
37
+
38
+ @total_entries = @json_data['total_entries']
39
+ @total_pages = @json_data['total_pages']
40
+ @per_page = @json_data['per_page']
41
+ @current_page = @json_data['current_page']
42
+
43
+ return true
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class CheckinList
3
+ class CheckinList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -21,8 +19,9 @@ module TheCity
21
19
  # CheckinList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- reader = options[:reader] || TheCity::CheckinListReader.new(options)
25
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:reader] = TheCity::CheckinListReader.new(@options) if @options[:reader].nil?
24
+ @json_data = @options[:reader].load_feed
26
25
 
27
26
  @total_entries = @json_data['total_entries']
28
27
  @total_pages = @json_data['total_pages']
data/lib/api/donation.rb CHANGED
@@ -1,25 +1,37 @@
1
1
  module TheCity
2
2
 
3
3
  class Donation < ApiObject
4
- tc_attr_accessor :id,
5
- :user_id,
6
- :fund_id,
4
+ tc_attr_accessor :split_id,
5
+ :external_id,
6
+ :amount,
7
+ :id,
8
+ :date,
9
+ :note,
10
+ :instrument,
11
+ :state,
7
12
  :batch_id,
8
- :amount,
9
- :instrument_type,
10
- :donation_state,
11
- :donation_date,
12
- :created_at,
13
- :updated_at,
14
- :fund_name,
15
- :primary_campus_id,
16
- :user_name,
17
- :user_type,
18
- :user_api_url,
19
- :user_is_member,
20
- :spouse_id,
21
- :spouse_name,
22
- :spouse_is_member
13
+ :user,
14
+ :fund
15
+
16
+ # tc_attr_accessor :id,
17
+ # :user_id,
18
+ # :fund_id,
19
+ # :batch_id,
20
+ # :amount,
21
+ # :instrument_type,
22
+ # :donation_state,
23
+ # :donation_date,
24
+ # :created_at,
25
+ # :updated_at,
26
+ # :fund_name,
27
+ # :primary_campus_id,
28
+ # :user_name,
29
+ # :user_type,
30
+ # :user_api_url,
31
+ # :user_is_member,
32
+ # :spouse_id,
33
+ # :spouse_name,
34
+ # :spouse_is_member
23
35
 
24
36
  # Loads the donation by the specified ID.
25
37
  #
@@ -44,6 +56,12 @@ module TheCity
44
56
  end
45
57
  end
46
58
 
59
+ # Convert amount to cents.
60
+ #
61
+ # @return Amount in cents.
62
+ def amount_cents
63
+ (self.amount.to_f * 100).round.to_i
64
+ end
47
65
  end
48
66
 
49
67
  end
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class DonationExportList
3
+ class DonationExportList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # DonationExportList.new({:donation_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::DonationExportListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::DonationExportListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,12 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class DonationList
3
+ class DonationList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
-
10
7
  # Constructor.
11
8
  #
12
9
  # @param options A hash of options for loading the list.
@@ -23,9 +20,10 @@ module TheCity
23
20
  # DonationList.new({:page => 2})
24
21
  #
25
22
  def initialize(options = {})
26
- options[:page] ||= 1
27
- reader = options[:reader] || TheCity::DonationListReader.new(options)
28
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::DonationListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
29
27
 
30
28
  @total_entries = @json_data['total_entries']
31
29
  @total_pages = @json_data['total_pages']
data/lib/api/fund_list.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class FundList
3
+ class FundList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
-
10
7
  # Constructor.
11
8
  #
12
9
  # @param options A hash of options for loading the list.
@@ -23,9 +20,10 @@ module TheCity
23
20
  # FundList.new({:page => 2})
24
21
  #
25
22
  def initialize(options = {})
26
- options[:page] ||= 1
27
- reader = options[:reader] || TheCity::FundListReader.new(options)
28
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::FundListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
29
27
 
30
28
  @total_entries = @json_data['total_entries']
31
29
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupAddressList
3
+ class GroupAddressList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupAddressList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupAddressListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupAddressListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupCheckinList
3
+ class GroupCheckinList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupCheckinList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupCheckinListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupCheckinListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupEventAttendanceList
3
+ class GroupEventAttendanceList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupEventAttendanceList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupEventAttendanceListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupEventAttendanceListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -15,6 +15,7 @@ module TheCity
15
15
  # @param group_export_id The ID of the group export to load.
16
16
  # @param options A hash of options for requesting data from the server.
17
17
  # :: group_id is required
18
+ # :: user_type is optional. It can be "Users" or "OfflineUsers"
18
19
  #
19
20
  # Returns a new {GroupExport} object.
20
21
  def self.load_by_id(group_export_id, options = {})
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupExportList
3
+ class GroupExportList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupExportList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupExportListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupExportListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupInvitationList
3
+ class GroupInvitationList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupInvitationList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupInvitationListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupInvitationListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,12 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupList
3
+ class GroupList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
-
10
7
  # Constructor.
11
8
  #
12
9
  # @param options A hash of options for loading the list.
@@ -23,9 +20,10 @@ module TheCity
23
20
  # UserList.new({:page => 2})
24
21
  #
25
22
  def initialize(options = {})
26
- options[:page] ||= 1
27
- reader = options[:reader] || TheCity::GroupListReader.new(options)
28
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::GroupListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
29
27
 
30
28
  @total_entries = @json_data['total_entries']
31
29
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupRoleList
3
+ class GroupRoleList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupRoleList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupRoleListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupRoleListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class GroupTagList
3
+ class GroupTagList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # GroupTagList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::GroupTagListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::GroupTagListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class InvitationList
3
+ class InvitationList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -22,8 +20,9 @@ module TheCity
22
20
  # InvitationList.new({:group_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::InvitationListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::InvitationListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class MetricList
3
+ class MetricList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of filters for loading the list.
@@ -31,9 +29,10 @@ module TheCity
31
29
  # MetricList.new({:page => 2, :filter => :contact_updated_in_the_last_2_weeks})
32
30
  #
33
31
  def initialize(options = {})
34
- options[:page] ||= 1
35
- reader = options[:reader] || TheCity::MetricListReader.new(options)
36
- @json_data = reader.load_feed
32
+ @options = options
33
+ @options[:page] ||= 1
34
+ @options[:reader] = TheCity::MetricListReader.new(@options) if @options[:reader].nil?
35
+ @json_data = @options[:reader].load_feed
37
36
 
38
37
  @total_entries = @json_data['total_entries']
39
38
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class MetricMeasurementList
3
+ class MetricMeasurementList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the list.
@@ -21,9 +19,10 @@ module TheCity
21
19
  # MetricMeasurementList.new({:group_id => 12345, :page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::MetricMeasurementListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::MetricMeasurementListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']
@@ -1,12 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class PledgeList
3
+ class PledgeList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
-
10
7
  # Constructor.
11
8
  #
12
9
  # @param options A hash of options for loading the list.
@@ -23,9 +20,10 @@ module TheCity
23
20
  # PledgeList.new({:page => 2})
24
21
  #
25
22
  def initialize(options = {})
26
- options[:page] ||= 1
27
- reader = options[:reader] || TheCity::PledgeListReader.new(options)
28
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::PledgeListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
29
27
 
30
28
  @total_entries = @json_data['total_entries']
31
29
  @total_pages = @json_data['total_pages']
data/lib/api/role_list.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class RoleList
3
+ class RoleList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :total_entries, :total_pages, :per_page, :current_page
8
-
9
7
  # Constructor.
10
8
  #
11
9
  # @param options A hash of options for loading the skill list.
@@ -21,9 +19,10 @@ module TheCity
21
19
  # RoleList.new(reader, {:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::RoleListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::RoleListReader.new(@options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
27
26
 
28
27
  @total_entries = @json_data['total_entries']
29
28
  @total_pages = @json_data['total_pages']