Class: NewStoreApi::UpdateAddressRequest

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

Overview

Update address request.

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

Returns a new instance of UpdateAddressRequest.



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

def initialize(last_updated_at = nil, address_line_1 = SKIP,
               address_line_2 = SKIP, city = SKIP, company_name = SKIP,
               contact_phone = SKIP, country_code = SKIP, full_name = SKIP,
               state = SKIP, zip_code = SKIP)
  @last_updated_at = last_updated_at
  @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 unless country_code == SKIP
  @full_name = full_name unless full_name == SKIP
  @state = state unless state == SKIP
  @zip_code = zip_code unless zip_code == SKIP
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/update_address_request.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/update_address_request.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/update_address_request.rb', line 27

def city
  @city
end

#company_nameString

Company name.

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/update_address_request.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/update_address_request.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/update_address_request.rb', line 39

def country_code
  @country_code
end

#full_nameString

Full name.

Returns:

  • (String)


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

def full_name
  @full_name
end

#last_updated_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


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

def last_updated_at
  @last_updated_at
end

#stateString

State/province or region of the address.

Returns:

  • (String)


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

def state
  @state
end

#zip_codeString

Postal code of the address.

Returns:

  • (String)


51
52
53
# File 'lib/new_store_api/models/update_address_request.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.



116
117
118
119
120
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
# File 'lib/new_store_api/models/update_address_request.rb', line 116

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  last_updated_at = if hash.key?('last_updated_at')
                      (DateTimeHelper.from_rfc3339(hash['last_updated_at']) if hash['last_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
  country_code = hash.key?('country_code') ? hash['country_code'] : 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.
  UpdateAddressRequest.new(last_updated_at,
                           address_line_1,
                           address_line_2,
                           city,
                           company_name,
                           contact_phone,
                           country_code,
                           full_name,
                           state,
                           zip_code)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/models/update_address_request.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['last_updated_at'] = 'last_updated_at'
  @_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
end

.nullablesObject

An array for nullable fields



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/new_store_api/models/update_address_request.rb', line 85

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

.optionalsObject

An array for optional fields



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/models/update_address_request.rb', line 70

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



162
163
164
165
166
167
168
169
# File 'lib/new_store_api/models/update_address_request.rb', line 162

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} last_updated_at: #{@last_updated_at.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}>"
end

#to_custom_last_updated_atObject



148
149
150
# File 'lib/new_store_api/models/update_address_request.rb', line 148

def to_custom_last_updated_at
  DateTimeHelper.to_rfc3339(last_updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



153
154
155
156
157
158
159
# File 'lib/new_store_api/models/update_address_request.rb', line 153

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} last_updated_at: #{@last_updated_at}, 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}>"
end