Class: BotSpec::AWS::LexService
- Inherits:
-
Object
- Object
- BotSpec::AWS::LexService
- Defined in:
- lib/botspec/lex/lex_service.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ LexService
constructor
A new instance of LexService.
- #interaction_to_lex_message(message) ⇒ Object
- #lex_client ⇒ Object
- #post_message(message, user_id = '') ⇒ Object
Constructor Details
#initialize(config) ⇒ LexService
Returns a new instance of LexService.
10 11 12 13 14 15 16 17 18 |
# File 'lib/botspec/lex/lex_service.rb', line 10 def initialize(config) if config[:stub_responses] @lex_client = Aws::Lex::Client.new(stub_responses: true) @lex_client.stub_responses(config[:stub_responses][:operation_to_stub], config[:stub_responses][:stub_data]) end @config = config @bot_name = config[:botname] @user_id = "botspec-#{SecureRandom.uuid}" end |
Class Method Details
.load(config) ⇒ Object
6 7 8 |
# File 'lib/botspec/lex/lex_service.rb', line 6 def self.load(config) return LexService.new(config) end |
Instance Method Details
#interaction_to_lex_message(message) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/botspec/lex/lex_service.rb', line 24 def () return { bot_name: @bot_name, bot_alias: "$LATEST", user_id: @user_id, session_attributes: { "String" => "String", }, request_attributes: { "String" => "String", }, input_text: , } end |
#lex_client ⇒ Object
20 21 22 |
# File 'lib/botspec/lex/lex_service.rb', line 20 def lex_client @lex_client ||= Aws::Lex::Client.new end |
#post_message(message, user_id = '') ⇒ Object
39 40 41 42 43 |
# File 'lib/botspec/lex/lex_service.rb', line 39 def , user_id='' resp = lex_client.post_text(()) sleep(1); resp end |