totter 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,47 @@
1
+ module Totter
2
+ class Client
3
+ # Client methods for working with avatars.
4
+ module Comments
5
+ # Gets comments for a given decision
6
+ #
7
+ # @param user_id [Numeric] The decision's user id
8
+ # @param decision_id [Numeric] The decision's id
9
+ # @return [Array]
10
+ # @example
11
+ # Seesaw.comments(1, 1)
12
+ def comments(user_id, decision_id)
13
+ get "users/#{user_id}/decisions/#{decision_id}/comments"
14
+ end
15
+
16
+ # Creates a new comment
17
+ #
18
+ # @param user_id [Numeric] The decision's user id
19
+ # @param decision_id [Numeric] The decision's id
20
+ # @param message [String] The comment body
21
+ # @return [Hashie::Mash]
22
+ # @example
23
+ # Seesaw.create_comment(1, 1, 'I love boots!')
24
+ def create_comment(user_id, decision_id, message)
25
+ options = {
26
+ comment: {
27
+ message: message
28
+ }
29
+ }
30
+ post "users/#{user_id}/decisions/#{decision_id}/comments", options
31
+ end
32
+
33
+ # Destroys a comment
34
+ #
35
+ # @param user_id [Numeric] The decision's user id
36
+ # @param decision_id [Numeric] The decision's id
37
+ # @param comment_id [Numeric] The comment id
38
+ # @return [Boolean]
39
+ # @example
40
+ # Seesaw.destroy_comment(1, 1, 15)
41
+ def destroy_comment(user_id, decision_id, comment_id)
42
+ boolean_from_response :delete, "users/#{user_id}/decisions/#{decision_id}/comments/#{comment_id}"
43
+ end
44
+
45
+ end
46
+ end
47
+ end
data/lib/totter/client.rb CHANGED
@@ -5,13 +5,14 @@ module Totter
5
5
  class Client
6
6
  Dir[File.expand_path('../client/*.rb', __FILE__)].each { |f| require f }
7
7
 
8
+ include Totter::Client::Avatars
8
9
  include Totter::Client::Decisions
9
- include Totter::Client::Users
10
+ include Totter::Client::Choices
11
+ include Totter::Client::Comments
10
12
  include Totter::Client::Slugs
11
13
  include Totter::Client::Timelines
12
- include Totter::Client::Choices
14
+ include Totter::Client::Users
13
15
  include Totter::Client::Votes
14
- include Totter::Client::Avatars
15
16
 
16
17
  attr_reader :access_token
17
18
  attr_reader :api_scheme
@@ -1,4 +1,4 @@
1
1
  module Totter
2
2
  # Verion of the Totter gem
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"comment":{"message":"I''d like to buy a vowel."}}'
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ Authorization:
15
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
16
+ Content-Type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Ua-Compatible:
26
+ - IE=Edge
27
+ Etag:
28
+ - ! '"7c6c3e5b00d55811bc29e3a7ee25afd0"'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ X-Request-Id:
32
+ - 85f61948a79c45aeb533d5519f412685
33
+ X-Runtime:
34
+ - '0.222125'
35
+ Connection:
36
+ - close
37
+ Server:
38
+ - thin 1.5.0 codename Knife
39
+ body:
40
+ encoding: US-ASCII
41
+ string: ! '{"created_at":"2013-02-06T18:31:13Z","decision_id":19,"decision_user_id":1,"id":2,"message":"I''d
42
+ like to buy a vowel.","meta":{"message_display_text":"I''d like to buy a vowel.","message_display_html":"I''d
43
+ like to buy a vowel.","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
44
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
45
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}'
46
+ http_version:
47
+ recorded_at: Wed, 06 Feb 2013 18:31:13 GMT
48
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,183 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ Authorization:
15
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
16
+ Content-Type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Ua-Compatible:
26
+ - IE=Edge
27
+ Etag:
28
+ - ! '"5ae9154c2be660f43a58e8c8e32eeb04"'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ X-Request-Id:
32
+ - 616d9ccd21df3c6cb245b6d6ee0386aa
33
+ X-Runtime:
34
+ - '0.010574'
35
+ Connection:
36
+ - close
37
+ Server:
38
+ - thin 1.5.0 codename Knife
39
+ body:
40
+ encoding: US-ASCII
41
+ string: ! '[{"created_at":"2013-02-06T18:27:51Z","decision_id":19,"decision_user_id":1,"id":1,"message":"More
42
+ cheese!","meta":{"message_display_text":"More cheese!","message_display_html":"More
43
+ cheese!","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
44
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
45
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}},{"created_at":"2013-02-06T18:31:13Z","decision_id":19,"decision_user_id":1,"id":2,"message":"I''d
46
+ like to buy a vowel.","meta":{"message_display_text":"I''d like to buy a vowel.","message_display_html":"I''d
47
+ like to buy a vowel.","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
48
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
49
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}]'
50
+ http_version:
51
+ recorded_at: Wed, 06 Feb 2013 18:34:13 GMT
52
+ - request:
53
+ method: post
54
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments
55
+ body:
56
+ encoding: UTF-8
57
+ string: ! '{"comment":{"message":"Going to be deleted"}}'
58
+ headers:
59
+ Accept:
60
+ - ! '*/*'
61
+ User-Agent:
62
+ - Ruby
63
+ Authorization:
64
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
65
+ Content-Type:
66
+ - application/json
67
+ response:
68
+ status:
69
+ code: 200
70
+ message: OK
71
+ headers:
72
+ Content-Type:
73
+ - application/json; charset=utf-8
74
+ X-Ua-Compatible:
75
+ - IE=Edge
76
+ Etag:
77
+ - ! '"97c5ef9e0ac3491983ce1cec6387dcc7"'
78
+ Cache-Control:
79
+ - max-age=0, private, must-revalidate
80
+ X-Request-Id:
81
+ - e87db82449a525d7778dcfa8add4d662
82
+ X-Runtime:
83
+ - '0.092157'
84
+ Connection:
85
+ - close
86
+ Server:
87
+ - thin 1.5.0 codename Knife
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ! '{"created_at":"2013-02-06T18:34:13Z","decision_id":19,"decision_user_id":1,"id":3,"message":"Going
91
+ to be deleted","meta":{"message_display_text":"Going to be deleted","message_display_html":"Going
92
+ to be deleted","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
93
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
94
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}'
95
+ http_version:
96
+ recorded_at: Wed, 06 Feb 2013 18:34:13 GMT
97
+ - request:
98
+ method: delete
99
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments/3
100
+ body:
101
+ encoding: US-ASCII
102
+ string: ''
103
+ headers:
104
+ Accept:
105
+ - ! '*/*'
106
+ User-Agent:
107
+ - Ruby
108
+ Authorization:
109
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
110
+ Content-Type:
111
+ - application/json
112
+ response:
113
+ status:
114
+ code: 204
115
+ message: No Content
116
+ headers:
117
+ X-Ua-Compatible:
118
+ - IE=Edge
119
+ Cache-Control:
120
+ - no-cache
121
+ X-Request-Id:
122
+ - 99eb80b099161967a2977cd6f348b113
123
+ X-Runtime:
124
+ - '0.047077'
125
+ Connection:
126
+ - close
127
+ Server:
128
+ - thin 1.5.0 codename Knife
129
+ body:
130
+ encoding: US-ASCII
131
+ string: ''
132
+ http_version:
133
+ recorded_at: Wed, 06 Feb 2013 18:34:13 GMT
134
+ - request:
135
+ method: get
136
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments
137
+ body:
138
+ encoding: US-ASCII
139
+ string: ''
140
+ headers:
141
+ Accept:
142
+ - ! '*/*'
143
+ User-Agent:
144
+ - Ruby
145
+ Authorization:
146
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
147
+ Content-Type:
148
+ - application/json
149
+ response:
150
+ status:
151
+ code: 200
152
+ message: OK
153
+ headers:
154
+ Content-Type:
155
+ - application/json; charset=utf-8
156
+ X-Ua-Compatible:
157
+ - IE=Edge
158
+ Etag:
159
+ - ! '"5ae9154c2be660f43a58e8c8e32eeb04"'
160
+ Cache-Control:
161
+ - max-age=0, private, must-revalidate
162
+ X-Request-Id:
163
+ - 16cfdf094d1c303fe06de116c4791baa
164
+ X-Runtime:
165
+ - '0.012185'
166
+ Connection:
167
+ - close
168
+ Server:
169
+ - thin 1.5.0 codename Knife
170
+ body:
171
+ encoding: US-ASCII
172
+ string: ! '[{"created_at":"2013-02-06T18:27:51Z","decision_id":19,"decision_user_id":1,"id":1,"message":"More
173
+ cheese!","meta":{"message_display_text":"More cheese!","message_display_html":"More
174
+ cheese!","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
175
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
176
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}},{"created_at":"2013-02-06T18:31:13Z","decision_id":19,"decision_user_id":1,"id":2,"message":"I''d
177
+ like to buy a vowel.","meta":{"message_display_text":"I''d like to buy a vowel.","message_display_html":"I''d
178
+ like to buy a vowel.","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
179
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
180
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}]'
181
+ http_version:
182
+ recorded_at: Wed, 06 Feb 2013 18:34:13 GMT
183
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:5000/v1/users/1/decisions/19/comments
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ Authorization:
15
+ - Bearer 9774e653f7b3c1de5f21b61adc08ba24
16
+ Content-Type:
17
+ - application/json
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ X-Ua-Compatible:
26
+ - IE=Edge
27
+ Etag:
28
+ - ! '"7ccebb8374bc09be7e090d8b36d4f74b"'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ X-Request-Id:
32
+ - a1dee5b8fb17f019631d0be3bd1638b6
33
+ X-Runtime:
34
+ - '0.571403'
35
+ Connection:
36
+ - close
37
+ Server:
38
+ - thin 1.5.0 codename Knife
39
+ body:
40
+ encoding: US-ASCII
41
+ string: ! '[{"created_at":"2013-02-06T18:27:51Z","decision_id":19,"decision_user_id":1,"id":1,"message":"More
42
+ cheese!","meta":{"message_display_text":"More cheese!","message_display_html":"More
43
+ cheese!","message_entities":[]},"user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-04T19:29:42Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
44
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
45
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}]'
46
+ http_version:
47
+ recorded_at: Wed, 06 Feb 2013 18:29:01 GMT
48
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class CommentsTest < Totter::TestCase
4
+ def test_comments
5
+ VCR.use_cassette 'comments/index' do
6
+ comments = local_client.comments(1, 19)
7
+ assert_equal Array, comments.class
8
+ assert_equal 'More cheese!', comments[0].message
9
+ end
10
+ end
11
+
12
+ def test_creating_comment
13
+ VCR.use_cassette 'comments/create' do
14
+ message = "I'd like to buy a vowel."
15
+ comment = local_client.create_comment(1, 19, message)
16
+ assert_equal message, comment.message
17
+ end
18
+ end
19
+
20
+ def test_destroying_comment
21
+ VCR.use_cassette 'comments/destroy' do
22
+ previous_length = local_client.comments(1, 19).length
23
+ comment = local_client.create_comment(1, 19, "Going to be deleted")
24
+ assert local_client.destroy_comment(1, 19, comment.id)
25
+ current_length = local_client.comments(1, 19).length
26
+ assert_equal previous_length, current_length
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: totter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-05 00:00:00.000000000 Z
13
+ date: 2013-02-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -63,6 +63,7 @@ files:
63
63
  - lib/totter/client.rb
64
64
  - lib/totter/client/avatars.rb
65
65
  - lib/totter/client/choices.rb
66
+ - lib/totter/client/comments.rb
66
67
  - lib/totter/client/decisions.rb
67
68
  - lib/totter/client/slugs.rb
68
69
  - lib/totter/client/stickers.rb
@@ -81,6 +82,9 @@ files:
81
82
  - test/cassettes/choices/create_for_image.yml
82
83
  - test/cassettes/choices/destroy.yml
83
84
  - test/cassettes/choices/show.yml
85
+ - test/cassettes/comments/create.yml
86
+ - test/cassettes/comments/destroy.yml
87
+ - test/cassettes/comments/index.yml
84
88
  - test/cassettes/decisions/analytics.yml
85
89
  - test/cassettes/decisions/create.yml
86
90
  - test/cassettes/decisions/destroy.yml
@@ -105,6 +109,7 @@ files:
105
109
  - test/test_helper.rb
106
110
  - test/totter/client/avatars_test.rb
107
111
  - test/totter/client/choices_test.rb
112
+ - test/totter/client/comments_test.rb
108
113
  - test/totter/client/decisions_test.rb
109
114
  - test/totter/client/slugs_test.rb
110
115
  - test/totter/client/stickers_test.rb
@@ -133,9 +138,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
138
  - - ! '>='
134
139
  - !ruby/object:Gem::Version
135
140
  version: '0'
136
- segments:
137
- - 0
138
- hash: 1986829954371603191
139
141
  requirements: []
140
142
  rubyforge_project:
141
143
  rubygems_version: 1.8.23
@@ -151,6 +153,9 @@ test_files:
151
153
  - test/cassettes/choices/create_for_image.yml
152
154
  - test/cassettes/choices/destroy.yml
153
155
  - test/cassettes/choices/show.yml
156
+ - test/cassettes/comments/create.yml
157
+ - test/cassettes/comments/destroy.yml
158
+ - test/cassettes/comments/index.yml
154
159
  - test/cassettes/decisions/analytics.yml
155
160
  - test/cassettes/decisions/create.yml
156
161
  - test/cassettes/decisions/destroy.yml
@@ -175,6 +180,7 @@ test_files:
175
180
  - test/test_helper.rb
176
181
  - test/totter/client/avatars_test.rb
177
182
  - test/totter/client/choices_test.rb
183
+ - test/totter/client/comments_test.rb
178
184
  - test/totter/client/decisions_test.rb
179
185
  - test/totter/client/slugs_test.rb
180
186
  - test/totter/client/stickers_test.rb