Class: TqlOtrFactoringDataExchange::FactoringCompanyInput

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb

Overview

Identifies the factoring company that purchased (bought out) the carrier’s loads.

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(company_name:, email:, phone:, additional_properties: nil) ⇒ FactoringCompanyInput

Returns a new instance of FactoringCompanyInput.



44
45
46
47
48
49
50
51
52
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 44

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

  @company_name = company_name
  @email = email
  @phone = phone
  @additional_properties = additional_properties
end

Instance Attribute Details

#company_nameString

Legal or DBA name of the factoring company.

Returns:

  • (String)


15
16
17
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 15

def company_name
  @company_name
end

#emailString

Contact email address for the factoring company.

Returns:

  • (String)


19
20
21
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 19

def email
  @email
end

#phoneString

Contact phone number for the factoring company.

Returns:

  • (String)


23
24
25
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 23

def phone
  @phone
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 55

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_name = hash.key?('companyName') ? hash['companyName'] : nil
  email = hash.key?('email') ? hash['email'] : nil
  phone = hash.key?('phone') ? hash['phone'] : 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.
  FactoringCompanyInput.new(company_name: company_name,
                            email: email,
                            phone: phone,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['company_name'] = 'companyName'
  @_hash['email'] = 'email'
  @_hash['phone'] = 'phone'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 35

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 79

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.company_name,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.email,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.phone,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['companyName'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['email'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['phone'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 111

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

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb', line 104

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