module PostPublisher
  module Twitter
    class Publisher
      def initialize(auth)
        @client = auth.client
      end

      def publish(args)
        result = @client.update(args.tweet)

        {
          content: args.tweet,
          id: result.id
        }

      rescue => error
        puts error
      end

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

module PostPublisher
  module Twitter
    class Publisher
      def initialize(auth)
        @client = auth.client
      end

      def publish(args)
        @client.update(args.tweet)
      rescue => error
        PostPublisher::Logger.error(error)
        return false
      end

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

Raise error when update or retweet failed
Raise error when update or retweet failed
