2015-01-12 15:12:48 -08:00
|
|
|
class Services::Tumblr < Service
|
2021-12-26 13:04:46 -08:00
|
|
|
include SocialHelper::TumblrMethods
|
2015-01-12 15:12:48 -08:00
|
|
|
|
|
|
|
def provider
|
|
|
|
"tumblr"
|
|
|
|
end
|
|
|
|
|
|
|
|
def post(answer)
|
|
|
|
Rails.logger.debug "posting to Tumblr {'answer' => #{answer.id}, 'user' => #{self.user_id}}"
|
|
|
|
create_post answer
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def client
|
|
|
|
@client ||= Tumblr::Client.new(
|
|
|
|
consumer_key: APP_CONFIG['sharing']['tumblr']['consumer_key'],
|
|
|
|
consumer_secret: APP_CONFIG['sharing']['tumblr']['consumer_secret'],
|
|
|
|
oauth_token: self.access_token,
|
|
|
|
oauth_token_secret: self.access_secret
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_post(answer)
|
|
|
|
client.text(
|
|
|
|
self.uid,
|
2021-12-26 13:04:46 -08:00
|
|
|
title: tumblr_title(answer),
|
|
|
|
body: tumblr_body(answer),
|
2015-01-12 15:12:48 -08:00
|
|
|
format: 'markdown',
|
|
|
|
tweet: 'off'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|