Class: NewStoreApi::AddressDataNoV1Dto

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

Overview

AddressDataNoV1Dto 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(city = nil, country = nil, street_name = nil, additional_address_details = SKIP, postal_code = SKIP, region = SKIP) ⇒ AddressDataNoV1Dto

Returns a new instance of AddressDataNoV1Dto.



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

def initialize(city = nil, country = nil, street_name = nil,
               additional_address_details = SKIP, postal_code = SKIP,
               region = SKIP)
  unless additional_address_details == SKIP
    @additional_address_details =
      additional_address_details
  end
  @city = city
  @country = country
  @postal_code = postal_code unless postal_code == SKIP
  @region = region unless region == SKIP
  @street_name = street_name
end

Instance Attribute Details

#additional_address_detailsString

Additional address details.

Returns:

  • (String)


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

def additional_address_details
  @additional_address_details
end

#cityString

City.

Returns:

  • (String)


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

def city
  @city
end

#countryString

City.

Returns:

  • (String)


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

def country
  @country
end

#postal_codeString

Postal code for the relevant city/post district.

Returns:

  • (String)


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

def postal_code
  @postal_code
end

#regionString

Country specific value for indicating the region/province within the tax authority.

Returns:

  • (String)


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

def region
  @region
end

#street_nameString

Street name.

Returns:

  • (String)


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

def street_name
  @street_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  city = hash.key?('city') ? hash['city'] : nil
  country = hash.key?('country') ? hash['country'] : nil
  street_name = hash.key?('street_name') ? hash['street_name'] : nil
  additional_address_details =
    hash.key?('additional_address_details') ? hash['additional_address_details'] : SKIP
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : SKIP
  region = hash.key?('region') ? hash['region'] : SKIP

  # Create object from extracted values.
  AddressDataNoV1Dto.new(city,
                         country,
                         street_name,
                         additional_address_details,
                         postal_code,
                         region)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/new_store_api/models/address_data_no_v1_dto.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['additional_address_details'] = 'additional_address_details'
  @_hash['city'] = 'city'
  @_hash['country'] = 'country'
  @_hash['postal_code'] = 'postal_code'
  @_hash['region'] = 'region'
  @_hash['street_name'] = 'street_name'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
# File 'lib/new_store_api/models/address_data_no_v1_dto.rb', line 50

def self.optionals
  %w[
    additional_address_details
    postal_code
    region
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.city,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.country,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.street_name,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['city'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['country'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['street_name'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



134
135
136
137
138
139
# File 'lib/new_store_api/models/address_data_no_v1_dto.rb', line 134

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_address_details: #{@additional_address_details.inspect}, city:"\
  " #{@city.inspect}, country: #{@country.inspect}, postal_code: #{@postal_code.inspect},"\
  " region: #{@region.inspect}, street_name: #{@street_name.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



126
127
128
129
130
131
# File 'lib/new_store_api/models/address_data_no_v1_dto.rb', line 126

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_address_details: #{@additional_address_details}, city: #{@city},"\
  " country: #{@country}, postal_code: #{@postal_code}, region: #{@region}, street_name:"\
  " #{@street_name}>"
end