Class: WhatsappSdk::Resource::InteractiveHeader
- Inherits:
-
Object
- Object
- WhatsappSdk::Resource::InteractiveHeader
- Defined in:
- lib/whatsapp_sdk/resource/interactive_header.rb
Defined Under Namespace
Modules: Type
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns document if the interactive header type is document.
-
#image ⇒ Object
Returns image if the interactive header type is image.
-
#text ⇒ Object
Returns Text string if the interactive header type is text.
-
#type ⇒ Object
Returns the interactive header type.
-
#video ⇒ Object
Returns video if the interactive header type is video.
Instance Method Summary collapse
-
#initialize(type:, text: nil, image: nil, document: nil, video: nil) ⇒ InteractiveHeader
constructor
A new instance of InteractiveHeader.
- #to_json ⇒ Object
Constructor Details
#initialize(type:, text: nil, image: nil, document: nil, video: nil) ⇒ InteractiveHeader
Returns a new instance of InteractiveHeader.
40 41 42 43 44 45 46 47 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 40 def initialize(type:, text: nil, image: nil, document: nil, video: nil) @type = type @text = text @image = image @document = document @video = video validate end |
Instance Attribute Details
#document ⇒ Object
Returns document if the interactive header type is document.
33 34 35 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 33 def document @document end |
#image ⇒ Object
Returns image if the interactive header type is image.
28 29 30 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 28 def image @image end |
#text ⇒ Object
Returns Text string if the interactive header type is text. For the header interactive, the character limit is 60 characters. For the body interactive, the character limit is 1024 characters.
23 24 25 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 23 def text @text end |
#type ⇒ Object
Returns the interactive header type.
9 10 11 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 9 def type @type end |
#video ⇒ Object
Returns video if the interactive header type is video.
38 39 40 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 38 def video @video end |
Instance Method Details
#to_json ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/whatsapp_sdk/resource/interactive_header.rb', line 49 def to_json json = { type: type } json[type.to_sym] = case type when "text" text when "image" image.to_json when "document" document.to_json when "video" video.to_json else raise "Invalid type: #{type}" end json end |