Class: VisaAcceptanceMergedSpec::ShipTo26

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/ship_to26.rb

Overview

ShipTo26 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, address3: SKIP, address4: SKIP, administrative_area: SKIP, building_number: SKIP, country: SKIP, district: SKIP, locality: SKIP, postal_code: SKIP, first_name: SKIP, last_name: SKIP, additional_properties: nil) ⇒ ShipTo26

Returns a new instance of ShipTo26.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 105

def initialize(address1: SKIP, address2: SKIP, address3: SKIP,
               address4: SKIP, administrative_area: SKIP,
               building_number: SKIP, country: SKIP, district: SKIP,
               locality: SKIP, postal_code: SKIP, first_name: SKIP,
               last_name: 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
  @address3 = address3 unless address3 == SKIP
  @address4 = address4 unless address4 == SKIP
  @administrative_area = administrative_area unless administrative_area == SKIP
  @building_number = building_number unless building_number == SKIP
  @country = country unless country == SKIP
  @district = district unless district == SKIP
  @locality = locality unless locality == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

First line of the shipping address.

Returns:

  • (String)


14
15
16
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 14

def address1
  @address1
end

#address2String

Second line of the shipping address.

Returns:

  • (String)


18
19
20
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 18

def address2
  @address2
end

#address3String

Third line of the shipping address.

Returns:

  • (String)


22
23
24
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 22

def address3
  @address3
end

#address4String

Fourth line of the shipping address.

Returns:

  • (String)


26
27
28
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 26

def address4
  @address4
end

#administrative_areaString

State or province of the shipping address. Use the [State, Province, and Territory Codes for the United States and Canada](

Returns:

  • (String)


32
33
34
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 32

def administrative_area
  @administrative_area
end

#building_numberString

Building number in the street address.

Returns:

  • (String)


36
37
38
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 36

def building_number
  @building_number
end

#countryString

Country of the shipping address. Use the two-character [ISO Standard Country Codes.](

Returns:

  • (String)


41
42
43
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 41

def country
  @country
end

#districtString

Neighborhood, community, or region within a city or municipality.

Returns:

  • (String)


45
46
47
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 45

def district
  @district
end

#first_nameString

First name of the recipient

Returns:

  • (String)


58
59
60
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 58

def first_name
  @first_name
end

#last_nameString

Last name of the recipient.

Returns:

  • (String)


62
63
64
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 62

def last_name
  @last_name
end

#localityString

City of the shipping address.

Returns:

  • (String)


49
50
51
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 49

def locality
  @locality
end

#postal_codeString

Postal code for the shipping address. The postal code must consist of 5 to 9 digits.

Returns:

  • (String)


54
55
56
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 54

def postal_code
  @postal_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 129

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
  address3 = hash.key?('address3') ? hash['address3'] : SKIP
  address4 = hash.key?('address4') ? hash['address4'] : SKIP
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : SKIP
  building_number =
    hash.key?('buildingNumber') ? hash['buildingNumber'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  district = hash.key?('district') ? hash['district'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : 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.
  ShipTo26.new(address1: address1,
               address2: address2,
               address3: address3,
               address4: address4,
               administrative_area: administrative_area,
               building_number: building_number,
               country: country,
               district: district,
               locality: locality,
               postal_code: postal_code,
               first_name: first_name,
               last_name: last_name,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['address3'] = 'address3'
  @_hash['address4'] = 'address4'
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['building_number'] = 'buildingNumber'
  @_hash['country'] = 'country'
  @_hash['district'] = 'district'
  @_hash['locality'] = 'locality'
  @_hash['postal_code'] = 'postalCode'
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 101

def self.nullables
  []
end

.optionalsObject

An array for optional fields



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 83

def self.optionals
  %w[
    address1
    address2
    address3
    address4
    administrative_area
    building_number
    country
    district
    locality
    postal_code
    first_name
    last_name
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



182
183
184
185
186
187
188
189
190
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 182

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1.inspect}, address2: #{@address2.inspect}, address3:"\
  " #{@address3.inspect}, address4: #{@address4.inspect}, administrative_area:"\
  " #{@administrative_area.inspect}, building_number: #{@building_number.inspect}, country:"\
  " #{@country.inspect}, district: #{@district.inspect}, locality: #{@locality.inspect},"\
  " postal_code: #{@postal_code.inspect}, first_name: #{@first_name.inspect}, last_name:"\
  " #{@last_name.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



172
173
174
175
176
177
178
179
# File 'lib/visa_acceptance_merged_spec/models/ship_to26.rb', line 172

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1}, address2: #{@address2}, address3: #{@address3},"\
  " address4: #{@address4}, administrative_area: #{@administrative_area}, building_number:"\
  " #{@building_number}, country: #{@country}, district: #{@district}, locality: #{@locality},"\
  " postal_code: #{@postal_code}, first_name: #{@first_name}, last_name: #{@last_name},"\
  " additional_properties: #{@additional_properties}>"
end