the-city-admin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/.autotest +9 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.rvmrc +1 -0
  5. data/.yardoc/checksums +50 -0
  6. data/.yardoc/object_types +0 -0
  7. data/.yardoc/objects/root.dat +0 -0
  8. data/.yardoc/proxy_types +0 -0
  9. data/Gemfile +11 -0
  10. data/Gemfile.lock +51 -0
  11. data/README +1 -0
  12. data/Rakefile +32 -0
  13. data/index.rb +123 -0
  14. data/lib/common.rb +163 -72
  15. data/lib/the_city_admin.rb +2 -2
  16. data/notes.txt +21 -0
  17. data/spec/api/address_list_spec.rb +0 -0
  18. data/spec/api/address_spec.rb +0 -0
  19. data/spec/api/group_address_list_spec.rb +93 -0
  20. data/spec/api/group_address_spec.rb +19 -0
  21. data/spec/api/group_checkin_list_spec.rb +93 -0
  22. data/spec/api/group_event_attendance_list_spec.rb +93 -0
  23. data/spec/api/group_export_spec.rb +19 -0
  24. data/spec/api/group_invitation_list_spec.rb +23 -0
  25. data/spec/api/group_invitation_spec.rb +19 -0
  26. data/spec/api/group_list_spec.rb +23 -0
  27. data/spec/api/group_role_list_spec.rb +23 -0
  28. data/spec/api/group_role_spec.rb +19 -0
  29. data/spec/api/group_spec.rb +19 -0
  30. data/spec/api/group_tag_list_spec.rb +23 -0
  31. data/spec/api/group_tag_spec.rb +19 -0
  32. data/spec/api/metric_list_spec.rb +22 -0
  33. data/spec/api/metric_measurement_list_spec.rb +23 -0
  34. data/spec/api/metric_measurement_spec.rb +19 -0
  35. data/spec/api/metric_spec.rb +19 -0
  36. data/spec/api/role_list_spec.rb +75 -0
  37. data/spec/api/role_spec.rb +19 -0
  38. data/spec/api/skill_list_spec.rb +76 -0
  39. data/spec/api/skilled_user_id_list_spec.rb +82 -0
  40. data/spec/api/skilled_user_list_spec.rb +82 -0
  41. data/spec/api/tag_group_list_spec.rb +72 -0
  42. data/spec/api/tag_list_spec.rb +77 -0
  43. data/spec/api/tag_spec.rb +19 -0
  44. data/spec/api/terminology_list_spec.rb +75 -0
  45. data/spec/api/terminology_spec.rb +19 -0
  46. data/spec/api/user_address_list_spec.rb +92 -0
  47. data/spec/api/user_address_spec.rb +19 -0
  48. data/spec/api/user_admin_privilege_list_spec.rb +94 -0
  49. data/spec/api/user_admin_privilege_spec.rb +19 -0
  50. data/spec/api/user_barcode_spec.rb +19 -0
  51. data/spec/api/user_family_list_spec.rb +91 -0
  52. data/spec/api/user_family_member_spec.rb +19 -0
  53. data/spec/api/user_invitation_list_spec.rb +91 -0
  54. data/spec/api/user_invitation_spec.rb +19 -0
  55. data/spec/api/user_list_spec.rb +76 -0
  56. data/spec/api/user_note_list_spec.rb +91 -0
  57. data/spec/api/user_note_spec.rb +19 -0
  58. data/spec/api/user_process_list_spec.rb +90 -0
  59. data/spec/api/user_process_spec.rb +19 -0
  60. data/spec/api/user_role_list_spec.rb +92 -0
  61. data/spec/api/user_role_spec.rb +18 -0
  62. data/spec/api/user_skill_list_spec.rb +91 -0
  63. data/spec/api/user_skill_spec.rb +19 -0
  64. data/spec/api/user_spec.rb +37 -0
  65. data/spec/api/web_hook_list_spec.rb +75 -0
  66. data/spec/api/web_hook_spec.rb +19 -0
  67. data/spec/factories/address.rb +21 -0
  68. data/spec/factories/address_list.rb +13 -0
  69. data/spec/factories/checkin.rb +35 -0
  70. data/spec/factories/checkin_list.rb +13 -0
  71. data/spec/factories/group.rb +30 -0
  72. data/spec/factories/group_address.rb +21 -0
  73. data/spec/factories/group_address_list.rb +13 -0
  74. data/spec/factories/group_checkin.rb +35 -0
  75. data/spec/factories/group_checkin_list.rb +13 -0
  76. data/spec/factories/group_event_attendance.rb +19 -0
  77. data/spec/factories/group_event_attendance_list.rb +13 -0
  78. data/spec/factories/group_export.rb +16 -0
  79. data/spec/factories/group_export_list.rb +13 -0
  80. data/spec/factories/group_role.rb +19 -0
  81. data/spec/factories/group_tag.rb +12 -0
  82. data/spec/factories/role.rb +22 -0
  83. data/spec/factories/role_list.rb +13 -0
  84. data/spec/factories/skill.rb +13 -0
  85. data/spec/factories/skill_list.rb +13 -0
  86. data/spec/factories/skilled_user_id_list.rb +13 -0
  87. data/spec/factories/skilled_user_list.rb +13 -0
  88. data/spec/factories/tag.rb +13 -0
  89. data/spec/factories/tag_group_list.rb +13 -0
  90. data/spec/factories/tag_list.rb +13 -0
  91. data/spec/factories/terminology.rb +10 -0
  92. data/spec/factories/terminology_list.rb +13 -0
  93. data/spec/factories/user.rb +51 -0
  94. data/spec/factories/user_address.rb +19 -0
  95. data/spec/factories/user_address_list.rb +13 -0
  96. data/spec/factories/user_admin_privilege.rb +11 -0
  97. data/spec/factories/user_admin_privilege_list.rb +13 -0
  98. data/spec/factories/user_barcode.rb +15 -0
  99. data/spec/factories/user_family_list.rb +13 -0
  100. data/spec/factories/user_family_member.rb +28 -0
  101. data/spec/factories/user_invitation.rb +16 -0
  102. data/spec/factories/user_invitation_list.rb +13 -0
  103. data/spec/factories/user_list.rb +13 -0
  104. data/spec/factories/user_note.rb +28 -0
  105. data/spec/factories/user_note_list.rb +13 -0
  106. data/spec/factories/user_process.rb +11 -0
  107. data/spec/factories/user_process_list.rb +13 -0
  108. data/spec/factories/user_role.rb +17 -0
  109. data/spec/factories/user_role_list.rb +13 -0
  110. data/spec/factories/user_skill.rb +10 -0
  111. data/spec/factories/user_skill_list.rb +13 -0
  112. data/spec/factories/web_hook.rb +12 -0
  113. data/spec/factories/web_hook_list.rb +13 -0
  114. data/spec/functional/the_city_admin_spec.rb +20 -0
  115. data/spec/readers/user_reader_spec.rb +7 -0
  116. data/spec/spec_helper.rb +31 -0
  117. data/spec/writers/skill_writer_spec.rb +0 -0
  118. data/spec/writers/tag_writer_spec.rb +80 -0
  119. data/spec/writers/user_writer_spec.rb +80 -0
  120. data/status.txt +187 -0
  121. data/test_scripts/addresses.rb +36 -0
  122. data/test_scripts/barcodes_checkins.rb +45 -0
  123. data/test_scripts/city_keys.rb +6 -0
  124. data/test_scripts/familes.rb +83 -0
  125. data/test_scripts/groups.rb +124 -0
  126. data/test_scripts/metrics.rb +72 -0
  127. data/test_scripts/roles.rb +94 -0
  128. data/test_scripts/skills.rb +55 -0
  129. data/test_scripts/tags.rb +71 -0
  130. data/test_scripts/terminology.rb +62 -0
  131. data/test_scripts/users.rb +325 -0
  132. data/test_scripts/webhooks.rb +57 -0
  133. data/thecity_admin_api.gemspec +39 -0
  134. data/thecity_headers.rb +27 -0
  135. metadata +238 -3
@@ -0,0 +1,71 @@
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
+ require 'ruby-debug'
9
+ require File.dirname(__FILE__) + '/../lib/the_city_admin.rb'
10
+
11
+ require File.dirname(__FILE__) + '/city_keys.rb'
12
+ include CityKeys
13
+
14
+ TheCity::AdminApi.connect(KEY, TOKEN)
15
+
16
+
17
+ puts "------------------------------------"
18
+
19
+ tag_list = TheCity::TagList.new
20
+ if tag_list.empty?
21
+ puts "No tags in list"
22
+ else
23
+ puts "Tags: #{tag_list.count}"
24
+ end
25
+
26
+ tag = TheCity::Tag.new
27
+ tag.name = 'Z Cool Guy'
28
+ if tag.save
29
+ puts "Tag created (#{tag.id})"
30
+ else
31
+ puts "Failed to create tag: #{tag.error_messages.join(', ')}"
32
+ end
33
+
34
+
35
+ tag_list2 = TheCity::TagList.new
36
+ if tag_list2.empty?
37
+ puts "No tags in list"
38
+ else
39
+ puts "Tags: #{tag_list2.count}"
40
+ end
41
+
42
+ tag2 = TheCity::Tag.load_by_id(tag.id)
43
+ if tag2.nil?
44
+ puts "Tag not found"
45
+ else
46
+ puts "Tag found by ID #{tag.id}"
47
+ end
48
+
49
+
50
+ tag.name = 'Z Some Guy'
51
+ if tag.save
52
+ puts "Tag updated (#{tag.id})"
53
+ else
54
+ puts "Failed to update tag: #{tag.error_messages.join(', ')}"
55
+ end
56
+
57
+
58
+ if tag.delete
59
+ puts "Tag #{tag.id} deleted"
60
+ else
61
+ puts "Unable to delete tag #{tag.id}: #{tag.error_messages.join(', ')}"
62
+ end
63
+
64
+ tag_list3 = TheCity::TagList.new
65
+ if tag_list3.empty?
66
+ puts "No tags in list"
67
+ else
68
+ puts "Tags: #{tag_list3.count}"
69
+ end
70
+
71
+ puts "####################################"
@@ -0,0 +1,62 @@
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
+ require 'ruby-debug'
9
+ require File.dirname(__FILE__) + '/../lib/the_city_admin.rb'
10
+
11
+ require File.dirname(__FILE__) + '/city_keys.rb'
12
+ include CityKeys
13
+
14
+ TheCity::AdminApi.connect(KEY, TOKEN)
15
+
16
+
17
+ puts "------------------------------------"
18
+
19
+ term_list = TheCity::TerminologyList.new
20
+ if term_list.empty?
21
+ puts "No terms in list"
22
+ else
23
+ puts "Terms: #{term_list.count}"
24
+ end
25
+
26
+
27
+ term = TheCity::Terminology.load_by_term('CG')
28
+ if term.nil?
29
+ puts "Terminology not found"
30
+ else
31
+ puts "Terminology found by term: #{term.term}::#{term.label}"
32
+ end
33
+
34
+ term.label = 'Dog'
35
+ if term.save
36
+ puts "Term updated (#{term.term})"
37
+ else
38
+ puts "Failed to create term: #{term.error_messages.join(', ')}"
39
+ end
40
+
41
+ term2 = TheCity::Terminology.load_by_term('CG')
42
+ if term2.nil?
43
+ puts "Terminology not found"
44
+ else
45
+ puts "Terminology found by term: #{term2.term}::#{term2.label}"
46
+ end
47
+
48
+ term2.label = 'Community'
49
+ if term2.save
50
+ puts "Term updated (#{term2.term})"
51
+ else
52
+ puts "Failed to create term: #{term2.error_messages.join(', ')}"
53
+ end
54
+
55
+ term3 = TheCity::Terminology.load_by_term('CG')
56
+ if term3.nil?
57
+ puts "Terminology not found"
58
+ else
59
+ puts "Terminology found by term: #{term3.term}::#{term3.label}"
60
+ end
61
+
62
+ puts "####################################"
@@ -0,0 +1,325 @@
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
+ require 'ruby-debug'
9
+ require File.dirname(__FILE__) + '/../lib/the_city_admin.rb'
10
+
11
+ require File.dirname(__FILE__) + '/city_keys.rb'
12
+ include CityKeys
13
+
14
+ TheCity::AdminApi.connect(KEY, TOKEN)
15
+
16
+
17
+ user_list = TheCity::UserList.new
18
+
19
+ user = user_list.first
20
+ puts user.full_name
21
+
22
+
23
+ # user_count = TheCity::UserCount.new
24
+ # puts user_count.count
25
+ # puts user_count.filter
26
+
27
+ # user_count = TheCity::UserCount.new({:filter => :created_in_the_last_7_Days})
28
+ # puts user_count.count
29
+ # puts user_count.filter
30
+
31
+ offline_user = TheCity::User.new
32
+ offline_user.first = 'Wes'
33
+ offline_user.last = 'Hays'
34
+ offline_user.email = 'someguy@someplace.org'
35
+
36
+
37
+ if offline_user.save
38
+ puts "Offline user created (#{offline_user.id})"
39
+ else
40
+ puts "Failed to create offline user: #{offline_user.error_messages.join(', ')}"
41
+ end
42
+
43
+ offline_user.first = 'Anna'
44
+ offline_user.email = 'somegal@someplace.org'
45
+
46
+ if offline_user.save
47
+ puts "Offline user updated (#{offline_user.id})"
48
+ else
49
+ puts "Failed to create offline user: #{offline_user.error_messages.join(', ')}"
50
+ end
51
+
52
+ offline_user2 = TheCity::User.load_by_id(offline_user.id)
53
+ puts "Loaded user first name: #{offline_user2.first}::#{offline_user2.email}"
54
+
55
+ if offline_user.delete
56
+ puts "OfflineUser #{offline_user.id} deleted"
57
+ else
58
+ puts "Unable to delete offline user #{offline_user.id}: #{offline_user.error_messages.join(', ')}"
59
+ end
60
+
61
+
62
+ # puts "------------------------------------"
63
+
64
+ # if user.addresses.empty?
65
+ # puts "No addresses for user"
66
+ # else
67
+ # puts "Addresses: #{user.addresses.size}"
68
+ # end
69
+
70
+ # address = TheCity::UserAddress.new
71
+ # address.user_id = user.id
72
+ # address.location_type = 'Work'
73
+ # address.street = '445 S. Virginia St'
74
+ # address.city = 'Reno'
75
+ # address.state = 'NV'
76
+ # address.zipcode = '89501'
77
+ # if address.save
78
+ # puts "Address saved: #{address.id}"
79
+ # else
80
+ # puts "** Unable to save new address"
81
+ # end
82
+
83
+
84
+ # address.street = '663 Beckwourth Dr'
85
+
86
+ # if address.save
87
+ # puts "Address updated: #{address.id}"
88
+ # else
89
+ # puts "** Unable to update address: #{address.error_messages.join(', ')}"
90
+ # end
91
+
92
+
93
+ # if user.addresses(true).empty?
94
+ # puts "No addresses for user"
95
+ # else
96
+ # puts "Addresses: #{user.addresses.size}"
97
+ # end
98
+
99
+ # user.addresses.each do |address|
100
+ # if address.delete
101
+ # puts "Address #{address.id} deleted"
102
+ # else
103
+ # puts "Unable to delete address #{address.id}: #{address.error_messages.join(', ')}"
104
+ # end
105
+ # end
106
+
107
+ # if user.addresses(true).empty?
108
+ # puts "No addresses for user"
109
+ # else
110
+ # puts "Addresses: #{user.addresses.size}"
111
+ # end
112
+
113
+
114
+ # puts "------------------------------------"
115
+
116
+ # if user.admin_privileges.empty?
117
+ # puts "No admin admin privileges for user"
118
+ # else
119
+ # puts "Admin privileges: #{user.admin_privileges.count}"
120
+ # end
121
+
122
+ # privilege = TheCity::UserAdminPrivilege.new
123
+ # privilege.title = TheCity::UserAdminPrivilege::Permissions[:resource_admin]
124
+ # privilege.user_id = user.id
125
+
126
+ # if privilege.save
127
+ # puts "Privilege saved"
128
+ # else
129
+ # puts "** Unable to save new privilege: #{privilege.error_messages.join(', ')}"
130
+ # end
131
+
132
+ # if user.admin_privileges(true).empty?
133
+ # puts "No admin admin privileges for user"
134
+ # else
135
+ # puts "Admin privileges: #{user.admin_privileges.count}"
136
+ # end
137
+
138
+ # puts "------------------------------------"
139
+
140
+ # # puts "ADD CHECK FOR FAMILY"
141
+ # if user.family.empty?
142
+ # puts "No family members for user"
143
+ # else
144
+ # puts user.family.names
145
+ # end
146
+
147
+ # puts "------------------------------------"
148
+
149
+ # if user.invitations.empty?
150
+ # puts "No invitations for user"
151
+ # else
152
+ # puts "Invitations: #{user.invitations.count}"
153
+ # end
154
+
155
+ # group_list = TheCity::GroupList.new
156
+ # group = group_list.first
157
+
158
+ # invitation = TheCity::UserInvitation.new
159
+ # invitation.user_id = user.id
160
+ # invitation.email = user.email
161
+ # invitation.group_id = group.id
162
+ # invitation.custom_message = 'Please join the group!'
163
+
164
+ # if invitation.save
165
+ # puts "Invitation saved"
166
+ # else
167
+ # puts "** Unable to save new invitation: #{invitation.error_messages.join(', ')}"
168
+ # end
169
+
170
+ # if user.invitations(true).empty?
171
+ # puts "No invitations for user"
172
+ # else
173
+ # puts "Invitations: #{user.invitations.count}"
174
+ # end
175
+
176
+ # puts "------------------------------------"
177
+
178
+ # if user.notes.empty?
179
+ # puts "No notes for user"
180
+ # else
181
+ # puts "Notes: #{user.notes.count}"
182
+ # end
183
+
184
+
185
+ # note = TheCity::UserNote.new
186
+ # note.author_id = user.id
187
+ # note.body = "Hello World"
188
+ # note.visible_to = [TheCity::UserNote::VisibleTo[:process_user], TheCity::UserNote::VisibleTo[:resource_admin]]
189
+
190
+ # if note.save
191
+ # puts "Note saved"
192
+ # else
193
+ # puts "** Unable to save new note"
194
+ # end
195
+
196
+ # if user.notes(true).empty?
197
+ # puts "No notes for user"
198
+ # else
199
+ # puts "Notes: #{user.notes.count}"
200
+ # end
201
+
202
+ # user.notes.each do |note|
203
+ # if note.delete
204
+ # puts "Note #{note.id} deleted"
205
+ # else
206
+ # puts "Unable to delete note #{note.id}: #{note.error_messages.join(', ')}"
207
+ # end
208
+ # end
209
+
210
+ # if user.notes(true).empty?
211
+ # puts "No notes for user"
212
+ # else
213
+ # puts "Notes: #{user.notes.count}"
214
+ # end
215
+
216
+
217
+ # puts "------------------------------------"
218
+
219
+ # if user.processes.empty?
220
+ # puts "No processes for user"
221
+ # else
222
+ # puts "Processes: #{user.processes.count}"
223
+ # end
224
+
225
+ # puts "------------------------------------"
226
+
227
+ # group_list = TheCity::GroupList.new
228
+ # group = group_list.first
229
+
230
+ # offline_user = TheCity::User.new
231
+ # offline_user.first = 'Wes'
232
+ # offline_user.last = 'Hays'
233
+ # offline_user.email = 'someguy@someplace.org'
234
+ # if offline_user.save
235
+ # puts "Offline user created #{offline_user.id}"
236
+ # else
237
+ # puts "Failed to create offline user: #{offline_user.error_messages.join(', ')}"
238
+ # end
239
+
240
+ # if offline_user.roles.empty?
241
+ # puts "No roles for user"
242
+ # else
243
+ # puts "Roles: #{offline_user.roles.size}"
244
+ # end
245
+
246
+ # role = TheCity::UserRole.new
247
+ # role.group_type = TheCity::UserRole::GroupTypes[:campus]
248
+ # role.title = TheCity::UserRole::Titles[:leader]
249
+ # role.user_id = offline_user.id
250
+ # role.group_id = group.id
251
+
252
+ # if role.save
253
+ # puts "Role saved"
254
+ # else
255
+ # puts "** Unable to save new role: #{role.error_messages.join(', ')}"
256
+ # end
257
+
258
+ # if offline_user.roles(true).empty?
259
+ # puts "No roles for user"
260
+ # else
261
+ # puts "Roles: #{user.roles.size}"
262
+ # end
263
+
264
+ # offline_user.roles.each do |role|
265
+ # if role.delete
266
+ # puts "Role #{role.id} deleted"
267
+ # else
268
+ # puts "Unable to delete role #{role.id}: #{role.error_messages.join(', ')}"
269
+ # end
270
+ # end
271
+
272
+ # if offline_user.roles(true).empty?
273
+ # puts "No roles for user"
274
+ # else
275
+ # puts "Roles: #{user.roles.size}"
276
+ # end
277
+
278
+ # if offline_user.delete
279
+ # puts "OfflineUser #{offline_user.id} deleted"
280
+ # else
281
+ # puts "Unable to delete offline user #{offline_user.id}: #{offline_user.error_messages.join(', ')}"
282
+ # end
283
+
284
+ # puts "------------------------------------"
285
+
286
+ # if user.skills.empty?
287
+ # puts "No skills for user"
288
+ # else
289
+ # puts "Skills: #{user.skills.size}"
290
+ # end
291
+
292
+ # skill_list = TheCity::SkillList.new
293
+ # skill = skill_list.first
294
+
295
+ # user_skill = TheCity::UserSkill.new
296
+ # user_skill.user_id = user.id
297
+ # user_skill.skill_id = skill.id
298
+
299
+ # if user_skill.save
300
+ # puts "User Skill saved"
301
+ # else
302
+ # puts "** Unable to save new user skill (#{user_skill.skill_id}): #{user_skill.error_messages.join(', ')}"
303
+ # end
304
+
305
+ # if user.skills(true).empty?
306
+ # puts "No skills for user"
307
+ # else
308
+ # puts "Skills: #{user.skills.size}"
309
+ # end
310
+
311
+ # user.skills(true).each do |us|
312
+ # if us.delete
313
+ # puts "User Skill #{us.name} deleted"
314
+ # else
315
+ # puts "Unable to delete user skill #{us.name}: #{us.error_messages.join(', ')}"
316
+ # end
317
+ # end
318
+
319
+ # if user.skills(true).empty?
320
+ # puts "No skills for user"
321
+ # else
322
+ # puts "Skills: #{user.skills.size}"
323
+ # end
324
+
325
+ puts "####################################"