index.rb in the-city-admin-0.1.1 vs index.rb in the-city-admin-0.1.2

- old
+ new

@@ -6,118 +6,138 @@ # ******************************************* require 'ruby-debug' require File.dirname(__FILE__) + '/lib/the_city_admin.rb' -# staging -# key = 'bc6b57204b0ee4818bb4b3befd0f3292e93a2d0a' -# token = '7cfed59b037125d3' +key = 'cf2903151e3213e66fd8080c7d8b65b1d6ccdd31' +token = '5c88b32edda7653c' -# Local -key = '66c59e2ee24553e7237259e30b4c17365681b95c' -token = 'a9ae4af3c3e80102' - - TheCity::AdminApi.connect(key, token) -###### USERS / GROUPS ####### +# puts "-----------------------------" +# puts "##### USERS #######" +# puts "-----------------------------" -puts "-----------------------------" -user = TheCity::User.new -user.title = 'Deacon' -user.first = 'James' -user.middle = 'Wesley' -user.last = 'Hays' -user.nickname = 'Wes' -user.gender = TheCity::User::Gender[:male] -user.email = 'wes+tc6@onthecity.org' -user.staff = false -user.member_since = Time.now.strftime("%Y-%m-%d") -user.birthdate = '1980-09-27' -user.primary_phone = '775-745-3013' -user.primary_phone_type = TheCity::User::PhoneType[:mobile] -user.secondary_phone = '775-677-7707' -user.secondary_phone_type = TheCity::User::PhoneType[:home] -#user.marital_status = TheCity::User::MaritalStatus[:married] -#user.primary_campus_id -#user.external_id_1 -#user.external_id_2 -#user.external_id_3 -unless user.save - user.error_messages.each { |em| puts em } -end +# user_list = TheCity::UserList.new -user.delete +# user_list.each do |u| +# puts u.full_name +# end - # puts "-----------------------------" +# user = TheCity::User.new +# user.title = 'Deacon' +# user.first = 'James' +# user.middle = 'Wesley' +# user.last = 'Hays' +# user.nickname = 'Wes' +# user.gender = TheCity::User::Gender[:male] +# user.email = 'someguy@somewhere.org' +# user.staff = false +# user.member_since = Time.now.strftime("%Y-%m-%d") +# user.birthdate = '1980-09-27' +# user.primary_phone = '775-111-2222' +# user.primary_phone_type = TheCity::User::PhoneType[:mobile] +# user.secondary_phone = '775-333-4444' +# user.secondary_phone_type = TheCity::User::PhoneType[:home] +# user.marital_status = TheCity::User::MaritalStatus[:married] +# #user.primary_campus_id +# #user.external_id_1 +# #user.external_id_2 +# #user.external_id_3 -# user = the_city.users[0] -# puts user.full_name -# user.first = 'Wes' -# puts user.full_name -# user.save -# puts user.id -# user2 = TheCity::User.load_user_by_id(user.id) -# puts user2.full_name +# if user.save +# puts "User #{user.full_name} saved (#{user.id})" +# else +# user.error_messages.each { |em| puts em } +# end -# group = the_city.groups[0] -# puts group.name -# group.name = 'Wes Group' -# puts group.name -# group.save -# group2 = TheCity::Group.load_group_by_id(group.id) -# puts group2.name +# user2 = TheCity::User.load_by_id(user.id) +# user2.email = 'somegirl@somewhere.org' +# user2.nickname = 'dog' +# if user2.save +# puts "User #{user2.full_name} updated (#{user2.id})" +# else +# user2.error_messages.each { |em| puts em } +# end +# if user.delete +# puts "User #{user.full_name} deleted (#{user.id})" +# else +# puts "Something bad happened" +# #user.error_messages.each { |em| puts em } +# end -###### USERS ####### +puts "-----------------------------" -# user = the_city.users[0] -# puts user.full_name +user_list = TheCity::UserList.new +user = user_list[0] +puts user.full_name +user.first = 'Wes' +puts user.full_name +user.save +puts user.id -# user2 = TheCity::User.load_user_by_id(1068169470) #(564114313) -# puts user2.full_name +user2 = TheCity::User.load_by_id(user.id) +puts user2.full_name -# user = the_city.users[1] -# puts user.full_name +puts "User has #{user.addresses.size} addresses" +puts "User has #{user.family.size} family members" +puts "User has #{user.notes.size} notes" +puts "User has #{user.roles.size} roles" +puts "User has #{user.skills.size} skills" +#puts "User has #{user.processes.size} processes" +puts "User has #{user.invitations.size} invitations" +#puts "User has #{user.admin_privileges.size} admin_privileges" + # This is currenly returning a 404 if no family members are found # puts user.family[0].name -# puts user.addresses[0].location_type -# puts user.notes[0].author -# puts user.roles[0].group_name -# puts user.skills[0].name -# puts user.processes[0].name -# puts user.invitations[0].source -# puts user.admin_privileges[0].title -###### GROUPS ####### +# puts "-----------------------------" -# group = the_city.groups[0] +# group_list = TheCity::GroupList.new +# group = group_list[0] # puts group.name -# puts group.id +# group.name = 'Wes Group' +# puts group.name +# group.save +# group2 = TheCity::Group.load_by_id(group.id) +# puts group2.name -# Fails with 500 error -# puts group.addresses[0].location_type -# puts group.roles[0].user_name -# puts group.tags[0].name +# # puts "-----------------------------" +# # puts "##### GROUPS #######" +# # puts "-----------------------------" -# puts group.invitations[0].source +# group_list = TheCity::GroupList.new -# metric = the_city.metrics[0] +# group = group_list[13] +# puts "Group Name: #{group.name} (#{group.id})" -# puts metric.name -# metric.measurements.total_entries.times do |i| -# puts "#{metric.measurements[i].created_at}: #{metric.measurements[i].value}" +# if group.roles.size == 0 +# puts "No group roles found" +# else +# puts group.roles[0].title # end -# new_measurement = TheCity::MetricMeasurement.new(:id => metric.id, :value => 999) -# new_measurement.save + +# if group.tags.size == 0 +# puts "No group tags found" +# else +# puts group.tags[0].name +# end + +# if group.invitations.size == 0 +# puts "No group invitations found" +# else +# puts group.invitations[0].id +# end +