Class: NewStoreApi::TransactionAddressDto

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

Overview

TransactionAddressDto 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(address_line_1 = SKIP, address_line_2 = SKIP, city = SKIP, country_code = SKIP, province = SKIP, state = SKIP, store_id = SKIP, zip_code = SKIP) ⇒ TransactionAddressDto

Returns a new instance of TransactionAddressDto.



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 77

def initialize(address_line_1 = SKIP, address_line_2 = SKIP, city = SKIP,
               country_code = SKIP, province = SKIP, state = SKIP,
               store_id = 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
  @province = province unless province == SKIP
  @state = state unless state == SKIP
  @store_id = store_id unless store_id == SKIP
  @zip_code = zip_code unless zip_code == SKIP
end

Instance Attribute Details

#address_line_1String

Location address line 1.

Returns:

  • (String)


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

def address_line_1
  @address_line_1
end

#address_line_2String

Location address line 2.

Returns:

  • (String)


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

def address_line_2
  @address_line_2
end

#cityString

Location city.

Returns:

  • (String)


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

def city
  @city
end

#country_codeString

Location city.

Returns:

  • (String)


26
27
28
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 26

def country_code
  @country_code
end

#provinceString

Location province.

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 30

def province
  @province
end

#stateString

Location state.

Returns:

  • (String)


34
35
36
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 34

def state
  @state
end

#store_idString

NewStore Store ID of the address.

Returns:

  • (String)


38
39
40
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 38

def store_id
  @store_id
end

#zip_codeString

Location ZIP code.

Returns:

  • (String)


42
43
44
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 42

def zip_code
  @zip_code
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



91
92
93
94
95
96
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/transaction_address_dto.rb', line 91

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
  province = hash.key?('province') ? hash['province'] : SKIP
  state = hash.key?('state') ? hash['state'] : SKIP
  store_id = hash.key?('store_id') ? hash['store_id'] : SKIP
  zip_code = hash.key?('zip_code') ? hash['zip_code'] : SKIP

  # Create object from extracted values.
  TransactionAddressDto.new(address_line_1,
                            address_line_2,
                            city,
                            country_code,
                            province,
                            state,
                            store_id,
                            zip_code)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 45

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['province'] = 'province'
  @_hash['state'] = 'state'
  @_hash['store_id'] = 'store_id'
  @_hash['zip_code'] = 'zip_code'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 59

def self.optionals
  %w[
    address_line_1
    address_line_2
    city
    country_code
    province
    state
    store_id
    zip_code
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



119
120
121
122
123
124
125
# File 'lib/new_store_api/models/transaction_address_dto.rb', line 119

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

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}, province: #{@province.inspect}, state: #{@state.inspect},"\
  " store_id: #{@store_id.inspect}, zip_code: #{@zip_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

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}, province: #{@province}, state: #{@state},"\
  " store_id: #{@store_id}, zip_code: #{@zip_code}>"
end