the-city-admin 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +2 -0
  3. data/.pryrc +3 -0
  4. data/.rspec +1 -1
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +12 -0
  8. data/Gemfile +6 -3
  9. data/Gemfile.lock +58 -28
  10. data/README.rdoc +4 -1
  11. data/examples/barcodes_checkins.rb +37 -14
  12. data/lib/api/checkin.rb +1 -1
  13. data/lib/api/checkin_list.rb +0 -1
  14. data/lib/api/checkin_list_by_callboard_number.rb +61 -0
  15. data/lib/api/checkin_list_by_pager_number.rb +61 -0
  16. data/lib/api/group_checkin.rb +13 -2
  17. data/lib/api/group_checkin_event.rb +24 -0
  18. data/lib/api/group_checkin_events_list.rb +64 -0
  19. data/lib/api/group_checkin_list.rb +2 -2
  20. data/lib/readers/api_reader.rb +9 -2
  21. data/lib/readers/checkin_list_by_callboard_number_reader.rb +27 -0
  22. data/lib/readers/checkin_list_by_pager_number_reader.rb +27 -0
  23. data/lib/readers/checkin_list_reader.rb +2 -2
  24. data/lib/readers/group_checkin_events_list_reader.rb +28 -0
  25. data/lib/readers/group_checkin_reader.rb +32 -0
  26. data/lib/readers/group_list_reader.rb +0 -1
  27. data/spec/api/checkin_list_by_callboard_number_spec.rb +91 -0
  28. data/spec/api/checkin_list_by_pager_number_spec.rb +98 -0
  29. data/spec/api/checkin_list_spec.rb +91 -0
  30. data/spec/api/group_address_list_spec.rb +1 -1
  31. data/spec/api/group_address_spec.rb +2 -3
  32. data/spec/api/group_checkin_events_list_spec.rb +91 -0
  33. data/spec/api/group_checkin_list_spec.rb +1 -1
  34. data/spec/api/group_checkin_spec.rb +12 -0
  35. data/spec/api/group_event_attendance_list_spec.rb +1 -1
  36. data/spec/api/group_export_spec.rb +1 -5
  37. data/spec/api/group_invitation_list_spec.rb +6 -6
  38. data/spec/api/group_invitation_spec.rb +1 -5
  39. data/spec/api/group_list_spec.rb +72 -7
  40. data/spec/api/group_role_list_spec.rb +6 -6
  41. data/spec/api/group_role_spec.rb +1 -5
  42. data/spec/api/group_spec.rb +1 -5
  43. data/spec/api/group_tag_list_spec.rb +6 -6
  44. data/spec/api/group_tag_spec.rb +1 -5
  45. data/spec/api/metric_list_spec.rb +6 -6
  46. data/spec/api/metric_measurement_list_spec.rb +6 -6
  47. data/spec/api/metric_measurement_spec.rb +2 -2
  48. data/spec/api/metric_spec.rb +2 -2
  49. data/spec/api/role_list_spec.rb +1 -1
  50. data/spec/api/role_spec.rb +2 -2
  51. data/spec/api/skill_list_spec.rb +1 -1
  52. data/spec/api/skilled_user_id_list_spec.rb +1 -1
  53. data/spec/api/skilled_user_list_spec.rb +1 -1
  54. data/spec/api/tag_group_list_spec.rb +1 -1
  55. data/spec/api/tag_list_spec.rb +1 -1
  56. data/spec/api/tag_spec.rb +2 -2
  57. data/spec/api/terminology_list_spec.rb +1 -1
  58. data/spec/api/terminology_spec.rb +2 -2
  59. data/spec/api/user_address_list_spec.rb +1 -1
  60. data/spec/api/user_address_spec.rb +2 -2
  61. data/spec/api/user_admin_privilege_list_spec.rb +1 -1
  62. data/spec/api/user_admin_privilege_spec.rb +2 -2
  63. data/spec/api/user_barcode_spec.rb +2 -2
  64. data/spec/api/user_family_list_spec.rb +1 -1
  65. data/spec/api/user_family_member_spec.rb +2 -2
  66. data/spec/api/user_invitation_list_spec.rb +1 -1
  67. data/spec/api/user_invitation_spec.rb +2 -2
  68. data/spec/api/user_list_spec.rb +1 -1
  69. data/spec/api/user_note_list_spec.rb +1 -1
  70. data/spec/api/user_note_spec.rb +2 -2
  71. data/spec/api/user_process_answer_list_spec.rb +1 -1
  72. data/spec/api/user_process_list_spec.rb +1 -1
  73. data/spec/api/user_process_spec.rb +2 -2
  74. data/spec/api/user_role_list_spec.rb +1 -1
  75. data/spec/api/user_role_spec.rb +2 -2
  76. data/spec/api/user_skill_list_spec.rb +1 -1
  77. data/spec/api/user_skill_spec.rb +2 -2
  78. data/spec/api/user_spec.rb +1 -2
  79. data/spec/api/web_hook_list_spec.rb +1 -1
  80. data/spec/api/web_hook_spec.rb +2 -2
  81. data/spec/factories/group_checkin_event.rb +20 -0
  82. data/spec/factories/group_checkin_events_list.rb +14 -0
  83. data/spec/factories/group_list.rb +13 -0
  84. data/spec/functional/the_city_admin_spec.rb +5 -5
  85. data/spec/readers/api_reader_spec.rb +3 -5
  86. data/spec/readers/user_reader_spec.rb +1 -1
  87. data/spec/spec_helper.rb +9 -7
  88. data/thecity_admin_api.gemspec +6 -5
  89. metadata +51 -8
  90. data/.autotest +0 -9
  91. data/.rvmrc +0 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjY3NmM0N2EwZmJjNTI2NTU3NGU1MGE2YTFmMGUzMWViMDFjYTg3YQ==
4
+ NzE0NmI4NWUyMjA0NDc5YTA3YWU0YTJmZmUwMjAzOWFlNDZmN2UwYg==
5
5
  data.tar.gz: !binary |-
6
- NzFiYzM4ZmY0ZWU5MmUxMjRmN2NhNzljZWU3N2RmYTgzYmU0NDc3Ng==
6
+ ZTFjOGI0OTA2MmQ5NDk0NzY1NjQ0Mzc2MmFhYzk5MDhmYmRlYjBiMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjllMGMzYzYzNTI1NWRjNDA1YWZmM2ZhZTc2ZDM0ZWU2M2IwNjc0ZmJiYWNi
10
- MjRjMDJjNmFiY2IxN2I1YTI1Y2U5ZWUzNzkyNGVkY2Q4NzdhNzViYjYyMDE1
11
- MTMxNmQzM2MwNmFiZjdkZWI0NzJmNDAxMGUyMzhkMTAyZmM5Yzc=
9
+ NWIzNzVjZGUyNTFkNDgyMjRjOWQwZGUyYmEyZDExM2QzYTUxMWU4ZjE4OTZi
10
+ ZDI4MDlmZmQ3MzUxZjEwNDYwZjI2YWMwOGY1MmFlNWM3ODA0ZTE2M2VkMTk5
11
+ NjIwNDNlNTdhMmQwM2EzNTM5ZDI1NjU1ZjgwOTQyYjVkNmNlNmQ=
12
12
  data.tar.gz: !binary |-
13
- ZjZjMGM2ZDJiNzY4OWQyNzFjODJhN2U0ZWE0ODk2OTFjNTM5ZjI3NGYxNjZl
14
- NDBlMmNiMzc3ZDQ4OWZkZTQ3NmY1OGM0N2E5Y2YyNGMwNzQ5NzlmNjFjNDQ4
15
- MjFjNjcwOTVlZmVmYTdlMDkzNWI5Nzc3ZDQ3OWRlZTc5OWFjZTI=
13
+ ZmExMmQ2YmQyZmNiYzc1ZTk4ODJlYzE5NDM4YzIyZjlhODJmOWE2YjIwOThj
14
+ NmNmYTBkZGVhYWUyYWI5YzllMmM1NWZiYzZlY2U1MjQ0ZWY3ZjI3NWZiMWE1
15
+ NmNhNjNlZGE2ZjViOTYyNTFiNDFhYWZkYTlhNGNhNDVjMTRkODc=
data/.gitignore CHANGED
@@ -6,3 +6,5 @@ bin/
6
6
  .bundle/
7
7
  .rbenv-version
8
8
  index.rb
9
+ .idea/*
10
+ coverage
data/.pryrc ADDED
@@ -0,0 +1,3 @@
1
+ Pry.commands.alias_command 'c', 'continue'
2
+ Pry.commands.alias_command 's', 'step'
3
+ Pry.commands.alias_command 'n', 'next'
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format documentation
2
+ --format progress
@@ -0,0 +1 @@
1
+ admin-api
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p545
@@ -0,0 +1,12 @@
1
+ bundler_args: --without development
2
+ language: ruby
3
+ rvm:
4
+ - jruby-19mode
5
+ - jruby-head
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.1
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: jruby-19mode
12
+ - rvm: jruby-head
data/Gemfile CHANGED
@@ -1,10 +1,13 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'typhoeus', '0.6.6'
4
- gem 'json'
3
+ gemspec
5
4
 
6
5
  group :development, :test do
6
+ gem 'rake'
7
7
  gem 'rspec'
8
- gem 'debugger'
8
+ gem 'pry'
9
+ gem 'pry-nav'
9
10
  gem 'factory_girl'
11
+ gem 'simplecov', :require => false
12
+ gem 'coveralls', :require => false
10
13
  end
@@ -1,52 +1,82 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ the-city-admin (0.7.1)
5
+ json
6
+ typhoeus (= 0.6.6)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
4
- activesupport (4.0.1)
5
- i18n (~> 0.6, >= 0.6.4)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
11
+ activesupport (4.1.0)
12
+ i18n (~> 0.6, >= 0.6.9)
13
+ json (~> 1.7, >= 1.7.7)
14
+ minitest (~> 5.1)
8
15
  thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
10
- atomic (1.1.14)
11
- columnize (0.3.6)
12
- debugger (1.6.2)
13
- columnize (>= 0.3.1)
14
- debugger-linecache (~> 1.2.0)
15
- debugger-ruby_core_source (~> 1.2.3)
16
- debugger-linecache (1.2.0)
17
- debugger-ruby_core_source (1.2.3)
16
+ tzinfo (~> 1.1)
17
+ coderay (1.1.0)
18
+ coveralls (0.7.0)
19
+ multi_json (~> 1.3)
20
+ rest-client
21
+ simplecov (>= 0.7)
22
+ term-ansicolor
23
+ thor
18
24
  diff-lcs (1.2.5)
19
- ethon (0.6.1)
25
+ docile (1.1.3)
26
+ ethon (0.6.3)
20
27
  ffi (>= 1.3.0)
21
28
  mime-types (~> 1.18)
22
- factory_girl (4.3.0)
29
+ factory_girl (4.4.0)
23
30
  activesupport (>= 3.0.0)
24
31
  ffi (1.9.3)
25
- i18n (0.6.5)
32
+ i18n (0.6.9)
26
33
  json (1.8.1)
27
- mime-types (1.25)
28
- minitest (4.7.5)
29
- multi_json (1.8.2)
34
+ method_source (0.8.2)
35
+ mime-types (1.25.1)
36
+ minitest (5.3.2)
37
+ multi_json (1.9.2)
38
+ pry (0.9.12.6)
39
+ coderay (~> 1.0)
40
+ method_source (~> 0.8)
41
+ slop (~> 3.4)
42
+ pry-nav (0.2.3)
43
+ pry (~> 0.9.10)
44
+ rake (10.2.2)
45
+ rest-client (1.6.7)
46
+ mime-types (>= 1.16)
30
47
  rspec (2.14.1)
31
48
  rspec-core (~> 2.14.0)
32
49
  rspec-expectations (~> 2.14.0)
33
50
  rspec-mocks (~> 2.14.0)
34
- rspec-core (2.14.7)
35
- rspec-expectations (2.14.4)
51
+ rspec-core (2.14.8)
52
+ rspec-expectations (2.14.5)
36
53
  diff-lcs (>= 1.1.3, < 2.0)
37
- rspec-mocks (2.14.4)
38
- thread_safe (0.1.3)
39
- atomic
54
+ rspec-mocks (2.14.6)
55
+ simplecov (0.8.2)
56
+ docile (~> 1.1.0)
57
+ multi_json
58
+ simplecov-html (~> 0.8.0)
59
+ simplecov-html (0.8.0)
60
+ slop (3.5.0)
61
+ term-ansicolor (1.3.0)
62
+ tins (~> 1.0)
63
+ thor (0.19.1)
64
+ thread_safe (0.3.3)
65
+ tins (1.1.0)
40
66
  typhoeus (0.6.6)
41
67
  ethon (~> 0.6.1)
42
- tzinfo (0.3.38)
68
+ tzinfo (1.1.0)
69
+ thread_safe (~> 0.1)
43
70
 
44
71
  PLATFORMS
45
72
  ruby
46
73
 
47
74
  DEPENDENCIES
48
- debugger
75
+ coveralls
49
76
  factory_girl
50
- json
77
+ pry
78
+ pry-nav
79
+ rake
51
80
  rspec
52
- typhoeus (= 0.6.6)
81
+ simplecov
82
+ the-city-admin!
@@ -1,3 +1,6 @@
1
+ {<img src="https://travis-ci.org/thecity/thecity-admin-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/thecity/thecity-admin-ruby]
2
+ {<img src="https://coveralls.io/repos/thecity/thecity-admin-ruby/badge.png" alt="Coverage Status" />}[https://coveralls.io/r/thecity/thecity-admin-ruby]
3
+
1
4
  = The City Admin API
2
5
 
3
6
  This Ruby project is an API wrapper for TheCity Admin API (https://api.onthecity.org)
@@ -42,7 +45,7 @@ Next you will need to initialize a connection
42
45
 
43
46
  This project is released under the MIT license (see LICENSE).
44
47
 
45
- This project is maintained by Wes Hays (https://github.com/weshays).
48
+ This project is maintained by Wes Hays (https://github.com/weshays) and Jason Hagglund (https://github.com/TheMetalCode).
46
49
 
47
50
 
48
51
  == Contributors
@@ -27,19 +27,42 @@ end
27
27
  puts "------------------------------------"
28
28
 
29
29
  checkin_list = TheCity::CheckinList.new
30
- # if checkin_list.empty?
31
- # puts "No checkins in list"
32
- # else
33
- # puts "Checkins: #{checkin_list.count}"
34
- # end
35
-
36
- # checkin = checkin_list[0]
37
-
38
- # checkin2 = TheCity::Checkin.load_by_id(checkin.id)
39
- # if checkin2.nil?
40
- # puts 'Checkin not found'
41
- # else
42
- # puts "Checkin: #{checkin2.barcode}"
43
- # end
30
+ if checkin_list.empty?
31
+ puts "No checkins in list"
32
+ else
33
+ puts "Checkins: #{checkin_list.count}"
34
+ end
35
+
36
+ checkin_list_by_pager_number = TheCity::CheckinListByPagerNumber.new('111')
37
+ if checkin_list_by_pager_number.empty?
38
+ puts "No checkins in list"
39
+ else
40
+ puts "Checkins: #{checkin_list.count}"
41
+ end
42
+
43
+ checkin_list_by_callboard_number = TheCity::CheckinListByCallboardNumber.new('12345')
44
+ if checkin_list_by_callboard_number.empty?
45
+ puts "No checkins in list"
46
+ else
47
+ puts "Checkins: #{checkin_list.count}"
48
+ end
49
+
50
+ checkin = checkin_list[0]
51
+
52
+ checkin2 = TheCity::Checkin.load_by_id(checkin.id)
53
+ if checkin2.nil?
54
+ puts 'Checkin not found'
55
+ else
56
+ puts "Checkin: #{checkin2.barcode}"
57
+ end
58
+
59
+ puts "------------------------------------"
60
+
61
+ group_checkin_events_list = TheCity::GroupCheckinEventsList.new({:group_id => 49861013})
62
+ if group_checkin_events_list.empty?
63
+ puts "No checkin events in list"
64
+ else
65
+ puts "Group Checkin Events: #{group_checkin_events_list.count}"
66
+ end
44
67
 
45
68
  puts "####################################"
@@ -26,7 +26,7 @@ module TheCity
26
26
  #
27
27
  # @param json_data (optional) JSON data of the Checkin.
28
28
  def initialize(json_data = nil)
29
- @writer_object = CheckinWriter
29
+ #@writer_object = CheckinWriter
30
30
  initialize_from_json_object(json_data) unless json_data.nil?
31
31
  end
32
32
 
@@ -29,7 +29,6 @@ module TheCity
29
29
  @current_page = @json_data['current_page']
30
30
  end
31
31
 
32
-
33
32
  # Get the specified note.
34
33
  #
35
34
  # @param index The index of the checkin to get.
@@ -0,0 +1,61 @@
1
+ module TheCity
2
+
3
+ class CheckinListByCallboardNumber < ApiList
4
+
5
+ include Enumerable
6
+
7
+ # Constructor.
8
+ #
9
+ # @param callboard_number The callboard number to filter by
10
+ # @param options A hash of options for loading the list.
11
+ #
12
+ # Options:
13
+ # :page - The page number to get.
14
+ # :reader - The Reader to use to load the data.
15
+ #
16
+ #
17
+ # Examples:
18
+ # CheckinListByCallboardNumber.new('12345')
19
+ #
20
+ # CheckinListByCallboardNumber.new('12345', {:page => 2})
21
+ #
22
+ def initialize(callboard_number, options = {})
23
+ @options = options
24
+ @options[:reader] = TheCity::CheckinListByCallboardNumberReader.new(callboard_number, @options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
26
+
27
+ @total_entries = @json_data['total_entries']
28
+ @total_pages = @json_data['total_pages']
29
+ @per_page = @json_data['per_page']
30
+ @current_page = @json_data['current_page']
31
+ end
32
+
33
+ # Get the specified checkin.
34
+ #
35
+ # @param index The index of the checkin to get.
36
+ #
37
+ # @return [Checkin]
38
+ def [](index)
39
+ Checkin.new( @json_data['checkins'][index] ) if @json_data['checkins'][index]
40
+ end
41
+
42
+
43
+ # This method is needed for Enumerable.
44
+ def each &block
45
+ @json_data['checkins'].each{ |checkin| yield( Checkin.new(checkin) )}
46
+ end
47
+
48
+
49
+ # Alias the count method
50
+ alias :size :count
51
+
52
+ # Checks if the list is empty.
53
+ #
54
+ # @return True on empty, false otherwise.
55
+ def empty?
56
+ @json_data['checkins'].empty?
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,61 @@
1
+ module TheCity
2
+
3
+ class CheckinListByPagerNumber < ApiList
4
+
5
+ include Enumerable
6
+
7
+ # Constructor.
8
+ #
9
+ # @param pager_number The pager number to filter by
10
+ # @param options A hash of options for loading the list.
11
+ #
12
+ # Options:
13
+ # :page - The page number to get.
14
+ # :reader - The Reader to use to load the data.
15
+ #
16
+ #
17
+ # Examples:
18
+ # CheckinListByPagerNumber.new('111')
19
+ #
20
+ # CheckinListByPagerNumber.new('111', {:page => 2})
21
+ #
22
+ def initialize(pager_number, options = {})
23
+ @options = options
24
+ @options[:reader] = TheCity::CheckinListByPagerNumberReader.new(pager_number, @options) if @options[:reader].nil?
25
+ @json_data = @options[:reader].load_feed
26
+
27
+ @total_entries = @json_data['total_entries']
28
+ @total_pages = @json_data['total_pages']
29
+ @per_page = @json_data['per_page']
30
+ @current_page = @json_data['current_page']
31
+ end
32
+
33
+ # Get the specified note.
34
+ #
35
+ # @param index The index of the checkin to get.
36
+ #
37
+ # @return [Checkin]
38
+ def [](index)
39
+ Checkin.new( @json_data['checkins'][index] ) if @json_data['checkins'][index]
40
+ end
41
+
42
+
43
+ # This method is needed for Enumerable.
44
+ def each &block
45
+ @json_data['checkins'].each{ |checkin| yield( Checkin.new(checkin) )}
46
+ end
47
+
48
+
49
+ # Alias the count method
50
+ alias :size :count
51
+
52
+ # Checks if the list is empty.
53
+ #
54
+ # @return True on empty, false otherwise.
55
+ def empty?
56
+ @json_data['checkins'].empty?
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -21,14 +21,25 @@ module TheCity
21
21
  :parent_group_id,
22
22
  :pager_number
23
23
 
24
-
25
24
  # Constructor.
26
25
  #
27
26
  # @param json_data JSON data of the group checkin.
28
27
  def initialize(json_data)
29
28
  initialize_from_json_object(json_data)
30
29
  end
31
-
30
+
31
+ # Loads the group_checkin by the specified ID.
32
+ #
33
+ # @param group_id The ID of the group to load.
34
+ # @param checkin_id The ID of the group_checkin to load.
35
+ #
36
+ # Returns a new {GroupCheckin} object.
37
+ def self.load_by_id(group_id, checkin_id)
38
+ reader = GroupCheckinReader.new(group_id, checkin_id, 'id')
39
+ self.new(reader.load_feed)
40
+ rescue
41
+ nil
42
+ end
32
43
  end
33
44
 
34
45
  end
@@ -0,0 +1,24 @@
1
+ module TheCity
2
+
3
+ class GroupCheckinEvent < ApiObject
4
+
5
+ tc_attr_accessor :ending_at,
6
+ :group_id,
7
+ :group_name,
8
+ :id,
9
+ :starting_at,
10
+ :title,
11
+ :shadow_event_ids
12
+
13
+ # Constructor.
14
+ #
15
+ # @param json_data JSON data of the group checkin event.
16
+ def initialize(json_data)
17
+ initialize_from_json_object(json_data)
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+