Class: VisaAcceptanceMergedSpec::ShipTo9

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/ship_to9.rb

Overview

ShipTo9 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(email: SKIP, title: SKIP, first_name: SKIP, middle_name: SKIP, last_name: SKIP, company: SKIP, address1: SKIP, address2: SKIP, district: SKIP, locality: SKIP, administrative_area: SKIP, postal_code: SKIP, country: SKIP, building_number: SKIP, phone_number: SKIP, immutable: SKIP, not_applicable: SKIP, county: SKIP, additional_properties: nil) ⇒ ShipTo9

Returns a new instance of ShipTo9.



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 228

def initialize(email: SKIP, title: SKIP, first_name: SKIP,
               middle_name: SKIP, last_name: SKIP, company: SKIP,
               address1: SKIP, address2: SKIP, district: SKIP,
               locality: SKIP, administrative_area: SKIP, postal_code: SKIP,
               country: SKIP, building_number: SKIP, phone_number: SKIP,
               immutable: SKIP, not_applicable: SKIP, county: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @email = email unless email == SKIP
  @title = title unless title == SKIP
  @first_name = first_name unless first_name == SKIP
  @middle_name = middle_name unless middle_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @company = company unless company == SKIP
  @address1 = address1 unless address1 == SKIP
  @address2 = address2 unless address2 == SKIP
  @district = district unless district == 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
  @building_number = building_number unless building_number == SKIP
  @phone_number = phone_number unless phone_number == SKIP
  @immutable = immutable unless immutable == SKIP
  @not_applicable = not_applicable unless not_applicable == SKIP
  @county = county unless county == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1 ⇒ String

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)


60
61
62
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 60

def address1
  @address1
end

#address2 ⇒ String

Second line of the shipping address. Optional field.

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)


70
71
72
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 70

def address2
  @address2
end

#administrative_area ⇒ String

State or province of the shipping address. Use the [State, Province, and Territory Codes for the United States and Canada]( (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)


99
100
101
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 99

def administrative_area
  @administrative_area
end

#building_number ⇒ String

Building number in the street address. For example, the building number is 187 in the following address: Rua da Quitanda 187

Returns:

  • (String)


143
144
145
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 143

def building_number
  @building_number
end

#company ⇒ String

Name of the customer’s company.

Returns:

  • (String)


49
50
51
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 49

def company
  @company
end

#country ⇒ String

Country of the shipping address. Use the two-character [ISO Standard Country Codes.]( 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)


137
138
139
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 137

def country
  @country
end

#county ⇒ String

U.S. county if available.

Returns:

  • (String)


173
174
175
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 173

def county
  @county
end

#district ⇒ String

Neighborhood, community, or region within a city or municipality.

Returns:

  • (String)


74
75
76
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 74

def district
  @district
end

#email ⇒ String

Customer's primary email address, including the full domain name.

Returns:

  • (String)


14
15
16
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 14

def email
  @email
end

#first_name ⇒ String

First name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


27
28
29
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 27

def first_name
  @first_name
end

#immutable ⇒ String

Indicates whether customers are permitted to edit the shipping address in their PayPal account. Possible values:

  • true: Customer cannot edit the shipping address.
  • false (default): Customer can edit the shipping address.

Returns:

  • (String)


157
158
159
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 157

def immutable
  @immutable
end

#last_name ⇒ String

Last name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


45
46
47
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 45

def last_name
  @last_name
end

#locality ⇒ String

City of the shipping address. 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)


86
87
88
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 86

def locality
  @locality
end

#middle_name ⇒ String

Middle name of the recipient.

Litle

Maximum length: 25

All other processors

Maximum length: 60 Optional field.

Returns:

  • (String)


36
37
38
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 36

def middle_name
  @middle_name
end

#not_applicable ⇒ String

Indicates whether the shipping address is displayed to the customer in their PayPal account. Possible values:

  • true: Shipping address is not displayed.
  • false (default): Shipping address is displayed. For example, for digital downloads and services in which a shipping address is not required, set the value to true.

Returns:

  • (String)


169
170
171
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 169

def not_applicable
  @not_applicable
end

#phone_number ⇒ String

Phone number associated with the shipping address.

Returns:

  • (String)


147
148
149
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 147

def phone_number
  @phone_number
end

#postal_code ⇒ String

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)


125
126
127
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 125

def postal_code
  @postal_code
end

#title ⇒ String

The title of the person receiving the product.

Returns:

  • (String)


18
19
20
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 18

def title
  @title
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 260

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  email = hash.key?('email') ? hash['email'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP
  first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
  middle_name = hash.key?('middleName') ? hash['middleName'] : SKIP
  last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
  company = hash.key?('company') ? hash['company'] : SKIP
  address1 = hash.key?('address1') ? hash['address1'] : SKIP
  address2 = hash.key?('address2') ? hash['address2'] : SKIP
  district = hash.key?('district') ? hash['district'] : 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
  building_number =
    hash.key?('buildingNumber') ? hash['buildingNumber'] : SKIP
  phone_number = hash.key?('phoneNumber') ? hash['phoneNumber'] : SKIP
  immutable = hash.key?('immutable') ? hash['immutable'] : SKIP
  not_applicable = hash.key?('notApplicable') ? hash['notApplicable'] : 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.
  ShipTo9.new(email: email,
              title: title,
              first_name: first_name,
              middle_name: middle_name,
              last_name: last_name,
              company: company,
              address1: address1,
              address2: address2,
              district: district,
              locality: locality,
              administrative_area: administrative_area,
              postal_code: postal_code,
              country: country,
              building_number: building_number,
              phone_number: phone_number,
              immutable: immutable,
              not_applicable: not_applicable,
              county: county,
              additional_properties: additional_properties)
end

.names ⇒ Object

A mapping from model property names to API property names.



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 176

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['email'] = 'email'
  @_hash['title'] = 'title'
  @_hash['first_name'] = 'firstName'
  @_hash['middle_name'] = 'middleName'
  @_hash['last_name'] = 'lastName'
  @_hash['company'] = 'company'
  @_hash['address1'] = 'address1'
  @_hash['address2'] = 'address2'
  @_hash['district'] = 'district'
  @_hash['locality'] = 'locality'
  @_hash['administrative_area'] = 'administrativeArea'
  @_hash['postal_code'] = 'postalCode'
  @_hash['country'] = 'country'
  @_hash['building_number'] = 'buildingNumber'
  @_hash['phone_number'] = 'phoneNumber'
  @_hash['immutable'] = 'immutable'
  @_hash['not_applicable'] = 'notApplicable'
  @_hash['county'] = 'county'
  @_hash
end

.nullables ⇒ Object

An array for nullable fields



224
225
226
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 224

def self.nullables
  []
end

.optionals ⇒ Object

An array for optional fields



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 200

def self.optionals
  %w[
    email
    title
    first_name
    middle_name
    last_name
    company
    address1
    address2
    district
    locality
    administrative_area
    postal_code
    country
    building_number
    phone_number
    immutable
    not_applicable
    county
  ]
end

Instance Method Details

#inspect ⇒ Object

Provides a debugging-friendly string with detailed object information.



327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 327

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} email: #{@email.inspect}, title: #{@title.inspect}, first_name:"\
  " #{@first_name.inspect}, middle_name: #{@middle_name.inspect}, last_name:"\
  " #{@last_name.inspect}, company: #{@company.inspect}, address1: #{@address1.inspect},"\
  " address2: #{@address2.inspect}, district: #{@district.inspect}, locality:"\
  " #{@locality.inspect}, administrative_area: #{@administrative_area.inspect}, postal_code:"\
  " #{@postal_code.inspect}, country: #{@country.inspect}, building_number:"\
  " #{@building_number.inspect}, phone_number: #{@phone_number.inspect}, immutable:"\
  " #{@immutable.inspect}, not_applicable: #{@not_applicable.inspect}, county:"\
  " #{@county.inspect}, additional_properties: #{@additional_properties}>"
end

#to_s ⇒ Object

Provides a human-readable string representation of the object.



315
316
317
318
319
320
321
322
323
324
# File 'lib/visa_acceptance_merged_spec/models/ship_to9.rb', line 315

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} email: #{@email}, title: #{@title}, first_name: #{@first_name},"\
  " middle_name: #{@middle_name}, last_name: #{@last_name}, company: #{@company}, address1:"\
  " #{@address1}, address2: #{@address2}, district: #{@district}, locality: #{@locality},"\
  " administrative_area: #{@administrative_area}, postal_code: #{@postal_code}, country:"\
  " #{@country}, building_number: #{@building_number}, phone_number: #{@phone_number},"\
  " immutable: #{@immutable}, not_applicable: #{@not_applicable}, county: #{@county},"\
  " additional_properties: #{@additional_properties}>"
end