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,28 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserAdminPrivilege < ApiObject
|
4
|
+
|
5
|
+
Permissions = {:api_admin => 'API Admin', :account_admin => 'Account Admin',
|
6
|
+
:designer => 'Designer', :financial_user => 'Financial User',
|
7
|
+
:group_admin => 'Group Admin', :process_user => 'Process User',
|
8
|
+
:reporting_user => 'Reporting User', :resource_admin => 'Resource Admin',
|
9
|
+
:support_admin => 'Support Admin', :user_admin => 'User Admin'}
|
10
|
+
|
11
|
+
tc_attr_accessor :title,
|
12
|
+
:user_id,
|
13
|
+
:user
|
14
|
+
|
15
|
+
|
16
|
+
# Constructor.
|
17
|
+
#
|
18
|
+
# @param json_data (optional) JSON data of the note.
|
19
|
+
def initialize(json_data = nil)
|
20
|
+
@writer_object = UserAdminPrivilegeWriter
|
21
|
+
initialize_from_json_object(json_data) unless json_data.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserAdminPrivilegeList
|
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
|
+
# :user_id - The ID of the user to load the admin privileges for. (required)
|
15
|
+
# :page - The page number to get.
|
16
|
+
# :reader - The Reader to use to load the data.
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# Examples:
|
20
|
+
# UserAdminPrivilegeList.new({:user_id => 12345})
|
21
|
+
#
|
22
|
+
# UserAdminPrivilegeList.new({:user_id => 12345, :page => 2})
|
23
|
+
#
|
24
|
+
def initialize(options = {})
|
25
|
+
options[:page] ||= 1
|
26
|
+
reader = options[:reader] || TheCity::UserAdminPrivilegeListReader.new(options)
|
27
|
+
@json_data = reader.load_feed
|
28
|
+
|
29
|
+
@total_entries = @json_data['total_entries']
|
30
|
+
@total_pages = @json_data['total_pages']
|
31
|
+
@per_page = @json_data['per_page']
|
32
|
+
@current_page = @json_data['current_page']
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Get the specified account admin privilege.
|
37
|
+
#
|
38
|
+
# @param index The index of the admin privilege to get.
|
39
|
+
#
|
40
|
+
# @return [UserAdminPrivilege]
|
41
|
+
def [](index)
|
42
|
+
UserAdminPrivilege.new( @json_data['account_roles'][index] ) if @json_data['account_roles'][index]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# This method is needed for Enumerable.
|
47
|
+
def each &block
|
48
|
+
@json_data['account_roles'].each{ |account_role| yield( UserAdminPrivilege.new(account_role) )}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Alias the count method
|
52
|
+
alias :size :count
|
53
|
+
|
54
|
+
# Checks if the list is empty.
|
55
|
+
#
|
56
|
+
# @return True on empty, false otherwise.
|
57
|
+
def empty?
|
58
|
+
@json_data['account_roles'].empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserBarcode < ApiObject
|
4
|
+
|
5
|
+
tc_attr_accessor :id,
|
6
|
+
:barcode,
|
7
|
+
:created_at
|
8
|
+
|
9
|
+
# Constructor.
|
10
|
+
#
|
11
|
+
# @param json_data JSON data of the user barcode.
|
12
|
+
def initialize(json_data)
|
13
|
+
initialize_from_json_object(json_data)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserCount < ApiObject
|
4
|
+
|
5
|
+
tc_attr_accessor :count,
|
6
|
+
:filter
|
7
|
+
|
8
|
+
|
9
|
+
# Constructor.
|
10
|
+
#
|
11
|
+
# @param options A hash of options for loading the user count.
|
12
|
+
#
|
13
|
+
# Options:
|
14
|
+
# :filter - The Reader to use to load the data.
|
15
|
+
#
|
16
|
+
#
|
17
|
+
# Examples:
|
18
|
+
# UserCount.new
|
19
|
+
#
|
20
|
+
# UserCount.new({:filter => :created_in_the_last_7_Days})
|
21
|
+
#
|
22
|
+
def initialize(options = {})
|
23
|
+
reader = options[:reader] || TheCity::UserCountReader.new(options)
|
24
|
+
@json_data = reader.load_feed
|
25
|
+
self.count = @json_data['count']
|
26
|
+
self.filter = @json_data['filter']
|
27
|
+
end
|
28
|
+
|
29
|
+
def save
|
30
|
+
raise 'User count does not have a save method'
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete
|
34
|
+
raise 'User count does not have a delete method'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserFamilyList
|
4
|
+
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
attr_reader :id, :created_at, :external_id
|
8
|
+
|
9
|
+
# Constructor.
|
10
|
+
#
|
11
|
+
# @param options A hash of options for loading the list.
|
12
|
+
#
|
13
|
+
# Options:
|
14
|
+
# :user_id - The ID of the user to load the family members for. (required)
|
15
|
+
# :page - The page number to get.
|
16
|
+
# :reader - The Reader to use to load the data.
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# Examples:
|
20
|
+
# UserFamilyList.new({:user_id => 12345})
|
21
|
+
#
|
22
|
+
# UserFamilyList.new({:user_id => 12345, :page => 2})
|
23
|
+
#
|
24
|
+
def initialize(options = {})
|
25
|
+
options[:page] ||= 1
|
26
|
+
reader = options[:reader] || TheCity::UserFamilyListReader.new(options)
|
27
|
+
@json_data = reader.load_feed
|
28
|
+
|
29
|
+
@id = @json_data['id']
|
30
|
+
@created_at = @json_data['created_at']
|
31
|
+
@external_id = @json_data['external_id']
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# All the famly member names in the list.
|
36
|
+
#
|
37
|
+
# @return array of names.
|
38
|
+
def all_names
|
39
|
+
@json_data['family_members'].collect { |user| user['name'] }
|
40
|
+
end
|
41
|
+
alias :names :all_names
|
42
|
+
|
43
|
+
|
44
|
+
# Get the specified family member.
|
45
|
+
#
|
46
|
+
# @param index The index of the family member to get.
|
47
|
+
#
|
48
|
+
# @return [UserFamilyMember]
|
49
|
+
def [](index)
|
50
|
+
UserFamilyMember.new( @json_data['family_members'][index] ) if @json_data['family_members'][index]
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# This method is needed for Enumerable.
|
55
|
+
def each &block
|
56
|
+
@json_data['family_members'].each{ |member| yield( UserFamilyMember.new(member) )}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Alias the count method
|
60
|
+
alias :size :count
|
61
|
+
|
62
|
+
# Checks if the list is empty.
|
63
|
+
#
|
64
|
+
# @return True on empty, false otherwise.
|
65
|
+
def empty?
|
66
|
+
@json_data['family_members'].empty?
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserFamilyMember < ApiObject
|
4
|
+
|
5
|
+
tc_attr_accessor :external_id_1,
|
6
|
+
:active,
|
7
|
+
:admin_url,
|
8
|
+
:api_url,
|
9
|
+
:birthdate,
|
10
|
+
:barcodes,
|
11
|
+
:email,
|
12
|
+
:family_role,
|
13
|
+
:name,
|
14
|
+
:user_id
|
15
|
+
|
16
|
+
|
17
|
+
# Constructor.
|
18
|
+
#
|
19
|
+
# @param json_data JSON data of the family member.
|
20
|
+
def initialize(json_data)
|
21
|
+
initialize_from_json_object(json_data)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserInvitation < ApiObject
|
4
|
+
|
5
|
+
tc_attr_accessor :created_at,
|
6
|
+
:custom_message,
|
7
|
+
:email,
|
8
|
+
:group_id,
|
9
|
+
:user_id,
|
10
|
+
:id,
|
11
|
+
:pending_approval,
|
12
|
+
:source
|
13
|
+
|
14
|
+
# Constructor.
|
15
|
+
#
|
16
|
+
# @param json_data (optional) JSON data of the invitation.
|
17
|
+
def initialize(json_data = nil)
|
18
|
+
@writer_object = UserInvitationWriter
|
19
|
+
initialize_from_json_object(json_data)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserInvitationList
|
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
|
+
# :user_id - The ID of the user to load the user invitations for. (required)
|
15
|
+
# :page - The page number to get.
|
16
|
+
# :reader - The Reader to use to load the data.
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# Examples:
|
20
|
+
# UserInvitationList.new({:user_id => 12345})
|
21
|
+
#
|
22
|
+
# UserInvitationList.new({:user_id => 12345, :page => 2})
|
23
|
+
#
|
24
|
+
def initialize(options = {})
|
25
|
+
options[:page] ||= 1
|
26
|
+
reader = options[:reader] || TheCity::UserInvitationListReader.new(options)
|
27
|
+
@json_data = reader.load_feed
|
28
|
+
|
29
|
+
@total_entries = @json_data['total_entries']
|
30
|
+
@total_pages = @json_data['total_pages']
|
31
|
+
@per_page = @json_data['per_page']
|
32
|
+
@current_page = @json_data['current_page']
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
# Get the specified invitation.
|
37
|
+
#
|
38
|
+
# @param index The index of the invitation to get.
|
39
|
+
#
|
40
|
+
# @return [UserInvitation]
|
41
|
+
def [](index)
|
42
|
+
UserInvitation.new( @json_data['invitations'][index] ) if @json_data['invitations'][index]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# This method is needed for Enumerable.
|
47
|
+
def each &block
|
48
|
+
@json_data['invitations'].each{ |invitation| yield( UserInvitation.new(invitation) )}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Alias the count method
|
52
|
+
alias :size :count
|
53
|
+
|
54
|
+
# Checks if the list is empty.
|
55
|
+
#
|
56
|
+
# @return True on empty, false otherwise.
|
57
|
+
def empty?
|
58
|
+
@json_data['invitations'].empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserList
|
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
|
+
# :page - The page number to get.
|
15
|
+
# :reader - The Reader to use to load the data.
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# Examples:
|
19
|
+
# UserList.new
|
20
|
+
#
|
21
|
+
# UserList.new({:page => 2})
|
22
|
+
#
|
23
|
+
def initialize(options = {})
|
24
|
+
options[:page] ||= 1
|
25
|
+
reader = options[:reader] || TheCity::UserListReader.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 names (first last).
|
38
|
+
def all_names
|
39
|
+
return [] unless @json_data['users']
|
40
|
+
@json_data['users'].collect { |user| [user['first'], user['last']].join(' ') }
|
41
|
+
end
|
42
|
+
alias :names :all_names
|
43
|
+
|
44
|
+
|
45
|
+
# Get the specified user.
|
46
|
+
#
|
47
|
+
# @param index The index of the user to get.
|
48
|
+
#
|
49
|
+
# @return [User]
|
50
|
+
def [](index)
|
51
|
+
User.new( @json_data['users'][index] ) if @json_data['users'] and @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
|
+
# Alias the count method
|
61
|
+
alias :size :count
|
62
|
+
|
63
|
+
# Checks if the list is empty.
|
64
|
+
#
|
65
|
+
# @return True on empty, false otherwise.
|
66
|
+
def empty?
|
67
|
+
@json_data['users'].empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserNote < ApiObject
|
4
|
+
|
5
|
+
VisibleTo = {:api_admin => "API Admin", :account_admin => "Account Admin",
|
6
|
+
:designer => "Designer", :financial_user => "Financial User",
|
7
|
+
:group_admin => "Group Admin", :process_user => "Process User",
|
8
|
+
:reporting_user => "Reporting User", :resource_admin => "Resource Admin",
|
9
|
+
:support_admin => "Support Admin", :user_admin => "User Admin"}
|
10
|
+
|
11
|
+
tc_attr_accessor :author,
|
12
|
+
:author_id,
|
13
|
+
:body,
|
14
|
+
:created_at,
|
15
|
+
:id,
|
16
|
+
:updated_at,
|
17
|
+
:visible_to
|
18
|
+
|
19
|
+
# Constructor.
|
20
|
+
#
|
21
|
+
# @param json_data (optional) JSON data of the note.
|
22
|
+
def initialize(json_data = nil)
|
23
|
+
@writer_object = UserNoteWriter
|
24
|
+
initialize_from_json_object(json_data)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|