class BotFramework::BotState

Public Class Methods

new(_service_url) click to toggle source
# File lib/bot_framework/bot_state.rb, line 3
def initialize(_service_url)
  @service_url = 'https://state.botframework.com'
end

Public Instance Methods

delete_state_for_user(opts = {}) click to toggle source

DeleteStateForUser Delete all data for a user in a channel (UserData and PrivateConversationData) @param channel_id channelId @param user_id id for the user on the channel @param [Hash] opts the optional parameters @return [Array<String>]

# File lib/bot_framework/bot_state.rb, line 13
def delete_state_for_user(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/users/#{opts['user_id']}"
  api_delete(uri)
end
get_conversation_data(opts = {}) click to toggle source

GetConversationData get the bots data for all users in a conversation @param channel_id the channelId @param conversation_id The id for the conversation on the channel @param [Hash] opts the optional parameters @return [BotData]

# File lib/bot_framework/bot_state.rb, line 25
def get_conversation_data(opts = {})
  # opts['channel_id'] & opts['conversation_id']
  uri = "/v3/botstate/#{opts['channel_id']}/conversations/#{opts['conversation_id']}"
  BotFramework::BotData.new api_get(uri)
end
get_private_conversation_data(opts = {}) click to toggle source

GetPrivateConversationData get bot's data for a single user in a conversation @param channel_id channelId @param conversation_id The id for the conversation on the channel @param user_id id for the user on the channel

# File lib/bot_framework/bot_state.rb, line 36
def get_private_conversation_data(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/conversations/#{opts['conversation_id']}/users/#{opts['user_id']}"
  BotFramework::BotData.new api_get(uri)
end
get_user_data(opts = {}) click to toggle source

GetUserData Get a bots data for the user across all conversations @param channel_id channelId @param user_id id for the user on the channel @return [BotData]

# File lib/bot_framework/bot_state.rb, line 47
def get_user_data(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/users/#{opts['user_id']}"
  BotFramework::BotData.new api_get(uri)
end
set_conversation_data(opts = {}) click to toggle source

SetConversationData Update the bot's data for all users in a conversation @param channel_id channelId @param conversation_id The id for the conversation on the channel @param bot_data the new botdata @return [BotData]

# File lib/bot_framework/bot_state.rb, line 58
def set_conversation_data(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/conversations/#{opts['conversation_id']}"
  api_post(uri, opts['bot_data'])
end
set_private_conversation_data(opts = {}) click to toggle source

SetPrivateConversationData Update the bot's data for a single user in a conversation @param channel_id channelId @param conversation_id The id for the conversation on the channel @param user_id id for the user on the channel @param bot_data the new botdata @param [Hash] opts the optional parameters @return [BotData]

# File lib/bot_framework/bot_state.rb, line 72
def set_private_conversation_data(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/conversations/#{opts['conversation_id']}/users/#{opts['user_id']}"
  api_post(uri, opts['bot_data'])
end
set_user_data(opts = {}) click to toggle source

SetUserData Update the bot's data for a user @param channel_id channelId @param user_id id for the user on the channel @param bot_data the new botdata @param [Hash] opts the optional parameters @return [BotData]

# File lib/bot_framework/bot_state.rb, line 84
def set_user_data(opts = {})
  uri = "/v3/botstate/#{opts['channel_id']}/users/#{opts['user_id']}"
  api_post(uri, opts['bot_data'])
end