Class: NewStoreApi::VertexAdministrativeOriginDto

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

Overview

VertexAdministrativeOriginDto 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, currency_code = nil, currency_value = nil, main_division = nil, postal_code = nil, street_address_1 = nil, street_address_2 = nil) ⇒ VertexAdministrativeOriginDto

Returns a new instance of VertexAdministrativeOriginDto.



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

def initialize(city = nil, country = nil, currency_code = nil,
               currency_value = nil, main_division = nil, postal_code = nil,
               street_address_1 = nil, street_address_2 = nil)
  @city = city
  @country = country
  @currency_code = currency_code
  @currency_value = currency_value
  @main_division = main_division
  @postal_code = postal_code
  @street_address_1 = street_address_1
  @street_address_2 = street_address_2
end

Instance Attribute Details

#cityString

The proper name of the city used to determine the Tax Area ID.

Returns:

  • (String)


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

def city
  @city
end

#countryString

The proper name of the city used to determine the Tax Area ID.

Returns:

  • (String)


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

def country
  @country
end

#currency_codeCurrency3Enum

The proper name of the city used to determine the Tax Area ID.

Returns:



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

def currency_code
  @currency_code
end

#currency_valueFloat

The rate (multiplier) used for converting the transaction currency amount to the filing currency amount.

Returns:

  • (Float)


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

def currency_value
  @currency_value
end

#main_divisionString

The proper name or the postal abbreviation of the state, province, or territory used to determine the Tax Area ID.

Returns:

  • (String)


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

def main_division
  @main_division
end

#postal_codeString

The postal code used to determine the Tax Area ID

Returns:

  • (String)


36
37
38
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 36

def postal_code
  @postal_code
end

#street_address_1String

The first line of the street address.

Returns:

  • (String)


40
41
42
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 40

def street_address_1
  @street_address_1
end

#street_address_2String

The second line of the street address.

Returns:

  • (String)


44
45
46
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 44

def street_address_2
  @street_address_2
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 84

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
  currency_code = hash.key?('currency_code') ? hash['currency_code'] : nil
  currency_value =
    hash.key?('currency_value') ? hash['currency_value'] : nil
  main_division = hash.key?('main_division') ? hash['main_division'] : nil
  postal_code = hash.key?('postal_code') ? hash['postal_code'] : nil
  street_address_1 =
    hash.key?('street_address_1') ? hash['street_address_1'] : nil
  street_address_2 =
    hash.key?('street_address_2') ? hash['street_address_2'] : nil

  # Create object from extracted values.
  VertexAdministrativeOriginDto.new(city,
                                    country,
                                    currency_code,
                                    currency_value,
                                    main_division,
                                    postal_code,
                                    street_address_1,
                                    street_address_2)
end

.namesObject

A mapping from model property names to API property names.



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 47

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['city'] = 'city'
  @_hash['country'] = 'country'
  @_hash['currency_code'] = 'currency_code'
  @_hash['currency_value'] = 'currency_value'
  @_hash['main_division'] = 'main_division'
  @_hash['postal_code'] = 'postal_code'
  @_hash['street_address_1'] = 'street_address_1'
  @_hash['street_address_2'] = 'street_address_2'
  @_hash
end

.nullablesObject

An array for nullable fields



66
67
68
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 66

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



113
114
115
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
147
148
149
150
151
152
153
154
155
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 113

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.currency_code,
                              ->(val) { Currency3Enum.validate(val) }) and
        APIHelper.valid_type?(value.currency_value,
                              ->(val) { val.instance_of? Float }) and
        APIHelper.valid_type?(value.main_division,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.postal_code,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.street_address_1,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.street_address_2,
                              ->(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['currency_code'],
                            ->(val) { Currency3Enum.validate(val) }) and
      APIHelper.valid_type?(value['currency_value'],
                            ->(val) { val.instance_of? Float }) and
      APIHelper.valid_type?(value['main_division'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['postal_code'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['street_address_1'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['street_address_2'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



167
168
169
170
171
172
173
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 167

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city.inspect}, country: #{@country.inspect}, currency_code:"\
  " #{@currency_code.inspect}, currency_value: #{@currency_value.inspect}, main_division:"\
  " #{@main_division.inspect}, postal_code: #{@postal_code.inspect}, street_address_1:"\
  " #{@street_address_1.inspect}, street_address_2: #{@street_address_2.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



158
159
160
161
162
163
164
# File 'lib/new_store_api/models/vertex_administrative_origin_dto.rb', line 158

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} city: #{@city}, country: #{@country}, currency_code: #{@currency_code},"\
  " currency_value: #{@currency_value}, main_division: #{@main_division}, postal_code:"\
  " #{@postal_code}, street_address_1: #{@street_address_1}, street_address_2:"\
  " #{@street_address_2}>"
end