Class: NewStoreApi::AddressResponse

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

Overview

AddressResponse 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(id = nil, country_code = nil, created_at = nil, updated_at = nil, address_line_1 = SKIP, address_line_2 = SKIP, city = SKIP, company_name = SKIP, contact_phone = SKIP, full_name = SKIP, state = SKIP, zip_code = SKIP) ⇒ AddressResponse

Returns a new instance of AddressResponse.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/new_store_api/models/address_response.rb', line 102

def initialize(id = nil, country_code = nil, created_at = nil,
               updated_at = nil, address_line_1 = SKIP,
               address_line_2 = SKIP, city = SKIP, company_name = SKIP,
               contact_phone = SKIP, full_name = SKIP, state = SKIP,
               zip_code = SKIP)
  @id = id
  @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
  @company_name = company_name unless company_name == SKIP
  @contact_phone = contact_phone unless contact_phone == SKIP
  @country_code = country_code
  @full_name = full_name unless full_name == SKIP
  @state = state unless state == SKIP
  @zip_code = zip_code unless zip_code == SKIP
  @created_at = created_at
  @updated_at = updated_at
end

Instance Attribute Details

#address_line_1String

First line of the address. Typically, the street and house number.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/address_response.rb', line 19

def address_line_1
  @address_line_1
end

#address_line_2String

Second line of the address. Typically, the apartment number or PO box

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/address_response.rb', line 23

def address_line_2
  @address_line_2
end

#cityString

The city/town of the address.

Returns:

  • (String)


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

def city
  @city
end

#company_nameString

Company name.

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/address_response.rb', line 31

def company_name
  @company_name
end

#contact_phoneString

Phone number of the address.

Returns:

  • (String)


35
36
37
# File 'lib/new_store_api/models/address_response.rb', line 35

def contact_phone
  @contact_phone
end

#country_codeString

Country code in ISO 3166-1 alpha-2 format.

Returns:

  • (String)


39
40
41
# File 'lib/new_store_api/models/address_response.rb', line 39

def country_code
  @country_code
end

#created_atDateTime

Postal code of the address.

Returns:

  • (DateTime)


55
56
57
# File 'lib/new_store_api/models/address_response.rb', line 55

def created_at
  @created_at
end

#full_nameString

Full name.

Returns:

  • (String)


43
44
45
# File 'lib/new_store_api/models/address_response.rb', line 43

def full_name
  @full_name
end

#idString

Identifier of the address.

Returns:

  • (String)


15
16
17
# File 'lib/new_store_api/models/address_response.rb', line 15

def id
  @id
end

#stateString

State/province or region of the address.

Returns:

  • (String)


47
48
49
# File 'lib/new_store_api/models/address_response.rb', line 47

def state
  @state
end

#updated_atDateTime

Postal code of the address.

Returns:

  • (DateTime)


59
60
61
# File 'lib/new_store_api/models/address_response.rb', line 59

def updated_at
  @updated_at
end

#zip_codeString

Postal code of the address.

Returns:

  • (String)


51
52
53
# File 'lib/new_store_api/models/address_response.rb', line 51

def zip_code
  @zip_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
157
158
# File 'lib/new_store_api/models/address_response.rb', line 122

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  country_code = hash.key?('country_code') ? hash['country_code'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               end
  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
  company_name = hash.key?('company_name') ? hash['company_name'] : SKIP
  contact_phone = hash.key?('contact_phone') ? hash['contact_phone'] : SKIP
  full_name = hash.key?('full_name') ? hash['full_name'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  zip_code = hash.key?('zip_code') ? hash['zip_code'] : SKIP

  # Create object from extracted values.
  AddressResponse.new(id,
                      country_code,
                      created_at,
                      updated_at,
                      address_line_1,
                      address_line_2,
                      city,
                      company_name,
                      contact_phone,
                      full_name,
                      state,
                      zip_code)
end

.namesObject

A mapping from model property names to API property names.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/new_store_api/models/address_response.rb', line 62

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['address_line_1'] = 'address_line_1'
  @_hash['address_line_2'] = 'address_line_2'
  @_hash['city'] = 'city'
  @_hash['company_name'] = 'company_name'
  @_hash['contact_phone'] = 'contact_phone'
  @_hash['country_code'] = 'country_code'
  @_hash['full_name'] = 'full_name'
  @_hash['state'] = 'state'
  @_hash['zip_code'] = 'zip_code'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash
end

.nullablesObject

An array for nullable fields



94
95
96
97
98
99
100
# File 'lib/new_store_api/models/address_response.rb', line 94

def self.nullables
  %w[
    company_name
    contact_phone
    state
  ]
end

.optionalsObject

An array for optional fields



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/new_store_api/models/address_response.rb', line 80

def self.optionals
  %w[
    address_line_1
    address_line_2
    city
    company_name
    contact_phone
    full_name
    state
    zip_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



179
180
181
182
183
184
185
186
187
# File 'lib/new_store_api/models/address_response.rb', line 179

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, address_line_1: #{@address_line_1.inspect},"\
  " address_line_2: #{@address_line_2.inspect}, city: #{@city.inspect}, company_name:"\
  " #{@company_name.inspect}, contact_phone: #{@contact_phone.inspect}, country_code:"\
  " #{@country_code.inspect}, full_name: #{@full_name.inspect}, state: #{@state.inspect},"\
  " zip_code: #{@zip_code.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}>"
end

#to_custom_created_atObject



160
161
162
# File 'lib/new_store_api/models/address_response.rb', line 160

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



164
165
166
# File 'lib/new_store_api/models/address_response.rb', line 164

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



169
170
171
172
173
174
175
176
# File 'lib/new_store_api/models/address_response.rb', line 169

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, address_line_1: #{@address_line_1}, address_line_2:"\
  " #{@address_line_2}, city: #{@city}, company_name: #{@company_name}, contact_phone:"\
  " #{@contact_phone}, country_code: #{@country_code}, full_name: #{@full_name}, state:"\
  " #{@state}, zip_code: #{@zip_code}, created_at: #{@created_at}, updated_at:"\
  " #{@updated_at}>"
end