Class: FreightFinancialsWebhookIngestionApi::Address

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/freight_financials_webhook_ingestion_api/models/address.rb

Overview

Address 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(city: SKIP, country: SKIP, line1: SKIP, line2: SKIP, name: SKIP, postal_code: SKIP, state: SKIP) ⇒ Address

Returns a new instance of Address.



74
75
76
77
78
79
80
81
82
83
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 74

def initialize(city: SKIP, country: SKIP, line1: SKIP, line2: SKIP,
               name: SKIP, postal_code: SKIP, state: SKIP)
  @city = city unless city == SKIP
  @country = country unless country == SKIP
  @line1 = line1 unless line1 == SKIP
  @line2 = line2 unless line2 == SKIP
  @name = name unless name == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @state = state unless state == SKIP
end

Instance Attribute Details

#cityString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 14

def city
  @city
end

#countryString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 18

def country
  @country
end

#line1String

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 22

def line1
  @line1
end

#line2String

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 26

def line2
  @line2
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 30

def name
  @name
end

#postal_codeString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 34

def postal_code
  @postal_code
end

#stateString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 38

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  city = hash.key?('city') ? hash['city'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  line1 = hash.key?('line1') ? hash['line1'] : SKIP
  line2 = hash.key?('line2') ? hash['line2'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP

  # Create object from extracted values.
  Address.new(city: city,
              country: country,
              line1: line1,
              line2: line2,
              name: name,
              postal_code: postal_code,
              state: state)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['city'] = 'city'
  @_hash['country'] = 'country'
  @_hash['line1'] = 'line1'
  @_hash['line2'] = 'line2'
  @_hash['name'] = 'name'
  @_hash['postal_code'] = 'postalCode'
  @_hash['state'] = 'state'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
70
71
72
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 67

def self.nullables
  %w[
    line2
    name
  ]
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 54

def self.optionals
  %w[
    city
    country
    line1
    line2
    name
    postal_code
    state
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



116
117
118
119
120
121
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 116

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city.inspect}, country: #{@country.inspect}, line1:"\
  " #{@line1.inspect}, line2: #{@line2.inspect}, name: #{@name.inspect}, postal_code:"\
  " #{@postal_code.inspect}, state: #{@state.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



109
110
111
112
113
# File 'lib/freight_financials_webhook_ingestion_api/models/address.rb', line 109

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city}, country: #{@country}, line1: #{@line1}, line2: #{@line2},"\
  " name: #{@name}, postal_code: #{@postal_code}, state: #{@state}>"
end