the-city-admin 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/api/address.rb +51 -0
- data/lib/api/address_list.rb +62 -0
- data/lib/api/api_object.rb +100 -0
- data/lib/api/barcode.rb +43 -0
- data/lib/api/checkin.rb +37 -0
- data/lib/api/checkin_list.rb +62 -0
- data/lib/api/family.rb +47 -0
- data/lib/api/family_member.rb +28 -0
- data/lib/api/group.rb +162 -0
- data/lib/api/group_address.rb +31 -0
- data/lib/api/group_address_list.rb +63 -0
- data/lib/api/group_checkin.rb +36 -0
- data/lib/api/group_checkin_list.rb +63 -0
- data/lib/api/group_event_attendance.rb +28 -0
- data/lib/api/group_event_attendance_list.rb +63 -0
- data/lib/api/group_export.rb +22 -0
- data/lib/api/group_export_list.rb +63 -0
- data/lib/api/group_invitation.rb +26 -0
- data/lib/api/group_invitation_list.rb +63 -0
- data/lib/api/group_list.rb +74 -0
- data/lib/api/group_role.rb +27 -0
- data/lib/api/group_role_list.rb +62 -0
- data/lib/api/group_tag.rb +20 -0
- data/lib/api/group_tag_list.rb +62 -0
- data/lib/api/metric.rb +50 -0
- data/lib/api/metric_list.rb +72 -0
- data/lib/api/metric_measurement.rb +29 -0
- data/lib/api/metric_measurement_list.rb +62 -0
- data/lib/api/role.rb +43 -0
- data/lib/api/role_list.rb +73 -0
- data/lib/api/skill.rb +21 -0
- data/lib/api/skill_list.rb +73 -0
- data/lib/api/skilled_user_id_list.rb +73 -0
- data/lib/api/skilled_user_list.rb +73 -0
- data/lib/api/tag.rb +32 -0
- data/lib/api/tag_group_list.rb +73 -0
- data/lib/api/tag_list.rb +73 -0
- data/lib/api/terminology.rb +32 -0
- data/lib/api/terminology_list.rb +73 -0
- data/lib/api/user.rb +207 -0
- data/lib/api/user_address.rb +31 -0
- data/lib/api/user_address_list.rb +62 -0
- data/lib/api/user_admin_privilege.rb +28 -0
- data/lib/api/user_admin_privilege_list.rb +63 -0
- data/lib/api/user_barcode.rb +20 -0
- data/lib/api/user_count.rb +40 -0
- data/lib/api/user_family_list.rb +71 -0
- data/lib/api/user_family_member.rb +28 -0
- data/lib/api/user_invitation.rb +26 -0
- data/lib/api/user_invitation_list.rb +63 -0
- data/lib/api/user_list.rb +72 -0
- data/lib/api/user_note.rb +31 -0
- data/lib/api/user_note_list.rb +63 -0
- data/lib/api/user_process.rb +21 -0
- data/lib/api/user_process_list.rb +63 -0
- data/lib/api/user_role.rb +34 -0
- data/lib/api/user_role_list.rb +74 -0
- data/lib/api/user_skill.rb +22 -0
- data/lib/api/user_skill_list.rb +74 -0
- data/lib/api/web_hook.rb +34 -0
- data/lib/api/web_hook_list.rb +74 -0
- data/lib/auto_load.rb +23 -0
- data/lib/cachers/cache_adapter.rb +50 -0
- data/lib/cachers/file/json_cache.rb +135 -0
- data/lib/common.rb +124 -0
- data/lib/exceptions.rb +5 -0
- data/lib/readers/address_list_reader.rb +21 -0
- data/lib/readers/address_reader.rb +22 -0
- data/lib/readers/api_reader.rb +28 -0
- data/lib/readers/checkin_list_reader.rb +21 -0
- data/lib/readers/checkin_reader.rb +22 -0
- data/lib/readers/family_reader.rb +21 -0
- data/lib/readers/group_address_list_reader.rb +25 -0
- data/lib/readers/group_checkin_list_reader.rb +25 -0
- data/lib/readers/group_event_attendance_list_reader.rb +25 -0
- data/lib/readers/group_export_list_reader.rb +25 -0
- data/lib/readers/group_invitation_list_reader.rb +23 -0
- data/lib/readers/group_list_reader.rb +25 -0
- data/lib/readers/group_reader.rb +21 -0
- data/lib/readers/group_role_list_reader.rb +23 -0
- data/lib/readers/group_tag_list_reader.rb +23 -0
- data/lib/readers/metric_list_reader.rb +22 -0
- data/lib/readers/metric_measurement_list_reader.rb +21 -0
- data/lib/readers/metric_measurement_reader.rb +22 -0
- data/lib/readers/metric_reader.rb +21 -0
- data/lib/readers/role_list_reader.rb +21 -0
- data/lib/readers/skill_list_reader.rb +21 -0
- data/lib/readers/skilled_user_id_list_reader.rb +22 -0
- data/lib/readers/skilled_user_list_reader.rb +22 -0
- data/lib/readers/tag_group_list_reader.rb +22 -0
- data/lib/readers/tag_list_reader.rb +22 -0
- data/lib/readers/tag_reader.rb +22 -0
- data/lib/readers/terminology_list_reader.rb +22 -0
- data/lib/readers/terminology_reader.rb +22 -0
- data/lib/readers/user_address_list_reader.rb +25 -0
- data/lib/readers/user_admin_privilege_list_reader.rb +23 -0
- data/lib/readers/user_count_reader.rb +32 -0
- data/lib/readers/user_family_list_reader.rb +24 -0
- data/lib/readers/user_invitation_list_reader.rb +23 -0
- data/lib/readers/user_list_reader.rb +25 -0
- data/lib/readers/user_note_list_reader.rb +23 -0
- data/lib/readers/user_process_list_reader.rb +23 -0
- data/lib/readers/user_reader.rb +24 -0
- data/lib/readers/user_role_list_reader.rb +23 -0
- data/lib/readers/user_skill_list_reader.rb +23 -0
- data/lib/readers/web_hook_list_reader.rb +21 -0
- data/lib/the_city_admin.rb +82 -0
- data/lib/writers/api_writer.rb +54 -0
- data/lib/writers/family_writer.rb +25 -0
- data/lib/writers/group_address_writer.rb +32 -0
- data/lib/writers/group_writer.rb +25 -0
- data/lib/writers/metric_measurement_writer.rb +25 -0
- data/lib/writers/metric_writer.rb +29 -0
- data/lib/writers/skill_writer.rb +25 -0
- data/lib/writers/tag_writer.rb +27 -0
- data/lib/writers/terminology_writer.rb +19 -0
- data/lib/writers/user_address_writer.rb +32 -0
- data/lib/writers/user_admin_privilege_writer.rb +24 -0
- data/lib/writers/user_invitation_writer.rb +23 -0
- data/lib/writers/user_note_writer.rb +25 -0
- data/lib/writers/user_role_writer.rb +28 -0
- data/lib/writers/user_skill_writer.rb +23 -0
- data/lib/writers/user_writer.rb +46 -0
- data/lib/writers/web_hook_writer.rb +20 -0
- metadata +184 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
# This adapter is the standard for all saving objects.
|
4
|
+
class ApiWriter
|
5
|
+
attr_reader :error_messages, :response_code
|
6
|
+
|
7
|
+
# Saves this object.
|
8
|
+
#
|
9
|
+
# @return True or ID on success, otherwise false.
|
10
|
+
def save_object
|
11
|
+
@url_data_params ||= {}
|
12
|
+
success = true
|
13
|
+
|
14
|
+
if @updatable_fields and !@updatable_fields.empty?
|
15
|
+
fields_to_remove = @url_data_params.keys - @updatable_fields
|
16
|
+
fields_to_remove.each { |ftr| @url_data_params.delete(ftr) }
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
response = TheCity::admin_request(@url_action, @url_data_path, @url_data_params)
|
21
|
+
@response_code = response.code
|
22
|
+
# No content but is a success
|
23
|
+
success = response.code == 204 ? {'success' => true} : JSON.parse(response.body)
|
24
|
+
rescue Exception => e
|
25
|
+
@error_messages = e.message.split(',')
|
26
|
+
success = false
|
27
|
+
end
|
28
|
+
|
29
|
+
return success
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# Deletes this object.
|
34
|
+
#
|
35
|
+
# @return True or ID on success, otherwise false.
|
36
|
+
def delete_object
|
37
|
+
success = true
|
38
|
+
|
39
|
+
begin
|
40
|
+
# @url_data_path should be the same as :put if this object is already
|
41
|
+
# setup and mapped to an object that exists
|
42
|
+
response = TheCity::admin_request(:delete, @url_data_delete_path)
|
43
|
+
success = response.code == 204 ? true : false # No content but is a success
|
44
|
+
rescue Exception => e
|
45
|
+
@error_messages = e.message.split(',')
|
46
|
+
success = false
|
47
|
+
end
|
48
|
+
|
49
|
+
return success
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class FamilyWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/families/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/families"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/families/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class GroupAddressWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/groups/#{data[:group_id]}/addresses/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/groups/#{data[:group_id]}/addresses"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/groups/#{data[:group_id]}/addresses/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
|
20
|
+
|
21
|
+
@updatable_fields = [:city,
|
22
|
+
:zipcode,
|
23
|
+
:street,
|
24
|
+
:location_type,
|
25
|
+
:state]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class GroupWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/groups/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/groups"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/groups/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class MetricMeasurementWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/metrics/#{data[:metric_id]}/measurements/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/metrics/#{data[:metric_id]}/measurements"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/metrics/#{data[:metric_id]}/measurements/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class MetricWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/metrics/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/metrics"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/metrics/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
|
20
|
+
@updatable_fields = [:name,
|
21
|
+
:description,
|
22
|
+
:category,
|
23
|
+
:subcategory,
|
24
|
+
:is_percent]
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class SkillWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/skills/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/skills"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/skills/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class TagWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/tags/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/tags"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/tags/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
|
20
|
+
@updatable_fields = [:name]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class TerminologyWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json data to save.
|
8
|
+
def initialize(data)
|
9
|
+
@url_action = :put
|
10
|
+
@url_data_path = "/terminology/#{data[:term]}"
|
11
|
+
@url_data_params = data
|
12
|
+
@updatable_fields = [:label]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserAddressWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/users/#{data[:user_id]}/addresses/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/users/#{data[:user_id]}/addresses"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/users/#{data[:user_id]}/addresses/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
|
20
|
+
|
21
|
+
@updatable_fields = [:city,
|
22
|
+
:zipcode,
|
23
|
+
:street,
|
24
|
+
:location_type,
|
25
|
+
:state]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserAdminPrivilegeWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
@url_action = :post
|
10
|
+
@url_data_path = "/users/#{data[:user_id]}/admin_privileges"
|
11
|
+
|
12
|
+
@url_data_params = data
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def delete_object
|
17
|
+
raise TheCityExceptions::TheCityResponseError.new('Unable to delete Admin Privilege')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserInvitationWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
@url_action = :post
|
10
|
+
@url_data_path = "/users/#{data[:user_id]}/invitations"
|
11
|
+
@url_data_params = data
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def delete_object
|
16
|
+
raise TheCityExceptions::TheCityResponseError.new('Unable to delete user invitation')
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserNoteWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/users/#{data[:author_id]}/notes/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/users/#{data[:author_id]}/notes"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/users/#{data[:author_id]}/notes/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserRoleWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/users/#{data[:user_id]}/roles/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/users/#{data[:user_id]}/roles"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/users/#{data[:user_id]}/roles/#{data[:id]}"
|
17
|
+
|
18
|
+
# user_id is not an option to submit with this path.
|
19
|
+
data.delete(:user_id)
|
20
|
+
|
21
|
+
@url_data_params = data
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserSkillWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
@url_action = :post
|
10
|
+
@url_data_path = "/users/#{data[:user_id]}/skills"
|
11
|
+
@url_data_delete_path = "/users/#{data[:user_id]}/skills/#{data[:skill_id] || data[:name]}"
|
12
|
+
|
13
|
+
# user_id is not an option to submit with this path.
|
14
|
+
data.delete(:user_id)
|
15
|
+
|
16
|
+
@url_data_params = data
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserWriter < ApiWriter
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param data The json object data to save.
|
8
|
+
def initialize(data)
|
9
|
+
if data[:id]
|
10
|
+
@url_action = :put
|
11
|
+
@url_data_path = "/users/#{data[:id]}"
|
12
|
+
else
|
13
|
+
@url_action = :post
|
14
|
+
@url_data_path = "/users"
|
15
|
+
end
|
16
|
+
@url_data_delete_path = "/users/#{data[:id]}"
|
17
|
+
|
18
|
+
@url_data_params = data
|
19
|
+
|
20
|
+
@updatable_fields = [:title,
|
21
|
+
:first,
|
22
|
+
:middle,
|
23
|
+
:last,
|
24
|
+
:nickname,
|
25
|
+
:gender,
|
26
|
+
:email,
|
27
|
+
:staff,
|
28
|
+
:primary_campus_id,
|
29
|
+
:member_since,
|
30
|
+
:birthdate,
|
31
|
+
:primary_phone,
|
32
|
+
:primary_phone_type,
|
33
|
+
:secondary_phone,
|
34
|
+
:secondary_phone_type,
|
35
|
+
:external_id_1,
|
36
|
+
:external_id_2,
|
37
|
+
:external_id_3,
|
38
|
+
:marital_status,
|
39
|
+
:is_an_organization]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|