Class: NewStoreApi::ExemptionClassItemExtendedDto

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

Overview

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

Returns a new instance of ExemptionClassItemExtendedDto.



62
63
64
65
66
67
68
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 62

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

Instance Attribute Details

#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])


19
20
21
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 19

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:



28
29
30
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 28

def exemption_class
  @exemption_class
end

#provider_codeString

The code that will be sent to the underlying tax provider (Avalara or Vertex) during tax exempted requests if the the relevant exemption_class is selected

Returns:

  • (String)


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

def provider_code
  @provider_code
end

#valid_countriesArray[TaxExemptionCountryCodeEnum]

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

Returns:



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

def valid_countries
  @valid_countries
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  exemption_class =
    hash.key?('exemption_class') ? hash['exemption_class'] : nil
  provider_code = hash.key?('provider_code') ? hash['provider_code'] : 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.
  ExemptionClassItemExtendedDto.new(exemption_class,
                                    provider_code,
                                    valid_countries,
                                    display_text)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 41

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

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    display_text
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



97
98
99
100
101
102
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 97

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

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
94
# File 'lib/new_store_api/models/exemption_class_item_extended_dto.rb', line 90

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