Class: Operationcode::Slack::Im
- Inherits:
-
Object
- Object
- Operationcode::Slack::Im
- Defined in:
- lib/operationcode/slack/im.rb,
lib/operationcode/slack/im/interactive.rb
Defined Under Namespace
Classes: Interactive
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #deliver(text = @text) ⇒ Object
-
#initialize(user: nil, channel: nil, text: '') ⇒ Im
constructor
A new instance of Im.
- #make_interactive_with!(interactive_message) ⇒ Object
Constructor Details
#initialize(user: nil, channel: nil, text: '') ⇒ Im
Returns a new instance of Im.
6 7 8 9 10 11 12 13 14 |
# File 'lib/operationcode/slack/im.rb', line 6 def initialize(user: nil, channel: nil, text: '') @user = user @channel = channel @text = text @payload = api_params raise(ArgumentError, 'either user or channel must be provided') if @user.nil? && @channel.nil? end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
4 5 6 |
# File 'lib/operationcode/slack/im.rb', line 4 def payload @payload end |
Instance Method Details
#deliver(text = @text) ⇒ Object
16 17 18 19 20 |
# File 'lib/operationcode/slack/im.rb', line 16 def deliver(text = @text) resolve_channel! set_payload_for!(text) Operationcode::Slack::Api::ChatPostMessage.post(with_data: @payload) end |
#make_interactive_with!(interactive_message) ⇒ Object
22 23 24 |
# File 'lib/operationcode/slack/im.rb', line 22 def make_interactive_with!() @payload['attachments'] = .payload.to_json end |