Class: ApiReference::ItemExternalConnection

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/item_external_connection.rb

Overview

Represents a connection between an Item and an external system for invoicing or tax calculation purposes.

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(external_connection_name:, external_entity_id:, additional_properties: nil) ⇒ ItemExternalConnection

Returns a new instance of ItemExternalConnection.



39
40
41
42
43
44
45
46
47
# File 'lib/api_reference/models/item_external_connection.rb', line 39

def initialize(external_connection_name:, external_entity_id:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @external_connection_name = external_connection_name
  @external_entity_id = external_entity_id
  @additional_properties = additional_properties
end

Instance Attribute Details

#external_connection_nameObject

The name of the external system this item is connected to.

Returns:

  • (Object)


15
16
17
# File 'lib/api_reference/models/item_external_connection.rb', line 15

def external_connection_name
  @external_connection_name
end

#external_entity_idString

The identifier of this item in the external system.

Returns:

  • (String)


19
20
21
# File 'lib/api_reference/models/item_external_connection.rb', line 19

def external_entity_id
  @external_entity_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/api_reference/models/item_external_connection.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  external_connection_name = hash.key?('external_connection_name') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ItemExternalConnectionExternalConnectionName), hash['external_connection_name']
  ) : nil
  external_entity_id =
    hash.key?('external_entity_id') ? hash['external_entity_id'] : 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.
  ItemExternalConnection.new(external_connection_name: external_connection_name,
                             external_entity_id: external_entity_id,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



35
36
37
# File 'lib/api_reference/models/item_external_connection.rb', line 35

def self.nullables
  []
end

.optionalsObject

An array for optional fields



30
31
32
# File 'lib/api_reference/models/item_external_connection.rb', line 30

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/api_reference/models/item_external_connection.rb', line 75

def self.validate(value)
  if value.instance_of? self
    return (
      UnionTypeLookUp.get(:ItemExternalConnectionExternalConnectionName)
                     .validate(value.external_connection_name) and
        APIHelper.valid_type?(value.external_entity_id,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    UnionTypeLookUp.get(:ItemExternalConnectionExternalConnectionName)
                   .validate(value['external_connection_name']) and
      APIHelper.valid_type?(value['external_entity_id'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



103
104
105
106
107
108
# File 'lib/api_reference/models/item_external_connection.rb', line 103

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

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
# File 'lib/api_reference/models/item_external_connection.rb', line 96

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