class RongCloud::Services::Message::MessageChannel

消息发送渠道,区分私信、系统消息、群组消息、讨论组消息、聊天室消息以及广播消息

Constants

CHANNEL_TO_REQUEST_DETAILS_MAP

各消息渠道各自对应请求路径以及特殊参数名

VALID_CHANNEL_NAMES

支持的消息渠道的列表

Public Class Methods

new(channel_name) click to toggle source

实例化消息渠道对象

@param channel_name [String] 渠道名称 @return [RongCloud::Services::Message::MessageChannel] 消息渠道实例 @raise [RongCloud::UnsupportedMessageChannelName] 消息渠道不支持

# File lib/rong_cloud/services/message/message_channel.rb, line 29
def initialize(channel_name)
  if VALID_CHANNEL_NAMES.include?(channel_name.to_s)
    @channel_name = channel_name.to_s.to_sym
  else
    raise UnsupportedMessageChannelName,
      "support only channels: #{VALID_CHANNEL_NAMES}"
  end
end

Public Instance Methods

api_path() click to toggle source
# File lib/rong_cloud/services/message/message_channel.rb, line 42
def api_path
  CHANNEL_TO_REQUEST_DETAILS_MAP[@channel_name][:api_path]
end
target_param_name() click to toggle source
# File lib/rong_cloud/services/message/message_channel.rb, line 38
def target_param_name
  CHANNEL_TO_REQUEST_DETAILS_MAP[@channel_name][:target_param_name]
end