Class: VisaAcceptanceMergedSpec::ReturnAddress

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

Overview

ReturnAddress 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, postal_code: SKIP, location: SKIP, additional_properties: nil) ⇒ ReturnAddress

Returns a new instance of ReturnAddress.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 80

def initialize(city: SKIP, state: SKIP, country: SKIP, location_id: SKIP,
               address1: 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
  @postal_code = postal_code unless postal_code == SKIP
  @location = location unless location == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#address1String

When merchant wants to send the rental address's street address.

Returns:

  • (String)


38
39
40
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 38

def address1
  @address1
end

#cityString

City where the auto was returned to the rental agency.

Returns:

  • (String)


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

def city
  @city
end

#countryString

Country where the auto was returned to the rental agency. Use the [ISO Standard Country Codes](

Returns:

  • (String)


28
29
30
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 28

def country
  @country
end

#locationString

This field contains the location where the taxi passenger was dropped off or where the auto rental vehicle was returned.

Returns:

  • (String)


47
48
49
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 47

def location
  @location
end

#location_idString

Code, address, phone number, etc. used to identify the location of the auto rental return. This field is supported only for MasterCard and American Express.

Returns:

  • (String)


34
35
36
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 34

def location_id
  @location_id
end

#postal_codeString

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

Returns:

  • (String)


42
43
44
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 42

def postal_code
  @postal_code
end

#stateString

State in which the auto was returned to the rental agency. Use the [State, Province, and Territory Codes for the United States and Canada]( For authorizations, this field is supported for Visa, MasterCard, and American Express. For captures, this field is supported only for MasterCard and American Express.

Returns:

  • (String)


23
24
25
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 23

def state
  @state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



97
98
99
100
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/visa_acceptance_merged_spec/models/return_address.rb', line 97

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
  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.
  ReturnAddress.new(city: city,
                    state: state,
                    country: country,
                    location_id: location_id,
                    address1: address1,
                    postal_code: postal_code,
                    location: location,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 50

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

.nullablesObject

An array for nullable fields



76
77
78
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 76

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 63

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



136
137
138
139
140
141
142
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 136

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},"\
  " postal_code: #{@postal_code.inspect}, location: #{@location.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
133
# File 'lib/visa_acceptance_merged_spec/models/return_address.rb', line 128

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