module Totter::Client::Avatars

Client methods for working with avatars.

Public Instance Methods

avatar(user_id, avatar_id) click to toggle source

Get a single avatar

@param user_id [Numeric] The avatar's user id @param avatar_id [Numeric] The avatar id @return [Hashie::Mash] @example

Totter.avatar(1, 1)
# File lib/totter/client/avatars.rb, line 12
def avatar(user_id, avatar_id)
  get("users/#{user_id}/avatars/#{avatar_id}").body
end
avatars(user_id) click to toggle source

Get all known avatars for a given user

@param user_id [Numeric] The avatar's user id @return [Array] @example

Totter.avatar(1)
# File lib/totter/client/avatars.rb, line 22
def avatars(user_id)
  get("users/#{user_id}/avatars").body
end
create_avatar(user_id, redirect_url = nil) click to toggle source

Creates a new avatar on the server, allowing for a signed S3 upload

@param user_id [Numeric] The avatar's user id @param redirect_url [String] The URL to redirect the browser on completion of the upload (optional) @return [Hashie::Mash] @example

Totter.create_avatar(1, 'http://google.com')
# File lib/totter/client/avatars.rb, line 33
def create_avatar(user_id, redirect_url = nil)
  data = {}
  data[:redirect_url] = redirect_url if redirect_url
  post("users/#{user_id}/avatars", data).body
end
destroy_avatar(user_id, avatar_id) click to toggle source

Destroy an avatar

@param user_id [Numeric] The avatar's user id @param avatar_id [Numeric] The avatar id @return [Boolean] True if follow was successful, false otherwise. @example

Totter.destroy_avatar(1, 1)
# File lib/totter/client/avatars.rb, line 46
def destroy_avatar(user_id, avatar_id)
  boolean_from_response(:delete, "users/#{user_id}/avatars/#{avatar_id}")
end