Class: Metalbird::Twitter::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/metalbird/twitter/publisher.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth) ⇒ Publisher

Returns a new instance of Publisher


4
5
6
# File 'lib/metalbird/twitter/publisher.rb', line 4

def initialize(auth)
  @client = auth.client
end

Instance Method Details

#publish(args) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/metalbird/twitter/publisher.rb', line 8

def publish(args)
  fail NotValidArgsError unless args.validate?

  options = {}
  options[:media_ids] = upload_images(args.images) if args.images?
  @client.update(args.tweet, options)
rescue => error
  Metalbird::Logger.error(error)
  return false
end

#retweet(args) ⇒ Object


19
20
21
22
23
24
25
# File 'lib/metalbird/twitter/publisher.rb', line 19

def retweet(args)
  tweet = ::Twitter::Tweet.new(id: args.tweet_id)
  @client.retweet(tweet)
rescue => error
  Metalbird::Logger.error(error)
  return false
end