class Slack::RPC::Connection
## Slack::RPC::Connection
A class for invoke Slack
RPC-Style command
Constants
- BASE_URL
###
Slack::RPC::Connection
.BASE_URL A base url to invokeSlack
RPC-Style command- HEADERS
###
Slack::RPC::Connection
.HEADERS HTTP request headers as Hash object
Attributes
token[RW]
Public Class Methods
new(token = nil)
click to toggle source
### Slack::RPC::Connection.new(token)
Creates a new instance of `Slack::RPC::Connection` class
# File lib/slack/rpc/connection.rb, line 31 def initialize(token = nil) @token = token end
Public Instance Methods
call(command, sub_command, params) { |response| ... }
click to toggle source
### Slack::RPC::Connection.call
(command, sub_commnad, params, &block) Call Slack
RPC-Style command
# File lib/slack/rpc/connection.rb, line 38 def call(command, sub_command, params, &block) params = params.clone.merge({:token => @token}) if @token faraday_response = connection.get("#{command}.#{sub_command}", params) response = Response.new(faraday_response) if block then yield response else response end end
Private Instance Methods
connection()
click to toggle source
### Slack::RPC::Connection.connection
retrieve Faraday Connection
object
# File lib/slack/rpc/connection.rb, line 54 def connection @connection ||= Faraday.new(:headers => HEADERS, :url => BASE_URL) { |faraday| faraday.request :url_encoded faraday.response :json faraday.adapter Faraday.default_adapter } end