Sha256: 2e6b187525b470e8903b1ca0131d95d676d06c787bc16ef3194b56f845849b0c

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

module Tumblr
  class Client
    module Blog
      
      @@standard_options = [:type, :id, :tag, :limit, :offset, :reblog_info, :notes_info, :filter]
      #
      #Gets the info about the blog
      #
      def blog_info(blog_name)
        get("v2/blog/#{blog_name}/info", {:api_key => @consumer_key})
      end

      #
      # Gets the avatar URL of specified size
      #
      def avatar(blog_name, size = nil)
        response = get_response("v2/blog/#{blog_name}/avatar", :size => size)
        if response.status == 301
          response.headers['Location']
        end
      end

      #
      # Gets the list of followers for the blog
      #
      def followers(blog_name, options={})
        if valid_options([:limit, :offset], options)
           get("v2/blog/#{blog_name}/followers", options)
        end
      end
      
      #
      # Gets the list of likes for the blog
      #
      def blog_likes(blog_name, options={})
        if valid_options([:limit, :offset], options)
          url = "v2/blog/#{blog_name}/likes"
          params = {:api_key => @consumer_key}
          unless options.empty?
            params.merge!(options)
          end
          get(url, params)
        end
      end

      def posts(blog_name, options={})
        url = "v2/blog/#{blog_name}/posts"
        
        if options.has_key?(:type)
          url = "#{url}/#{options[:type]}"
        end
        
        params = {:api_key => @consumer_key}
        unless options.empty?
          params.merge!(options)
        end
        get(url, params)
      end

      def queue(blog_name)
        get("v2/blog/#{blog_name}/posts/queue", {})
      end
      
      def draft(blog_name)
        get("v2/blog/#{blog_name}/posts/draft", {})
      end
        
      def submissions(blog_name)
        get("v2/blog/#{blog_name}/posts/submission", {})
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tumblr_client-0.6.11 lib/tumblr/blog.rb