Sha256: 63aea91ab35ab0181763b350ffc44eb0019bb44f5537b4755fe1fd9d5d295c8e

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

module Typetalk
  class Api

    module Topic

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


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


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


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


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

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
typetalk-0.0.1 lib/typetalk/api/topic.rb