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.
- data/.autotest +9 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.yardoc/checksums +50 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +51 -0
- data/README +1 -0
- data/Rakefile +32 -0
- data/index.rb +123 -0
- data/lib/common.rb +163 -72
- data/lib/the_city_admin.rb +2 -2
- data/notes.txt +21 -0
- data/spec/api/address_list_spec.rb +0 -0
- data/spec/api/address_spec.rb +0 -0
- data/spec/api/group_address_list_spec.rb +93 -0
- data/spec/api/group_address_spec.rb +19 -0
- data/spec/api/group_checkin_list_spec.rb +93 -0
- data/spec/api/group_event_attendance_list_spec.rb +93 -0
- data/spec/api/group_export_spec.rb +19 -0
- data/spec/api/group_invitation_list_spec.rb +23 -0
- data/spec/api/group_invitation_spec.rb +19 -0
- data/spec/api/group_list_spec.rb +23 -0
- data/spec/api/group_role_list_spec.rb +23 -0
- data/spec/api/group_role_spec.rb +19 -0
- data/spec/api/group_spec.rb +19 -0
- data/spec/api/group_tag_list_spec.rb +23 -0
- data/spec/api/group_tag_spec.rb +19 -0
- data/spec/api/metric_list_spec.rb +22 -0
- data/spec/api/metric_measurement_list_spec.rb +23 -0
- data/spec/api/metric_measurement_spec.rb +19 -0
- data/spec/api/metric_spec.rb +19 -0
- data/spec/api/role_list_spec.rb +75 -0
- data/spec/api/role_spec.rb +19 -0
- data/spec/api/skill_list_spec.rb +76 -0
- data/spec/api/skilled_user_id_list_spec.rb +82 -0
- data/spec/api/skilled_user_list_spec.rb +82 -0
- data/spec/api/tag_group_list_spec.rb +72 -0
- data/spec/api/tag_list_spec.rb +77 -0
- data/spec/api/tag_spec.rb +19 -0
- data/spec/api/terminology_list_spec.rb +75 -0
- data/spec/api/terminology_spec.rb +19 -0
- data/spec/api/user_address_list_spec.rb +92 -0
- data/spec/api/user_address_spec.rb +19 -0
- data/spec/api/user_admin_privilege_list_spec.rb +94 -0
- data/spec/api/user_admin_privilege_spec.rb +19 -0
- data/spec/api/user_barcode_spec.rb +19 -0
- data/spec/api/user_family_list_spec.rb +91 -0
- data/spec/api/user_family_member_spec.rb +19 -0
- data/spec/api/user_invitation_list_spec.rb +91 -0
- data/spec/api/user_invitation_spec.rb +19 -0
- data/spec/api/user_list_spec.rb +76 -0
- data/spec/api/user_note_list_spec.rb +91 -0
- data/spec/api/user_note_spec.rb +19 -0
- data/spec/api/user_process_list_spec.rb +90 -0
- data/spec/api/user_process_spec.rb +19 -0
- data/spec/api/user_role_list_spec.rb +92 -0
- data/spec/api/user_role_spec.rb +18 -0
- data/spec/api/user_skill_list_spec.rb +91 -0
- data/spec/api/user_skill_spec.rb +19 -0
- data/spec/api/user_spec.rb +37 -0
- data/spec/api/web_hook_list_spec.rb +75 -0
- data/spec/api/web_hook_spec.rb +19 -0
- data/spec/factories/address.rb +21 -0
- data/spec/factories/address_list.rb +13 -0
- data/spec/factories/checkin.rb +35 -0
- data/spec/factories/checkin_list.rb +13 -0
- data/spec/factories/group.rb +30 -0
- data/spec/factories/group_address.rb +21 -0
- data/spec/factories/group_address_list.rb +13 -0
- data/spec/factories/group_checkin.rb +35 -0
- data/spec/factories/group_checkin_list.rb +13 -0
- data/spec/factories/group_event_attendance.rb +19 -0
- data/spec/factories/group_event_attendance_list.rb +13 -0
- data/spec/factories/group_export.rb +16 -0
- data/spec/factories/group_export_list.rb +13 -0
- data/spec/factories/group_role.rb +19 -0
- data/spec/factories/group_tag.rb +12 -0
- data/spec/factories/role.rb +22 -0
- data/spec/factories/role_list.rb +13 -0
- data/spec/factories/skill.rb +13 -0
- data/spec/factories/skill_list.rb +13 -0
- data/spec/factories/skilled_user_id_list.rb +13 -0
- data/spec/factories/skilled_user_list.rb +13 -0
- data/spec/factories/tag.rb +13 -0
- data/spec/factories/tag_group_list.rb +13 -0
- data/spec/factories/tag_list.rb +13 -0
- data/spec/factories/terminology.rb +10 -0
- data/spec/factories/terminology_list.rb +13 -0
- data/spec/factories/user.rb +51 -0
- data/spec/factories/user_address.rb +19 -0
- data/spec/factories/user_address_list.rb +13 -0
- data/spec/factories/user_admin_privilege.rb +11 -0
- data/spec/factories/user_admin_privilege_list.rb +13 -0
- data/spec/factories/user_barcode.rb +15 -0
- data/spec/factories/user_family_list.rb +13 -0
- data/spec/factories/user_family_member.rb +28 -0
- data/spec/factories/user_invitation.rb +16 -0
- data/spec/factories/user_invitation_list.rb +13 -0
- data/spec/factories/user_list.rb +13 -0
- data/spec/factories/user_note.rb +28 -0
- data/spec/factories/user_note_list.rb +13 -0
- data/spec/factories/user_process.rb +11 -0
- data/spec/factories/user_process_list.rb +13 -0
- data/spec/factories/user_role.rb +17 -0
- data/spec/factories/user_role_list.rb +13 -0
- data/spec/factories/user_skill.rb +10 -0
- data/spec/factories/user_skill_list.rb +13 -0
- data/spec/factories/web_hook.rb +12 -0
- data/spec/factories/web_hook_list.rb +13 -0
- data/spec/functional/the_city_admin_spec.rb +20 -0
- data/spec/readers/user_reader_spec.rb +7 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/writers/skill_writer_spec.rb +0 -0
- data/spec/writers/tag_writer_spec.rb +80 -0
- data/spec/writers/user_writer_spec.rb +80 -0
- data/status.txt +187 -0
- data/test_scripts/addresses.rb +36 -0
- data/test_scripts/barcodes_checkins.rb +45 -0
- data/test_scripts/city_keys.rb +6 -0
- data/test_scripts/familes.rb +83 -0
- data/test_scripts/groups.rb +124 -0
- data/test_scripts/metrics.rb +72 -0
- data/test_scripts/roles.rb +94 -0
- data/test_scripts/skills.rb +55 -0
- data/test_scripts/tags.rb +71 -0
- data/test_scripts/terminology.rb +62 -0
- data/test_scripts/users.rb +325 -0
- data/test_scripts/webhooks.rb +57 -0
- data/thecity_admin_api.gemspec +39 -0
- data/thecity_headers.rb +27 -0
- metadata +238 -3
@@ -0,0 +1,45 @@
|
|
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
|
+
barcode = TheCity::Barcode.load_by_id(12345)
|
20
|
+
if barcode.nil?
|
21
|
+
puts 'Barcode not found'
|
22
|
+
else
|
23
|
+
puts "Barcode: #{barcode.barcode}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
puts "------------------------------------"
|
28
|
+
|
29
|
+
checkin_list = TheCity::CheckinList.new
|
30
|
+
# if checkin_list.empty?
|
31
|
+
# puts "No checkins in list"
|
32
|
+
# else
|
33
|
+
# puts "Checkins: #{checkin_list.count}"
|
34
|
+
# end
|
35
|
+
|
36
|
+
# checkin = checkin_list[0]
|
37
|
+
|
38
|
+
# checkin2 = TheCity::Checkin.load_by_id(checkin.id)
|
39
|
+
# if checkin2.nil?
|
40
|
+
# puts 'Checkin not found'
|
41
|
+
# else
|
42
|
+
# puts "Checkin: #{checkin2.barcode}"
|
43
|
+
# end
|
44
|
+
|
45
|
+
puts "####################################"
|
@@ -0,0 +1,83 @@
|
|
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
|
+
user_list = TheCity::UserList.new
|
20
|
+
user1 = user_list[0]
|
21
|
+
# user2 = user_list[1]
|
22
|
+
|
23
|
+
family = TheCity::Family.new
|
24
|
+
family.external_id = 'family123'
|
25
|
+
|
26
|
+
member1 = TheCity::FamilyMember.new
|
27
|
+
member1.user_id = user1.id
|
28
|
+
member1.name = user1.full_name
|
29
|
+
member1.email = user1.email
|
30
|
+
member1.external_id_1 = 'weshays123'
|
31
|
+
member1.birthdate = user1.birthdate
|
32
|
+
member1.family_role = TheCity::FamilyMember::Roles[:spouse]
|
33
|
+
family.add_family_member(member1)
|
34
|
+
|
35
|
+
# member2 = TheCity::FamilyMember.new
|
36
|
+
# member2.user_id = user2.id
|
37
|
+
# member2.name = user2.full_name
|
38
|
+
# member2.email = user2.email
|
39
|
+
# member2.external_id_1 = 'annahays123'
|
40
|
+
# member2.birthdate = user1.birthdate
|
41
|
+
# member2.family_role = TheCity::FamilyMember::Roles[:spouse]
|
42
|
+
# family.add_family_member(member2)
|
43
|
+
|
44
|
+
if family.save
|
45
|
+
puts "Family saved"
|
46
|
+
else
|
47
|
+
puts "** Unable to save new family: #{family.error_messages.join(', ')}"
|
48
|
+
#puts family.to_attributes
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
#family2 = TheCity::Family.load_by_id(398768686)
|
53
|
+
|
54
|
+
# if family.nil?
|
55
|
+
# puts "Family found with #{family.members.size} members"
|
56
|
+
# else
|
57
|
+
# puts "Family: #{family.id}"
|
58
|
+
# end
|
59
|
+
|
60
|
+
|
61
|
+
# if family.save
|
62
|
+
# puts "Family saved"
|
63
|
+
# else
|
64
|
+
# puts "** Unable to save new family: #{family.error_messages.join(', ')}"
|
65
|
+
# end
|
66
|
+
|
67
|
+
|
68
|
+
# family..
|
69
|
+
|
70
|
+
# if family.save
|
71
|
+
# puts "Family updated: #{family.id}"
|
72
|
+
# else
|
73
|
+
# puts "** Unable to update family: #{family.error_messages.join(', ')}"
|
74
|
+
# end
|
75
|
+
|
76
|
+
# if family.delete
|
77
|
+
# puts "Family #{family.id} deleted"
|
78
|
+
# else
|
79
|
+
# puts "Unable to delete family user #{family.id}: #{family.error_messages.join(', ')}"
|
80
|
+
# end
|
81
|
+
|
82
|
+
|
83
|
+
puts "####################################"
|
@@ -0,0 +1,124 @@
|
|
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
|
+
group_list = TheCity::GroupList.new
|
17
|
+
|
18
|
+
group = group_list.first
|
19
|
+
puts group.name
|
20
|
+
|
21
|
+
puts "------------------------------------"
|
22
|
+
|
23
|
+
if group.addresses.empty?
|
24
|
+
puts "No addresses for group"
|
25
|
+
else
|
26
|
+
puts "Addresses: #{group.addresses.size}"
|
27
|
+
end
|
28
|
+
|
29
|
+
address = TheCity::GroupAddress.new
|
30
|
+
address.group_id = group.id
|
31
|
+
address.location_type = 'Work'
|
32
|
+
address.street = '445 S. Virginia St'
|
33
|
+
address.city = 'Reno'
|
34
|
+
address.state = 'NV'
|
35
|
+
address.zipcode = '89501'
|
36
|
+
if address.save
|
37
|
+
puts "Address saved: #{address.id}"
|
38
|
+
else
|
39
|
+
uts "** Unable to create address: #{address.error_messages.join(', ')}"
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
address.street = '663 Beckwourth Dr'
|
44
|
+
|
45
|
+
if address.save
|
46
|
+
puts "Address updated: #{address.id}"
|
47
|
+
else
|
48
|
+
puts "** Unable to update address: #{address.error_messages.join(', ')}"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
if group.addresses(true).empty?
|
53
|
+
puts "No addresses for group"
|
54
|
+
else
|
55
|
+
puts "Addresses: #{group.addresses.size}"
|
56
|
+
end
|
57
|
+
|
58
|
+
group.addresses.each do |address|
|
59
|
+
if address.delete
|
60
|
+
puts "Address #{address.id} deleted"
|
61
|
+
else
|
62
|
+
puts "Unable to delete address #{address.id}: #{address.error_messages.join(', ')}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if group.addresses(true).empty?
|
67
|
+
puts "No addresses for group"
|
68
|
+
else
|
69
|
+
puts "Addresses: #{group.addresses.size}"
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "------------------------------------"
|
73
|
+
|
74
|
+
# if group.checkins.empty?
|
75
|
+
# puts "No checkins for group"
|
76
|
+
# else
|
77
|
+
# puts "Checkins: #{group.checkins.size}"
|
78
|
+
# end
|
79
|
+
|
80
|
+
# puts "------------------------------------"
|
81
|
+
|
82
|
+
# if group.event_attendances.empty?
|
83
|
+
# puts "No event attendances for group"
|
84
|
+
# else
|
85
|
+
# puts "Events: #{group.event_attendances.size}"
|
86
|
+
# end
|
87
|
+
|
88
|
+
# puts "------------------------------------"
|
89
|
+
|
90
|
+
# if group.exports.empty?
|
91
|
+
# puts "No exports for group"
|
92
|
+
# else
|
93
|
+
# puts "Exports: #{group.exports.size}"
|
94
|
+
# end
|
95
|
+
|
96
|
+
# puts "------------------------------------"
|
97
|
+
|
98
|
+
# if group.invitations.empty?
|
99
|
+
# puts "No invitations for group"
|
100
|
+
# else
|
101
|
+
# puts "Invitations: #{group.invitations.size}"
|
102
|
+
# end
|
103
|
+
|
104
|
+
# puts "------------------------------------"
|
105
|
+
|
106
|
+
# if group.roles.empty?
|
107
|
+
# puts "No roles for group"
|
108
|
+
# else
|
109
|
+
# puts "Roles: #{group.roles.size}"
|
110
|
+
# end
|
111
|
+
|
112
|
+
# puts "------------------------------------"
|
113
|
+
|
114
|
+
# if group.tags.empty?
|
115
|
+
# puts "No tags for group"
|
116
|
+
# else
|
117
|
+
# puts "Tags: #{group.tags.size}"
|
118
|
+
# end
|
119
|
+
|
120
|
+
puts "------------------------------------"
|
121
|
+
|
122
|
+
puts "####################################"
|
123
|
+
|
124
|
+
|
@@ -0,0 +1,72 @@
|
|
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
|
+
metric_list = TheCity::MetricList.new
|
20
|
+
if metric_list.empty?
|
21
|
+
puts "No metrics in list"
|
22
|
+
else
|
23
|
+
puts "Metrices: #{metric_list.count}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
metric = TheCity::Metric.new
|
28
|
+
metric.name = "CoolThing#{Time.now.to_i}"
|
29
|
+
if metric.save
|
30
|
+
puts "Metric created (#{metric.id})"
|
31
|
+
else
|
32
|
+
puts "Failed to create metric: #{metric.error_messages.join(', ')}"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
metric_list2 = TheCity::MetricList.new
|
37
|
+
if metric_list2.empty?
|
38
|
+
puts "No metrics in list"
|
39
|
+
else
|
40
|
+
puts "Metrics: #{metric_list2.count}"
|
41
|
+
end
|
42
|
+
|
43
|
+
metric2 = TheCity::Metric.load_by_id(metric.id)
|
44
|
+
if metric2.nil?
|
45
|
+
puts "Metric not found"
|
46
|
+
else
|
47
|
+
puts "Metric found by ID #{metric2.id}"
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
metric2.name = "HelloWorld#{Time.now.to_i}"
|
52
|
+
if metric2.save
|
53
|
+
puts "Metric updated (#{metric2.id})"
|
54
|
+
else
|
55
|
+
puts "Failed to update metric: #{metric2.error_messages.join(', ')}"
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
if metric2.delete
|
60
|
+
puts "Metric #{metric2.id} deleted"
|
61
|
+
else
|
62
|
+
puts "Unable to delete metric #{metric2.id}: #{metric2.error_messages.join(', ')}"
|
63
|
+
end
|
64
|
+
|
65
|
+
metric_list3 = TheCity::MetricList.new
|
66
|
+
if metric_list3.empty?
|
67
|
+
puts "No metrics in list"
|
68
|
+
else
|
69
|
+
puts "Metrics: #{metric_list3.count}"
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "####################################"
|
@@ -0,0 +1,94 @@
|
|
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
|
+
puts '--- USER ROLE SETUP ---'
|
20
|
+
group_list = TheCity::GroupList.new
|
21
|
+
group = group_list.first
|
22
|
+
|
23
|
+
offline_user = TheCity::User.new
|
24
|
+
offline_user.first = 'Wes'
|
25
|
+
offline_user.last = 'Hays'
|
26
|
+
offline_user.email = 'someguy@someplace.org'
|
27
|
+
if offline_user.save
|
28
|
+
puts "Offline user created #{offline_user.id}"
|
29
|
+
else
|
30
|
+
puts "Failed to create offline user: #{offline_user.error_messages.join(', ')}"
|
31
|
+
end
|
32
|
+
|
33
|
+
if offline_user.roles.empty?
|
34
|
+
puts "No roles for user"
|
35
|
+
else
|
36
|
+
puts "Roles: #{offline_user.roles.size}"
|
37
|
+
end
|
38
|
+
|
39
|
+
role = TheCity::UserRole.new
|
40
|
+
role.group_type = TheCity::UserRole::GroupTypes[:campus]
|
41
|
+
role.title = TheCity::UserRole::Titles[:leader]
|
42
|
+
role.user_id = offline_user.id
|
43
|
+
role.group_id = group.id
|
44
|
+
|
45
|
+
if role.save
|
46
|
+
puts "Role saved"
|
47
|
+
else
|
48
|
+
puts "** Unable to save new role: #{role.error_messages.join(', ')}"
|
49
|
+
end
|
50
|
+
puts '--- USER ROLE SETUP DONE ---'
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
role_list = TheCity::RoleList.new
|
56
|
+
if role_list.empty?
|
57
|
+
puts "No roles in list"
|
58
|
+
else
|
59
|
+
puts "Roles: #{role_list.count}"
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
puts '--- USER ROLE TEARDOWN ---'
|
66
|
+
if offline_user.roles(true).empty?
|
67
|
+
puts "No roles for user"
|
68
|
+
else
|
69
|
+
puts "Roles: #{user.roles.size}"
|
70
|
+
end
|
71
|
+
|
72
|
+
offline_user.roles.each do |role|
|
73
|
+
if role.delete
|
74
|
+
puts "Role #{role.id} deleted"
|
75
|
+
else
|
76
|
+
puts "Unable to delete role #{role.id}: #{role.error_messages.join(', ')}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if offline_user.roles(true).empty?
|
81
|
+
puts "No roles for user"
|
82
|
+
else
|
83
|
+
puts "Roles: #{user.roles.size}"
|
84
|
+
end
|
85
|
+
|
86
|
+
if offline_user.delete
|
87
|
+
puts "OfflineUser #{offline_user.id} deleted"
|
88
|
+
else
|
89
|
+
puts "Unable to delete offline user #{offline_user.id}: #{offline_user.error_messages.join(', ')}"
|
90
|
+
end
|
91
|
+
puts '--- USER ROLE TEARDOWN DONE ---'
|
92
|
+
|
93
|
+
|
94
|
+
puts "####################################"
|
@@ -0,0 +1,55 @@
|
|
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
|
+
skill_list = TheCity::SkillList.new
|
20
|
+
if skill_list.empty?
|
21
|
+
puts "No skils in list"
|
22
|
+
else
|
23
|
+
puts "Skills: #{skill_list.count}"
|
24
|
+
end
|
25
|
+
|
26
|
+
skill = TheCity::Skill.new
|
27
|
+
skill.name = 'ZProgrammer'
|
28
|
+
if skill.save
|
29
|
+
puts "Skill created (#{skill.id})"
|
30
|
+
else
|
31
|
+
puts "Failed to create skill: #{skill.error_messages.join(', ')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
skill_list2 = TheCity::SkillList.new
|
36
|
+
if skill_list2.empty?
|
37
|
+
puts "No skills in list"
|
38
|
+
else
|
39
|
+
puts "Skills: #{skill_list2.count}"
|
40
|
+
end
|
41
|
+
|
42
|
+
if skill.delete
|
43
|
+
puts "Skill #{skill.id} deleted"
|
44
|
+
else
|
45
|
+
puts "Unable to delete skill #{skill.id}: #{skill.error_messages.join(', ')}"
|
46
|
+
end
|
47
|
+
|
48
|
+
skill_list3 = TheCity::SkillList.new
|
49
|
+
if skill_list3.empty?
|
50
|
+
puts "No skills in list"
|
51
|
+
else
|
52
|
+
puts "Skills: #{skill_list3.count}"
|
53
|
+
end
|
54
|
+
|
55
|
+
puts "####################################"
|