Class: WhatsAppCloudApi::Component
- Defined in:
- lib/whats_app_cloud_api/models/component.rb
Overview
Component Model.
Instance Attribute Summary collapse
-
#index ⇒ String
Required when type=button.
-
#parameters ⇒ List of Object
Required when type=button.
-
#sub_type ⇒ SubTypeEnum
Required when type=button.
-
#type ⇒ ComponentTypeEnum
Describes the component type.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(type = nil, parameters = nil, sub_type = nil, index = nil) ⇒ Component
constructor
A new instance of Component.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(type = nil, parameters = nil, sub_type = nil, index = nil) ⇒ Component
Returns a new instance of Component.
56 57 58 59 60 61 62 63 64 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 56 def initialize(type = nil, parameters = nil, sub_type = nil, index = nil) @type = type unless type == SKIP @sub_type = sub_type unless sub_type == SKIP @parameters = parameters unless parameters == SKIP @index = index unless index == SKIP end |
Instance Attribute Details
#index ⇒ String
Required when type=button. Not used for the other types. Position index of the button. You can have up to 3 buttons using index values of 0 to 2.
31 32 33 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 31 def index @index end |
#parameters ⇒ List of Object
Required when type=button. Array of parameter objects with the content of the message. For components of type=button, see the button parameter object.
26 27 28 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 26 def parameters @parameters end |
#sub_type ⇒ SubTypeEnum
Required when type=button. Not used for the other types. Type of button to create.
20 21 22 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 20 def sub_type @sub_type end |
#type ⇒ ComponentTypeEnum
Describes the component type. For text-based templates, we only support the type=body.
15 16 17 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 15 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 67 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : SKIP parameters = hash.key?('parameters') ? hash['parameters'] : SKIP sub_type = hash.key?('sub_type') ? hash['sub_type'] : SKIP index = hash.key?('index') ? hash['index'] : SKIP # Create object from extracted values. Component.new(type, parameters, sub_type, index) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['sub_type'] = 'sub_type' @_hash['parameters'] = 'parameters' @_hash['index'] = 'index' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
52 53 54 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 52 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 |
# File 'lib/whats_app_cloud_api/models/component.rb', line 44 def optionals %w[ sub_type index ] end |