Class: Tumblr::Client

Inherits:
Weary::Client
  • Object
show all
Defined in:
lib/tumblr/client.rb

Constant Summary collapse

API_VERSION =
"v2"
USER_AGENT =
"Tumblr API Client (Ruby)/#{Tumblr::VERSION} (+http://github.com/mwunsch/tumblr)"
POST_OPTIONS =
[
  :state, :tags, :tweet, :date, :format, :slug,
  :title, :body, # Text posts
  :caption, :link, :source, :data, #Photo posts
  :quote, # Quote posts
  :url, :description, # Link posts
  :conversation, # Chat posts
  :external_url, # Audio posts
  :embed, # Video posts
  :answer # Answer posts ??
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname = nil, oauth_params = {}) ⇒ Client

Returns a new instance of Client.



129
130
131
132
133
134
135
136
# File 'lib/tumblr/client.rb', line 129

def initialize(hostname = nil, oauth_params = {})
  @defaults = {}
  @defaults[:hostname] = hostname if hostname
  [:consumer_key, :consumer_secret, :token, :token_secret].each do |param|
    @defaults[param] = value_for_key_as_string_or_symbol(oauth_params, param) if hash_includes_key_as_string_or_symbol?(oauth_params, param)
  end
  @defaults[:api_key] = value_for_key_as_string_or_symbol(oauth_params, :consumer_key)
end

Class Method Details

.load(hostname = nil, path = nil) ⇒ Object



123
124
125
126
127
# File 'lib/tumblr/client.rb', line 123

def self.load(hostname = nil, path = nil)
  require "tumblr/credentials"
  credentials = Tumblr::Credentials.new(path).read
  self.new(hostname, credentials)
end