Class: Whatsapp::Messages::Interactive::Header
- Defined in:
- lib/ruby/whatsapp/messages/interactive/header.rb
Defined Under Namespace
Modules: Types Classes: HeaderError
Instance Attribute Summary collapse
Class Method Summary collapse
-
.serialize(type:) ⇒ Hash
Serialized representation of the Header.
Instance Method Summary collapse
-
#initialize(type:, **kwargs) ⇒ Header
constructor
A new instance of Header.
-
#serialize ⇒ Hash
Serialized representation of the Header.
Constructor Details
#initialize(type:, **kwargs) ⇒ Header
Returns a new instance of Header.
25 26 27 28 29 30 |
# File 'lib/ruby/whatsapp/messages/interactive/header.rb', line 25 def initialize(type:, **kwargs) @type = type @kwargs = kwargs validate! end |
Instance Attribute Details
#type ⇒ String
18 19 20 |
# File 'lib/ruby/whatsapp/messages/interactive/header.rb', line 18 def type @type end |
Class Method Details
.serialize(type:) ⇒ Hash
Returns Serialized representation of the Header.
34 35 36 |
# File 'lib/ruby/whatsapp/messages/interactive/header.rb', line 34 def serialize(type:, **) new(type:, **).serialize end |
Instance Method Details
#serialize ⇒ Hash
Returns Serialized representation of the Header.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ruby/whatsapp/messages/interactive/header.rb', line 40 def serialize case type when Types::TEXT then serialize_text when Types::IMAGE then serialize_image when Types::DOCUMENT then serialize_document when Types::VIDEO then serialize_video else raise HeaderError, "Unsupported header type: #{type.inspect}" end end |