class SlackMessage::Response

Attributes

channel[R]
original_response[R]
profile_handle[R]
scheduled_message_id[R]
timestamp[R]

Public Class Methods

new(api_response, profile_handle) click to toggle source
# File lib/slack_message/response.rb, line 4
def initialize(api_response, profile_handle)
  @original_response = JSON.parse(api_response.body)
  @ok = @original_response["ok"]
  @channel = @original_response["channel"]

  @timestamp = @original_response["ts"]
  @scheduled_message_id = @original_response["scheduled_message_id"]

  @profile_handle = profile_handle
end

Public Instance Methods

inspect() click to toggle source
# File lib/slack_message/response.rb, line 31
def inspect
  identifier = if scheduled?
    "scheduled_message_id=#{scheduled_message_id}"
  else
    "timestamp=#{timestamp}"
  end

  ok_msg = @ok ? "ok" : "error"

  "<SlackMessage::Response #{ok_msg} profile_handle=:#{profile_handle} channel=#{channel} #{identifier}>"
end
marshal_dump() click to toggle source
# File lib/slack_message/response.rb, line 15
def marshal_dump
  [ @profile_handle, @channel, @timestamp, @original_response, @ok, @original_response ]
end
marshal_load(data) click to toggle source
# File lib/slack_message/response.rb, line 19
def marshal_load(data)
  @profile_handle, @channel, @timestamp, @original_response, @ok, @original_response = data
end
scheduled?() click to toggle source
# File lib/slack_message/response.rb, line 27
def scheduled?
  !!scheduled_message_id
end
sent_to_user?() click to toggle source
# File lib/slack_message/response.rb, line 23
def sent_to_user?
  channel =~ /^D.*/ # users are D for DM, channels start w/ C
end