Sha256: 65580f702b295d4b5258e6283ecbf8c55a4080c7ffec987791267b7d91cbf87d
Contents?: true
Size: 1.72 KB
Versions: 6
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true module Qismo module Resources module BotResource # # Send message to room as bot # # @param options [Hash] # @option options [String] :room_id # @option options [String] :message # @option options [String] :type required if type is not `text` # @!attribute payload [Hash] required if type is not `text` # # @return [Response] # def send_message(options = {}) options[:sender_email] = Qismo.admin_email validate_existence_of!(:sender_email, :message, :room_id, on: options) options[:room_id] = options[:room_id].to_s Qismo.client.post("/#{Qismo.client.app_id}/bot", options) end # # Notify admin and/or agent that bot need human help # # @param room_id [Integer] # @param roles [Array<Integer>] # @param options [Hash] # @option options [TrueClass] :find_online_agent # # @return [Response] # def handover(room_id, *roles, **options) if roles.empty? Qismo.client.request(:post, "/#{Qismo.client.app_id}/bot/#{room_id}/hand_over", { headers: { authorization: Qismo.client.secret_key }, }) else int_roles = [] roles.each { |role| int_roles.append(role) } if roles.size == 1 options[:role] = int_roles.first else options[:roles] = int_roles end options = options.compact Qismo.client.request(:post, "/#{Qismo.client.app_id}/bot/#{room_id}/hand_over_to_role", { json: options, headers: { authorization: Qismo.client.secret_key }, }) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems