Class: CyberSourceMergedSpec::ShippingDetails2

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

Overview

ShippingDetails2 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(ship_from_postal_code: SKIP, additional_properties: nil) ⇒ ShippingDetails2

Returns a new instance of ShippingDetails2.



47
48
49
50
51
52
53
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 47

def initialize(ship_from_postal_code: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @ship_from_postal_code = ship_from_postal_code unless ship_from_postal_code == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#ship_from_postal_codeString

Postal code for the address from which the goods are shipped, which is used to establish nexus. The default is the postal code associated with your CyberSource account. The postal code must consist of 5 to 9 digits. 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 This field is frequently used for Level II and Level III transactions.

Returns:

  • (String)


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

def ship_from_postal_code
  @ship_from_postal_code
end

Class Method Details

.from_element(root) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 75

def self.from_element(root)
  ship_from_postal_code = XmlUtilities.from_element(root,
                                                    'shipFromPostalCode',
                                                    String)

  new(ship_from_postal_code: ship_from_postal_code,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  ship_from_postal_code =
    hash.key?('shipFromPostalCode') ? hash['shipFromPostalCode'] : 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.
  ShippingDetails2.new(ship_from_postal_code: ship_from_postal_code,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['ship_from_postal_code'] = 'shipFromPostalCode'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 36

def self.optionals
  %w[
    ship_from_postal_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



103
104
105
106
107
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 103

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} ship_from_postal_code: #{@ship_from_postal_code.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} ship_from_postal_code: #{@ship_from_postal_code}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



84
85
86
87
88
89
90
91
92
93
# File 'lib/cyber_source_merged_spec/models/shipping_details2.rb', line 84

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

  XmlUtilities.add_as_subelement(doc, root, 'shipFromPostalCode',
                                 ship_from_postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end