Method: Twterm::RESTClient#unretweet

Defined in:
lib/twterm/rest_client.rb

#unretweet(status) ⇒ Object



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/twterm/rest_client.rb', line 348

def unretweet(status)
  send_request do
    Twitter::REST::Request.new(rest_client, :post, "/1.1/statuses/unretweet/#{status.id}.json").perform
  end
    .then do |json, *_|
      json[:retweet_count] -= 1
      json[:retweeted] = false

      Twitter::Tweet.new(json)
    end
    .then do |tweet|
      status = status_repository.create(tweet)

      publish(Event::Message::Success.new('Successfully unretweeted: @%s "%s"' % [
        tweet.user.screen_name, status.text
      ]))

      status
    end
end