totter 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/totter/client.rb CHANGED
@@ -83,7 +83,7 @@ module Totter
83
83
  request['Content-Type'] = 'application/json'
84
84
 
85
85
  # Add params as JSON if they exist
86
- request.body = MultiJson.dump(params) if method == :post and params
86
+ request.body = MultiJson.dump(params) if [:post, :put].include?(method) and params
87
87
 
88
88
  # Request
89
89
  response = http.request(request)
@@ -46,7 +46,6 @@ module Totter
46
46
  def destroy_avatar(user_id, avatar_id)
47
47
  boolean_from_response :delete, "users/#{user_id}/avatars/#{avatar_id}"
48
48
  end
49
-
50
49
  end
51
50
  end
52
51
  end
@@ -24,6 +24,29 @@ module Totter
24
24
  get "users/#{user}"
25
25
  end
26
26
 
27
+ # Updates a given user
28
+ #
29
+ # @param user_id [Numeric] A Seesaw user ID.
30
+ # @param options [Hash] Properties to be updated
31
+ # @option options [String] :given_name The given name of the user
32
+ # @option options [String] :family_name The Family name of the user
33
+ # @option options [String] :email The email address of the user
34
+ # @option options [String] :username The username of the user
35
+ # @param preferences [Hash] Preferences to be set
36
+ # @option preferences [Boolean] :notification_friends Notify when friends post a decision
37
+ # @option preferences [Boolean] :notification_invitee_votes Notify when invitee votes
38
+ # @option preferences [Boolean] :notification_comments Notify when someone comments on user's decision
39
+ # @option preferences [Boolean] :notification_following_votes Notify when user is following other_user who votes
40
+ # @option preferences [Boolean] :notification_other_votes Notify using throttled notifier when non-invited users vote on your post
41
+ # @option preferences [Boolean] :notification_after_votes Notify when other_user votes after user has already voted on a decision
42
+ # @option preferences [Boolean] :notification_following Notify when other_user starts follwing user
43
+ def update_me(options = {}, preferences = {})
44
+ data = {
45
+ user: options.merge({preferences: preferences})
46
+ }
47
+ put "me", data
48
+ end
49
+
27
50
  # Follow a user.
28
51
  #
29
52
  # Requires authenticatied client.
@@ -1,4 +1,4 @@
1
1
  module Totter
2
2
  # Verion of the Totter gem
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: http://localhost:5000/v1/me
6
+ body:
7
+ encoding: UTF-8
8
+ string: ! '{"user":{"given_name":"Aaron","family_name":"Gotwalt","preferences":{"notification_comments":false}}}'
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
+ - ! '"75305ec8cca38ce8d35794580b736c70"'
29
+ Cache-Control:
30
+ - max-age=0, private, must-revalidate
31
+ X-Request-Id:
32
+ - faa6c0c63d26b22adc17cb44580dfd46
33
+ X-Runtime:
34
+ - '0.112755'
35
+ Connection:
36
+ - close
37
+ Server:
38
+ - thin 1.5.0 codename Knife
39
+ body:
40
+ encoding: US-ASCII
41
+ string: ! '{"biography":null,"created_at":"2013-01-23T03:22:06Z","email":null,"family_name":"Gotwalt","given_name":"Aaron","id":1,"meta":null,"phone_number":"+17174683737","preferences":{"notification_friends":false,"notification_invitee_votes":true,"notification_comments":false,"notification_following_votes":true,"notification_other_votes":true,"notification_after_votes":false,"notification_following":true},"updated_at":"2013-02-03T06:41:56Z","username":null,"website":null,"avatar_url":"https://recess-dev.s3.amazonaws.com/default_avatars/v1/photo_1.png","full_name":"Aaron
42
+ Gotwalt","short_name":"Aaron G","display_name":"Aaron Gotwalt","short_display_name":"Aaron
43
+ G","analytics":{"votes":0,"decisions":0,"followers":0,"following":0},"formatted_phone_number":"(717)
44
+ 468-3737","roles":[],"default_timeline":"g"}'
45
+ http_version:
46
+ recorded_at: Sun, 03 Feb 2013 06:41:56 GMT
47
+ recorded_with: VCR 2.4.0
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class AvatarsTest < Totter::TestCase
4
-
5
4
  def test_avatar
6
5
  VCR.use_cassette 'avatars/show' do
7
6
  client = local_client
@@ -35,5 +34,4 @@ class AvatarsTest < Totter::TestCase
35
34
  assert client.destroy_avatar(avatar.user_id, avatar.id)
36
35
  end
37
36
  end
38
-
39
37
  end
@@ -16,6 +16,25 @@ class UsersTest < Totter::TestCase
16
16
  end
17
17
  end
18
18
 
19
+ def test_update_me
20
+ VCR.use_cassette 'users/update' do
21
+ client = local_client
22
+ options = {
23
+ given_name: "Aaron",
24
+ family_name: 'Gotwalt'
25
+ }
26
+ preferences = {
27
+ notification_comments: false
28
+ }
29
+
30
+ result = client.update_me(options, preferences)
31
+ assert_equal 'Aaron', result.given_name
32
+ assert_equal 'Gotwalt', result.family_name
33
+ refute result.preferences.notification_comments
34
+ end
35
+ end
36
+
37
+
19
38
  def test_following
20
39
  VCR.use_cassette 'users/following' do
21
40
  assert local_client.follow('gotwalt'), 'follow user'
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.1
4
+ version: 0.2.2
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-02 00:00:00.000000000 Z
13
+ date: 2013-02-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -89,6 +89,7 @@ files:
89
89
  - test/cassettes/timelines/global.yml
90
90
  - test/cassettes/users/following.yml
91
91
  - test/cassettes/users/me.yml
92
+ - test/cassettes/users/update.yml
92
93
  - test/cassettes/users/user.yml
93
94
  - test/cassettes/votes/create.yml
94
95
  - test/support/client_macros.rb
@@ -148,6 +149,7 @@ test_files:
148
149
  - test/cassettes/timelines/global.yml
149
150
  - test/cassettes/users/following.yml
150
151
  - test/cassettes/users/me.yml
152
+ - test/cassettes/users/update.yml
151
153
  - test/cassettes/users/user.yml
152
154
  - test/cassettes/votes/create.yml
153
155
  - test/support/client_macros.rb