Class: TqlOtrFactoringDataExchange::Location

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

Overview

Physical address of the stop.

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(name: SKIP, address: SKIP, address2: SKIP, city: SKIP, state: SKIP, postal_code: SKIP, country: 'US', additional_properties: nil) ⇒ Location

Returns a new instance of Location.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 75

def initialize(name: SKIP, address: SKIP, address2: SKIP, city: SKIP,
               state: SKIP, postal_code: SKIP, country: 'US',
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name unless name == SKIP
  @address = address unless address == SKIP
  @address2 = address2 unless address2 == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @country = country unless country == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#addressString

Street address line 1.

Returns:

  • (String)


18
19
20
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 18

def address
  @address
end

#address2String

Street address line 2 (suite, unit, dock, etc.).

Returns:

  • (String)


22
23
24
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 22

def address2
  @address2
end

#cityString

City name.

Returns:

  • (String)


26
27
28
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 26

def city
  @city
end

#countryString

[ISO 3166-1](www.iso.org/iso-3166-country-codes.html) alpha-2 country code.

Returns:

  • (String)


39
40
41
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 39

def country
  @country
end

#nameString

Facility or company name at this stop.

Returns:

  • (String)


14
15
16
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 14

def name
  @name
end

#postal_codeString

ZIP or postal code.

Returns:

  • (String)


34
35
36
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 34

def postal_code
  @postal_code
end

#stateString

Two-letter state/province code.

Returns:

  • (String)


30
31
32
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 30

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
118
119
120
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  address = hash.key?('address') ? hash['address'] : SKIP
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  country = hash['country'] ||= 'US'

  # 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.
  Location.new(name: name,
               address: address,
               address2: address2,
               city: city,
               state: state,
               postal_code: postal_code,
               country: country,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



68
69
70
71
72
73
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 68

def self.nullables
  %w[
    name
    address2
  ]
end

.optionalsObject

An array for optional fields



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 55

def self.optionals
  %w[
    name
    address
    address2
    city
    state
    postal_code
    country
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Location | Hash)

    value against the validation is performed.



124
125
126
127
128
129
130
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 124

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



141
142
143
144
145
146
147
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 141

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

#to_sObject

Provides a human-readable string representation of the object.



133
134
135
136
137
138
# File 'lib/tql_otr_factoring_data_exchange/models/location.rb', line 133

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