Sha256: fb7019db630d19b195fdb2f8877d0c6f345984d2684538f9797c778a586cab25

Contents?: true

Size: 1.6 KB

Versions: 19

Compression:

Stored size: 1.6 KB

Contents

module Totter
  class Client
    # Client methods for working with avatars.
    module Avatars
      # 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)
      def avatar(user_id, avatar_id)
        get("users/#{user_id}/avatars/#{avatar_id}").body
      end

      # Get all known avatars for a given user
      #
      # @param user_id [Numeric] The avatar's user id
      # @return [Array]
      # @example
      #   Totter.avatar(1)
      def avatars(user_id)
        get("users/#{user_id}/avatars").body
      end

      # 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')
      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 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)
      def destroy_avatar(user_id, avatar_id)
        boolean_from_response(:delete, "users/#{user_id}/avatars/#{avatar_id}")
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
totter-0.4.8 lib/totter/client/avatars.rb
totter-0.4.7 lib/totter/client/avatars.rb
totter-0.4.6 lib/totter/client/avatars.rb
totter-0.4.5 lib/totter/client/avatars.rb
totter-0.4.4 lib/totter/client/avatars.rb
totter-0.4.3 lib/totter/client/avatars.rb
totter-0.4.2 lib/totter/client/avatars.rb
totter-0.4.1 lib/totter/client/avatars.rb
totter-0.4.0 lib/totter/client/avatars.rb
totter-0.3.9 lib/totter/client/avatars.rb
totter-0.3.8 lib/totter/client/avatars.rb
totter-0.3.7 lib/totter/client/avatars.rb
totter-0.3.6 lib/totter/client/avatars.rb
totter-0.3.5 lib/totter/client/avatars.rb
totter-0.3.4 lib/totter/client/avatars.rb
totter-0.3.3 lib/totter/client/avatars.rb
totter-0.3.2 lib/totter/client/avatars.rb
totter-0.3.1 lib/totter/client/avatars.rb
totter-0.3.0 lib/totter/client/avatars.rb