Class: CyberSourceMergedSpec::AddressDetails

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/address_details.rb

Overview

AddressDetails 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(address1: SKIP, address2: SKIP, city: SKIP, state: SKIP, country: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ AddressDetails

Returns a new instance of AddressDetails.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 65

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

  @address1 = address1 unless address1 == SKIP
  @address2 = address2 unless address2 == SKIP
  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @country = country unless country == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 14

def address1
  @address1
end

#address2String

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 18

def address2
  @address2
end

#cityString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 22

def city
  @city
end

#countryString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 30

def country
  @country
end

#postal_codeString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 34

def postal_code
  @postal_code
end

#stateString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 26

def state
  @state
end

Class Method Details

.from_element(root) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 108

def self.from_element(root)
  address1 = XmlUtilities.from_element(root, 'address1', String)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  city = XmlUtilities.from_element(root, 'city', String)
  state = XmlUtilities.from_element(root, 'state', String)
  country = XmlUtilities.from_element(root, 'country', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)

  new(address1: address1,
      address2: address2,
      city: city,
      state: state,
      country: country,
      postal_code: postal_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address1 = hash.key?('address1') ? hash['address1'] : SKIP
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : 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.
  AddressDetails.new(address1: address1,
                     address2: address2,
                     city: city,
                     state: state,
                     country: country,
                     postal_code: postal_code,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 37

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

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
58
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 49

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



149
150
151
152
153
154
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 149

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

#to_sObject

Provides a human-readable string representation of the object.



141
142
143
144
145
146
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 141

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

#to_xml_element(doc, root_name) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/cyber_source_merged_spec/models/address_details.rb', line 125

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'address1', address1)
  XmlUtilities.add_as_subelement(doc, root, 'address2', address2)
  XmlUtilities.add_as_subelement(doc, root, 'city', city)
  XmlUtilities.add_as_subelement(doc, root, 'state', state)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end