Retrospring/app/models/services/twitter.rb

29 lines
712 B
Ruby
Raw Normal View History

2014-12-12 12:42:34 -08:00
class Services::Twitter < Service
include Rails.application.routes.url_helpers
include SocialHelper::TwitterMethods
2014-12-12 12:42:34 -08:00
def provider
"twitter"
end
def post(answer)
Rails.logger.debug "posting to Twitter {'answer' => #{answer.id}, 'user' => #{self.user_id}}"
post_tweet answer
end
private
def client
@client ||= Twitter::REST::Client.new(
consumer_key: APP_CONFIG['sharing']['twitter']['consumer_key'],
consumer_secret: APP_CONFIG['sharing']['twitter']['consumer_secret'],
access_token: self.access_token,
access_token_secret: self.access_secret
)
end
def post_tweet(answer)
client.update! prepare_tweet(answer)
2014-12-12 12:42:34 -08:00
end
end