the-city-admin 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -5
- data/examples/tags.rb +23 -33
- data/lib/api/group.rb +1 -10
- data/lib/api/skill.rb +18 -3
- data/lib/common.rb +15 -10
- data/lib/readers/api_reader.rb +7 -11
- data/lib/readers/skill_reader.rb +21 -0
- data/lib/writers/api_writer.rb +1 -1
- data/thecity_admin_api.gemspec +2 -2
- metadata +5 -5
- data/index.rb +0 -356
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -16,9 +16,12 @@ GEM
|
|
16
16
|
debugger-ruby_core_source (>= 1.1.1)
|
17
17
|
debugger-ruby_core_source (1.1.3)
|
18
18
|
diff-lcs (1.1.3)
|
19
|
+
ethon (0.5.3)
|
20
|
+
ffi (~> 1.0.11)
|
21
|
+
mime-types (~> 1.18)
|
19
22
|
factory_girl (4.0.0)
|
20
23
|
activesupport (>= 3.0.0)
|
21
|
-
ffi (1.
|
24
|
+
ffi (1.0.11)
|
22
25
|
i18n (0.6.1)
|
23
26
|
json (1.7.5)
|
24
27
|
mime-types (1.19)
|
@@ -31,9 +34,8 @@ GEM
|
|
31
34
|
rspec-expectations (2.11.2)
|
32
35
|
diff-lcs (~> 1.1.3)
|
33
36
|
rspec-mocks (2.11.2)
|
34
|
-
typhoeus (0.
|
35
|
-
|
36
|
-
mime-types (~> 1.18)
|
37
|
+
typhoeus (0.5.1)
|
38
|
+
ethon (= 0.5.3)
|
37
39
|
|
38
40
|
PLATFORMS
|
39
41
|
ruby
|
@@ -44,4 +46,4 @@ DEPENDENCIES
|
|
44
46
|
factory_girl
|
45
47
|
json
|
46
48
|
rspec
|
47
|
-
typhoeus (= 0.
|
49
|
+
typhoeus (= 0.5.1)
|
data/examples/tags.rb
CHANGED
@@ -17,55 +17,45 @@ TheCity::AdminApi.connect(KEY, TOKEN)
|
|
17
17
|
puts "------------------------------------"
|
18
18
|
|
19
19
|
tag_list = TheCity::TagList.new
|
20
|
-
|
21
|
-
puts "No tags in list"
|
22
|
-
else
|
23
|
-
puts "Tags: #{tag_list.count}"
|
24
|
-
end
|
20
|
+
puts "Tags: #{tag_list.total_entries}"
|
25
21
|
|
22
|
+
|
23
|
+
puts "*******************"
|
26
24
|
tag = TheCity::Tag.new
|
27
|
-
tag.name = '
|
25
|
+
tag.name = 'zProgrammer'
|
26
|
+
|
28
27
|
if tag.save
|
29
|
-
puts "Tag
|
28
|
+
puts "Tag SAVED"
|
30
29
|
else
|
31
|
-
puts "
|
30
|
+
puts "FAILED TO SAVE TAG: #{tag.error_messages}"
|
32
31
|
end
|
32
|
+
puts "*******************"
|
33
33
|
|
34
|
+
tag_list = TheCity::TagList.new
|
35
|
+
puts "Tags: #{tag_list.total_entries}"
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
puts "No tags in list"
|
38
|
-
else
|
39
|
-
puts "Tags: #{tag_list2.count}"
|
40
|
-
end
|
37
|
+
puts "*******************"
|
38
|
+
tag.name = 'zProgrammer 2'
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
puts "Tag not found"
|
40
|
+
if tag.save
|
41
|
+
puts "Tag Updated"
|
45
42
|
else
|
46
|
-
puts "
|
43
|
+
puts "FAILED TO SAVE TAG: #{tag.error_messages}"
|
47
44
|
end
|
45
|
+
puts "*******************"
|
48
46
|
|
49
47
|
|
50
|
-
|
51
|
-
if tag.
|
52
|
-
puts "Tag
|
48
|
+
puts "*******************"
|
49
|
+
if tag.delete
|
50
|
+
puts "Tag Deleted"
|
53
51
|
else
|
54
|
-
puts "
|
52
|
+
puts "FAILED TO DELETE TAG: #{tag.error_messages}"
|
55
53
|
end
|
54
|
+
puts "*******************"
|
56
55
|
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
else
|
61
|
-
puts "Unable to delete tag #{tag.id}: #{tag.error_messages.join(', ')}"
|
62
|
-
end
|
57
|
+
tag_list = TheCity::TagList.new
|
58
|
+
puts "Tags: #{tag_list.total_entries}"
|
63
59
|
|
64
|
-
tag_list3 = TheCity::TagList.new
|
65
|
-
if tag_list3.empty?
|
66
|
-
puts "No tags in list"
|
67
|
-
else
|
68
|
-
puts "Tags: #{tag_list3.count}"
|
69
|
-
end
|
70
60
|
|
71
61
|
puts "####################################"
|
data/lib/api/group.rb
CHANGED
@@ -55,6 +55,7 @@ module TheCity
|
|
55
55
|
elsif reader.is_a?(Hash)
|
56
56
|
initialize_from_json_object(reader)
|
57
57
|
end
|
58
|
+
@writer_object = GroupWriter
|
58
59
|
|
59
60
|
@address_list = nil
|
60
61
|
@checkin_list = nil
|
@@ -163,16 +164,6 @@ module TheCity
|
|
163
164
|
return @tag_list
|
164
165
|
end
|
165
166
|
|
166
|
-
|
167
|
-
|
168
|
-
# Save this object.
|
169
|
-
#
|
170
|
-
# @return True on success, otherwise false.
|
171
|
-
def save
|
172
|
-
writer = GroupWriter.new(self.to_attributes)
|
173
|
-
writer.save_feed
|
174
|
-
end
|
175
|
-
|
176
167
|
end
|
177
168
|
|
178
169
|
end
|
data/lib/api/skill.rb
CHANGED
@@ -6,12 +6,27 @@ module TheCity
|
|
6
6
|
:name,
|
7
7
|
:created_at
|
8
8
|
|
9
|
+
|
10
|
+
# Loads the skill by the specified ID.
|
11
|
+
#
|
12
|
+
# @param skill_id The ID of the skill to load.
|
13
|
+
#
|
14
|
+
# Returns a new {Skill} object.
|
15
|
+
def self.load_by_id(fund_id)
|
16
|
+
skill_reader = SkillReader.new(fund_id)
|
17
|
+
self.new(skill_reader)
|
18
|
+
end
|
19
|
+
|
9
20
|
# Constructor.
|
10
21
|
#
|
11
|
-
# @param
|
12
|
-
def initialize(
|
22
|
+
# @param reader (optional) The object that has the data. This can be a {SkillReader} or Hash object.
|
23
|
+
def initialize(reader = nil)
|
13
24
|
@writer_object = SkillWriter
|
14
|
-
|
25
|
+
if reader.is_a?(SkillReader)
|
26
|
+
initialize_from_json_object(reader.load_feed)
|
27
|
+
elsif reader.is_a?(Hash)
|
28
|
+
initialize_from_json_object(reader)
|
29
|
+
end
|
15
30
|
end
|
16
31
|
|
17
32
|
end
|
data/lib/common.rb
CHANGED
@@ -3,25 +3,26 @@ module TheCity
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
|
6
|
-
def self.admin_request(method, path, params = {})
|
7
|
-
headers = self._build_admin_headers(method, path, params)
|
6
|
+
def self.admin_request(method, path, params = {}, body = '')
|
7
|
+
headers = self._build_admin_headers(method, path, params, body)
|
8
8
|
url = THE_CITY_ADMIN_PATH+path
|
9
9
|
|
10
10
|
response =
|
11
11
|
case method
|
12
12
|
when :post
|
13
|
-
Typhoeus::Request.post(url, {:headers => headers, :
|
13
|
+
Typhoeus::Request.post(url, {:headers => headers, :body => body})
|
14
14
|
when :get
|
15
15
|
Typhoeus::Request.get(url, {:headers => headers, :params => params})
|
16
16
|
when :put
|
17
|
-
Typhoeus::Request.put(url, {:headers => headers, :
|
17
|
+
Typhoeus::Request.put(url, {:headers => headers, :body => body})
|
18
18
|
when :delete
|
19
19
|
Typhoeus::Request.delete(url, {:headers => headers, :params => params})
|
20
20
|
end
|
21
21
|
|
22
|
+
|
22
23
|
unless response.success?
|
23
|
-
if response.
|
24
|
-
raise TheCityExceptions::UnableToConnectToTheCity.new(response.
|
24
|
+
if response.code > 0
|
25
|
+
raise TheCityExceptions::UnableToConnectToTheCity.new(response.body)
|
25
26
|
else
|
26
27
|
begin
|
27
28
|
error_messages = JSON.parse(response.body)['error_message']
|
@@ -38,14 +39,17 @@ module TheCity
|
|
38
39
|
end
|
39
40
|
|
40
41
|
|
41
|
-
def self._build_admin_headers(method, path, params)
|
42
|
+
def self._build_admin_headers(method, path, params, body)
|
42
43
|
get_vars = method == :post ? '' : '?'
|
43
|
-
|
44
|
+
if params
|
45
|
+
get_vars += params.to_a.sort.collect { |kv_pair| "#{kv_pair[0]}=#{kv_pair[1].to_s}" }.join('&')
|
46
|
+
end
|
44
47
|
get_vars = '' if get_vars == '?'
|
45
48
|
method_request = method.to_s.upcase
|
46
|
-
url = THE_CITY_ADMIN_PATH + path + get_vars
|
49
|
+
url = THE_CITY_ADMIN_PATH + path + get_vars + body
|
47
50
|
current_time = Time.now.to_i.to_s
|
48
51
|
string_to_sign = current_time.to_s + method_request + url
|
52
|
+
|
49
53
|
unencoded_hmac = OpenSSL::HMAC.digest('sha256', TheCity::AdminApi::API_KEY, string_to_sign)
|
50
54
|
unescaped_hmac = Base64.encode64(unencoded_hmac).chomp
|
51
55
|
hmac_signature = CGI.escape(unescaped_hmac)
|
@@ -54,7 +58,8 @@ module TheCity
|
|
54
58
|
'X-City-User-Token' => TheCity::AdminApi::API_TOKEN,
|
55
59
|
'X-City-Time' => current_time,
|
56
60
|
'Accept' => 'application/vnd.thecity.admin.v1+json',
|
57
|
-
'Content-Type' => 'application/json'
|
61
|
+
'Content-Type' => 'application/json',
|
62
|
+
'Content-Length' => body.length}
|
58
63
|
end
|
59
64
|
|
60
65
|
end
|
data/lib/readers/api_reader.rb
CHANGED
@@ -18,30 +18,26 @@ module TheCity
|
|
18
18
|
@url_data_params ||= {}
|
19
19
|
response = TheCity::admin_request(:get, @url_data_path, @url_data_params)
|
20
20
|
data = JSON.parse(response.body)
|
21
|
-
@headers =
|
21
|
+
@headers = response.headers
|
22
22
|
@cacher.save_data(@class_key, data) unless @cacher.nil?
|
23
23
|
#end
|
24
24
|
|
25
25
|
return data
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns either the value of the X-City-RateLimit-Limit-By-Ip header or
|
33
|
-
# X-City-RateLimit-Limit-By-Account header, whichever is lower.
|
28
|
+
# Returns either the value of the x-city-ratelimit-limit-by-ip header or
|
29
|
+
# x-city-ratelimit-limit-by-account header, whichever is lower.
|
34
30
|
def rate_limit
|
35
31
|
if @headers
|
36
|
-
[@headers['
|
32
|
+
[@headers['x-city-ratelimit-limit-by-ip'].to_i, @headers['x-city-ratelimit-limit-by-account'].to_i].min
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
|
-
# Returns either the value of the
|
41
|
-
#
|
36
|
+
# Returns either the value of the x-city-ratelimit-remaining-by-ip header or
|
37
|
+
# x-city-ratelimit-remaining-by-account header, whichever is lower.
|
42
38
|
def rate_limit_remaining
|
43
39
|
if @headers
|
44
|
-
[@headers['
|
40
|
+
[@headers['x-city-ratelimit-remaining-by-ip'].to_i, @headers['x-city-ratelimit-remaining-by-account'].to_i].min
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TheCity
|
2
|
+
|
3
|
+
class SkillReader < ApiReader
|
4
|
+
|
5
|
+
# Constructor.
|
6
|
+
#
|
7
|
+
# <b>skill_id</b> The ID of the skill to load.
|
8
|
+
# <b>CacheAdapter cacher</b> (optional) The cacher to be used to cache data.
|
9
|
+
def initialize(skill_id, cacher = nil)
|
10
|
+
#@class_key = "funds_#{fund_id}"
|
11
|
+
@url_data_path = "/skills/#{skill_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
|
+
|
data/lib/writers/api_writer.rb
CHANGED
@@ -22,7 +22,7 @@ module TheCity
|
|
22
22
|
end
|
23
23
|
|
24
24
|
begin
|
25
|
-
response = TheCity::admin_request(@url_action, @url_data_path, @url_data_params)
|
25
|
+
response = TheCity::admin_request(@url_action, @url_data_path, nil, @url_data_params.to_json)
|
26
26
|
@response_code = response.code
|
27
27
|
# No content but is a success
|
28
28
|
success = response.code == 204 ? {'success' => true} : JSON.parse(response.body)
|
data/thecity_admin_api.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
PROJECT_GEM = 'the-city-admin'
|
3
|
-
PROJECT_GEM_VERSION = '0.
|
3
|
+
PROJECT_GEM_VERSION = '0.4.0'
|
4
4
|
|
5
5
|
s.name = PROJECT_GEM
|
6
6
|
s.version = PROJECT_GEM_VERSION
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.summary = 'Ruby gem/plugin to interact with The City Admin API (https://api.OnTheCity.org).'
|
16
16
|
s.description = 'Ruby gem/plugin to interact with The City Admin API (https://api.OnTheCity.org). Checkout the project on github for more detail.'
|
17
17
|
|
18
|
-
s.add_dependency('typhoeus', '0.
|
18
|
+
s.add_dependency('typhoeus', '0.5.1')
|
19
19
|
|
20
20
|
|
21
21
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the-city-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.5.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.5.1
|
30
30
|
description: Ruby gem/plugin to interact with The City Admin API (https://api.OnTheCity.org).
|
31
31
|
Checkout the project on github for more detail.
|
32
32
|
email: wes@onthecity.org
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- examples/thecity_headers.rb
|
60
60
|
- examples/users.rb
|
61
61
|
- examples/webhooks.rb
|
62
|
-
- index.rb
|
63
62
|
- lib/api/address.rb
|
64
63
|
- lib/api/address_list.rb
|
65
64
|
- lib/api/api_object.rb
|
@@ -165,6 +164,7 @@ files:
|
|
165
164
|
- lib/readers/pledge_reader.rb
|
166
165
|
- lib/readers/role_list_reader.rb
|
167
166
|
- lib/readers/skill_list_reader.rb
|
167
|
+
- lib/readers/skill_reader.rb
|
168
168
|
- lib/readers/skilled_user_id_list_reader.rb
|
169
169
|
- lib/readers/skilled_user_list_reader.rb
|
170
170
|
- lib/readers/tag_group_list_reader.rb
|
data/index.rb
DELETED
@@ -1,356 +0,0 @@
|
|
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
|
-
# TCA_ENV = 'development'
|
9
|
-
# THE_CITY_ADMIN_PATH = 'http://api.devthecity.org:9292'
|
10
|
-
# key = 'Dev Key'
|
11
|
-
# token = 'dev token'
|
12
|
-
|
13
|
-
key = 'YOUR KEY'
|
14
|
-
token = 'YOUR TOKEN'
|
15
|
-
|
16
|
-
require 'open-uri'
|
17
|
-
require 'csv'
|
18
|
-
require 'ruby-debug'
|
19
|
-
require File.dirname(__FILE__) + '/lib/the_city_admin.rb'
|
20
|
-
|
21
|
-
TheCity::AdminApi.connect(key, token)
|
22
|
-
|
23
|
-
# group_export = TheCity::GroupExport.new
|
24
|
-
# group_export.group_id = 73608
|
25
|
-
# if group_export.save
|
26
|
-
# puts "Export created"
|
27
|
-
# else
|
28
|
-
# puts "Export failed: #{group_export.error_messages.join(', ')}"
|
29
|
-
# end
|
30
|
-
|
31
|
-
|
32
|
-
# done = false
|
33
|
-
# page = 1
|
34
|
-
# count = 0
|
35
|
-
|
36
|
-
# while !done
|
37
|
-
# export_list = TheCity::GroupExportList.new({:page => page, :group_id => 73608})
|
38
|
-
|
39
|
-
# export_list.each do |export|
|
40
|
-
# count += 1
|
41
|
-
# puts "#{count}) #{export.id} :: #{export.state}"
|
42
|
-
# end
|
43
|
-
|
44
|
-
# if export_list.total_pages <= page
|
45
|
-
# done = true
|
46
|
-
# else
|
47
|
-
# page += 1
|
48
|
-
# end
|
49
|
-
# end
|
50
|
-
|
51
|
-
# export_list = TheCity::GroupExportList.new({:page => page, :group_id => 73608})
|
52
|
-
# group_export = export_list[0]
|
53
|
-
# puts group_export.inspect
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
group_export = TheCity::GroupExport.load_by_id(100996, {:group_id => 73608})
|
58
|
-
path = group_export.authenticated_s3_url
|
59
|
-
|
60
|
-
data = open(path).read()
|
61
|
-
|
62
|
-
CSV.parse(data, {:headers => true}).each do |row|
|
63
|
-
puts [row[2], row[4]].join(' ')
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
# puts "-----------------------------"
|
68
|
-
# puts "##### Web Hooks #######"
|
69
|
-
# puts "-----------------------------"
|
70
|
-
|
71
|
-
# web_hooks = TheCity::WebHookList.new({:page => 1})
|
72
|
-
# web_hooks.each do |hook|
|
73
|
-
# puts hook.inspect
|
74
|
-
# end
|
75
|
-
|
76
|
-
# web_hook1 = TheCity::WebHook.new({:callback_uri => 'https://www.somedomain.com/city/callbacks/fund/create',
|
77
|
-
# :object => TheCity::WebHook::Objects[:fund],
|
78
|
-
# :event => TheCity::WebHook::Events[:create]})
|
79
|
-
|
80
|
-
# web_hook2 = TheCity::WebHook.new({:callback_uri => 'https://www.somedomain.com/city/callbacks/pledge/create',
|
81
|
-
# :object => TheCity::WebHook::Objects[:pledge],
|
82
|
-
# :event => TheCity::WebHook::Events[:create]})
|
83
|
-
|
84
|
-
# web_hook3 = TheCity::WebHook.new({:callback_uri => 'https://www.somedomain.com/city/callbacks/donation/create',
|
85
|
-
# :object => TheCity::WebHook::Objects[:donation],
|
86
|
-
# :event => TheCity::WebHook::Events[:create]})
|
87
|
-
|
88
|
-
# puts web_hook1.save ? 'Web Hook saved' : 'Web Hook failed'
|
89
|
-
# puts web_hook2.save ? 'Web Hook saved' : 'Web Hook failed'
|
90
|
-
# puts web_hook3.save ? 'Web Hook saved' : 'Web Hook failed'
|
91
|
-
|
92
|
-
# web_hooks = TheCity::WebHookList.new({:page => 1})
|
93
|
-
# web_hooks.each do |hook|
|
94
|
-
# puts hook.inspect
|
95
|
-
# puts hook.delete
|
96
|
-
# end
|
97
|
-
|
98
|
-
|
99
|
-
# puts "-----------------------------"
|
100
|
-
# puts "##### Invitations #######"
|
101
|
-
# puts "-----------------------------"
|
102
|
-
|
103
|
-
# invitation_list = TheCity::InvitationList.new({:page => 1})
|
104
|
-
|
105
|
-
# invitation_list.each do |invitation|
|
106
|
-
# puts invitation.inspect
|
107
|
-
# end
|
108
|
-
|
109
|
-
# puts "-----------------------------"
|
110
|
-
# puts "##### FUNDS / DONATIONS / PLEDGES #######"
|
111
|
-
# puts "-----------------------------"
|
112
|
-
|
113
|
-
|
114
|
-
# donation_list = TheCity::DonationList.new({:page => 1, :include_details => 1, :start_date => '2012-09-01', :end_date => '2012-09-30'})
|
115
|
-
|
116
|
-
# donation_list.each do |donation|
|
117
|
-
# puts [donation.user_name, donation.amount].join(' :: ')
|
118
|
-
# end
|
119
|
-
|
120
|
-
|
121
|
-
# fund_list = TheCity::FundList.new({:page => 1})
|
122
|
-
|
123
|
-
# fund_list.each do |fund|
|
124
|
-
# puts [fund.id, fund.name].join(' :: ')
|
125
|
-
# end
|
126
|
-
|
127
|
-
# sfund = TheCity::Fund.load_fund_by_id(fund_list.first.id)
|
128
|
-
|
129
|
-
# puts [sfund.id, sfund.name].join(' :-: ')
|
130
|
-
|
131
|
-
# done = false
|
132
|
-
# page = 1
|
133
|
-
# count = 0
|
134
|
-
|
135
|
-
# while !done
|
136
|
-
# group_list = TheCity::GroupList.new({:page => page, :group_types => 'CG', :include_inactive => true})
|
137
|
-
|
138
|
-
# group_list.each do |group|
|
139
|
-
# count += 1
|
140
|
-
# puts "#{count}) #{group.name} [#{group.group_type}]"
|
141
|
-
# end
|
142
|
-
|
143
|
-
# if group_list.total_pages <= page
|
144
|
-
# done = true
|
145
|
-
# else
|
146
|
-
# page += 1
|
147
|
-
# end
|
148
|
-
# end
|
149
|
-
|
150
|
-
|
151
|
-
# done = false
|
152
|
-
# page = 1
|
153
|
-
# count = 0
|
154
|
-
|
155
|
-
# while !done
|
156
|
-
# tag_list = TheCity::TagList.new({:page => page})
|
157
|
-
|
158
|
-
# tag_list.each do |tag|
|
159
|
-
# count += 1
|
160
|
-
# puts "#{count}) #{tag.name} :: #{tag.id}"
|
161
|
-
# end
|
162
|
-
|
163
|
-
# if tag_list.total_pages <= page
|
164
|
-
# done = true
|
165
|
-
# else
|
166
|
-
# page += 1
|
167
|
-
# end
|
168
|
-
# end
|
169
|
-
|
170
|
-
# tag_list = TheCity::TagList.new({:page => page})
|
171
|
-
# tag = tag_list[0]
|
172
|
-
|
173
|
-
# puts tag.name
|
174
|
-
# tag.name = "Wes Hays #{Random.rand(99999)}"
|
175
|
-
# if tag.save
|
176
|
-
# puts "TAG SAVED"
|
177
|
-
# else
|
178
|
-
# puts "TAG FAILED TO SAVE: #{tag.error_messages}"
|
179
|
-
# end
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
# puts "-----------------------------"
|
186
|
-
# puts "##### USERS #######"
|
187
|
-
# puts "-----------------------------"
|
188
|
-
|
189
|
-
|
190
|
-
# wes = TheCity::User.load_by_id(746076)
|
191
|
-
|
192
|
-
# wes.first = "Jim"
|
193
|
-
# if wes.save
|
194
|
-
# puts "Wes Saved"
|
195
|
-
# else
|
196
|
-
# puts "WES FAILED TO SAVE: #{wes.error_messages}"
|
197
|
-
# end
|
198
|
-
|
199
|
-
|
200
|
-
# user_list = TheCity::UserList.new
|
201
|
-
|
202
|
-
# user_list.each do |u|
|
203
|
-
# puts u.full_name
|
204
|
-
# end
|
205
|
-
|
206
|
-
# puts "-----------------------------"
|
207
|
-
|
208
|
-
# user = TheCity::User.new
|
209
|
-
# user.title = 'Deacon'
|
210
|
-
# user.first = 'James'
|
211
|
-
# user.middle = 'Wesley'
|
212
|
-
# user.last = 'Hays'
|
213
|
-
# user.nickname = 'Wes'
|
214
|
-
# user.gender = TheCity::User::Gender[:male]
|
215
|
-
# user.email = 'someguy@somewhere.org'
|
216
|
-
# user.staff = false
|
217
|
-
# user.member_since = Time.now.strftime("%Y-%m-%d")
|
218
|
-
# user.birthdate = '1980-09-27'
|
219
|
-
# user.primary_phone = '775-111-2222'
|
220
|
-
# user.primary_phone_type = TheCity::User::PhoneType[:mobile]
|
221
|
-
# user.secondary_phone = '775-333-4444'
|
222
|
-
# user.secondary_phone_type = TheCity::User::PhoneType[:home]
|
223
|
-
# user.marital_status = TheCity::User::MaritalStatus[:married]
|
224
|
-
# #user.primary_campus_id
|
225
|
-
# #user.external_id_1
|
226
|
-
# #user.external_id_2
|
227
|
-
# #user.external_id_3
|
228
|
-
|
229
|
-
# if user.save
|
230
|
-
# puts "User #{user.full_name} saved (#{user.id})"
|
231
|
-
# else
|
232
|
-
# user.error_messages.each { |em| puts em }
|
233
|
-
# end
|
234
|
-
|
235
|
-
# user2 = TheCity::User.load_by_id(user.id)
|
236
|
-
# user2.email = 'somegirl@somewhere.org'
|
237
|
-
# user2.nickname = 'dog'
|
238
|
-
|
239
|
-
# if user2.save
|
240
|
-
# puts "User #{user2.full_name} updated (#{user2.id})"
|
241
|
-
# else
|
242
|
-
# user2.error_messages.each { |em| puts em }
|
243
|
-
# end
|
244
|
-
|
245
|
-
# if user.delete
|
246
|
-
# puts "User #{user.full_name} deleted (#{user.id})"
|
247
|
-
# else
|
248
|
-
# puts "Something bad happened"
|
249
|
-
# #user.error_messages.each { |em| puts em }
|
250
|
-
# end
|
251
|
-
|
252
|
-
|
253
|
-
# puts "-----------------------------"
|
254
|
-
|
255
|
-
# user_list = TheCity::UserList.new
|
256
|
-
|
257
|
-
# user = user_list[0]
|
258
|
-
# puts user.full_name
|
259
|
-
# user.first = 'Wes'
|
260
|
-
# puts user.full_name
|
261
|
-
# user.save
|
262
|
-
# puts user.id
|
263
|
-
|
264
|
-
# user2 = TheCity::User.load_by_id(user.id)
|
265
|
-
# puts user2.full_name
|
266
|
-
|
267
|
-
# puts "User has #{user.addresses.size} addresses"
|
268
|
-
# puts "User has #{user.family.size} family members"
|
269
|
-
# puts "User has #{user.notes.size} notes"
|
270
|
-
# puts "User has #{user.roles.size} roles"
|
271
|
-
# puts "User has #{user.skills.size} skills"
|
272
|
-
# #puts "User has #{user.processes.size} processes"
|
273
|
-
# puts "User has #{user.invitations.size} invitations"
|
274
|
-
# #puts "User has #{user.admin_privileges.size} admin_privileges"
|
275
|
-
|
276
|
-
|
277
|
-
# This is currenly returning a 404 if no family members are found
|
278
|
-
# puts user.family[0].name
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
# puts "-----------------------------"
|
283
|
-
|
284
|
-
|
285
|
-
# group_list = TheCity::GroupList.new(:)
|
286
|
-
# puts group.name
|
287
|
-
# group.name = 'Wes Group'
|
288
|
-
# puts group.name
|
289
|
-
# group.save
|
290
|
-
# group2 = TheCity::Group.load_by_id(group.id)
|
291
|
-
# puts group2.name
|
292
|
-
|
293
|
-
|
294
|
-
# puts "-----------------------------"
|
295
|
-
# puts "##### GROUPS #######"
|
296
|
-
# puts "-----------------------------"
|
297
|
-
|
298
|
-
# group_list = TheCity::GroupList.new
|
299
|
-
|
300
|
-
# group = group_list[13]
|
301
|
-
# puts "Group Name: #{group.name} (#{group.id})"
|
302
|
-
|
303
|
-
# if group.roles.size == 0
|
304
|
-
# puts "No group roles found"
|
305
|
-
# else
|
306
|
-
# puts group.roles[0].title
|
307
|
-
# end
|
308
|
-
|
309
|
-
# if group.tags.size == 0
|
310
|
-
# puts "No group tags found"
|
311
|
-
# else
|
312
|
-
# puts group.tags[0].name
|
313
|
-
# end
|
314
|
-
|
315
|
-
# if group.invitations.size == 0
|
316
|
-
# puts "No group invitations found"
|
317
|
-
# else
|
318
|
-
# puts group.invitations[0].id
|
319
|
-
# end
|
320
|
-
|
321
|
-
|
322
|
-
# puts "-----------------------------"
|
323
|
-
# puts "##### SKILLS #######"
|
324
|
-
# puts "-----------------------------"
|
325
|
-
|
326
|
-
# skill_list = TheCity::SkillList.new
|
327
|
-
|
328
|
-
# puts skill_list.inspect
|
329
|
-
|
330
|
-
# # skill_list.each do |skill|
|
331
|
-
# # puts skill.name
|
332
|
-
# # end
|
333
|
-
|
334
|
-
|
335
|
-
# puts "-----------------------------"
|
336
|
-
# puts "##### USERS #######"
|
337
|
-
# puts "-----------------------------"
|
338
|
-
|
339
|
-
# done = false
|
340
|
-
# page = 1
|
341
|
-
|
342
|
-
|
343
|
-
# while !done
|
344
|
-
# user_list = TheCity::UserList.new({:page => page})
|
345
|
-
|
346
|
-
# user_list.each do |user|
|
347
|
-
# puts user.full_name
|
348
|
-
# end
|
349
|
-
|
350
|
-
# if user_list.total_pages <= page
|
351
|
-
# done = true
|
352
|
-
# else
|
353
|
-
# page += 1
|
354
|
-
# end
|
355
|
-
# end
|
356
|
-
|