Sha256: cac54c2164c92805dd29352441afa973e70601dc92c294cfb3a9e78a994f753b

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 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
      #   Seesaw.avatar(1, 1)
      def avatar(user_id, avatar_id)
        get "users/#{user_id}/avatars/#{avatar_id}"
      end

      # Get all known avatars for a given user
      #
      # @param user_id [Numeric] The avatar's user id
      # @return [Array]
      # @example
      #   Seesaw.avatar(1)
      def avatars(user_id)
        get "users/#{user_id}/avatars"
      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
      #   Seesaw.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
      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
      #   Seesaw.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

3 entries across 3 versions & 1 rubygems

Version Path
totter-0.2.4 lib/totter/client/avatars.rb
totter-0.2.3 lib/totter/client/avatars.rb
totter-0.2.2 lib/totter/client/avatars.rb