Class: CyberSourceMergedSpec::Address
- Defined in:
- lib/cyber_source_merged_spec/models/address.rb
Overview
Contains address information related to the order
Instance Attribute Summary collapse
-
#address1 ⇒ String
First line of the street address.
-
#address2 ⇒ String
Second line of the street address.
-
#administrative_area ⇒ String
State, province, or territory of the street address.
-
#country ⇒ String
Country of the street address.
-
#locality ⇒ String
City of the street address.
-
#postal_code ⇒ String
Postal code of the street address.
Class Method Summary collapse
- .from_element(root) ⇒ Object
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(address1: SKIP, address2: SKIP, locality: SKIP, country: SKIP, administrative_area: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ Address
constructor
A new instance of Address.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ Object
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, locality: SKIP, country: SKIP, administrative_area: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ Address
Returns a new instance of Address.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 70 def initialize(address1: SKIP, address2: SKIP, locality: SKIP, country: SKIP, administrative_area: 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 @locality = locality unless locality == SKIP @country = country unless country == SKIP @administrative_area = administrative_area unless administrative_area == SKIP @postal_code = postal_code unless postal_code == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#address1 ⇒ String
First line of the street address
14 15 16 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 14 def address1 @address1 end |
#address2 ⇒ String
Second line of the street address
18 19 20 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 18 def address2 @address2 end |
#administrative_area ⇒ String
State, province, or territory of the street address. Use the two-character codes located in the Support Center.
34 35 36 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 34 def administrative_area @administrative_area end |
#country ⇒ String
Country of the street address. Use the two-character codes located in the Support Center. Required if address1 is present.
29 30 31 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 29 def country @country end |
#locality ⇒ String
City of the street address. Required when adding the address to a list.
23 24 25 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 23 def locality @locality end |
#postal_code ⇒ String
Postal code of the street address. Required when adding the address to a list.
39 40 41 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 39 def postal_code @postal_code end |
Class Method Details
.from_element(root) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 115 def self.from_element(root) address1 = XmlUtilities.from_element(root, 'address1', String) address2 = XmlUtilities.from_element(root, 'address2', String) locality = XmlUtilities.from_element(root, 'locality', String) country = XmlUtilities.from_element(root, 'country', String) administrative_area = XmlUtilities.from_element(root, 'administrativeArea', String) postal_code = XmlUtilities.from_element(root, 'postalCode', String) new(address1: address1, address2: address2, locality: locality, country: country, administrative_area: administrative_area, postal_code: postal_code, additional_properties: additional_properties) end |
.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 107 108 109 110 111 112 113 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 86 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 locality = hash.key?('locality') ? hash['locality'] : SKIP country = hash.key?('country') ? hash['country'] : SKIP administrative_area = hash.key?('administrativeArea') ? hash['administrativeArea'] : 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. Address.new(address1: address1, address2: address2, locality: locality, country: country, administrative_area: administrative_area, postal_code: postal_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 42 def self.names @_hash = {} if @_hash.nil? @_hash['address1'] = 'address1' @_hash['address2'] = 'address2' @_hash['locality'] = 'locality' @_hash['country'] = 'country' @_hash['administrative_area'] = 'administrativeArea' @_hash['postal_code'] = 'postalCode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
66 67 68 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 66 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 54 def self.optionals %w[ address1 address2 locality country administrative_area postal_code ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
159 160 161 162 163 164 165 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 159 def inspect class_name = self.class.name.split('::').last "<#{class_name} address1: #{@address1.inspect}, address2: #{@address2.inspect}, locality:"\ " #{@locality.inspect}, country: #{@country.inspect}, administrative_area:"\ " #{@administrative_area.inspect}, postal_code: #{@postal_code.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
151 152 153 154 155 156 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 151 def to_s class_name = self.class.name.split('::').last "<#{class_name} address1: #{@address1}, address2: #{@address2}, locality: #{@locality},"\ " country: #{@country}, administrative_area: #{@administrative_area}, postal_code:"\ " #{@postal_code}, additional_properties: #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/cyber_source_merged_spec/models/address.rb', line 134 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, 'locality', locality) XmlUtilities.add_as_subelement(doc, root, 'country', country) XmlUtilities.add_as_subelement(doc, root, 'administrativeArea', administrative_area) XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |