Class: CyberSourceMergedSpec::ShipTo2

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

Overview

ShipTo2 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(administrative_area: SKIP, country: SKIP, postal_code: SKIP, email: SKIP, county: SKIP, additional_properties: nil) ⇒ ShipTo2

Returns a new instance of ShipTo2.



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 102

def initialize(administrative_area: SKIP, country: SKIP, postal_code: SKIP,
               email: SKIP, county: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @administrative_area = administrative_area unless administrative_area == SKIP
  @country = country unless country == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @email = email unless email == SKIP
  @county = county unless county == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#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)


25
26
27
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 25

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)


39
40
41
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 39

def country
  @country
end

#countyString

U.S. county if available.

Returns:

  • (String)


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

def county
  @county
end

#emailString

Email of the recipient.

Returns:

  • (String)


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

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


65
66
67
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 65

def postal_code
  @postal_code
end

Class Method Details

.from_element(root) ⇒ Object



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

def self.from_element(root)
  administrative_area = XmlUtilities.from_element(root,
                                                  'administrativeArea',
                                                  String)
  country = XmlUtilities.from_element(root, 'country', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)
  email = XmlUtilities.from_element(root, 'email', String)
  county = XmlUtilities.from_element(root, 'county', String)

  new(administrative_area: administrative_area,
      country: country,
      postal_code: postal_code,
      email: email,
      county: county,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 116

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  county = hash.key?('county') ? hash['county'] : 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.
  ShipTo2.new(administrative_area: administrative_area,
              country: country,
              postal_code: postal_code,
              email: email,
              county: county,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



76
77
78
79
80
81
82
83
84
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 76

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['country'] = 'country'
  @_hash['postal_code'] = 'postalCode'
  @_hash['email'] = 'email'
  @_hash['county'] = 'county'
  @_hash
end

.nullablesObject

An array for nullable fields



98
99
100
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 98

def self.nullables
  []
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 87

def self.optionals
  %w[
    administrative_area
    country
    postal_code
    email
    county
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



184
185
186
187
188
189
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 184

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

#to_sObject

Provides a human-readable string representation of the object.



176
177
178
179
180
181
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 176

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

#to_xml_element(doc, root_name) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/cyber_source_merged_spec/models/ship_to2.rb', line 160

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

  XmlUtilities.add_as_subelement(doc, root, 'administrativeArea',
                                 administrative_area)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'email', email)
  XmlUtilities.add_as_subelement(doc, root, 'county', county)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end