class Postwill::Providers::Tumblr
Public Class Methods
new(options)
click to toggle source
# File lib/postwill/providers/tumblr.rb, line 4 def initialize(options) @client ||= ::Tumblr::Client.new( consumer_key: credentials[:consumer_key], consumer_secret: credentials[:consumer_secret], oauth_token: options[:access_token], oauth_token_secret: options[:access_token_secret] ) end
Private Instance Methods
credentials()
click to toggle source
# File lib/postwill/providers/tumblr.rb, line 30 def credentials Postwill::Settings.config.providers.tumblr end
post(options)
click to toggle source
# File lib/postwill/providers/tumblr.rb, line 15 def post(options) image = options[:image] text = options[:text] title = options[:title] user = options[:user] if image result = client.photo(user, data: [image], caption: text) else result = client.text(user, body: text, title: title) end response(result) end
response(result)
click to toggle source
# File lib/postwill/providers/tumblr.rb, line 34 def response(result) raise Exception, result['errors'] unless result.dig('id') result end