totter 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/totter/client.rb +2 -0
- data/lib/totter/client/avatars.rb +52 -0
- data/lib/totter/version.rb +1 -1
- data/test/cassettes/avatars/create.yml +44 -0
- data/test/cassettes/avatars/destroy.yml +81 -0
- data/test/cassettes/avatars/index.yml +44 -0
- data/test/cassettes/avatars/show.yml +44 -0
- data/test/totter/client/avatars_test.rb +39 -0
- metadata +13 -4
data/lib/totter/client.rb
CHANGED
@@ -10,6 +10,7 @@ require 'totter/client/slugs'
|
|
10
10
|
require 'totter/client/timelines'
|
11
11
|
require 'totter/client/choices'
|
12
12
|
require 'totter/client/votes'
|
13
|
+
require 'totter/client/avatars'
|
13
14
|
|
14
15
|
module Totter
|
15
16
|
# API client for interacting with the Seesaw API
|
@@ -20,6 +21,7 @@ module Totter
|
|
20
21
|
include Totter::Client::Timelines
|
21
22
|
include Totter::Client::Choices
|
22
23
|
include Totter::Client::Votes
|
24
|
+
include Totter::Client::Avatars
|
23
25
|
|
24
26
|
attr_reader :access_token
|
25
27
|
attr_reader :api_scheme
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Totter
|
2
|
+
class Client
|
3
|
+
# Client methods for working with avatars
|
4
|
+
module Avatars
|
5
|
+
# Get a single avatar
|
6
|
+
#
|
7
|
+
# @param user_id [Numeric] The avatar's user id
|
8
|
+
# @param avatar_id [Numeric] The avatar id
|
9
|
+
# @return [Hashie::Mash]
|
10
|
+
# @example
|
11
|
+
# Seesaw.avatar(1, 1)
|
12
|
+
def avatar(user_id, avatar_id)
|
13
|
+
get "users/#{user_id}/avatars/#{avatar_id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get all known avatars for a given user
|
17
|
+
#
|
18
|
+
# @param user_id [Numeric] The avatar's user id
|
19
|
+
# @return [Array]
|
20
|
+
# @example
|
21
|
+
# Seesaw.avatar(1)
|
22
|
+
def avatars(user_id)
|
23
|
+
get "users/#{user_id}/avatars"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Creates a new avatar on the server, allowing for a signed S3 upload
|
27
|
+
#
|
28
|
+
# @param user_id [Numeric] The avatar's user id
|
29
|
+
# @param redirect_url [String] The URL to redirect the browser on completion of the upload (optional)
|
30
|
+
# @return [Hashie::Mash]
|
31
|
+
# @example
|
32
|
+
# Seesaw.create_avatar(1, 'http://google.com')
|
33
|
+
def create_avatar(user_id, redirect_url = nil)
|
34
|
+
data = {}
|
35
|
+
data[:redirect_url] = redirect_url if redirect_url
|
36
|
+
post "users/#{user_id}/avatars", data
|
37
|
+
end
|
38
|
+
|
39
|
+
# Destroy an avatar
|
40
|
+
#
|
41
|
+
# @param user_id [Numeric] The avatar's user id
|
42
|
+
# @param avatar_id [Numeric] The avatar id
|
43
|
+
# @return [Boolean] True if follow was successful, false otherwise.
|
44
|
+
# @example
|
45
|
+
# Seesaw.destroy_avatar(1, 1)
|
46
|
+
def destroy_avatar(user_id, avatar_id)
|
47
|
+
boolean_from_response :delete, "users/#{user_id}/avatars/#{avatar_id}"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/totter/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:5000/v1/users/1/avatars
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
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
|
+
- ! '"90b8cbd9868674f0d8800f43fc668013"'
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
X-Request-Id:
|
32
|
+
- b37b9283196bd5ff12cf90e8b86685ca
|
33
|
+
X-Runtime:
|
34
|
+
- '0.255412'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- thin 1.5.0 codename Knife
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! '{"bucket":null,"created_at":"2013-02-02T18:22:55Z","file_name":null,"id":5,"updated_at":"2013-02-02T18:22:55Z","user_id":1,"image_uri":"https://s3.amazonaws.com/","user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":null,"given_name":null,"id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-01T19:29:50Z","username":null,"website":null,"avatar_url":"https://s3.amazonaws.com/","full_name":"1","short_name":"1","display_name":"1","short_display_name":"1","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}},"upload":{"url":"https://recess-dev.s3.amazonaws.com/","params":{"AWSAccessKeyId":"AKIAIYAL2IUDRW6PBPUQ","key":"gotwalt-pro.sf.gotwalt.com/avatars/5/1359829375/${filename}","policy":"eyJleHBpcmF0aW9uIjoiMjAxMy0wMi0wMlQxOToyMjo1NloiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJyZWNlc3MtZGV2In0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJnb3R3YWx0LXByby5zZi5nb3R3YWx0LmNvbS9hdmF0YXJzLzUvMTM1OTgyOTM3NS8iXSx7ImFjbCI6InB1YmxpYy1yZWFkIn0seyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6Imh0dHA6Ly9sb2NhbGhvc3Q6NTAwMC92MS91c2Vycy8xL2F2YXRhcnMvMEszbjF1M3czMzNtMkgyRDBvL3MzIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDQ4NTc2XV19","signature":"7jW5uHMhxVZgTdtOK1jNFzK9tA0=","acl":"public-read","success_action_redirect":"http://localhost:5000/v1/users/1/avatars/0K3n1u3w333m2H2D0o/s3"}}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Sat, 02 Feb 2013 18:22:56 GMT
|
44
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,81 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:5000/v1/users/1/avatars
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
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
|
+
- ! '"1169cc19d277e7388c1ec482d761007c"'
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
X-Request-Id:
|
32
|
+
- 5e1af0401d95a7790a36daa008d873bf
|
33
|
+
X-Runtime:
|
34
|
+
- '0.029068'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- thin 1.5.0 codename Knife
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! '{"bucket":null,"created_at":"2013-02-02T18:24:55Z","file_name":null,"id":7,"updated_at":"2013-02-02T18:24:55Z","user_id":1,"image_uri":"https://s3.amazonaws.com/","user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":null,"given_name":null,"id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-01T19:29:50Z","username":null,"website":null,"avatar_url":"https://s3.amazonaws.com/","full_name":"1","short_name":"1","display_name":"1","short_display_name":"1","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}},"upload":{"url":"https://recess-dev.s3.amazonaws.com/","params":{"AWSAccessKeyId":"AKIAIYAL2IUDRW6PBPUQ","key":"gotwalt-pro.sf.gotwalt.com/avatars/7/1359829495/${filename}","policy":"eyJleHBpcmF0aW9uIjoiMjAxMy0wMi0wMlQxOToyNDo1NVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJyZWNlc3MtZGV2In0sWyJzdGFydHMtd2l0aCIsIiRrZXkiLCJnb3R3YWx0LXByby5zZi5nb3R3YWx0LmNvbS9hdmF0YXJzLzcvMTM1OTgyOTQ5NS8iXSx7ImFjbCI6InB1YmxpYy1yZWFkIn0seyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6Imh0dHA6Ly9sb2NhbGhvc3Q6NTAwMC92MS91c2Vycy8xL2F2YXRhcnMvM28xdjJxM2owWDBVMnowaDE4L3MzIn0sWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDQ4NTc2XV19","signature":"2Fw64yEOH1e9v7+yCJdu9GPd6sM=","acl":"public-read","success_action_redirect":"http://localhost:5000/v1/users/1/avatars/3o1v2q3j0X0U2z0h18/s3"}}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Sat, 02 Feb 2013 18:24:55 GMT
|
44
|
+
- request:
|
45
|
+
method: delete
|
46
|
+
uri: http://localhost:5000/v1/users/1/avatars/7
|
47
|
+
body:
|
48
|
+
encoding: US-ASCII
|
49
|
+
string: ''
|
50
|
+
headers:
|
51
|
+
Accept:
|
52
|
+
- ! '*/*'
|
53
|
+
User-Agent:
|
54
|
+
- Ruby
|
55
|
+
Authorization:
|
56
|
+
- Bearer 9774e653f7b3c1de5f21b61adc08ba24
|
57
|
+
Content-Type:
|
58
|
+
- application/json
|
59
|
+
response:
|
60
|
+
status:
|
61
|
+
code: 204
|
62
|
+
message: No Content
|
63
|
+
headers:
|
64
|
+
X-Ua-Compatible:
|
65
|
+
- IE=Edge
|
66
|
+
Cache-Control:
|
67
|
+
- no-cache
|
68
|
+
X-Request-Id:
|
69
|
+
- 1150fb00a0d6270e6db3d4d5130a946b
|
70
|
+
X-Runtime:
|
71
|
+
- '0.015612'
|
72
|
+
Connection:
|
73
|
+
- close
|
74
|
+
Server:
|
75
|
+
- thin 1.5.0 codename Knife
|
76
|
+
body:
|
77
|
+
encoding: US-ASCII
|
78
|
+
string: ''
|
79
|
+
http_version:
|
80
|
+
recorded_at: Sat, 02 Feb 2013 18:24:55 GMT
|
81
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:5000/v1/users/1/avatars
|
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
|
+
- ! '"94500a03fa9233fe4b3220b746631ccd"'
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
X-Request-Id:
|
32
|
+
- e1f49d9455241e5915d9e9b696c8080b
|
33
|
+
X-Runtime:
|
34
|
+
- '0.017104'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- thin 1.5.0 codename Knife
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! '[{"bucket":"recess-dev","created_at":"2013-01-23T03:22:06Z","file_name":"default_avatars/v1/photo_1.png","id":1,"updated_at":"2013-01-23T03:22:06Z","user_id":1,"image_uri":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":null,"given_name":null,"id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-01T19:29:50Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"1","short_name":"1","display_name":"1","short_display_name":"1","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}]'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Sat, 02 Feb 2013 18:20:25 GMT
|
44
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:5000/v1/users/1/avatars/1
|
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
|
+
- ! '"963c8209a175b4b862ab2c5011631790"'
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
X-Request-Id:
|
32
|
+
- 27bab858409a15053a0ac863d2a85b4e
|
33
|
+
X-Runtime:
|
34
|
+
- '0.015356'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- thin 1.5.0 codename Knife
|
39
|
+
body:
|
40
|
+
encoding: US-ASCII
|
41
|
+
string: ! '{"bucket":"recess-dev","created_at":"2013-01-23T03:22:06Z","file_name":"default_avatars/v1/photo_1.png","id":1,"updated_at":"2013-01-23T03:22:06Z","user_id":1,"image_uri":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","user":{"biography":null,"created_at":"2013-01-23T03:22:06Z","family_name":null,"given_name":null,"id":1,"meta":null,"moderated_decisions_count":null,"stickers":["test","blah","tester"],"updated_at":"2013-02-01T19:29:50Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"1","short_name":"1","display_name":"1","short_display_name":"1","analytics":{"votes":0,"decisions":0,"followers":0,"following":0}}}'
|
42
|
+
http_version:
|
43
|
+
recorded_at: Sat, 02 Feb 2013 18:21:25 GMT
|
44
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AvatarsTest < Totter::TestCase
|
4
|
+
|
5
|
+
def test_avatar
|
6
|
+
VCR.use_cassette 'avatars/show' do
|
7
|
+
client = local_client
|
8
|
+
avatar = client.avatar(1, 1)
|
9
|
+
assert_equal 1, avatar.id
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_avatars
|
14
|
+
VCR.use_cassette 'avatars/index' do
|
15
|
+
client = local_client
|
16
|
+
avatars = client.avatars(1)
|
17
|
+
assert_equal Array, avatars.class
|
18
|
+
assert_equal 1, avatars.length
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_create_avatar
|
23
|
+
VCR.use_cassette 'avatars/create' do
|
24
|
+
client = local_client
|
25
|
+
avatar = client.create_avatar(1, 'http://google.com')
|
26
|
+
assert_equal 1, avatar.user_id
|
27
|
+
assert avatar.upload
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_destroy_avatar
|
32
|
+
VCR.use_cassette 'avatars/destroy' do
|
33
|
+
client = local_client
|
34
|
+
avatar = client.create_avatar(1)
|
35
|
+
assert client.destroy_avatar(avatar.user_id, avatar.id)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
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.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- Readme.markdown
|
62
62
|
- lib/totter.rb
|
63
63
|
- lib/totter/client.rb
|
64
|
+
- lib/totter/client/avatars.rb
|
64
65
|
- lib/totter/client/choices.rb
|
65
66
|
- lib/totter/client/decisions.rb
|
66
67
|
- lib/totter/client/slugs.rb
|
@@ -69,6 +70,10 @@ files:
|
|
69
70
|
- lib/totter/client/votes.rb
|
70
71
|
- lib/totter/error.rb
|
71
72
|
- lib/totter/version.rb
|
73
|
+
- test/cassettes/avatars/create.yml
|
74
|
+
- test/cassettes/avatars/destroy.yml
|
75
|
+
- test/cassettes/avatars/index.yml
|
76
|
+
- test/cassettes/avatars/show.yml
|
72
77
|
- test/cassettes/choices/create_choice_upload.yml
|
73
78
|
- test/cassettes/choices/create_for_image.yml
|
74
79
|
- test/cassettes/choices/destroy.yml
|
@@ -88,6 +93,7 @@ files:
|
|
88
93
|
- test/cassettes/votes/create.yml
|
89
94
|
- test/support/client_macros.rb
|
90
95
|
- test/test_helper.rb
|
96
|
+
- test/totter/client/avatars_test.rb
|
91
97
|
- test/totter/client/choices_test.rb
|
92
98
|
- test/totter/client/decisions_test.rb
|
93
99
|
- test/totter/client/slugs_test.rb
|
@@ -116,9 +122,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
122
|
- - ! '>='
|
117
123
|
- !ruby/object:Gem::Version
|
118
124
|
version: '0'
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
hash: -941973653779003141
|
122
125
|
requirements: []
|
123
126
|
rubyforge_project:
|
124
127
|
rubygems_version: 1.8.23
|
@@ -126,6 +129,10 @@ signing_key:
|
|
126
129
|
specification_version: 3
|
127
130
|
summary: Ruby gem for working with the Seesaw API.
|
128
131
|
test_files:
|
132
|
+
- test/cassettes/avatars/create.yml
|
133
|
+
- test/cassettes/avatars/destroy.yml
|
134
|
+
- test/cassettes/avatars/index.yml
|
135
|
+
- test/cassettes/avatars/show.yml
|
129
136
|
- test/cassettes/choices/create_choice_upload.yml
|
130
137
|
- test/cassettes/choices/create_for_image.yml
|
131
138
|
- test/cassettes/choices/destroy.yml
|
@@ -145,6 +152,7 @@ test_files:
|
|
145
152
|
- test/cassettes/votes/create.yml
|
146
153
|
- test/support/client_macros.rb
|
147
154
|
- test/test_helper.rb
|
155
|
+
- test/totter/client/avatars_test.rb
|
148
156
|
- test/totter/client/choices_test.rb
|
149
157
|
- test/totter/client/decisions_test.rb
|
150
158
|
- test/totter/client/slugs_test.rb
|
@@ -153,3 +161,4 @@ test_files:
|
|
153
161
|
- test/totter/client/votes_test.rb
|
154
162
|
- test/totter/client_test.rb
|
155
163
|
- test/totter_test.rb
|
164
|
+
has_rdoc:
|