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,20 @@
1
+ require File.join(Dir.pwd, 'spec', 'spec_helper')
2
+
3
+ describe 'AdminApi' do
4
+
5
+ before do
6
+ simulate_connection_to_server
7
+ end
8
+
9
+ after do
10
+
11
+ end
12
+
13
+ it 'should get a list of users without any paramters'
14
+ it 'should get a list of users with parameters'
15
+ it 'should get a user count without any paramters'
16
+ it 'should get a user count with the specified paramters'
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'UserReader' do
4
+
5
+ it 'should pass if ....'
6
+
7
+ end
@@ -0,0 +1,31 @@
1
+ # Project:: TheCity Admin API
2
+ # File:: the_city.rb
3
+ #
4
+ # Author:: Wes Hays <weshays@gbdev.com>
5
+ # Link:: https://github.com/weshays/admin-api-ruby
6
+ # Version:: 0.1a
7
+ # Package:: TheCity::Admin
8
+
9
+
10
+ require File.expand_path( File.dirname(__FILE__) + '/../lib/the_city_admin.rb')
11
+
12
+ require 'rubygems'
13
+ require 'rspec'
14
+ require 'ruby-debug'
15
+
16
+ require 'factory_girl'
17
+ Dir.glob(File.dirname(__FILE__) + "/factories/*").each { |f| require f }
18
+
19
+
20
+ TheCityResponse = Struct.new(:code, :body)
21
+
22
+ RSpec.configure do |config|
23
+ config.tty = true
24
+ config.mock_with :rspec
25
+ config.include FactoryGirl::Syntax::Methods
26
+ end
27
+
28
+
29
+ def simulate_connection_to_server
30
+ @the_city = TheCity::AdminApi.new('cf2903151e3213e66fd8080c7d8b65b1d6ccdd31', '5c88b32edda7653c')
31
+ end
File without changes
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'TagWriter' do
4
+
5
+ it 'should show connection error messages if server cannot be reached' do
6
+ TheCity.stub(:admin_request) { raise TheCityExceptions::UnableToConnectToTheCity.new('Unable to connect to server') }
7
+ tag_data = {:name => 'Cool People'}
8
+ tag = TheCity::Tag.new(tag_data)
9
+ tag.id.should be_nil
10
+ tag.save.should === false
11
+ tag.id.should be_nil
12
+ tag.error_messages.should == ['Unable to connect to server']
13
+ end
14
+
15
+
16
+ it 'should save if all data is valid for new tag' do
17
+ request_data = FactoryGirl.attributes_for(:tag, {:id => 12345}).to_json
18
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
19
+ tag_data = {:name => 'Cool People'}
20
+ tag = TheCity::Tag.new(tag_data)
21
+ tag.id.should be_nil
22
+ tag.save.should === true
23
+ tag.id.should == 12345
24
+ end
25
+
26
+
27
+ it 'should show error messages if save fails for new tag' do
28
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('tag already exists') }
29
+ tag_data = {:name => 'Cool People'}
30
+ tag = TheCity::Tag.new(tag_data)
31
+ tag.id.should be_nil
32
+ tag.save.should === false
33
+ tag.id.should be_nil
34
+ tag.error_messages.should == ['tag already exists']
35
+ end
36
+
37
+
38
+ it 'should save if all data is valid for existing tag' do
39
+ request_data = FactoryGirl.attributes_for(:tag, {:id => 12345}).to_json
40
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
41
+ tag_data = FactoryGirl.attributes_for(:tag, {:id => 12345})
42
+ tag = TheCity::Tag.new(tag_data)
43
+ tag.id.should == 12345
44
+ tag.save.should === true
45
+ tag.id.should == 12345
46
+ end
47
+
48
+
49
+ it 'should show error messages if save fails for existing tag' do
50
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('something bad happened') }
51
+ tag_data = FactoryGirl.attributes_for(:tag, {:id => 12345})
52
+ tag = TheCity::Tag.new(tag_data)
53
+ tag.id.should == 12345
54
+ tag.save.should === false
55
+ tag.id.should == 12345
56
+ tag.error_messages.should == ['something bad happened']
57
+ end
58
+
59
+
60
+ it 'should delete if data ID exists for the existing tag' do
61
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(204, '{}') )
62
+ tag_data = FactoryGirl.attributes_for(:tag, {:id => 12345})
63
+ tag = TheCity::Tag.new(tag_data)
64
+ tag.is_deleted?.should === false
65
+ tag.delete
66
+ tag.is_deleted?.should === true
67
+ end
68
+
69
+
70
+ it 'should show error messages if data fails to be deleted' do
71
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('something bad happened') }
72
+ tag_data = FactoryGirl.attributes_for(:tag, {:id => 12345})
73
+ tag = TheCity::Tag.new(tag_data)
74
+ tag.is_deleted?.should === false
75
+ tag.delete
76
+ tag.is_deleted?.should === false
77
+ tag.error_messages.should == ['something bad happened']
78
+ end
79
+
80
+ end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'UserWriter' do
4
+
5
+ it 'should show connection error messages if server cannot be reached' do
6
+ TheCity.stub(:admin_request) { raise TheCityExceptions::UnableToConnectToTheCity.new('Unable to connect to server') }
7
+ user_data = FactoryGirl.attributes_for(:user, {:id => nil})
8
+ user = TheCity::User.new(user_data)
9
+ user.id.should be_nil
10
+ user.save.should === false
11
+ user.id.should be_nil
12
+ user.error_messages.should == ['Unable to connect to server']
13
+ end
14
+
15
+
16
+ it 'should save if all data is valid for new user' do
17
+ request_data = FactoryGirl.attributes_for(:user, {:id => 12345}).to_json
18
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
19
+ user_data = FactoryGirl.attributes_for(:user, {:id => nil})
20
+ user = TheCity::User.new(user_data)
21
+ user.id.should be_nil
22
+ user.save.should === true
23
+ user.id.should == 12345
24
+ end
25
+
26
+
27
+ it 'should show error messages if save fails for new user' do
28
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('email address already exists') }
29
+ user_data = FactoryGirl.attributes_for(:user, {:id => nil})
30
+ user = TheCity::User.new(user_data)
31
+ user.id.should be_nil
32
+ user.save.should === false
33
+ user.id.should be_nil
34
+ user.error_messages.should == ['email address already exists']
35
+ end
36
+
37
+
38
+ it 'should save if all data is valid for existing user' do
39
+ request_data = FactoryGirl.attributes_for(:user, {:id => 12345}).to_json
40
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(200, request_data) )
41
+ user_data = FactoryGirl.attributes_for(:user, {:id => 12345})
42
+ user = TheCity::User.new(user_data)
43
+ user.id.should == 12345
44
+ user.save.should === true
45
+ user.id.should == 12345
46
+ end
47
+
48
+
49
+ it 'should show error messages if save fails for existing user' do
50
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('something bad happened') }
51
+ user_data = FactoryGirl.attributes_for(:user, {:id => 12345})
52
+ user = TheCity::User.new(user_data)
53
+ user.id.should == 12345
54
+ user.save.should === false
55
+ user.id.should == 12345
56
+ user.error_messages.should == ['something bad happened']
57
+ end
58
+
59
+
60
+ it 'should delete if data ID exists for the existing user' do
61
+ TheCity.stub(:admin_request).and_return( TheCityResponse.new(204, '{}') )
62
+ user_data = FactoryGirl.attributes_for(:user, {:id => 12345})
63
+ user = TheCity::User.new(user_data)
64
+ user.is_deleted?.should === false
65
+ user.delete
66
+ user.is_deleted?.should === true
67
+ end
68
+
69
+
70
+ it 'should show error messages if data fails to be deleted' do
71
+ TheCity.stub(:admin_request) { raise TheCityExceptions::TheCityResponseError.new('something bad happened') }
72
+ user_data = FactoryGirl.attributes_for(:user, {:id => 12345})
73
+ user = TheCity::User.new(user_data)
74
+ user.is_deleted?.should === false
75
+ user.delete
76
+ user.is_deleted?.should === false
77
+ user.error_messages.should == ['something bad happened']
78
+ end
79
+
80
+ end
data/status.txt ADDED
@@ -0,0 +1,187 @@
1
+ Items with a "+" in front are done.
2
+ Items with a "-" in front are almost done.
3
+
4
+
5
+ ## User Endpoints ##
6
+ +Users Index
7
+ +Users Show
8
+ +Users Create
9
+ +Users Update
10
+ +Users Destroy
11
+ +Users Count
12
+ Users Memberize
13
+ Users Dememberize
14
+ Users Deactivate
15
+ Users Bulk Memberize
16
+ Users Bulk Deactivate
17
+ +Users Addresses Index
18
+ +Users Addresses Show
19
+ +Users Addresses Create
20
+ +Users Addresses Update
21
+ +Users Addresses Destroy
22
+ +Users Admin Privileges Index
23
+ +Users Admin Privileges Create
24
+ Users Barcodes Index
25
+ Users Barcodes Show
26
+ Users Barcodes Create
27
+ Users Barcodes Destroy
28
+ Users Checkins Index
29
+ Users Checkins Show
30
+ Users Checkins Last
31
+ Users Event Attendances Index
32
+ Users Event Attendances Show
33
+ Users Event Attendances Recent
34
+ Users Event Attendances Dates
35
+ +Users Invitations Index
36
+ +Users Invitations Create
37
+ +Users Family Index
38
+ Users Family Create
39
+ Users Family Update
40
+ Users Family Destroy
41
+ +Users Notes Index
42
+ +Users Notes Show
43
+ +Users Notes Create
44
+ +Users Processes Index
45
+ Users Processes Show
46
+ Users Processes Answers Index
47
+ Users Processes Notes Index
48
+ +Users Roles Index
49
+ +Users Roles Show
50
+ +Users Roles Create
51
+ +Users Roles Destroy
52
+ Users Roles Activate
53
+ Users Roles Deactivate
54
+ Users Roles Promote
55
+ Users Roles Demote
56
+ +Users Skills Index
57
+ +Users Skills Create
58
+ +Users Skills Destroy
59
+
60
+
61
+ ## Group Endpoints ##
62
+ +Groups Index
63
+ +Groups Show
64
+ +Groups Create
65
+ +Groups Update
66
+ Groups Count
67
+ Groups Schedule Archive
68
+ Groups Schedule Deletion
69
+ Groups Undo Scheduled Archive
70
+ Groups Undo Scheduled Deletion
71
+ Groups Unarchive
72
+ +Groups Addresses Index
73
+ +Groups Addresses Show
74
+ +Groups Addresses Create
75
+ +Groups Addresses Update
76
+ +Groups Addresses Destroy
77
+ +Groups Checkins Index
78
+ Groups Checkins Show
79
+ Groups Event Attendances Index
80
+ Groups Event Attendances Show
81
+ +Groups Exports Index
82
+ Groups Exports Show
83
+ Groups Exports Create
84
+ Groups Health Assessments Index
85
+ +Groups Invitations Index
86
+ Groups Invitations Create
87
+ +Groups Roles Index
88
+ Groups Roles Show
89
+ Groups Roles Create
90
+ Groups Roles Destroy
91
+ Groups Roles Activate
92
+ Groups Roles Deactivate
93
+ Groups Roles Promote
94
+ Groups Roles Demote
95
+ Groups Roles Deactivate All
96
+ +Groups Tags Index
97
+ +Groups Tags Create
98
+ +Groups Tags Destroy
99
+
100
+
101
+ ## Address Endpoints ##
102
+ +Addresses Index
103
+ +Addresses Show
104
+ Addresses Groups
105
+
106
+
107
+ ## Barcode Endpoints ##
108
+ +Barcodes Show
109
+
110
+ ## Checkin Endpoints ##
111
+ Checkins Index
112
+ Checkins Show
113
+ Checkins By Barcode
114
+ Checkins By Callboard Number
115
+ Checkins By Pager Number
116
+ Checkins By Parent Receipt Barcode
117
+
118
+
119
+ ##Custom Field Endpoints ##
120
+ Custom Fields Index
121
+ Custom Fields Show
122
+ Custom Fields Create
123
+ Custom Fields Update
124
+ Custom Fields Destroy
125
+ Custom Fields Users Index
126
+ Custom Fields Users Count
127
+
128
+
129
+ ## Family Endpoints ##
130
+ Families Show
131
+ Families Create
132
+ Families Update
133
+ Families Destroy
134
+
135
+
136
+ ## Invitation Endpoints ##
137
+ Invitations Index
138
+ Invitations Bulk Invite
139
+
140
+
141
+ ## Metric Endpoints ##
142
+ +Metrics Index
143
+ +Metrics Show
144
+ +Metrics Create
145
+ +Metrics Update
146
+ +Metrics Destroy
147
+ Metrics Measurements Index
148
+ Metrics Measurements Show
149
+ Metrics Measurements Create
150
+ Metrics Measurements Update
151
+ Metrics Measurements Destroy
152
+ Metrics Measurements Last
153
+ Metrics Measurements Values
154
+
155
+
156
+ ## Role Endpoints ##
157
+ +Roles Index
158
+
159
+
160
+ ## Skill Endpoints ##
161
+ +Skills Index
162
+ +Skills Show
163
+ +Skills Create
164
+ +Skills Destroy
165
+ Skills Users Index
166
+ Skills User Ids
167
+
168
+
169
+ ## Tag Endpoints ##
170
+ +Tags Index
171
+ +Tags Show
172
+ +Tags Create
173
+ +Tags Update
174
+ +Tags Destroy
175
+ Tags Groups Index
176
+
177
+
178
+ ## Terminology Endpoints ##
179
+ +Terminology Index
180
+ +Terminology Show
181
+ +Terminology Update
182
+
183
+
184
+ ## WebHook Endpoints ##
185
+ +WebHooks Index
186
+ +WebHooks Create
187
+ +WebHooks Destroy
@@ -0,0 +1,36 @@
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
+ address_list = TheCity::AddressList.new
20
+ if address_list.empty?
21
+ puts "No addresses in list"
22
+ else
23
+ puts "Addresss: #{address_list.count}"
24
+ end
25
+
26
+ address = address_list[0]
27
+
28
+ address2 = TheCity::Address.load_by_id(address.id)
29
+
30
+ if address2.street == address.street
31
+ puts "Address found (#{address.street})"
32
+ else
33
+ puts "Failed to load address"
34
+ end
35
+
36
+ puts "####################################"