Class: Mocodo::Dialogue

Inherits:
Base
  • Object
show all
Defined in:
lib/mocodo/dialogue.rb

Constant Summary collapse

EndPoint =
"/dialogue/v1/dialogue"

Constants inherited from Base

Base::BaseURL

Instance Attribute Summary collapse

Attributes inherited from Base

#api_key, #response

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Dialogue

Returns a new instance of Dialogue.



6
7
8
9
# File 'lib/mocodo/dialogue.rb', line 6

def initialize(*args)
  super
  @config = {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/mocodo/dialogue.rb', line 5

def config
  @config
end

Instance Method Details

#configure(options = {}) ⇒ Object



11
12
13
# File 'lib/mocodo/dialogue.rb', line 11

def configure(options = {})
  @config.merge!(options)
end

#create_dialogue(talk) ⇒ Object



19
20
21
22
23
24
# File 'lib/mocodo/dialogue.rb', line 19

def create_dialogue(talk)
  response = post(build_url(EndPoint), @config.merge(utt: talk).to_json, {'Content-Type' =>'application/json'})
  response = JSON.parse(response, symbolize_names: true)
  configure(response)
  return response[:utt]
end

#get_current_data(option = nil) ⇒ Object



15
16
17
# File 'lib/mocodo/dialogue.rb', line 15

def get_current_data(option=nil)
  option.nil? ? @config : @config[option]
end