Class: ConnectWise::TaxCodeLevel

Inherits:
Object
  • Object
show all
Defined in:
lib/connect_wise/models/tax_code_level.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ TaxCodeLevel

Initializes the object

Raises:

  • (ArgumentError)


112
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
# File 'lib/connect_wise/models/tax_code_level.rb', line 112

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::TaxCodeLevel` initialize method' unless attributes.is_a?(Hash)

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    raise ArgumentError, "`#{k}` is not a valid attribute in `ConnectWise::TaxCodeLevel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym)

    h[k.to_sym] = v
  end

  self.tax_rate = attributes[:tax_rate] if attributes.key?(:tax_rate)

  self.rate_type = attributes[:rate_type] if attributes.key?(:rate_type)

  self.id = attributes[:id] if attributes.key?(:id)

  self.tax_level = attributes[:tax_level] if attributes.key?(:tax_level)

  self.taxable_max = attributes[:taxable_max] if attributes.key?(:taxable_max)

  self.caption = attributes[:caption] if attributes.key?(:caption)

  self.tax_code_xref = attributes[:tax_code_xref] if attributes.key?(:tax_code_xref)

  self.agency_xref = attributes[:agency_xref] if attributes.key?(:agency_xref)

  self.tax_services_flag = attributes[:tax_services_flag] if attributes.key?(:tax_services_flag)

  self.tax_expenses_flag = attributes[:tax_expenses_flag] if attributes.key?(:tax_expenses_flag)

  self.tax_products_flag = attributes[:tax_products_flag] if attributes.key?(:tax_products_flag)

  self.single_unit_flag = attributes[:single_unit_flag] if attributes.key?(:single_unit_flag)

  self.single_unit_minimum = attributes[:single_unit_minimum] if attributes.key?(:single_unit_minimum)

  self.single_unit_maximum = attributes[:single_unit_maximum] if attributes.key?(:single_unit_maximum)

  return unless attributes.key?(:_info)
  return unless (value = attributes[:_info]).is_a?(Hash)

  self._info = value
end

Instance Attribute Details

#_infoObject

Returns the value of attribute _info.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def _info
  @_info
end

#agency_xrefObject

Max length: 100;



25
26
27
# File 'lib/connect_wise/models/tax_code_level.rb', line 25

def agency_xref
  @agency_xref
end

#captionObject

Max length: 25;



19
20
21
# File 'lib/connect_wise/models/tax_code_level.rb', line 19

def caption
  @caption
end

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def id
  @id
end

#rate_typeObject

Returns the value of attribute rate_type.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def rate_type
  @rate_type
end

#single_unit_flagObject

Returns the value of attribute single_unit_flag.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def single_unit_flag
  @single_unit_flag
end

#single_unit_maximumObject

Returns the value of attribute single_unit_maximum.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def single_unit_maximum
  @single_unit_maximum
end

#single_unit_minimumObject

Returns the value of attribute single_unit_minimum.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def single_unit_minimum
  @single_unit_minimum
end

#tax_code_xrefObject

Max length: 50;



22
23
24
# File 'lib/connect_wise/models/tax_code_level.rb', line 22

def tax_code_xref
  @tax_code_xref
end

#tax_expenses_flagObject

Returns the value of attribute tax_expenses_flag.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def tax_expenses_flag
  @tax_expenses_flag
end

#tax_levelObject

Returns the value of attribute tax_level.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def tax_level
  @tax_level
end

#tax_products_flagObject

Returns the value of attribute tax_products_flag.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def tax_products_flag
  @tax_products_flag
end

#tax_rateObject

Returns the value of attribute tax_rate.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def tax_rate
  @tax_rate
end

#tax_services_flagObject

Returns the value of attribute tax_services_flag.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def tax_services_flag
  @tax_services_flag
end

#taxable_maxObject

Returns the value of attribute taxable_max.



16
17
18
# File 'lib/connect_wise/models/tax_code_level.rb', line 16

def taxable_max
  @taxable_max
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



70
71
72
# File 'lib/connect_wise/models/tax_code_level.rb', line 70

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/connect_wise/models/tax_code_level.rb', line 49

def self.attribute_map
  {
    tax_rate: :taxRate,
    rate_type: :rateType,
    id: :id,
    tax_level: :taxLevel,
    taxable_max: :taxableMax,
    caption: :caption,
    tax_code_xref: :taxCodeXref,
    agency_xref: :agencyXref,
    tax_services_flag: :taxServicesFlag,
    tax_expenses_flag: :taxExpensesFlag,
    tax_products_flag: :taxProductsFlag,
    single_unit_flag: :singleUnitFlag,
    single_unit_minimum: :singleUnitMinimum,
    single_unit_maximum: :singleUnitMaximum,
    _info: :_info
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



218
219
220
# File 'lib/connect_wise/models/tax_code_level.rb', line 218

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/connect_wise/models/tax_code_level.rb', line 96

def self.openapi_nullable
  Set.new(i[
            tax_rate
            rate_type
            taxable_max
            tax_services_flag
            tax_expenses_flag
            tax_products_flag
            single_unit_flag
            single_unit_minimum
            single_unit_maximum
          ])
end

.openapi_typesObject

Attribute type mapping.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/connect_wise/models/tax_code_level.rb', line 75

def self.openapi_types
  {
    tax_rate: :Float,
    rate_type: :String,
    id: :Integer,
    tax_level: :Integer,
    taxable_max: :Float,
    caption: :String,
    tax_code_xref: :String,
    agency_xref: :String,
    tax_services_flag: :Boolean,
    tax_expenses_flag: :Boolean,
    tax_products_flag: :Boolean,
    single_unit_flag: :Boolean,
    single_unit_minimum: :Float,
    single_unit_maximum: :Float,
    _info: :'Hash<String, String>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/connect_wise/models/tax_code_level.rb', line 182

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    tax_rate == other.tax_rate &&
    rate_type == other.rate_type &&
    id == other.id &&
    tax_level == other.tax_level &&
    taxable_max == other.taxable_max &&
    caption == other.caption &&
    tax_code_xref == other.tax_code_xref &&
    agency_xref == other.agency_xref &&
    tax_services_flag == other.tax_services_flag &&
    tax_expenses_flag == other.tax_expenses_flag &&
    tax_products_flag == other.tax_products_flag &&
    single_unit_flag == other.single_unit_flag &&
    single_unit_minimum == other.single_unit_minimum &&
    single_unit_maximum == other.single_unit_maximum &&
    _info == other._info
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/connect_wise/models/tax_code_level.rb', line 248

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = ConnectWise.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value



319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/connect_wise/models/tax_code_level.rb', line 319

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/connect_wise/models/tax_code_level.rb', line 225

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }) if attributes[self.class.attribute_map[key]].is_a?(Array)
    elsif !attributes[self.class.attribute_map[key]].nil?
      send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(other) ⇒ Boolean

See Also:

  • `==` method


205
206
207
# File 'lib/connect_wise/models/tax_code_level.rb', line 205

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.



211
212
213
# File 'lib/connect_wise/models/tax_code_level.rb', line 211

def hash
  [tax_rate, rate_type, id, tax_level, taxable_max, caption, tax_code_xref, agency_xref, tax_services_flag, tax_expenses_flag, tax_products_flag, single_unit_flag, single_unit_minimum, single_unit_maximum, _info].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?



158
159
160
# File 'lib/connect_wise/models/tax_code_level.rb', line 158

def list_invalid_properties
  []
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



295
296
297
# File 'lib/connect_wise/models/tax_code_level.rb', line 295

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/connect_wise/models/tax_code_level.rb', line 301

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object



289
290
291
# File 'lib/connect_wise/models/tax_code_level.rb', line 289

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid



164
165
166
167
168
169
# File 'lib/connect_wise/models/tax_code_level.rb', line 164

def valid?
  rate_type_validator = EnumAttributeValidator.new('String', %w[Amount Percent])
  return false unless rate_type_validator.valid?(@rate_type)

  true
end