the-city-admin 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rvmrc +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -14
- data/README.rdoc +58 -0
- data/{test_scripts → examples}/addresses.rb +0 -0
- data/{test_scripts → examples}/barcodes_checkins.rb +0 -0
- data/{test_scripts → examples}/city_keys.rb +0 -0
- data/{test_scripts → examples}/familes.rb +0 -0
- data/{test_scripts → examples}/groups.rb +0 -0
- data/{test_scripts → examples}/metrics.rb +0 -0
- data/{test_scripts → examples}/roles.rb +0 -0
- data/{test_scripts → examples}/skills.rb +0 -0
- data/{test_scripts → examples}/tags.rb +0 -0
- data/{test_scripts → examples}/terminology.rb +0 -0
- data/examples/thecity_headers.rb +49 -0
- data/{test_scripts → examples}/users.rb +0 -0
- data/{test_scripts → examples}/webhooks.rb +0 -0
- data/index.rb +17 -137
- data/lib/api/pledge.rb +40 -0
- data/lib/api/pledge_list.rb +74 -0
- data/lib/api/user_process_answer.rb +22 -0
- data/lib/api/user_process_answer_list.rb +64 -0
- data/lib/readers/address_list_reader.rb +1 -1
- data/lib/readers/address_reader.rb +1 -1
- data/lib/readers/api_reader.rb +4 -4
- data/lib/readers/checkin_list_reader.rb +1 -1
- data/lib/readers/checkin_reader.rb +1 -1
- data/lib/readers/family_reader.rb +1 -1
- data/lib/readers/group_address_list_reader.rb +1 -1
- data/lib/readers/group_checkin_list_reader.rb +1 -1
- data/lib/readers/group_event_attendance_list_reader.rb +1 -1
- data/lib/readers/group_export_list_reader.rb +1 -1
- data/lib/readers/group_invitation_list_reader.rb +1 -1
- data/lib/readers/group_list_reader.rb +3 -5
- data/lib/readers/group_reader.rb +1 -1
- data/lib/readers/group_role_list_reader.rb +1 -1
- data/lib/readers/group_tag_list_reader.rb +1 -1
- data/lib/readers/metric_list_reader.rb +1 -1
- data/lib/readers/metric_measurement_list_reader.rb +1 -1
- data/lib/readers/metric_measurement_reader.rb +1 -1
- data/lib/readers/metric_reader.rb +1 -1
- data/lib/readers/pledge_list_reader.rb +23 -0
- data/lib/readers/pledge_reader.rb +21 -0
- data/lib/readers/role_list_reader.rb +1 -1
- data/lib/readers/skill_list_reader.rb +1 -1
- data/lib/readers/skilled_user_id_list_reader.rb +1 -1
- data/lib/readers/skilled_user_list_reader.rb +1 -1
- data/lib/readers/tag_group_list_reader.rb +1 -1
- data/lib/readers/tag_list_reader.rb +1 -1
- data/lib/readers/tag_reader.rb +1 -1
- data/lib/readers/terminology_list_reader.rb +1 -1
- data/lib/readers/terminology_reader.rb +1 -1
- data/lib/readers/user_address_list_reader.rb +1 -1
- data/lib/readers/user_admin_privilege_list_reader.rb +1 -1
- data/lib/readers/user_count_reader.rb +1 -1
- data/lib/readers/user_family_list_reader.rb +1 -1
- data/lib/readers/user_invitation_list_reader.rb +1 -1
- data/lib/readers/user_list_reader.rb +1 -1
- data/lib/readers/user_note_list_reader.rb +1 -1
- data/lib/readers/user_process_answer_list_reader.rb +24 -0
- data/lib/readers/user_process_list_reader.rb +1 -1
- data/lib/readers/user_reader.rb +1 -1
- data/lib/readers/user_role_list_reader.rb +1 -1
- data/lib/readers/user_skill_list_reader.rb +1 -1
- data/lib/readers/web_hook_list_reader.rb +1 -1
- data/spec/api/user_process_answer_list_spec.rb +84 -0
- data/spec/factories/user_process_answer.rb +13 -0
- data/spec/factories/user_process_answer_list.rb +12 -0
- data/spec/spec_helper.rb +1 -0
- data/thecity_admin_api.gemspec +3 -3
- metadata +32 -20
- data/README +0 -1
- data/notes.txt +0 -21
- data/status.txt +0 -187
- data/thecity_headers.rb +0 -27
@@ -0,0 +1,22 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserProcessAnswer < ApiObject
|
4
|
+
|
5
|
+
tc_attr_accessor :question_id,
|
6
|
+
:question,
|
7
|
+
:required,
|
8
|
+
:answered_at,
|
9
|
+
:answer
|
10
|
+
|
11
|
+
# Constructor.
|
12
|
+
#
|
13
|
+
# @param json_data JSON data of the note.
|
14
|
+
def initialize(json_data)
|
15
|
+
initialize_from_json_object(json_data)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class UserProcessAnswerList
|
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 answers for the process. (required)
|
15
|
+
# :process_id - The ID of the user's process to load the answers for. (required)
|
16
|
+
# :page - The page number to get.
|
17
|
+
# :reader - The Reader to use to load the data.
|
18
|
+
#
|
19
|
+
#
|
20
|
+
# Examples:
|
21
|
+
# UserProcessAnswerList.new({:user_id => 12345, :process_id => 23456})
|
22
|
+
#
|
23
|
+
# UserProcessAnswerList.new({:user_id => 12345, :process_id => 23456, :page => 2})
|
24
|
+
#
|
25
|
+
def initialize(options = {})
|
26
|
+
options[:page] ||= 1
|
27
|
+
reader = options[:reader] || TheCity::UserProcessAnswerListReader.new(options)
|
28
|
+
@json_data = reader.load_feed
|
29
|
+
|
30
|
+
@total_entries = @json_data['total_entries']
|
31
|
+
@total_pages = @json_data['total_pages']
|
32
|
+
@per_page = @json_data['per_page']
|
33
|
+
@current_page = @json_data['current_page']
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
# Get the specified processes.
|
38
|
+
#
|
39
|
+
# @param index The index of the process to get.
|
40
|
+
#
|
41
|
+
# @return [UserProcesses]
|
42
|
+
def [](index)
|
43
|
+
UserProcessAnswer.new( @json_data['answers'][index] ) if @json_data['answers'][index]
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# This method is needed for Enumerable.
|
48
|
+
def each &block
|
49
|
+
@json_data['answers'].each{ |process| yield( UserProcessAnswer.new(process) )}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Alias the count method
|
53
|
+
alias :size :count
|
54
|
+
|
55
|
+
# Checks if the list is empty.
|
56
|
+
#
|
57
|
+
# @return True on empty, false otherwise.
|
58
|
+
def empty?
|
59
|
+
@json_data['answers'].empty?
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(options = {}, cacher = nil)
|
10
10
|
page = options[:page] || 1
|
11
|
-
|
11
|
+
#@class_key = "address_list_#{page}"
|
12
12
|
@url_data_path = "/addresses"
|
13
13
|
@url_data_params = {:page => page}
|
14
14
|
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param options (optional) Options for including more information.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(address_id, options = {}, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "address_#{address_id}"
|
12
12
|
@url_data_path = "/addresses/#{address_id}"
|
13
13
|
|
14
14
|
# The object to store and load the cache.
|
data/lib/readers/api_reader.rb
CHANGED
@@ -11,14 +11,14 @@ module TheCity
|
|
11
11
|
#
|
12
12
|
# @return the data loaded in a JSON object.
|
13
13
|
def load_feed
|
14
|
-
if !@cacher.nil? and !@cacher.is_cache_expired?( @class_key )
|
15
|
-
|
16
|
-
else
|
14
|
+
# if !@cacher.nil? and !@cacher.is_cache_expired?( @class_key )
|
15
|
+
# data = @cacher.get_data( @class_key )
|
16
|
+
# else
|
17
17
|
@url_data_params ||= {}
|
18
18
|
response = TheCity::admin_request(:get, @url_data_path, @url_data_params)
|
19
19
|
data = JSON.parse(response.body)
|
20
20
|
@cacher.save_data(@class_key, data) unless @cacher.nil?
|
21
|
-
end
|
21
|
+
#end
|
22
22
|
|
23
23
|
return data
|
24
24
|
end
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(options = {}, cacher = nil)
|
10
10
|
page = options[:page] || 1
|
11
|
-
|
11
|
+
#@class_key = "checkin_list_#{page}"
|
12
12
|
@url_data_path = "/checkins"
|
13
13
|
@url_data_params = {:page => page}
|
14
14
|
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param options (optional) Options for including more information.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(checkin_id, options = {}, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "checkin_#{tag_id}"
|
12
12
|
@url_data_path = "/checkins/#{tag_id}"
|
13
13
|
|
14
14
|
# The object to store and load the cache.
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(options = {}, cacher = nil)
|
10
10
|
id = options[:id] || options[:external_id]
|
11
|
-
|
11
|
+
# @class_key = "family_#{id}"
|
12
12
|
@url_data_path = "/families/#{id}"
|
13
13
|
@url_data_params = {}
|
14
14
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_addresses"
|
14
14
|
@url_data_path = "/groups/#{group_id}/addresses"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_checkins"
|
14
14
|
@url_data_path = "/groups/#{group_id}/checkins"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_event_attendances"
|
14
14
|
@url_data_path = "/groups/#{group_id}/event_attendances"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_exports"
|
14
14
|
@url_data_path = "/groups/#{group_id}/exports"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_invitations_#{page}"
|
14
14
|
@url_data_path = "/groups/#{group_id}/invitations"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -8,13 +8,11 @@ module TheCity
|
|
8
8
|
# @param options A hash of options for requesting data from the server.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
|
-
|
12
|
-
filter = options[:filter]
|
11
|
+
options[:page] ||= 1
|
13
12
|
|
14
|
-
|
13
|
+
#@class_key = "group_list_#{options[:page]}_{some_kind_of_md5_thing_here}"
|
15
14
|
@url_data_path = "/groups"
|
16
|
-
@url_data_params =
|
17
|
-
@url_data_params.merge!({:filter => filter}) if filter
|
15
|
+
@url_data_params = options
|
18
16
|
|
19
17
|
# The object to store and load the cache.
|
20
18
|
@cacher = cacher unless cacher.nil?
|
data/lib/readers/group_reader.rb
CHANGED
@@ -7,7 +7,7 @@ module TheCity
|
|
7
7
|
# <b>group_id</b> The ID of the group to load.
|
8
8
|
# <b>CacheAdapter cacher</b> (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(group_id, cacher = nil)
|
10
|
-
|
10
|
+
#@class_key = "groups_#{group_id}"
|
11
11
|
@url_data_path = "/groups/#{group_id}"
|
12
12
|
|
13
13
|
# The object to store and load the cache.
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_roles_#{page}"
|
14
14
|
@url_data_path = "/groups/#{group_id}/roles"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
group_id = options[:group_id]
|
13
|
-
|
13
|
+
#@class_key = "groups_#{group_id}_tags_#{page}"
|
14
14
|
@url_data_path = "/groups/#{group_id}/tags"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param options A hash of options for requesting data from the server.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(metric_id, page = 1, options = {}, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "metric_#{metric_id}_measurement_list_#{page}"
|
12
12
|
@url_data_path = "/metrics/#{metric_id}/measurements"
|
13
13
|
@url_data_params = {:page => page}
|
14
14
|
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# <b>measurement_id</b> The ID of the measurement to load.
|
9
9
|
# <b>CacheAdapter cacher</b> (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(metric_id, measurement_id, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "metrics_#{metric_id}_measurements_#{measurement_id}"
|
12
12
|
@url_data_path = "/metrics/#{metric_id}/measurements/#{measurement_id}"
|
13
13
|
|
14
14
|
# The object to store and load the cache.
|
@@ -7,7 +7,7 @@ module TheCity
|
|
7
7
|
# <b>metric_id</b> The ID of the metric to load.
|
8
8
|
# <b>CacheAdapter cacher</b> (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(metric_id, cacher = nil)
|
10
|
-
|
10
|
+
#@class_key = "metrics_#{metric_id}"
|
11
11
|
@url_data_path = "/metrics/#{metric_id}"
|
12
12
|
|
13
13
|
# The object to store and load the cache.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class PledgeListReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# @param page The page number to get. Default is 1.
|
8
|
+
# @param options A hash of options for requesting data from the server.
|
9
|
+
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
|
+
def initialize(options = {}, cacher = nil)
|
11
|
+
options[:page] ||= 1
|
12
|
+
|
13
|
+
#@class_key = "pledge_list_#{options[:page]}_{some_kind_of_md5_thing_here}"
|
14
|
+
@url_data_path = "/pledges"
|
15
|
+
@url_data_params = options
|
16
|
+
|
17
|
+
# The object to store and load the cache.
|
18
|
+
@cacher = cacher unless cacher.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class PledgeReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# <b>pledge_id</b> The ID of the pledge to load.
|
8
|
+
# <b>CacheAdapter cacher</b> (optional) The cacher to be used to cache data.
|
9
|
+
def initialize(pledge_id, cacher = nil)
|
10
|
+
#@class_key = "pledges_#{pledge_id}"
|
11
|
+
@url_data_path = "/pledges/#{pledge_id}"
|
12
|
+
|
13
|
+
# The object to store and load the cache.
|
14
|
+
@cacher = cacher unless cacher.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(options = {}, cacher = nil)
|
10
10
|
page = options[:page] || 1
|
11
|
-
|
11
|
+
#@class_key = "role_list_#{page}"
|
12
12
|
@url_data_path = "/roles"
|
13
13
|
@url_data_params = {:page => page}
|
14
14
|
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
9
9
|
def initialize(options = {}, cacher = nil)
|
10
10
|
page = options[:page] || 1
|
11
|
-
|
11
|
+
#@class_key = "skill_list_#{page}"
|
12
12
|
@url_data_path = "/skills"
|
13
13
|
@url_data_params = {:page => page}
|
14
14
|
|
@@ -9,7 +9,7 @@ module TheCity
|
|
9
9
|
# @param options A hash of options for requesting data from the server.
|
10
10
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
11
11
|
def initialize(skill_id, page = 1, options = {}, cacher = nil)
|
12
|
-
|
12
|
+
#@class_key = "skilled_user_id_list_#{page}"
|
13
13
|
@url_data_path = "/skills/#{skill_id}/user_ids"
|
14
14
|
@url_data_params = {:page => page}
|
15
15
|
|
@@ -9,7 +9,7 @@ module TheCity
|
|
9
9
|
# @param options A hash of options for requesting data from the server.
|
10
10
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
11
11
|
def initialize(skill_id, page = 1, options = {}, cacher = nil)
|
12
|
-
|
12
|
+
#@class_key = "skilled_user_list_#{page}"
|
13
13
|
@url_data_path = "/skills/#{skill_id}/users"
|
14
14
|
@url_data_params = {:page => page}
|
15
15
|
|
@@ -9,7 +9,7 @@ module TheCity
|
|
9
9
|
# @param options A hash of options for requesting data from the server.
|
10
10
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
11
11
|
def initialize(tag_id, page = 1, options = {}, cacher = nil)
|
12
|
-
|
12
|
+
#@class_key = "tag_#{tag_id}_group_list_#{page}"
|
13
13
|
@url_data_path = "/tags/#{tag_id}/groups"
|
14
14
|
@url_data_params = {:page => page}
|
15
15
|
|
data/lib/readers/tag_reader.rb
CHANGED
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param options (optional) Options for including more information.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(tag_id, options = {}, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "tags_#{tag_id}"
|
12
12
|
@url_data_path = "/tags/#{tag_id}"
|
13
13
|
|
14
14
|
# The object to store and load the cache.
|
@@ -8,7 +8,7 @@ module TheCity
|
|
8
8
|
# @param options (optional) Options for including more information.
|
9
9
|
# @param [CacheAdapter] cacher (optional) The cacher to be used to cache data.
|
10
10
|
def initialize(term, options = {}, cacher = nil)
|
11
|
-
|
11
|
+
#@class_key = "terminology_#{term}"
|
12
12
|
@url_data_path = "/terminology/#{term}"
|
13
13
|
|
14
14
|
# The object to store and load the cache.
|
@@ -10,7 +10,7 @@ module TheCity
|
|
10
10
|
def initialize(options = {}, cacher = nil)
|
11
11
|
page = options[:page] || 1
|
12
12
|
user_id = options[:user_id]
|
13
|
-
|
13
|
+
#@class_key = "users_#{user_id}_addresses"
|
14
14
|
@url_data_path = "/users/#{user_id}/addresses"
|
15
15
|
@url_data_params = {:page => page}
|
16
16
|
|