Class: Slack::RPC::Connection
- Inherits:
-
Object
- Object
- Slack::RPC::Connection
- Defined in:
- lib/slack/rpc/connection.rb
Overview
## Slack::RPC::Connection A class for invoke Slack RPC-Style command
Constant Summary collapse
- BASE_URL =
### Slack::RPC::Connection.BASE_URL A base url to invoke Slack RPC-Style command
"https://slack.com/api"
- HEADERS =
### Slack::RPC::Connection.HEADERS HTTP request headers as Hash object
{ "Accept" => "application/json", "User-Agent" => "Slack Ruby Gem #{Slack::VERSION}" }
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#call(command, sub_command, params, &block) ⇒ Object
### Slack::RPC::Connection.call(command, sub_commnad, params, &block) Call Slack RPC-Style command.
-
#initialize(token = nil) ⇒ Connection
constructor
### Slack::RPC::Connection.new(token) Creates a new instance of ‘Slack::RPC::Connection` class.
Constructor Details
#initialize(token = nil) ⇒ Connection
### Slack::RPC::Connection.new(token) Creates a new instance of ‘Slack::RPC::Connection` class
31 32 33 |
# File 'lib/slack/rpc/connection.rb', line 31 def initialize(token = nil) @token = token end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
13 14 15 |
# File 'lib/slack/rpc/connection.rb', line 13 def token @token end |
Instance Method Details
#call(command, sub_command, params, &block) ⇒ Object
### Slack::RPC::Connection.call(command, sub_commnad, params, &block) Call Slack RPC-Style command
38 39 40 41 42 43 44 45 46 47 |
# 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 |