Class: CyberSourceMergedSpec::ShipTo27

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

Overview

ShipTo27 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, administrative_area: SKIP, country: SKIP, destination_types: SKIP, locality: SKIP, first_name: SKIP, last_name: SKIP, middle_name: SKIP, phone_number: SKIP, postal_code: SKIP, destination_code: SKIP, method: SKIP, email: SKIP, company: SKIP, additional_properties: nil) ⇒ ShipTo27

Returns a new instance of ShipTo27.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 225

def initialize(address1: SKIP, address2: SKIP, address3: SKIP,
               administrative_area: SKIP, country: SKIP,
               destination_types: SKIP, locality: SKIP, first_name: SKIP,
               last_name: SKIP, middle_name: SKIP, phone_number: SKIP,
               postal_code: SKIP, destination_code: SKIP, method: SKIP,
               email: SKIP, company: 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
  @administrative_area = administrative_area unless administrative_area == SKIP
  @country = country unless country == SKIP
  @destination_types = destination_types unless destination_types == SKIP
  @locality = locality unless locality == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @middle_name = middle_name unless middle_name == SKIP
  @phone_number = phone_number unless phone_number == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @destination_code = destination_code unless destination_code == SKIP
  @method = method unless method == SKIP
  @email = email unless email == SKIP
  @company = company unless company == 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_to27.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_to27.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_to27.rb', line 40

def address3
  @address3
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)


55
56
57
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 55

def administrative_area
  @administrative_area
end

#companyString

Name of the customer’s company.

Returns:

  • (String)


174
175
176
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 174

def company
  @company
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)


69
70
71
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 69

def country
  @country
end

#destination_codeInteger

Indicates destination chosen for the transaction. Possible values:

  • 01- Ship to cardholder billing address
  • 02- Ship to another verified address on file with merchant
  • 03- Ship to address that is different than billing address
  • 04- Ship to store (store address should be populated on request)
  • 05- Digital goods
  • 06- Travel and event tickets, not shipped
  • 07- Other

Returns:

  • (Integer)


153
154
155
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 153

def destination_code
  @destination_code
end

#destination_typesString

Shipping destination of item. Example: Commercial, Residential, Store

Returns:

  • (String)


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

def destination_types
  @destination_types
end

#emailString

Email of the recipient.

Returns:

  • (String)


170
171
172
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 170

def email
  @email
end

#first_nameString

First name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


94
95
96
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 94

def first_name
  @first_name
end

#last_nameString

Last name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


103
104
105
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 103

def last_name
  @last_name
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_to27.rb', line 85

def locality
  @locality
end

#methodString

Shipping method for the product. Possible values:

  • lowcost: Lowest-cost service
  • sameday: Courier or same-day service
  • oneday: Next-day or overnight service
  • twoday: Two-day service
  • threeday: Three-day service
  • pickup: Store pick-up
  • other: Other shipping method
  • none: No shipping method because product is a service or subscription Required for American Express SafeKey (U.S.).

Returns:

  • (String)


166
167
168
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 166

def method
  @method
end

#middle_nameString

Middle name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


112
113
114
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 112

def middle_name
  @middle_name
end

#phone_numberString

Phone number associated with the shipping address.

Returns:

  • (String)


116
117
118
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 116

def phone_number
  @phone_number
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)


142
143
144
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 142

def postal_code
  @postal_code
end

Class Method Details

.from_element(root) ⇒ Object



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 305

def self.from_element(root)
  address1 = XmlUtilities.from_element(root, 'address1', String)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  address3 = XmlUtilities.from_element(root, 'address3', String)
  administrative_area = XmlUtilities.from_element(root,
                                                  'administrativeArea',
                                                  String)
  country = XmlUtilities.from_element(root, 'country', String)
  destination_types = XmlUtilities.from_element(root, 'destinationTypes',
                                                String)
  locality = XmlUtilities.from_element(root, 'locality', String)
  first_name = XmlUtilities.from_element(root, 'firstName', String)
  last_name = XmlUtilities.from_element(root, 'lastName', String)
  middle_name = XmlUtilities.from_element(root, 'middleName', String)
  phone_number = XmlUtilities.from_element(root, 'phoneNumber', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)
  destination_code = XmlUtilities.from_element(root, 'destinationCode',
                                               Integer)
  method = XmlUtilities.from_element(root, 'method', String)
  email = XmlUtilities.from_element(root, 'email', String)
  company = XmlUtilities.from_element(root, 'company', String)

  new(address1: address1,
      address2: address2,
      address3: address3,
      administrative_area: administrative_area,
      country: country,
      destination_types: destination_types,
      locality: locality,
      first_name: first_name,
      last_name: last_name,
      middle_name: middle_name,
      phone_number: phone_number,
      postal_code: postal_code,
      destination_code: destination_code,
      method: method,
      email: email,
      company: company,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 254

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
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  destination_types =
    hash.key?('destinationTypes') ? hash['destinationTypes'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
  middle_name = hash.key?('middleName') ? hash['middleName'] : SKIP
  phone_number = hash.key?('phoneNumber') ? hash['phoneNumber'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  destination_code =
    hash.key?('destinationCode') ? hash['destinationCode'] : SKIP
  method = hash.key?('method') ? hash['method'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  company = hash.key?('company') ? hash['company'] : 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.
  ShipTo27.new(address1: address1,
               address2: address2,
               address3: address3,
               administrative_area: administrative_area,
               country: country,
               destination_types: destination_types,
               locality: locality,
               first_name: first_name,
               last_name: last_name,
               middle_name: middle_name,
               phone_number: phone_number,
               postal_code: postal_code,
               destination_code: destination_code,
               method: method,
               email: email,
               company: company,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 177

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['address3'] = 'address3'
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['country'] = 'country'
  @_hash['destination_types'] = 'destinationTypes'
  @_hash['locality'] = 'locality'
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['middle_name'] = 'middleName'
  @_hash['phone_number'] = 'phoneNumber'
  @_hash['postal_code'] = 'postalCode'
  @_hash['destination_code'] = 'destinationCode'
  @_hash['method'] = 'method'
  @_hash['email'] = 'email'
  @_hash['company'] = 'company'
  @_hash
end

.nullablesObject

An array for nullable fields



221
222
223
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 221

def self.nullables
  []
end

.optionalsObject

An array for optional fields



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 199

def self.optionals
  %w[
    address1
    address2
    address3
    administrative_area
    country
    destination_types
    locality
    first_name
    last_name
    middle_name
    phone_number
    postal_code
    destination_code
    method
    email
    company
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



386
387
388
389
390
391
392
393
394
395
396
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 386

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1.inspect}, address2: #{@address2.inspect}, address3:"\
  " #{@address3.inspect}, administrative_area: #{@administrative_area.inspect}, country:"\
  " #{@country.inspect}, destination_types: #{@destination_types.inspect}, locality:"\
  " #{@locality.inspect}, first_name: #{@first_name.inspect}, last_name:"\
  " #{@last_name.inspect}, middle_name: #{@middle_name.inspect}, phone_number:"\
  " #{@phone_number.inspect}, postal_code: #{@postal_code.inspect}, destination_code:"\
  " #{@destination_code.inspect}, method: #{@method.inspect}, email: #{@email.inspect},"\
  " company: #{@company.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



375
376
377
378
379
380
381
382
383
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 375

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} address1: #{@address1}, address2: #{@address2}, address3: #{@address3},"\
  " administrative_area: #{@administrative_area}, country: #{@country}, destination_types:"\
  " #{@destination_types}, locality: #{@locality}, first_name: #{@first_name}, last_name:"\
  " #{@last_name}, middle_name: #{@middle_name}, phone_number: #{@phone_number}, postal_code:"\
  " #{@postal_code}, destination_code: #{@destination_code}, method: #{@method}, email:"\
  " #{@email}, company: #{@company}, additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/cyber_source_merged_spec/models/ship_to27.rb', line 346

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, 'address3', address3)
  XmlUtilities.add_as_subelement(doc, root, 'administrativeArea',
                                 administrative_area)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'destinationTypes',
                                 destination_types)
  XmlUtilities.add_as_subelement(doc, root, 'locality', locality)
  XmlUtilities.add_as_subelement(doc, root, 'firstName', first_name)
  XmlUtilities.add_as_subelement(doc, root, 'lastName', last_name)
  XmlUtilities.add_as_subelement(doc, root, 'middleName', middle_name)
  XmlUtilities.add_as_subelement(doc, root, 'phoneNumber', phone_number)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'destinationCode',
                                 destination_code)
  XmlUtilities.add_as_subelement(doc, root, 'method', method)
  XmlUtilities.add_as_subelement(doc, root, 'email', email)
  XmlUtilities.add_as_subelement(doc, root, 'company', company)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end