Class: NewStoreApi::SalesOrderAddress

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sales_order_address.rb

Overview

Address

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(address_line_1 = SKIP, address_line_2 = SKIP, city = SKIP, country_code = SKIP, first_name = SKIP, last_name = SKIP, note = SKIP, phone = SKIP, province = SKIP, salutation = SKIP, second_name = SKIP, state = SKIP, suffix = SKIP, title = SKIP, zip_code = SKIP) ⇒ SalesOrderAddress

Returns a new instance of SalesOrderAddress.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/new_store_api/models/sales_order_address.rb', line 122

def initialize(address_line_1 = SKIP, address_line_2 = SKIP, city = SKIP,
               country_code = SKIP, first_name = SKIP, last_name = SKIP,
               note = SKIP, phone = SKIP, province = SKIP,
               salutation = SKIP, second_name = SKIP, state = SKIP,
               suffix = SKIP, title = SKIP, zip_code = SKIP)
  @address_line_1 = address_line_1 unless address_line_1 == SKIP
  @address_line_2 = address_line_2 unless address_line_2 == SKIP
  @city = city unless city == SKIP
  @country_code = country_code unless country_code == SKIP
  @first_name = first_name unless first_name == SKIP
  @last_name = last_name unless last_name == SKIP
  @note = note unless note == SKIP
  @phone = phone unless phone == SKIP
  @province = province unless province == SKIP
  @salutation = salutation unless salutation == SKIP
  @second_name = second_name unless second_name == SKIP
  @state = state unless state == SKIP
  @suffix = suffix unless suffix == SKIP
  @title = title unless title == SKIP
  @zip_code = zip_code unless zip_code == SKIP
end

Instance Attribute Details

#address_line_1String

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/sales_order_address.rb', line 14

def address_line_1
  @address_line_1
end

#address_line_2String

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/sales_order_address.rb', line 18

def address_line_2
  @address_line_2
end

#cityString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/sales_order_address.rb', line 22

def city
  @city
end

#country_codeCountryCodeEnum

Country code for this address. Must be ISO-3166 reference

Returns:



27
28
29
# File 'lib/new_store_api/models/sales_order_address.rb', line 27

def country_code
  @country_code
end

#first_nameString

Country code for this address. Must be ISO-3166 reference

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/sales_order_address.rb', line 32

def first_name
  @first_name
end

#last_nameString

Country code for this address. Must be ISO-3166 reference

Returns:

  • (String)


37
38
39
# File 'lib/new_store_api/models/sales_order_address.rb', line 37

def last_name
  @last_name
end

#noteString

A note to leave remarks on address change.

Returns:

  • (String)


41
42
43
# File 'lib/new_store_api/models/sales_order_address.rb', line 41

def note
  @note
end

#phoneString

A note to leave remarks on address change.

Returns:

  • (String)


45
46
47
# File 'lib/new_store_api/models/sales_order_address.rb', line 45

def phone
  @phone
end

#provinceString

A note to leave remarks on address change.

Returns:

  • (String)


49
50
51
# File 'lib/new_store_api/models/sales_order_address.rb', line 49

def province
  @province
end

#salutationString

e.g. Mr., Ms., Mrs., ...

Returns:

  • (String)


53
54
55
# File 'lib/new_store_api/models/sales_order_address.rb', line 53

def salutation
  @salutation
end

#second_nameString

e.g. Mr., Ms., Mrs., ...

Returns:

  • (String)


57
58
59
# File 'lib/new_store_api/models/sales_order_address.rb', line 57

def second_name
  @second_name
end

#stateString

e.g. Mr., Ms., Mrs., ...

Returns:

  • (String)


61
62
63
# File 'lib/new_store_api/models/sales_order_address.rb', line 61

def state
  @state
end

#suffixString

e.g. Jr., Sr., III, ...

Returns:

  • (String)


65
66
67
# File 'lib/new_store_api/models/sales_order_address.rb', line 65

def suffix
  @suffix
end

#titleString

e.g. Dr., Prof., Pres., ...

Returns:

  • (String)


69
70
71
# File 'lib/new_store_api/models/sales_order_address.rb', line 69

def title
  @title
end

#zip_codeString

e.g. Dr., Prof., Pres., ...

Returns:

  • (String)


73
74
75
# File 'lib/new_store_api/models/sales_order_address.rb', line 73

def zip_code
  @zip_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/new_store_api/models/sales_order_address.rb', line 145

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  address_line_1 =
    hash.key?('address_line_1') ? hash['address_line_1'] : SKIP
  address_line_2 =
    hash.key?('address_line_2') ? hash['address_line_2'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  country_code = hash.key?('country_code') ? hash['country_code'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  note = hash.key?('note') ? hash['note'] : SKIP
  phone = hash.key?('phone') ? hash['phone'] : SKIP
  province = hash.key?('province') ? hash['province'] : SKIP
  salutation = hash.key?('salutation') ? hash['salutation'] : SKIP
  second_name = hash.key?('second_name') ? hash['second_name'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  suffix = hash.key?('suffix') ? hash['suffix'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP
  zip_code = hash.key?('zip_code') ? hash['zip_code'] : SKIP

  # Create object from extracted values.
  SalesOrderAddress.new(address_line_1,
                        address_line_2,
                        city,
                        country_code,
                        first_name,
                        last_name,
                        note,
                        phone,
                        province,
                        salutation,
                        second_name,
                        state,
                        suffix,
                        title,
                        zip_code)
end

.namesObject

A mapping from model property names to API property names.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/new_store_api/models/sales_order_address.rb', line 76

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['address_line_1'] = 'address_line_1'
  @_hash['address_line_2'] = 'address_line_2'
  @_hash['city'] = 'city'
  @_hash['country_code'] = 'country_code'
  @_hash['first_name'] = 'first_name'
  @_hash['last_name'] = 'last_name'
  @_hash['note'] = 'note'
  @_hash['phone'] = 'phone'
  @_hash['province'] = 'province'
  @_hash['salutation'] = 'salutation'
  @_hash['second_name'] = 'second_name'
  @_hash['state'] = 'state'
  @_hash['suffix'] = 'suffix'
  @_hash['title'] = 'title'
  @_hash['zip_code'] = 'zip_code'
  @_hash
end

.nullablesObject

An array for nullable fields



118
119
120
# File 'lib/new_store_api/models/sales_order_address.rb', line 118

def self.nullables
  []
end

.optionalsObject

An array for optional fields



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/new_store_api/models/sales_order_address.rb', line 97

def self.optionals
  %w[
    address_line_1
    address_line_2
    city
    country_code
    first_name
    last_name
    note
    phone
    province
    salutation
    second_name
    state
    suffix
    title
    zip_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



196
197
198
199
200
201
202
203
204
205
# File 'lib/new_store_api/models/sales_order_address.rb', line 196

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} address_line_1: #{@address_line_1.inspect}, address_line_2:"\
  " #{@address_line_2.inspect}, city: #{@city.inspect}, country_code:"\
  " #{@country_code.inspect}, first_name: #{@first_name.inspect}, last_name:"\
  " #{@last_name.inspect}, note: #{@note.inspect}, phone: #{@phone.inspect}, province:"\
  " #{@province.inspect}, salutation: #{@salutation.inspect}, second_name:"\
  " #{@second_name.inspect}, state: #{@state.inspect}, suffix: #{@suffix.inspect}, title:"\
  " #{@title.inspect}, zip_code: #{@zip_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} address_line_1: #{@address_line_1}, address_line_2: #{@address_line_2},"\
  " city: #{@city}, country_code: #{@country_code}, first_name: #{@first_name}, last_name:"\
  " #{@last_name}, note: #{@note}, phone: #{@phone}, province: #{@province}, salutation:"\
  " #{@salutation}, second_name: #{@second_name}, state: #{@state}, suffix: #{@suffix}, title:"\
  " #{@title}, zip_code: #{@zip_code}>"
end