Sha256: 7f5216d77d38b54b273aea87db61d9373e6c4aa4571ad6c7bd39123290231c96

Contents?: true

Size: 787 Bytes

Versions: 1

Compression:

Stored size: 787 Bytes

Contents

require 'slack/rtmapi2/client'
require 'slack/rtmapi2/version'
require 'slack_web'

require 'net/http'

# Slack
class Slack
  # class Slack Real Time Messaging API
  class RtmApi2
    attr_writer :client
    attr_accessor :rtm_state_data
    def self.get_url(options)
      body = SlackWeb.call(method: 'rtm.start', token: options[:token])
      URI(body['url'])
    end

    def initialize(options)
      @token = options.fetch(:token)
      @api_url = options[:slack_api_url] || 'https://slack.com/api'
    end

    def start_rtm
      @rtm_state_data = SlackWeb.call(method: 'rtm.start', token: @token)
      @websocket_url = URI(@rtm_state_data['url'])
      client
    end

    def client
      @client ||= Slack::RtmApi2::Client.new websocket_url: @websocket_url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slack-rtmapi2-2.0.2 lib/slack/rtmapi2.rb