the-city-admin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. data/lib/api/address.rb +51 -0
  2. data/lib/api/address_list.rb +62 -0
  3. data/lib/api/api_object.rb +100 -0
  4. data/lib/api/barcode.rb +43 -0
  5. data/lib/api/checkin.rb +37 -0
  6. data/lib/api/checkin_list.rb +62 -0
  7. data/lib/api/family.rb +47 -0
  8. data/lib/api/family_member.rb +28 -0
  9. data/lib/api/group.rb +162 -0
  10. data/lib/api/group_address.rb +31 -0
  11. data/lib/api/group_address_list.rb +63 -0
  12. data/lib/api/group_checkin.rb +36 -0
  13. data/lib/api/group_checkin_list.rb +63 -0
  14. data/lib/api/group_event_attendance.rb +28 -0
  15. data/lib/api/group_event_attendance_list.rb +63 -0
  16. data/lib/api/group_export.rb +22 -0
  17. data/lib/api/group_export_list.rb +63 -0
  18. data/lib/api/group_invitation.rb +26 -0
  19. data/lib/api/group_invitation_list.rb +63 -0
  20. data/lib/api/group_list.rb +74 -0
  21. data/lib/api/group_role.rb +27 -0
  22. data/lib/api/group_role_list.rb +62 -0
  23. data/lib/api/group_tag.rb +20 -0
  24. data/lib/api/group_tag_list.rb +62 -0
  25. data/lib/api/metric.rb +50 -0
  26. data/lib/api/metric_list.rb +72 -0
  27. data/lib/api/metric_measurement.rb +29 -0
  28. data/lib/api/metric_measurement_list.rb +62 -0
  29. data/lib/api/role.rb +43 -0
  30. data/lib/api/role_list.rb +73 -0
  31. data/lib/api/skill.rb +21 -0
  32. data/lib/api/skill_list.rb +73 -0
  33. data/lib/api/skilled_user_id_list.rb +73 -0
  34. data/lib/api/skilled_user_list.rb +73 -0
  35. data/lib/api/tag.rb +32 -0
  36. data/lib/api/tag_group_list.rb +73 -0
  37. data/lib/api/tag_list.rb +73 -0
  38. data/lib/api/terminology.rb +32 -0
  39. data/lib/api/terminology_list.rb +73 -0
  40. data/lib/api/user.rb +207 -0
  41. data/lib/api/user_address.rb +31 -0
  42. data/lib/api/user_address_list.rb +62 -0
  43. data/lib/api/user_admin_privilege.rb +28 -0
  44. data/lib/api/user_admin_privilege_list.rb +63 -0
  45. data/lib/api/user_barcode.rb +20 -0
  46. data/lib/api/user_count.rb +40 -0
  47. data/lib/api/user_family_list.rb +71 -0
  48. data/lib/api/user_family_member.rb +28 -0
  49. data/lib/api/user_invitation.rb +26 -0
  50. data/lib/api/user_invitation_list.rb +63 -0
  51. data/lib/api/user_list.rb +72 -0
  52. data/lib/api/user_note.rb +31 -0
  53. data/lib/api/user_note_list.rb +63 -0
  54. data/lib/api/user_process.rb +21 -0
  55. data/lib/api/user_process_list.rb +63 -0
  56. data/lib/api/user_role.rb +34 -0
  57. data/lib/api/user_role_list.rb +74 -0
  58. data/lib/api/user_skill.rb +22 -0
  59. data/lib/api/user_skill_list.rb +74 -0
  60. data/lib/api/web_hook.rb +34 -0
  61. data/lib/api/web_hook_list.rb +74 -0
  62. data/lib/auto_load.rb +23 -0
  63. data/lib/cachers/cache_adapter.rb +50 -0
  64. data/lib/cachers/file/json_cache.rb +135 -0
  65. data/lib/common.rb +124 -0
  66. data/lib/exceptions.rb +5 -0
  67. data/lib/readers/address_list_reader.rb +21 -0
  68. data/lib/readers/address_reader.rb +22 -0
  69. data/lib/readers/api_reader.rb +28 -0
  70. data/lib/readers/checkin_list_reader.rb +21 -0
  71. data/lib/readers/checkin_reader.rb +22 -0
  72. data/lib/readers/family_reader.rb +21 -0
  73. data/lib/readers/group_address_list_reader.rb +25 -0
  74. data/lib/readers/group_checkin_list_reader.rb +25 -0
  75. data/lib/readers/group_event_attendance_list_reader.rb +25 -0
  76. data/lib/readers/group_export_list_reader.rb +25 -0
  77. data/lib/readers/group_invitation_list_reader.rb +23 -0
  78. data/lib/readers/group_list_reader.rb +25 -0
  79. data/lib/readers/group_reader.rb +21 -0
  80. data/lib/readers/group_role_list_reader.rb +23 -0
  81. data/lib/readers/group_tag_list_reader.rb +23 -0
  82. data/lib/readers/metric_list_reader.rb +22 -0
  83. data/lib/readers/metric_measurement_list_reader.rb +21 -0
  84. data/lib/readers/metric_measurement_reader.rb +22 -0
  85. data/lib/readers/metric_reader.rb +21 -0
  86. data/lib/readers/role_list_reader.rb +21 -0
  87. data/lib/readers/skill_list_reader.rb +21 -0
  88. data/lib/readers/skilled_user_id_list_reader.rb +22 -0
  89. data/lib/readers/skilled_user_list_reader.rb +22 -0
  90. data/lib/readers/tag_group_list_reader.rb +22 -0
  91. data/lib/readers/tag_list_reader.rb +22 -0
  92. data/lib/readers/tag_reader.rb +22 -0
  93. data/lib/readers/terminology_list_reader.rb +22 -0
  94. data/lib/readers/terminology_reader.rb +22 -0
  95. data/lib/readers/user_address_list_reader.rb +25 -0
  96. data/lib/readers/user_admin_privilege_list_reader.rb +23 -0
  97. data/lib/readers/user_count_reader.rb +32 -0
  98. data/lib/readers/user_family_list_reader.rb +24 -0
  99. data/lib/readers/user_invitation_list_reader.rb +23 -0
  100. data/lib/readers/user_list_reader.rb +25 -0
  101. data/lib/readers/user_note_list_reader.rb +23 -0
  102. data/lib/readers/user_process_list_reader.rb +23 -0
  103. data/lib/readers/user_reader.rb +24 -0
  104. data/lib/readers/user_role_list_reader.rb +23 -0
  105. data/lib/readers/user_skill_list_reader.rb +23 -0
  106. data/lib/readers/web_hook_list_reader.rb +21 -0
  107. data/lib/the_city_admin.rb +82 -0
  108. data/lib/writers/api_writer.rb +54 -0
  109. data/lib/writers/family_writer.rb +25 -0
  110. data/lib/writers/group_address_writer.rb +32 -0
  111. data/lib/writers/group_writer.rb +25 -0
  112. data/lib/writers/metric_measurement_writer.rb +25 -0
  113. data/lib/writers/metric_writer.rb +29 -0
  114. data/lib/writers/skill_writer.rb +25 -0
  115. data/lib/writers/tag_writer.rb +27 -0
  116. data/lib/writers/terminology_writer.rb +19 -0
  117. data/lib/writers/user_address_writer.rb +32 -0
  118. data/lib/writers/user_admin_privilege_writer.rb +24 -0
  119. data/lib/writers/user_invitation_writer.rb +23 -0
  120. data/lib/writers/user_note_writer.rb +25 -0
  121. data/lib/writers/user_role_writer.rb +28 -0
  122. data/lib/writers/user_skill_writer.rb +23 -0
  123. data/lib/writers/user_writer.rb +46 -0
  124. data/lib/writers/web_hook_writer.rb +20 -0
  125. metadata +184 -0
data/lib/api/role.rb ADDED
@@ -0,0 +1,43 @@
1
+ module TheCity
2
+
3
+ class Role < ApiObject
4
+
5
+ GroupTypes = {:cg => 'CG', :service => 'Service', :campus => 'Campus'}
6
+
7
+ Titles = {:leader => 'Leader', :manager => 'Manager',
8
+ :volunteer => 'Volunteer', :participant => 'Participant'}
9
+
10
+
11
+ tc_attr_accessor :group_name,
12
+ :created_at,
13
+ :group_api_url,
14
+ :title,
15
+ :group_type,
16
+ :user_api_url,
17
+ :id,
18
+ :user_type,
19
+ :group_id,
20
+ :user_id,
21
+ :last_engaged,
22
+ :user_name,
23
+ :active
24
+
25
+ # Constructor.
26
+ #
27
+ # @param json_data JSON data of the group tag.
28
+ def initialize(json_data)
29
+ @writer_object = TagWriter
30
+ initialize_from_json_object(json_data)
31
+ end
32
+
33
+ def save
34
+ raise 'Role does not have a save method'
35
+ end
36
+
37
+ def delete
38
+ raise 'Role does not have a delete method'
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,73 @@
1
+ module TheCity
2
+
3
+ class RoleList
4
+
5
+ include Enumerable
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ # Constructor.
10
+ #
11
+ # @param options A hash of options for loading the skill list.
12
+ #
13
+ # Options:
14
+ # :page - The page number to get.
15
+ # :reader - The Reader to use to load the data.
16
+ #
17
+ #
18
+ # Examples:
19
+ # RoleList.new(reader, {:page => 3})
20
+ #
21
+ # RoleList.new(reader, {:page => 2})
22
+ #
23
+ def initialize(options = {})
24
+ options[:page] ||= 1
25
+ reader = options[:reader] || TheCity::RoleListReader.new(options)
26
+ @json_data = reader.load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the roles in the list.
36
+ #
37
+ # @return array of role names.
38
+ def all_roles
39
+ return [] if @json_data['roles'].nil?
40
+ @json_data['roles'].collect { |role| role['title'] }
41
+ end
42
+ alias :roles :all_roles
43
+
44
+
45
+ # Get the specified role.
46
+ #
47
+ # @param index The index of the role to get.
48
+ #
49
+ # @return [Role]
50
+ def [](index)
51
+ Role.new( @json_data['roles'][index] ) if @json_data['roles'][index]
52
+ end
53
+
54
+
55
+ # This method is needed for Enumerable.
56
+ def each &block
57
+ @json_data['roles'].each{ |role| yield( Role.new(role) )}
58
+ end
59
+
60
+
61
+ # Alias the count method
62
+ alias :size :count
63
+
64
+ # Checks if the list is empty.
65
+ #
66
+ # @return True on empty, false otherwise.
67
+ def empty?
68
+ @json_data['roles'].empty?
69
+ end
70
+
71
+ end
72
+
73
+ end
data/lib/api/skill.rb ADDED
@@ -0,0 +1,21 @@
1
+ module TheCity
2
+
3
+ class Skill < ApiObject
4
+
5
+ tc_attr_accessor :id,
6
+ :name,
7
+ :created_at
8
+
9
+ # Constructor.
10
+ #
11
+ # @param json_data (optional) JSON data of the Skill.
12
+ def initialize(json_data = nil)
13
+ @writer_object = SkillWriter
14
+ initialize_from_json_object(json_data) unless json_data.nil?
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+
21
+
@@ -0,0 +1,73 @@
1
+ module TheCity
2
+
3
+ class SkillList
4
+
5
+ include Enumerable
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ # Constructor.
10
+ #
11
+ # @param options A hash of options for loading the skill list.
12
+ #
13
+ # Options:
14
+ # :page - The page number to get.
15
+ # :reader - The Reader to use to load the data.
16
+ #
17
+ #
18
+ # Examples:
19
+ # SkillList.new
20
+ #
21
+ # SkillList.new({:page => 2})
22
+ #
23
+ def initialize(options = {})
24
+ options[:page] ||= 1
25
+ reader = options[:reader] || TheCity::SkillListReader.new(options)
26
+ @json_data = reader.load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the skills in the list.
36
+ #
37
+ # @return array of skill names.
38
+ def all_skills
39
+ return [] if @json_data['skills'].nil?
40
+ @json_data['skills'].collect { |skill| skill['name'] }
41
+ end
42
+ alias :skills :all_skills
43
+
44
+
45
+ # Get the specified skill.
46
+ #
47
+ # @param index The index of the skill to get.
48
+ #
49
+ # @return [Skill]
50
+ def [](index)
51
+ Skill.new( @json_data['skills'][index] ) if @json_data['skills'][index]
52
+ end
53
+
54
+
55
+ # This method is needed for Enumerable.
56
+ def each &block
57
+ @json_data['skills'].each{ |skill| yield( Skill.new(skill) )}
58
+ end
59
+
60
+
61
+ # Alias the count method
62
+ alias :size :count
63
+
64
+ # Checks if the list is empty.
65
+ #
66
+ # @return True on empty, false otherwise.
67
+ def empty?
68
+ @json_data['skills'].empty?
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,73 @@
1
+ module TheCity
2
+
3
+ class SkilledUserIdList
4
+
5
+ include Enumerable
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ # Constructor.
10
+ #
11
+ # @param options A hash of options for loading the list.
12
+ #
13
+ # Options:
14
+ # :skill_id - The skill ID to load the user for. (Required)
15
+ # :page - The page number to get.
16
+ #
17
+ #
18
+ # Examples:
19
+ # SkilledUserList.new
20
+ #
21
+ # SkilledUserList.new({:page => 2})
22
+ #
23
+ def initialize(options = {})
24
+ options[:page] ||= 1
25
+ reader = options[:reader] || TheCity::SkilledUserIdListReader.new(options)
26
+ @json_data = reader.load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the user ids in the list.
36
+ #
37
+ # @return array of user ids.
38
+ def all_user_ids
39
+ return [] if @json_data['user_ids'].nil?
40
+ @json_data['user_ids'].collect { |user_id| user_id }
41
+ end
42
+ alias :user_ids :all_user_ids
43
+
44
+
45
+ # Get the specified skill.
46
+ #
47
+ # @param index The index of the skill to get.
48
+ #
49
+ # @return [User]
50
+ def [](index)
51
+ @json_data['user_ids'][index] if @json_data['user_ids'][index]
52
+ end
53
+
54
+
55
+ # This method is needed for Enumerable.
56
+ def each &block
57
+ @json_data['user_ids'].each{ |user_id| yield( user_id )}
58
+ end
59
+
60
+
61
+ # Alias the count method
62
+ alias :size :count
63
+
64
+ # Checks if the list is empty.
65
+ #
66
+ # @return True on empty, false otherwise.
67
+ def empty?
68
+ @json_data['user_ids'].empty?
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,73 @@
1
+ module TheCity
2
+
3
+ class SkilledUserList
4
+
5
+ include Enumerable
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ # Constructor.
10
+ #
11
+ # @param options A hash of options for loading the list.
12
+ #
13
+ # Options:
14
+ # :skill_id - The skill ID to load the user for. (Required)
15
+ # :page - The page number to get.
16
+ #
17
+ #
18
+ # Examples:
19
+ # SkilledUserList.new
20
+ #
21
+ # SkilledUserList.new({:page => 2})
22
+ #
23
+ def initialize(options = {})
24
+ options[:page] ||= 1
25
+ reader = options[:reader] || TheCity::SkilledUserListReader.new(options)
26
+ @json_data = reader.load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the users in the list.
36
+ #
37
+ # @return array of skill names.
38
+ def all_users
39
+ return [] if @json_data['users'].nil?
40
+ @json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }
41
+ end
42
+ alias :users :all_users
43
+
44
+
45
+ # Get the specified skill.
46
+ #
47
+ # @param index The index of the skill to get.
48
+ #
49
+ # @return [User]
50
+ def [](index)
51
+ User.new( @json_data['users'][index] ) if @json_data['users'][index]
52
+ end
53
+
54
+
55
+ # This method is needed for Enumerable.
56
+ def each &block
57
+ @json_data['users'].each{ |user| yield( User.new(user) )}
58
+ end
59
+
60
+
61
+ # Alias the count method
62
+ alias :size :count
63
+
64
+ # Checks if the list is empty.
65
+ #
66
+ # @return True on empty, false otherwise.
67
+ def empty?
68
+ @json_data['users'].empty?
69
+ end
70
+
71
+ end
72
+
73
+ end
data/lib/api/tag.rb ADDED
@@ -0,0 +1,32 @@
1
+ module TheCity
2
+
3
+ class Tag < ApiObject
4
+
5
+ tc_attr_accessor :id,
6
+ :name,
7
+ :created_at
8
+
9
+
10
+ # Loads the tag by the specified ID.
11
+ #
12
+ # @param tag_id The ID of the tag to load.
13
+ #
14
+ # Returns a new {Tag} object.
15
+ def self.load_by_id(tag_id)
16
+ reader = TagReader.new(tag_id)
17
+ self.new(reader.load_feed)
18
+ rescue
19
+ nil
20
+ end
21
+
22
+ # Constructor.
23
+ #
24
+ # @param json_data (optional) JSON data of the Tag.
25
+ def initialize(json_data = nil)
26
+ @writer_object = TagWriter
27
+ initialize_from_json_object(json_data) unless json_data.nil?
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,73 @@
1
+ module TheCity
2
+
3
+ class TagGroupList
4
+
5
+ include Enumerable
6
+
7
+ attr_reader :total_entries, :total_pages, :per_page, :current_page
8
+
9
+ # Constructor.
10
+ #
11
+ # @param options A hash of options for loading the list.
12
+ #
13
+ # Options:
14
+ # :tag_id - The tag ID to load the groups for. (Required)
15
+ # :page - The page number to get.
16
+ #
17
+ #
18
+ # Examples:
19
+ # SkilledUserList.new
20
+ #
21
+ # SkilledUserList.new({:page => 2})
22
+ #
23
+ def initialize(options = {})
24
+ options[:page] ||= 1
25
+ reader = options[:reader] || TheCity::TagGroupListReader.new(options)
26
+ @json_data = reader.load_feed
27
+
28
+ @total_entries = @json_data['total_entries']
29
+ @total_pages = @json_data['total_pages']
30
+ @per_page = @json_data['per_page']
31
+ @current_page = @json_data['current_page']
32
+ end
33
+
34
+
35
+ # All the tags in the list.
36
+ #
37
+ # @return array of group names.
38
+ def all_groups
39
+ return [] if @json_data['groups'].nil?
40
+ @json_data['groups'].collect { |group| group['name'] }
41
+ end
42
+ alias :groups :all_groups
43
+
44
+
45
+ # Get the specified tag.
46
+ #
47
+ # @param index The index of the tag to get.
48
+ #
49
+ # @return [TagGroup]
50
+ def [](index)
51
+ Group.new( @json_data['groups'][index] ) if @json_data['groups'][index]
52
+ end
53
+
54
+
55
+ # This method is needed for Enumerable.
56
+ def each &block
57
+ @json_data['groups'].each{ |group| yield( Group.new(group) )}
58
+ end
59
+
60
+
61
+ # Alias the count method
62
+ alias :size :count
63
+
64
+ # Checks if the list is empty.
65
+ #
66
+ # @return True on empty, false otherwise.
67
+ def empty?
68
+ @json_data['groups'].empty?
69
+ end
70
+
71
+ end
72
+
73
+ end