Class: WhatsAppCloudApi::Currency

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

Overview

Currency Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(fallback_value = nil, code = nil, amount_1000 = nil) ⇒ Currency

Returns a new instance of Currency.



43
44
45
46
47
48
49
# File 'lib/whats_app_cloud_api/models/currency.rb', line 43

def initialize(fallback_value = nil,
               code = nil,
               amount_1000 = nil)
  @fallback_value = fallback_value unless fallback_value == SKIP
  @code = code unless code == SKIP
  @amount_1000 = amount_1000 unless amount_1000 == SKIP
end

Instance Attribute Details

#amount_1000Integer

Amount multiplied by 1000.

Returns:

  • (Integer)


22
23
24
# File 'lib/whats_app_cloud_api/models/currency.rb', line 22

def amount_1000
  @amount_1000
end

#codeString

Currency code as defined in ISO 4217.

Returns:

  • (String)


18
19
20
# File 'lib/whats_app_cloud_api/models/currency.rb', line 18

def code
  @code
end

#fallback_valueString

Default text if localization fails.

Returns:

  • (String)


14
15
16
# File 'lib/whats_app_cloud_api/models/currency.rb', line 14

def fallback_value
  @fallback_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/whats_app_cloud_api/models/currency.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  fallback_value =
    hash.key?('fallback_value') ? hash['fallback_value'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  amount_1000 = hash.key?('amount_1000') ? hash['amount_1000'] : SKIP

  # Create object from extracted values.
  Currency.new(fallback_value,
               code,
               amount_1000)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/whats_app_cloud_api/models/currency.rb', line 25

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

Instance Method Details

#nullablesObject

An array for nullable fields



39
40
41
# File 'lib/whats_app_cloud_api/models/currency.rb', line 39

def nullables
  []
end

#optionalsObject

An array for optional fields



34
35
36
# File 'lib/whats_app_cloud_api/models/currency.rb', line 34

def optionals
  []
end