Class: VisaAcceptanceMergedSpec::ShipTo8

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

Overview

ShipTo8 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(method: SKIP, first_name: SKIP, last_name: SKIP, address1: SKIP, address2: SKIP, locality: SKIP, postal_code: SKIP, administrative_area: SKIP, country: SKIP, phone_number: SKIP, additional_properties: nil) ⇒ ShipTo8

Returns a new instance of ShipTo8.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 100

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

  @method = method unless method == SKIP
  @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
  @postal_code = postal_code unless postal_code == SKIP
  @administrative_area = administrative_area unless administrative_area == 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.

Returns:

  • (String)


35
36
37
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 35

def address1
  @address1
end

#address2String

Second line of the shipping address

Returns:

  • (String)


39
40
41
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 39

def address2
  @address2
end

#administrative_areaString

State or province of shipping address. This is a State, Province, and Territory Codes for the United States and Canada.

Returns:

  • (String)


52
53
54
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 52

def administrative_area
  @administrative_area
end

#countryString

Country of shipping address. This is a two-character ISO Standard Country Codes.

Returns:

  • (String)


57
58
59
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 57

def country
  @country
end

#first_nameString

First name of the recipient.

Returns:

  • (String)


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

def first_name
  @first_name
end

#last_nameString

Last name of the recipient.

Returns:

  • (String)


31
32
33
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 31

def last_name
  @last_name
end

#localityString

City of the shipping address.

Returns:

  • (String)


43
44
45
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 43

def locality
  @locality
end

#methodString

shipping method for the product. Possible values are:

  • sameday
  • oneday
  • twoday
  • threeday
  • lowcost
  • pickup
  • other
  • none

Returns:

  • (String)


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

def method
  @method
end

#phone_numberString

Phone number of shipping address.

Returns:

  • (String)


61
62
63
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 61

def phone_number
  @phone_number
end

#postal_codeString

Postal code of shipping address. Consists of 5 to 9 digits.

Returns:

  • (String)


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

def postal_code
  @postal_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 121

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  method = hash.key?('method') ? hash['method'] : SKIP
  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
  postal_code = hash.key?('postalCode') ? hash['postalCode'] : SKIP
  administrative_area =
    hash.key?('administrativeArea') ? hash['administrativeArea'] : 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.
  ShipTo8.new(method: method,
              first_name: first_name,
              last_name: last_name,
              address1: address1,
              address2: address2,
              locality: locality,
              postal_code: postal_code,
              administrative_area: administrative_area,
              country: country,
              phone_number: phone_number,
              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
76
77
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 64

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

.nullablesObject

An array for nullable fields



96
97
98
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 96

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



168
169
170
171
172
173
174
175
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 168

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} method: #{@method.inspect}, first_name: #{@first_name.inspect}, last_name:"\
  " #{@last_name.inspect}, address1: #{@address1.inspect}, address2: #{@address2.inspect},"\
  " locality: #{@locality.inspect}, postal_code: #{@postal_code.inspect}, administrative_area:"\
  " #{@administrative_area.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.



159
160
161
162
163
164
165
# File 'lib/visa_acceptance_merged_spec/models/ship_to8.rb', line 159

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