Sha256: 8e5b01a0849a5f44acb2fe2d8a2bcf518b0db4c6711e896453dd70b1be217a2c

Contents?: true

Size: 1.47 KB

Versions: 5

Compression:

Stored size: 1.47 KB

Contents

module Lapse
  class Client
    # Client methods for working with users
    module Users
      # Authenticates a user
      #
      # Requires authenticatied client.
      #
      # @return [Hashie::Mash]
      # @see Lapse::Client
      # @example
      #   client.me
      def authenticate(twitter_access_token)
        result = post('authenticate', twitter_access_token: twitter_access_token)
        hash = {
          :user => result.body,
          :access_token => result.headers['x-access-token']
        }

        case @result_format
        when :mashie
          Hashie::Mash.new(hash)
        else
          hash
        end
      end

      # Get the current user
      #
      # Requires authenticatied client.
      #
      # @return [Hashie::Mash]
      # @see Totter::Client
      # @example
      #   client.me
      def me
        get('me').body
      end

      def user(user_id, params = {})
        get("users/#{user_id}", params).body
      end

      def follow(user_id)
        boolean_from_response(:post, "users/#{user_id}/follow")
      end

      def unfollow(user_id)
        boolean_from_response(:post, "users/#{user_id}/unfollow")
      end

      def following(user_id, params = {})
        get("users/#{user_id}/following", params).body
      end

      def followers(user_id, params = {})
        get("users/#{user_id}/followers", params).body
      end

      def block(user_id)
        boolean_from_response(:post, "users/#{user_id}/block")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lapse-0.0.16 lib/lapse/client/users.rb
lapse-0.0.15 lib/lapse/client/users.rb
lapse-0.0.14 lib/lapse/client/users.rb
lapse-0.0.13 lib/lapse/client/users.rb
lapse-0.0.12 lib/lapse/client/users.rb