Sha256: 450a12ada9b4a0b01e3930835a3203a0a40f100e3a4c31a9ce3c9e8937701d32

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

class Tumblr
  class Writer < Weary::Base
    
    headers({"User-Agent" => Tumblr::USER_AGENT})
    
    def initialize(*credentials)
      @defaults = {:generator => Tumblr::GENERATOR}
      @defaults.merge!({:email => credentials[0], :password => credentials[1]}) unless credentials.blank?
    end
    
    # http://www.tumblr.com/docs/en/api#api_write
    post :write do |write|
      write.url = 'http://www.tumblr.com/api/write'
      write.requires = [:email, :password, :type]
      write.with = (Post::BASIC_PARAMS | Post::POST_PARAMS)
    end
    
    # http://www.tumblr.com/docs/en/api#editing_posts
    post :edit do |edit|
      edit.url = 'http://www.tumblr.com/api/write'
      edit.requires = [:email, :password, :'post-id']
      edit.with = (Post::BASIC_PARAMS | Post::POST_PARAMS)
    end
    
    # http://www.tumblr.com/docs/en/api#reblogging_posts
    post :reblog do |reblog|
      reblog.url = 'http://www.tumblr.com/api/reblog'
      reblog.requires = [:email, :password, :'post-id', :'reblog-key']
      reblog.with = (Post::BASIC_PARAMS | Post::POST_PARAMS | Post::REBLOG_PARAMS)
    end
    
    # http://www.tumblr.com/docs/en/api#deleting_posts
    post :delete do |del|
      del.url = 'http://www.tumblr.com/api/delete'
      del.requires = [:email, :password, :'post-id']
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tumblr-rb-1.3.0 lib/tumblr/writer.rb