Sha256: a8c5a0e7dc4b9f31c8e33babdc4c1ff9cf97fd9bcabf6ba6577214458151a318

Contents?: true

Size: 1.87 KB

Versions: 7

Compression:

Stored size: 1.87 KB

Contents

module Typetalk
  class Api

    module Topic

      def get_topics(options={})
        options = {token:nil}.merge(options)

        response = connection.get do |req|
          req.url "#{endpoint}/topics"
          req.params[:access_token] = options[:token] || access_token
        end
        parse_response(response)
      end


      def get_topic(topic_id, options={})
        options = {token:nil, count:nil, from:nil, direction:nil}.merge(options)

        response = connection.get do |req|
          req.url "#{endpoint}/topics/#{topic_id}"
          req.params[:access_token] = options[:token] || access_token
          req.params[:count] = options[:count] unless options[:count].nil?
          req.params[:from] = options[:from] unless options[:from].nil?
          req.params[:direction] = options[:direction] unless options[:direction].nil?
        end
        parse_response(response)
      end


      def get_topic_members(topic_id, options={})
        options = {token:nil}.merge(options)

        response = connection.get do |req|
          req.url "#{endpoint}/topics/#{topic_id}/members/status"
          req.params[:access_token] = options[:token] || access_token
        end
        parse_response(response)
      end


      def favorite_topic(topic_id, options={})
        options = {token:nil}.merge(options)

        response = connection.post do |req|
          req.url "#{endpoint}/topics/#{topic_id}/favorite"
          req.params[:access_token] = options[:token] || access_token
        end
        parse_response(response)
      end


      def unfavorite_topic(topic_id, options={})
        options = {token:nil}.merge(options)

        response = connection.delete do |req|
          req.url "#{endpoint}/topics/#{topic_id}/favorite"
          req.params[:access_token] = options[:token] || access_token
        end
        parse_response(response)
      end

    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
typetalk-0.1.1 lib/typetalk/api/topic.rb
typetalk-0.1.0 lib/typetalk/api/topic.rb
typetalk-0.0.6 lib/typetalk/api/topic.rb
typetalk-0.0.5 lib/typetalk/api/topic.rb
typetalk-0.0.4 lib/typetalk/api/topic.rb
typetalk-0.0.3 lib/typetalk/api/topic.rb
typetalk-0.0.2 lib/typetalk/api/topic.rb