Sha256: 994270597018241c5c011031f638c5fae62e05bd7eaa6a78750ec6dcd863049e

Contents?: true

Size: 1.31 KB

Versions: 4

Compression:

Stored size: 1.31 KB

Contents

require 'lita'
require 'lita/adapters/ringcentral/connector'

module Lita
  module Adapters
    class RingCentral < Adapter
      namespace 'ringcentral'

      # Required attributes
      config :app_key, type: String, required: true
      config :app_secret, type: String, required: true
      config :sms_number, type: String, required: true

      # Optional attributes
      config :server, type: String, default: 'platform.devtest.ringcentral.com'
      config :username, type: String
      config :extension, type: String
      config :password, type: String
      config :token, type: String

      attr_reader :connector

      def initialize(robot)
        super
        @connector = Connector.new(
          robot,
          config.app_key,
          config.app_secret,
          config.server,
          config.username,
          config.extension,
          config.password,
          config.token,
          config.sms_number)
      end

      def run
        @connector.connect
        sleep
      rescue Interrupt
        shut_down
      end

      def send_messages(target, strings)
        Lita.logger.info 'Sending Message'
        @connector.message target.user.id, strings
      end

      def shut_down
        robot.trigger :disconnected
      end
    end
    Lita.register_adapter :ringcentral, RingCentral
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lita-ringcentral-0.1.0 lib/lita/adapters/ringcentral.rb
lita-ringcentral-0.0.3 lib/lita/adapters/ringcentral.rb
lita-ringcentral-0.0.2 lib/lita/adapters/ringcentral.rb
lita-ringcentral-0.0.1 lib/lita/adapters/ringcentral.rb