Sha256: 7ab1a5e5ba312bffe8d813e8849c3c2a4ad310f87a4ccfd83edb84bd16edf50f

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 Bytes

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#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

4 entries across 4 versions & 1 rubygems

Version Path
tumblr-rb-1.2.0 lib/tumblr/writer.rb
tumblr-rb-1.1.1 lib/tumblr/writer.rb
tumblr-rb-1.1.0 lib/tumblr/writer.rb
tumblr-rb-1.0.0 lib/tumblr/writer.rb