Class: ModernTreasury::CounterpartyShippingAddress

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/counterparty_shipping_address.rb

Overview

The counterparty’s shipping address where physical goods should be delivered.

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(line1:, locality:, region:, postal_code:, country:, line2: SKIP, additional_properties: nil) ⇒ CounterpartyShippingAddress

Returns a new instance of CounterpartyShippingAddress.



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 61

def initialize(line1:, locality:, region:, postal_code:, country:,
               line2: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @line1 = line1
  @line2 = line2 unless line2 == SKIP
  @locality = locality
  @region = region
  @postal_code = postal_code
  @country = country
  @additional_properties = additional_properties
end

Instance Attribute Details

#countryString

Country code conforms to [ISO 3166-1 alpha-2]

Returns:

  • (String)


35
36
37
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 35

def country
  @country
end

#line1String

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 15

def line1
  @line1
end

#line2String

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 19

def line2
  @line2
end

#localityString

Locality or City.

Returns:

  • (String)


23
24
25
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 23

def locality
  @locality
end

#postal_codeString

The postal code of the address.

Returns:

  • (String)


31
32
33
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 31

def postal_code
  @postal_code
end

#regionString

Region or State.

Returns:

  • (String)


27
28
29
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 27

def region
  @region
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  line1 = hash.key?('line1') ? hash['line1'] : nil
  locality = hash.key?('locality') ? hash['locality'] : nil
  region = hash.key?('region') ? hash['region'] : nil
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  line2 = hash.key?('line2') ? hash['line2'] : SKIP

  # 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.
  CounterpartyShippingAddress.new(line1: line1,
                                  locality: locality,
                                  region: region,
                                  postal_code: postal_code,
                                  country: country,
                                  line2: line2,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['line1'] = 'line1'
  @_hash['line2'] = 'line2'
  @_hash['locality'] = 'locality'
  @_hash['region'] = 'region'
  @_hash['postal_code'] = 'postal_code'
  @_hash['country'] = 'country'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 50

def self.optionals
  %w[
    line2
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



113
114
115
116
117
118
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 113

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} line1: #{@line1.inspect}, line2: #{@line2.inspect}, locality:"\
  " #{@locality.inspect}, region: #{@region.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.



105
106
107
108
109
110
# File 'lib/modern_treasury/models/counterparty_shipping_address.rb', line 105

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