Class: CcipDirectoryAndConfigurationRestApiV1::FeeTokenEnriched

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb

Overview

FeeTokenEnriched Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(symbol:, name:, address:, decimals:, additional_properties: nil) ⇒ FeeTokenEnriched

Returns a new instance of FeeTokenEnriched.



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

def initialize(symbol:, name:, address:, decimals:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @symbol = symbol
  @name = name
  @address = address
  @decimals = decimals
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressString

Token contract address on this chain

Returns:

  • (String)


22
23
24
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 22

def address
  @address
end

#decimalsInteger

Number of decimals for the token

Returns:

  • (Integer)


26
27
28
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 26

def decimals
  @decimals
end

#nameString

Token name (e.g., Chainlink, Wrapped Ether)

Returns:

  • (String)


18
19
20
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 18

def name
  @name
end

#symbolString

Token symbol (e.g., LINK, WETH)

Returns:

  • (String)


14
15
16
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 14

def symbol
  @symbol
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  symbol = hash.key?('symbol') ? hash['symbol'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  address = hash.key?('address') ? hash['address'] : nil
  decimals = hash.key?('decimals') ? hash['decimals'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  FeeTokenEnriched.new(symbol: symbol,
                       name: name,
                       address: address,
                       decimals: decimals,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['symbol'] = 'symbol'
  @_hash['name'] = 'name'
  @_hash['address'] = 'address'
  @_hash['decimals'] = 'decimals'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 39

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 87

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.symbol,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.address,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.decimals,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['symbol'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['address'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['decimals'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 123

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} symbol: #{@symbol.inspect}, name: #{@name.inspect}, address:"\
  " #{@address.inspect}, decimals: #{@decimals.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/fee_token_enriched.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} symbol: #{@symbol}, name: #{@name}, address: #{@address}, decimals:"\
  " #{@decimals}, additional_properties: #{@additional_properties}>"
end