Class: CyberSourceMergedSpec::ShipTo30

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

Overview

ShipTo30 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:, country:, address2: SKIP, address3: SKIP, address4: SKIP, administrative_area: SKIP, locality: SKIP, postal_code: SKIP, additional_properties: nil) ⇒ ShipTo30

Returns a new instance of ShipTo30.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 144

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

  @address1 = address1
  @address2 = address2 unless address2 == SKIP
  @address3 = address3 unless address3 == SKIP
  @address4 = address4 unless address4 == SKIP
  @administrative_area = administrative_area unless administrative_area == SKIP
  @country = country
  @locality = locality unless locality == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

First line of the shipping address. Required field for authorization if any shipping address information is included in the request; otherwise, optional.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


21
22
23
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 21

def address1
  @address1
end

#address2String

Second line of the shipping address. Optional field.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


31
32
33
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 31

def address2
  @address2
end

#address3String

Third line of the shipping address.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


40
41
42
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 40

def address3
  @address3
end

#address4String

Fourth line of the shipping address.

Returns:

  • (String)


44
45
46
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 44

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](https://developer.cybersource.com/library/documentation/sbc/quickr ef/states_and_provinces.pdf) (maximum length: 2) Required field for authorization if any shipping address information is included in the request and shipping to the U.S. or Canada; otherwise, optional.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


59
60
61
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 59

def administrative_area
  @administrative_area
end

#countryString

Country of the shipping address. Use the two-character [ISO Standard Country Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/cou ntries_alpha_list.pdf) Required field for authorization if any shipping address information is included in the request; otherwise, optional.

Tax Calculation

Optional field for U.S., Canadian, international tax, and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


73
74
75
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 73

def country
  @country
end

#localityString

City of the shipping address. Required field for authorization if any shipping address information is included in the request and shipping to the U.S. or Canada; otherwise, optional.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


85
86
87
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 85

def locality
  @locality
end

#postal_codeString

Postal code for the shipping address. The postal code must consist of 5 to 9 digits. Required field for authorization if any shipping address information is included in the request and shipping to the U.S. or Canada; otherwise, optional. When the billing country is the U.S., the 9-digit postal code must follow this format: [5 digits][dash][4 digits] Example 12345-6789 When the billing country is Canada, the 6-digit postal code must follow this format: [alpha][numeric][alpha][space][numeric][alpha][numeric] Example A1B 2C3

American Express Direct

Before sending the postal code to the processor, all nonalphanumeric characters are removed and, if the remaining value is longer than nine characters, the value is truncated starting from the right side.

Tax Calculation

Optional field for U.S. and Canadian taxes. Not applicable to international and value added taxes. Billing address objects will be used to determine the cardholder’s location when shipTo objects are not present.

Returns:

  • (String)


111
112
113
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 111

def postal_code
  @postal_code
end

Class Method Details

.from_element(root) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 195

def self.from_element(root)
  address1 = XmlUtilities.from_element(root, 'address1', String)
  country = XmlUtilities.from_element(root, 'country', String)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  address3 = XmlUtilities.from_element(root, 'address3', String)
  address4 = XmlUtilities.from_element(root, 'address4', String)
  administrative_area = XmlUtilities.from_element(root,
                                                  'administrativeArea',
                                                  String)
  locality = XmlUtilities.from_element(root, 'locality', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)

  new(address1: address1,
      country: country,
      address2: address2,
      address3: address3,
      address4: address4,
      administrative_area: administrative_area,
      locality: locality,
      postal_code: postal_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 162

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address1 = hash.key?('address1') ? hash['address1'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  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
  locality = hash.key?('locality') ? hash['locality'] : 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.
  ShipTo30.new(address1: address1,
               country: country,
               address2: address2,
               address3: address3,
               address4: address4,
               administrative_area: administrative_area,
               locality: locality,
               postal_code: postal_code,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 114

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['address3'] = 'address3'
  @_hash['address4'] = 'address4'
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['country'] = 'country'
  @_hash['locality'] = 'locality'
  @_hash['postal_code'] = 'postalCode'
  @_hash
end

.nullablesObject

An array for nullable fields



140
141
142
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 140

def self.nullables
  []
end

.optionalsObject

An array for optional fields



128
129
130
131
132
133
134
135
136
137
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 128

def self.optionals
  %w[
    address2
    address3
    address4
    administrative_area
    locality
    postal_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



246
247
248
249
250
251
252
253
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 246

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}, country: #{@country.inspect}, locality:"\
  " #{@locality.inspect}, postal_code: #{@postal_code.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



237
238
239
240
241
242
243
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 237

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

#to_xml_element(doc, root_name) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/cyber_source_merged_spec/models/ship_to30.rb', line 218

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, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'address2', address2)
  XmlUtilities.add_as_subelement(doc, root, 'address3', address3)
  XmlUtilities.add_as_subelement(doc, root, 'address4', address4)
  XmlUtilities.add_as_subelement(doc, root, 'administrativeArea',
                                 administrative_area)
  XmlUtilities.add_as_subelement(doc, root, 'locality', locality)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end