Class: CyberSourceMergedSpec::RentalAddress

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

Overview

RentalAddress 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(city: SKIP, state: SKIP, country: SKIP, location_id: SKIP, address1: SKIP, address2: SKIP, postal_code: SKIP, location: SKIP, additional_properties: nil) ⇒ RentalAddress

Returns a new instance of RentalAddress.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 96

def initialize(city: SKIP, state: SKIP, country: SKIP, location_id: SKIP,
               address1: SKIP, address2: SKIP, postal_code: SKIP,
               location: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @city = city unless city == SKIP
  @state = state unless state == SKIP
  @country = country unless country == SKIP
  @location_id = location_id unless location_id == SKIP
  @address1 = address1 unless address1 == SKIP
  @address2 = address2 unless address2 == SKIP
  @postal_code = postal_code unless postal_code == SKIP
  @location = location unless location == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

Address from where the vehicle was rented.

Returns:

  • (String)


41
42
43
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 41

def address1
  @address1
end

#address2String

Address from where the vehicle was rented.

Returns:

  • (String)


45
46
47
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 45

def address2
  @address2
end

#cityString

City in which the auto was rented. For authorizations, this field is supported for Visa, MasterCard, and American Express. For captures, this field is supported only for American Express. For all other card types, this field is ignored.

Returns:

  • (String)


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

def city
  @city
end

#countryString

Country where the auto was rented. Use the [ISO Standard Country Codes.](https://developer.cybersource.com/library/documentation/sbc/quickr ef/countries_alpha_list.pdf) This field is supported only for American Express.

Returns:

  • (String)


32
33
34
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 32

def country
  @country
end

#locationString

This field contains the location where a taxi passenger was picked up or where an auto rental vehicle was picked up. In most cases, this is the rental agency's business name that appears on the storefront and/or customer receipts, commonly referred to as the DBA (Doing Business As) name. However, if the vehicle was picked up at another location (e.g., a hotel,auto dealership, repair shop, etc.), the name of that location should be used. This entry must be easily recognized by the Cardmember to avoid unnecessary inquiries. If the name is more than 38 characters, use proper and meaningful abbreviation, when possible.

Returns:

  • (String)


61
62
63
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 61

def location
  @location
end

#location_idString

The agency code, address, phone number, etc., used to identify the location where the vehicle was rented.

Returns:

  • (String)


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

def location_id
  @location_id
end

#postal_codeString

When merchant wants to send the rental address's postal code.

Returns:

  • (String)


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

def postal_code
  @postal_code
end

#stateString

State in which the auto was rented. 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).

Returns:

  • (String)


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

def state
  @state
end

Class Method Details

.from_element(root) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 146

def self.from_element(root)
  city = XmlUtilities.from_element(root, 'city', String)
  state = XmlUtilities.from_element(root, 'state', String)
  country = XmlUtilities.from_element(root, 'country', String)
  location_id = XmlUtilities.from_element(root, 'locationId', String)
  address1 = XmlUtilities.from_element(root, 'address1', String)
  address2 = XmlUtilities.from_element(root, 'address2', String)
  postal_code = XmlUtilities.from_element(root, 'postalCode', String)
  location = XmlUtilities.from_element(root, 'location', String)

  new(city: city,
      state: state,
      country: country,
      location_id: location_id,
      address1: address1,
      address2: address2,
      postal_code: postal_code,
      location: location,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



114
115
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
142
143
144
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 114

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  city = hash.key?('city') ? hash['city'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  country = hash.key?('country') ? hash['country'] : SKIP
  location_id = hash.key?('locationId') ? hash['locationId'] : SKIP
  address1 = hash.key?('address1') ? hash['address1'] : SKIP
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  location = hash.key?('location') ? hash['location'] : 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.
  RentalAddress.new(city: city,
                    state: state,
                    country: country,
                    location_id: location_id,
                    address1: address1,
                    address2: address2,
                    postal_code: postal_code,
                    location: location,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 64

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['city'] = 'city'
  @_hash['state'] = 'state'
  @_hash['country'] = 'country'
  @_hash['location_id'] = 'locationId'
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['postal_code'] = 'postalCode'
  @_hash['location'] = 'location'
  @_hash
end

.nullablesObject

An array for nullable fields



92
93
94
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 92

def self.nullables
  []
end

.optionalsObject

An array for optional fields



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 78

def self.optionals
  %w[
    city
    state
    country
    location_id
    address1
    address2
    postal_code
    location
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



194
195
196
197
198
199
200
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 194

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city.inspect}, state: #{@state.inspect}, country:"\
  " #{@country.inspect}, location_id: #{@location_id.inspect}, address1: #{@address1.inspect},"\
  " address2: #{@address2.inspect}, postal_code: #{@postal_code.inspect}, location:"\
  " #{@location.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



185
186
187
188
189
190
191
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 185

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city}, state: #{@state}, country: #{@country}, location_id:"\
  " #{@location_id}, address1: #{@address1}, address2: #{@address2}, postal_code:"\
  " #{@postal_code}, location: #{@location}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/cyber_source_merged_spec/models/rental_address.rb', line 167

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

  XmlUtilities.add_as_subelement(doc, root, 'city', city)
  XmlUtilities.add_as_subelement(doc, root, 'state', state)
  XmlUtilities.add_as_subelement(doc, root, 'country', country)
  XmlUtilities.add_as_subelement(doc, root, 'locationId', location_id)
  XmlUtilities.add_as_subelement(doc, root, 'address1', address1)
  XmlUtilities.add_as_subelement(doc, root, 'address2', address2)
  XmlUtilities.add_as_subelement(doc, root, 'postalCode', postal_code)
  XmlUtilities.add_as_subelement(doc, root, 'location', location)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end