Sha256: 6c23b6e0b83e617fcdc3780a92d73c962ab398e94011e2a89b6bea10e4bff44c

Contents?: true

Size: 996 Bytes

Versions: 10

Compression:

Stored size: 996 Bytes

Contents

# frozen_string_literal: true

module Boppers
  module Notifier
    class Twitter
      attr_reader :consumer_key, :consumer_secret,
                  :access_token, :access_secret, :user, :subscribe

      def initialize(consumer_key:, consumer_secret:, access_token:, access_secret:, user:, subscribe: nil)
        require "twitter"

        @consumer_key = consumer_key
        @consumer_secret = consumer_secret
        @access_token = access_token
        @access_secret = access_secret
        @user = user
        @subscribe = subscribe
      end

      def call(title, message, _options)
        client = ::Twitter::REST::Client.new do |config|
          config.consumer_key        = consumer_key
          config.consumer_secret     = consumer_secret
          config.access_token        = access_token
          config.access_token_secret = access_secret
        end

        body = "#{title}\n\n#{message}"

        client.create_direct_message(user, body)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
boppers-0.0.10 lib/boppers/notifier/twitter.rb
boppers-0.0.9 lib/boppers/notifier/twitter.rb
boppers-0.0.8 lib/boppers/notifier/twitter.rb
boppers-0.0.7 lib/boppers/notifier/twitter.rb
boppers-0.0.6 lib/boppers/notifier/twitter.rb
boppers-0.0.5 lib/boppers/notifier/twitter.rb
boppers-0.0.4 lib/boppers/notifier/twitter.rb
boppers-0.0.3 lib/boppers/notifier/twitter.rb
boppers-0.0.2 lib/boppers/notifier/twitter.rb
boppers-0.0.1 lib/boppers/notifier/twitter.rb