Class: DocomoNlu::Spontaneous
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- DocomoNlu::Spontaneous
- Defined in:
- lib/docomo_nlu/spontaneous.rb
Class Method Summary collapse
Instance Method Summary collapse
- #dialogue(voice_text, params = {}) ⇒ Object
-
#initialize ⇒ Spontaneous
constructor
A new instance of Spontaneous.
- #registration(app_id = "", registration_id = "docomo-nlu", app_kind = "docomo-nlu", notification = false) ⇒ Object
Constructor Details
#initialize ⇒ Spontaneous
Returns a new instance of Spontaneous.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/docomo_nlu/spontaneous.rb', line 16 def initialize super { clientVer: "1.0.4", language: "ja-JP", location: { lat: "0", lon: "0" }, appRecvTime: Time.now.strftime("%Y-%m-%d %H:%M:%S"), appSendTime: Time.now.strftime("%Y-%m-%d %H:%M:%S"), }.each do |k, v| @attributes.store(k, v) end end |
Class Method Details
.headers ⇒ Object
51 52 53 54 55 |
# File 'lib/docomo_nlu/spontaneous.rb', line 51 def headers new_headers = static_headers.clone new_headers["Content-Type"] = "application/json;charset=UTF-8" new_headers end |
Instance Method Details
#dialogue(voice_text, params = {}) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/docomo_nlu/spontaneous.rb', line 41 def dialogue(voice_text, params = {}) @attributes[:voiceText] = voice_text params.each do |k, v| @attributes[k] ||= v end res = connection.post("/SpontaneousDialogueServer/dialogue", @attributes.to_json, self.class.headers) JSON.parse(res.body) end |
#registration(app_id = "", registration_id = "docomo-nlu", app_kind = "docomo-nlu", notification = false) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/docomo_nlu/spontaneous.rb', line 29 def registration(app_id = "", registration_id = "docomo-nlu", app_kind = "docomo-nlu", notification = false) body = { bot_id: @attributes[:botId], app_id: app_id, registration_id: registration_id, app_kind: app_kind, notification: notification, } res = connection.post("/UserRegistrationServer/users/applications", body.to_json, self.class.headers) @attributes.store(:appId, JSON.parse(res.body)["app_id"]) end |