Class: CyberSourceMergedSpec::ShipTo34

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

Overview

ShipTo34 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(first_name: SKIP, last_name: SKIP, address1: SKIP, country: SKIP, phone_number: SKIP, additional_properties: nil) ⇒ ShipTo34

Returns a new instance of ShipTo34.



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 86

def initialize(first_name: SKIP, last_name: SKIP, address1: SKIP,
               country: SKIP, phone_number: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @address1 = address1 unless address1 == SKIP
  @country = country unless country == SKIP
  @phone_number = phone_number unless phone_number == 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)


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

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


53
54
55
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 53

def country
  @country
end

#first_nameString

First name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


19
20
21
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 19

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)


28
29
30
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 28

def last_name
  @last_name
end

#phone_numberString

Phone number associated with the shipping address.

Returns:

  • (String)


57
58
59
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 57

def phone_number
  @phone_number
end

Class Method Details

.from_element(root) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 127

def self.from_element(root)
  first_name = XmlUtilities.from_element(root, 'firstName', String)
  last_name = XmlUtilities.from_element(root, 'lastName', String)
  address1 = XmlUtilities.from_element(root, 'address1', String)
  country = XmlUtilities.from_element(root, 'country', String)
  phone_number = XmlUtilities.from_element(root, 'phoneNumber', String)

  new(first_name: first_name,
      last_name: last_name,
      address1: address1,
      country: country,
      phone_number: phone_number,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
  address1 = hash.key?('address1') ? hash['address1'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  phone_number = hash.key?('phoneNumber') ? hash['phoneNumber'] : 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.
  ShipTo34.new(first_name: first_name,
               last_name: last_name,
               address1: address1,
               country: country,
               phone_number: phone_number,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



60
61
62
63
64
65
66
67
68
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 60

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['first_name'] = 'firstName'
  @_hash['last_name'] = 'lastName'
  @_hash['address1'] = 'address1'
  @_hash['country'] = 'country'
  @_hash['phone_number'] = 'phoneNumber'
  @_hash
end

.nullablesObject

An array for nullable fields



82
83
84
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 82

def self.nullables
  []
end

.optionalsObject

An array for optional fields



71
72
73
74
75
76
77
78
79
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 71

def self.optionals
  %w[
    first_name
    last_name
    address1
    country
    phone_number
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



165
166
167
168
169
170
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 165

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

#to_sObject

Provides a human-readable string representation of the object.



157
158
159
160
161
162
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 157

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

#to_xml_element(doc, root_name) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/cyber_source_merged_spec/models/ship_to34.rb', line 142

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

  XmlUtilities.add_as_subelement(doc, root, 'firstName', first_name)
  XmlUtilities.add_as_subelement(doc, root, 'lastName', last_name)
  XmlUtilities.add_as_subelement(doc, root, 'address1', address1)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'phoneNumber', phone_number)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end