Class: CcipDirectoryAndConfigurationRestApiV1::ChainInfo

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

Overview

Chain information used in lane endpoints. Note: chainType and chainFamily are intentionally excluded from this schema for API responses.

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(chain_id:, display_name:, selector:, internal_id:, additional_properties: nil) ⇒ ChainInfo

Returns a new instance of ChainInfo.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 50

def initialize(chain_id:, display_name:, selector:, internal_id:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @chain_id = chain_id
  @display_name = display_name
  @selector = selector
  @internal_id = internal_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#chain_idObject

Identifier of the chain (numeric for EVM chains, string for Solana/Aptos chains)

Returns:

  • (Object)


16
17
18
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 16

def chain_id
  @chain_id
end

#display_nameString

Human-readable name of the chain

Returns:

  • (String)


20
21
22
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 20

def display_name
  @display_name
end

#internal_idString

Internal identifier used in configuration

Returns:

  • (String)


28
29
30
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 28

def internal_id
  @internal_id
end

#selectorString

CCIP chain selector as a string

Returns:

  • (String)


24
25
26
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 24

def selector
  @selector
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  chain_id = hash.key?('chainId') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ChainInfoChainId), hash['chainId']
  ) : nil
  display_name = hash.key?('displayName') ? hash['displayName'] : nil
  selector = hash.key?('selector') ? hash['selector'] : nil
  internal_id = hash.key?('internalId') ? hash['internalId'] : 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.
  ChainInfo.new(chain_id: chain_id,
                display_name: display_name,
                selector: selector,
                internal_id: internal_id,
                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['chain_id'] = 'chainId'
  @_hash['display_name'] = 'displayName'
  @_hash['selector'] = 'selector'
  @_hash['internal_id'] = 'internalId'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 41

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (ChainInfo | Hash)

    value against the validation is performed.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 91

def self.validate(value)
  if value.instance_of? self
    return (
      UnionTypeLookUp.get(:ChainInfoChainId)
                     .validate(value.chain_id) and
        APIHelper.valid_type?(value.display_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.selector,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.internal_id,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    UnionTypeLookUp.get(:ChainInfoChainId)
                   .validate(value['chainId']) and
      APIHelper.valid_type?(value['displayName'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['selector'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['internalId'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



128
129
130
131
132
133
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 128

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} chain_id: #{@chain_id.inspect}, display_name: #{@display_name.inspect},"\
  " selector: #{@selector.inspect}, internal_id: #{@internal_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



120
121
122
123
124
125
# File 'lib/ccip_directory_and_configuration_rest_api_v1/models/chain_info.rb', line 120

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} chain_id: #{@chain_id}, display_name: #{@display_name}, selector:"\
  " #{@selector}, internal_id: #{@internal_id}, additional_properties:"\
  " #{@additional_properties}>"
end