Class: NewStoreApi::AvalaraExemptionClassItemDto

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

Overview

AvalaraExemptionClassItemDto 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(avalara_entity_use_code = nil, exemption_class = nil, valid_countries = nil, display_text = SKIP) ⇒ AvalaraExemptionClassItemDto

Returns a new instance of AvalaraExemptionClassItemDto.



67
68
69
70
71
72
73
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 67

def initialize(avalara_entity_use_code = nil, exemption_class = nil,
               valid_countries = nil, display_text = SKIP)
  @avalara_entity_use_code = avalara_entity_use_code
  @display_text = display_text unless display_text == SKIP
  @exemption_class = exemption_class
  @valid_countries = valid_countries
end

Instance Attribute Details

#avalara_entity_use_codeString

Avalara entity use code.

  • For pre-defined tax exemption classes, value must correspond to the Avalara entity use code. For the possible options, please refer to the [List of entity use codes](https://knowledge.avalara.com/bundle/hff1682048150115_hff1682048150 115/page/List_of_entity_use_codes.html).
  • For custom tax exemption classes, value must correspond to the custom entity use code defined under the exempt entity custom tax rule.

Returns:

  • (String)


21
22
23
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 21

def avalara_entity_use_code
  @avalara_entity_use_code
end

#display_textHash[String, Object]

Display text to be used in Associate App while rendering the exemption class.

  • Required for custom tax exemption classes.
  • Optional for pre-defined tax exemption classes.
  • Keys must be a valid ISO 639-1 language code.
  • Must include English translation by default.

Returns:

  • (Hash[String, Object])


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

def display_text
  @display_text
end

#exemption_classExemptionClassEnum

Display text to be used in Associate App while rendering the exemption class.

  • Required for custom tax exemption classes.
  • Optional for pre-defined tax exemption classes.
  • Keys must be a valid ISO 639-1 language code.
  • Must include English translation by default.

Returns:



39
40
41
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 39

def exemption_class
  @exemption_class
end

#valid_countriesArray[TaxExemptionCountryCodeEnum]

The list of countries where this tax exemption class is valid.

Returns:



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

def valid_countries
  @valid_countries
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  avalara_entity_use_code =
    hash.key?('avalara_entity_use_code') ? hash['avalara_entity_use_code'] : nil
  exemption_class =
    hash.key?('exemption_class') ? hash['exemption_class'] : nil
  valid_countries =
    hash.key?('valid_countries') ? hash['valid_countries'] : nil
  display_text = hash.key?('display_text') ? hash['display_text'] : SKIP

  # Create object from extracted values.
  AvalaraExemptionClassItemDto.new(avalara_entity_use_code,
                                   exemption_class,
                                   valid_countries,
                                   display_text)
end

.namesObject

A mapping from model property names to API property names.



46
47
48
49
50
51
52
53
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 46

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['avalara_entity_use_code'] = 'avalara_entity_use_code'
  @_hash['display_text'] = 'display_text'
  @_hash['exemption_class'] = 'exemption_class'
  @_hash['valid_countries'] = 'valid_countries'
  @_hash
end

.nullablesObject

An array for nullable fields



63
64
65
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 63

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 56

def self.optionals
  %w[
    display_text
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 97

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.avalara_entity_use_code,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.exemption_class,
                              ->(val) { ExemptionClassEnum.validate(val) }) and
        APIHelper.valid_type?(value.valid_countries,
                              ->(val) { TaxExemptionCountryCodeEnum.validate(val) })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['avalara_entity_use_code'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['exemption_class'],
                            ->(val) { ExemptionClassEnum.validate(val) }) and
      APIHelper.valid_type?(value['valid_countries'],
                            ->(val) { TaxExemptionCountryCodeEnum.validate(val) })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



130
131
132
133
134
135
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 130

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} avalara_entity_use_code: #{@avalara_entity_use_code.inspect}, display_text:"\
  " #{@display_text.inspect}, exemption_class: #{@exemption_class.inspect}, valid_countries:"\
  " #{@valid_countries.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
127
# File 'lib/new_store_api/models/avalara_exemption_class_item_dto.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} avalara_entity_use_code: #{@avalara_entity_use_code}, display_text:"\
  " #{@display_text}, exemption_class: #{@exemption_class}, valid_countries:"\
  " #{@valid_countries}>"
end