Class: Stealth::Services::Bandwidth::ReplyHandler
- Inherits:
-
Stealth::Services::BaseReplyHandler
- Object
- Stealth::Services::BaseReplyHandler
- Stealth::Services::Bandwidth::ReplyHandler
- Defined in:
- lib/stealth/services/bandwidth/reply_handler.rb
Constant Summary collapse
- ALPHA_ORDINALS =
('A'..'Z').to_a.freeze
Instance Attribute Summary collapse
-
#recipient_id ⇒ Object
readonly
Returns the value of attribute recipient_id.
-
#reply ⇒ Object
readonly
Returns the value of attribute reply.
-
#translated_reply ⇒ Object
readonly
Returns the value of attribute translated_reply.
Instance Method Summary collapse
- #audio ⇒ Object
- #delay ⇒ Object
- #file ⇒ Object
- #image ⇒ Object
-
#initialize(recipient_id: nil, reply: nil) ⇒ ReplyHandler
constructor
A new instance of ReplyHandler.
- #text ⇒ Object
- #video ⇒ Object
Constructor Details
#initialize(recipient_id: nil, reply: nil) ⇒ ReplyHandler
Returns a new instance of ReplyHandler.
13 14 15 16 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 13 def initialize(recipient_id: nil, reply: nil) @recipient_id = recipient_id @reply = reply end |
Instance Attribute Details
#recipient_id ⇒ Object (readonly)
Returns the value of attribute recipient_id.
11 12 13 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 11 def recipient_id @recipient_id end |
#reply ⇒ Object (readonly)
Returns the value of attribute reply.
11 12 13 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 11 def reply @reply end |
#translated_reply ⇒ Object (readonly)
Returns the value of attribute translated_reply.
11 12 13 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 11 def translated_reply @translated_reply end |
Instance Method Details
#audio ⇒ Object
58 59 60 61 62 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 58 def audio check_text_length format_response({ text: reply['text'], media: [reply['audio_url']] }) end |
#delay ⇒ Object
76 77 78 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 76 def delay end |
#file ⇒ Object
70 71 72 73 74 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 70 def file check_text_length format_response({ text: reply['text'], media: [reply['file_url']] }) end |
#image ⇒ Object
52 53 54 55 56 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 52 def image check_text_length format_response({ text: reply['text'], media: [reply['image_url']] }) end |
#text ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 18 def text check_text_length @translated_reply = reply['text'] suggestions = generate_suggestions(suggestions: reply['suggestions']) = (buttons: reply['buttons']) if suggestions.present? @translated_reply = [ @translated_reply, 'Reply with:' ].join("\n\n") suggestions.each_with_index do |suggestion, i| @translated_reply = [ @translated_reply, "\"#{ALPHA_ORDINALS[i]}\" for #{suggestion}" ].join("\n") end end if .present? .each do || @translated_reply = [ @translated_reply, ].join("\n\n") end end format_response({ text: @translated_reply }) end |
#video ⇒ Object
64 65 66 67 68 |
# File 'lib/stealth/services/bandwidth/reply_handler.rb', line 64 def video check_text_length format_response({ text: reply['text'], media: [reply['video_url']] }) end |