Retrospring/app/models/services/tumblr.rb

33 lines
792 B
Ruby
Raw Normal View History

2015-01-12 15:12:48 -08:00
class Services::Tumblr < Service
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,
title: tumblr_title(answer),
body: tumblr_body(answer),
2015-01-12 15:12:48 -08:00
format: 'markdown',
tweet: 'off'
)
end
end