Class: CyberSourceMergedSpec::ShipTo7

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

Overview

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

Returns a new instance of ShipTo7.



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

def initialize(first_name: SKIP, last_name: SKIP, address1: SKIP,
               address2: SKIP, locality: SKIP, administrative_area: SKIP,
               postal_code: SKIP, country: 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
  @address2 = address2 unless address2 == SKIP
  @locality = locality unless locality == SKIP
  @administrative_area = administrative_area unless administrative_area == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @country = country unless country == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

First line of the shipping address.

Returns:

  • (String)


22
23
24
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 22

def address1
  @address1
end

#address2String

Second line of the shipping address.

Returns:

  • (String)


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

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

Returns:

  • (String)


37
38
39
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 37

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)

Returns:

  • (String)


49
50
51
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 49

def country
  @country
end

#first_nameString

First name of the recipient.

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 14

def first_name
  @first_name
end

#last_nameString

Last name of the recipient.

Returns:

  • (String)


18
19
20
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 18

def last_name
  @last_name
end

#localityString

City of the shipping address.

Returns:

  • (String)


30
31
32
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 30

def locality
  @locality
end

#postal_codeString

Postal code for the shipping address. The postal code must consist of 5 to 9 digits.

Returns:

  • (String)


42
43
44
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 42

def postal_code
  @postal_code
end

Class Method Details

.from_element(root) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 135

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)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  locality = XmlUtilities.from_element(root, 'locality', String)
  administrative_area = XmlUtilities.from_element(root,
                                                  'administrativeArea',
                                                  String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)
  country = XmlUtilities.from_element(root, 'country', String)

  new(first_name: first_name,
      last_name: last_name,
      address1: address1,
      address2: address2,
      locality: locality,
      administrative_area: administrative_area,
      postal_code: postal_code,
      country: country,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 102

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
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  locality = hash.key?('locality') ? hash['locality'] : SKIP
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  country = hash.key?('country') ? hash['country'] : 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.
  ShipTo7.new(first_name: first_name,
              last_name: last_name,
              address1: address1,
              address2: address2,
              locality: locality,
              administrative_area: administrative_area,
              postal_code: postal_code,
              country: country,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 52

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

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 66

def self.optionals
  %w[
    first_name
    last_name
    address1
    address2
    locality
    administrative_area
    postal_code
    country
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



186
187
188
189
190
191
192
193
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 186

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

#to_sObject

Provides a human-readable string representation of the object.



177
178
179
180
181
182
183
# File 'lib/cyber_source_merged_spec/models/ship_to7.rb', line 177

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

#to_xml_element(doc, root_name) ⇒ Object



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

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

  root
end