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
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class SkillList
3
+ class SkillList < 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
  # SkillList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::SkillListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::SkillListReader.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 SkilledUserIdList
3
+ class SkilledUserIdList < 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
  # SkilledUserList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::SkilledUserIdListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::SkilledUserIdListReader.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 SkilledUserList
3
+ class SkilledUserList < 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
  # SkilledUserList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::SkilledUserListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::SkilledUserListReader.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 TagGroupList
3
+ class TagGroupList < 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
  # SkilledUserList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::TagGroupListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::TagGroupListReader.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']
data/lib/api/tag_list.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class TagList
3
+ class TagList < 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
  # TagList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::TagListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::TagListReader.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 TerminologyList
3
+ class TerminologyList < 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
  # TerminologyList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::TerminologyListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::TerminologyListReader.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']
data/lib/api/user.rb CHANGED
@@ -42,17 +42,24 @@ module TheCity
42
42
  :external_id_3,
43
43
  :middle,
44
44
  :email,
45
- :marital_status
45
+ :marital_status,
46
+
47
+ :addresses, # include_addresses
48
+
49
+ :family_id, # include_family
50
+ :family_role, # include_family
51
+ :external_family_id # include_family
46
52
 
47
53
 
48
54
  # Loads the user by the specified ID.
49
55
  #
50
56
  # @param user_id The ID of the user to load.
57
+ # @param options (optional) Options for including more information.
51
58
  #
52
59
  # Returns a new {User} object.
53
- def self.load_by_id(user_id)
54
- reader = UserReader.new(user_id)
55
- self.new(reader.load_feed)
60
+ def self.load_by_id(user_id, options = {})
61
+ reader = UserReader.new(user_id, options)
62
+ self.new(reader.load_feed, options)
56
63
  rescue
57
64
  nil
58
65
  end
@@ -66,7 +73,10 @@ module TheCity
66
73
  @writer_object = UserWriter
67
74
  initialize_from_json_object(json_data) unless json_data.nil?
68
75
 
69
- @address_list = nil
76
+ unless options[:include_addresses].nil?
77
+ @addresses = @addresses.collect { |addr| UserAddress.new(addr.merge({:user_id => self.id})) }
78
+ end
79
+
70
80
  @family_list = nil
71
81
  @note_list = nil
72
82
  @role_list = nil
@@ -77,6 +87,15 @@ module TheCity
77
87
  end
78
88
 
79
89
 
90
+ # The first with the nickname in parens if available.
91
+ #
92
+ # @return A string of the first name with the nickname if available.
93
+ def first_name_with_nickname
94
+ with_nickname = self.nickname.to_s.empty? ? nil : "(#{self.nickname})"
95
+ [self.first, with_nickname].compact.join(' ')
96
+ end
97
+
98
+
80
99
  # The first and last name of the user.
81
100
  #
82
101
  # @return A string of the full name
@@ -86,24 +105,6 @@ module TheCity
86
105
  end
87
106
 
88
107
 
89
- # Address information.
90
- #
91
- # @param force_reload (optional) Data is cached on first call. If data needs to be
92
- # reloaded from the server on a subsequent call then
93
- # a force reload is need.
94
- #
95
- # @return [UserAddressList]
96
- def addresses(force_reload = false)
97
- unless force_reload
98
- return @address_list unless @address_list.nil?
99
- end
100
- return nil unless self.id
101
-
102
- @address_list = UserAddressList.new({:user_id => self.id})
103
- return @address_list
104
- end
105
-
106
-
107
108
  # The family information.
108
109
  #
109
110
  # @return [UserFamilyList]
@@ -2,18 +2,19 @@ module TheCity
2
2
 
3
3
  class UserAddress < ApiObject
4
4
 
5
- tc_attr_accessor :city,
6
- :created_at,
7
- :id,
8
- :latitude,
9
- :location_type,
10
- :longitude,
11
- :privacy,
12
- :state,
13
- :street,
14
- :updated_at,
15
- :user_id,
16
- :zipcode
5
+ tc_attr_accessor :user_id,
6
+ :id,
7
+ :city,
8
+ :state,
9
+ :street,
10
+ :street2,
11
+ :zipcode,
12
+ :longitude,
13
+ :latitude,
14
+ :location_type,
15
+ :privacy,
16
+ :created_at,
17
+ :updated_at
17
18
 
18
19
 
19
20
  # Constructor.
@@ -23,6 +24,10 @@ module TheCity
23
24
  @writer_object = UserAddressWriter
24
25
  initialize_from_json_object(json_data) unless json_data.nil?
25
26
  end
27
+
28
+ def home_address?
29
+ self.location_type.downcase == 'home'
30
+ end
26
31
 
27
32
  end
28
33
 
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserAddressList
3
+ class UserAddressList < 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
  # UserAddressList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- reader = options[:reader] || TheCity::UserAddressListReader.new(options)
26
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:reader] = TheCity::UserAddressListReader.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 UserAdminPrivilegeList
3
+ class UserAdminPrivilegeList < 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,9 +20,10 @@ module TheCity
22
20
  # UserAdminPrivilegeList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserAdminPrivilegeListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserAdminPrivilegeListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @total_entries = @json_data['total_entries']
30
29
  @total_pages = @json_data['total_pages']
@@ -1,6 +1,6 @@
1
1
  module TheCity
2
2
 
3
- class UserFamilyList
3
+ class UserFamilyList < ApiList
4
4
 
5
5
  include Enumerable
6
6
 
@@ -22,9 +22,10 @@ module TheCity
22
22
  # UserFamilyList.new({:user_id => 12345, :page => 2})
23
23
  #
24
24
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserFamilyListReader.new(options)
27
- @json_data = reader.load_feed
25
+ @options = options
26
+ @options[:page] ||= 1
27
+ @options[:reader] = TheCity::UserFamilyListReader.new(@options) if @options[:reader].nil?
28
+ @json_data = @options[:reader].load_feed
28
29
 
29
30
  @id = @json_data['id']
30
31
  @created_at = @json_data['created_at']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserInvitationList
3
+ class UserInvitationList < 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,9 +20,10 @@ module TheCity
22
20
  # UserInvitationList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserInvitationListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserInvitationListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @total_entries = @json_data['total_entries']
30
29
  @total_pages = @json_data['total_pages']
data/lib/api/user_list.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserList
3
+ class UserList < 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
  # UserList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::UserListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options.clone
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::UserListReader.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 UserNoteList
3
+ class UserNoteList < 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,9 +20,10 @@ module TheCity
22
20
  # UserNoteList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserNoteListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserNoteListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @total_entries = @json_data['total_entries']
30
29
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserProcessAnswerList
3
+ class UserProcessAnswerList < 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.
@@ -23,9 +21,10 @@ module TheCity
23
21
  # UserProcessAnswerList.new({:user_id => 12345, :process_id => 23456, :page => 2})
24
22
  #
25
23
  def initialize(options = {})
26
- options[:page] ||= 1
27
- reader = options[:reader] || TheCity::UserProcessAnswerListReader.new(options)
28
- @json_data = reader.load_feed
24
+ @options = options
25
+ @options[:page] ||= 1
26
+ @options[:reader] = TheCity::UserProcessAnswerListReader.new(@options) if @options[:reader].nil?
27
+ @json_data = @options[:reader].load_feed
29
28
 
30
29
  @total_entries = @json_data['total_entries']
31
30
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserProcessList
3
+ class UserProcessList < 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,9 +20,10 @@ module TheCity
22
20
  # UserProcessList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserProcessListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserProcessListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @total_entries = @json_data['total_entries']
30
29
  @total_pages = @json_data['total_pages']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserRoleList
3
+ class UserRoleList < 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,9 +20,10 @@ module TheCity
22
20
  # UserRoleList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserRoleListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserRoleListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @user_id = options[:user_id] || nil
30
29
  @total_entries = @json_data['total_entries']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class UserSkillList
3
+ class UserSkillList < 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,9 +20,10 @@ module TheCity
22
20
  # UserSkillList.new({:user_id => 12345, :page => 2})
23
21
  #
24
22
  def initialize(options = {})
25
- options[:page] ||= 1
26
- reader = options[:reader] || TheCity::UserSkillListReader.new(options)
27
- @json_data = reader.load_feed
23
+ @options = options
24
+ @options[:page] ||= 1
25
+ @options[:reader] = TheCity::UserSkillListReader.new(@options) if @options[:reader].nil?
26
+ @json_data = @options[:reader].load_feed
28
27
 
29
28
  @user_id = options[:user_id] || nil
30
29
  @total_entries = @json_data['total_entries']
@@ -1,11 +1,9 @@
1
1
  module TheCity
2
2
 
3
- class WebHookList
3
+ class WebHookList < 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
  # UserSkillList.new({:page => 2})
22
20
  #
23
21
  def initialize(options = {})
24
- options[:page] ||= 1
25
- reader = options[:reader] || TheCity::WebHookListReader.new(options)
26
- @json_data = reader.load_feed
22
+ @options = options
23
+ @options[:page] ||= 1
24
+ @options[:reader] = TheCity::WebHookListReader.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']
data/lib/auto_load.rb CHANGED
@@ -3,6 +3,7 @@ module TheCity
3
3
  require THECITY_LIB_DIR + '/exceptions.rb'
4
4
 
5
5
  api_path = THECITY_LIB_DIR + '/api/'
6
+ require api_path + 'api_list.rb'
6
7
  require api_path + 'api_object.rb'
7
8
  Dir["#{api_path}/*.rb"].each { |f| require(f) }
8
9
 
@@ -7,15 +7,19 @@ module TheCity
7
7
  # @param options A hash of options for requesting data from the server.
8
8
  # @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
9
9
  def initialize(options = {}, cacher = nil)
10
- page = options[:page] || 1
10
+ options[:page] ||= 1
11
11
  #@class_key = "address_list_#{page}"
12
12
  @url_data_path = "/addresses"
13
- @url_data_params = {:page => page}
13
+ @url_data_params = white_list_options(options)
14
14
 
15
15
  # The object to store and load the cache.
16
16
  @cacher = cacher unless cacher.nil?
17
17
  end
18
18
 
19
+ def white_list_options
20
+ white_list = [:page]
21
+ options.clone.delete_if { |key, value| !white_list.include?(key) }
22
+ end
19
23
  end
20
24
 
21
25
  end
@@ -7,15 +7,20 @@ module TheCity
7
7
  # @param options A hash of options for requesting data from the server.
8
8
  # @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
9
9
  def initialize(options = {}, cacher = nil)
10
- page = options[:page] || 1
10
+ options[:page] ||= 1
11
11
  #@class_key = "checkin_list_#{page}"
12
12
  @url_data_path = "/checkins"
13
- @url_data_params = {:page => page}
13
+ @url_data_params = white_list_options(options)
14
14
 
15
15
  # The object to store and load the cache.
16
16
  @cacher = cacher unless cacher.nil?
17
17
  end
18
18
 
19
+ def white_list_options
20
+ white_list = [:page, :include_checked_out]
21
+ options.clone.delete_if { |key, value| !white_list.include?(key) }
22
+ end
23
+
19
24
  end
20
25
 
21
26
  end
@@ -7,14 +7,19 @@ module TheCity
7
7
  # @param options A hash of options for requesting data from the server.
8
8
  # @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
9
9
  def initialize(options = {}, cacher = nil)
10
- page = options[:page] || 1
10
+ options[:page] ||= 1
11
11
  #@class_key = "groups_#{group_id}_exports"
12
12
  @url_data_path = "/donations/exports"
13
- @url_data_params = {:page => page}
13
+ @url_data_params = white_list_options(options)
14
14
 
15
15
  # The object to store and load the cache.
16
16
  @cacher = cacher unless cacher.nil?
17
17
  end
18
+
19
+ def white_list_options
20
+ white_list = [:page]
21
+ options.clone.delete_if { |key, value| !white_list.include?(key) }
22
+ end
18
23
 
19
24
  end
20
25