Sha256: 4a0a960f75c6a01be6fbfbbe48f251f738fb5c0b0506ad1a16d87507e79e9b7d

Contents?: true

Size: 1.58 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

Version Path
totter-0.2.1 lib/totter/client/avatars.rb