Class: Services::Twitter

Inherits:
Service show all
Defined in:
app/models/services/twitter.rb

Constant Summary collapse

MAX_CHARACTERS =
280
SHORTENED_URL_LENGTH =
23
%r{https?://\S+}

Instance Attribute Summary

Attributes inherited from Service

#access_level, #info

Instance Method Summary collapse

Methods inherited from Service

auth, first_from_omniauth, initialize_from_omniauth, options, service_type, titles

Instance Method Details

#delete_from_service(opts) ⇒ Object


29
30
31
32
# File 'app/models/services/twitter.rb', line 29

def delete_from_service(opts)
  logger.debug "event=delete_from_service type=twitter sender_id=#{user_id} tweet_id=#{opts[:tweet_id]}"
  delete_from_twitter(opts[:tweet_id])
end

#post(post, url = '') ⇒ Object


14
15
16
17
18
19
# File 'app/models/services/twitter.rb', line 14

def post post, url=''
  logger.debug "event=post_to_service type=twitter sender_id=#{user_id} post=#{post.guid}"
  tweet = attempt_post post
  post.tweet_id = tweet.id
  post.save
end

#post_opts(post) ⇒ Object


25
26
27
# File 'app/models/services/twitter.rb', line 25

def post_opts(post)
  {tweet_id: post.tweet_id} if post.tweet_id.present?
end

#profile_photo_urlObject


21
22
23
# File 'app/models/services/twitter.rb', line 21

def profile_photo_url
  client.user(nickname).profile_image_url_https "original"
end

#providerObject


10
11
12
# File 'app/models/services/twitter.rb', line 10

def provider
  "twitter"
end