Class: WhatsAppCloudApi::Language

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/whats_app_cloud_api/models/language.rb

Overview

Language Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(code = nil, policy = 'deterministic') ⇒ Language

Returns a new instance of Language.



41
42
43
44
45
# File 'lib/whats_app_cloud_api/models/language.rb', line 41

def initialize(code = nil,
               policy = 'deterministic')
  @code = code unless code == SKIP
  @policy = policy unless policy == SKIP
end

Instance Attribute Details

#codeString

The code of the language or locale to use. Accepts both language and language_locale formats (e.g., en and en_US).

Returns:

  • (String)


15
16
17
# File 'lib/whats_app_cloud_api/models/language.rb', line 15

def code
  @code
end

#policyString

The language policy the message should follow.

Returns:

  • (String)


19
20
21
# File 'lib/whats_app_cloud_api/models/language.rb', line 19

def policy
  @policy
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/whats_app_cloud_api/models/language.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  code = hash.key?('code') ? hash['code'] : SKIP
  policy = hash['policy'] ||= 'deterministic'

  # Create object from extracted values.
  Language.new(code,
               policy)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/whats_app_cloud_api/models/language.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['code'] = 'code'
  @_hash['policy'] = 'policy'
  @_hash
end

Instance Method Details

#nullablesObject

An array for nullable fields



37
38
39
# File 'lib/whats_app_cloud_api/models/language.rb', line 37

def nullables
  []
end

#optionalsObject

An array for optional fields



30
31
32
33
34
# File 'lib/whats_app_cloud_api/models/language.rb', line 30

def optionals
  %w[
    policy
  ]
end