Class: NewStoreApi::TaxExemption

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

Overview

Order-level tax exemption: the exemption category and certificate number.

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(mclass = SKIP, number = SKIP) ⇒ TaxExemption

Returns a new instance of TaxExemption.



45
46
47
48
# File 'lib/new_store_api/models/tax_exemption.rb', line 45

def initialize(mclass = SKIP, number = SKIP)
  @mclass = mclass unless mclass == SKIP
  @number = number unless number == SKIP
end

Instance Attribute Details

#mclassString

The tax exemption category the order qualifies under, for example CHARITY_ORGANIZATION.

Returns:

  • (String)


15
16
17
# File 'lib/new_store_api/models/tax_exemption.rb', line 15

def mclass
  @mclass
end

#numberString

Tax exemption certificate number.

Returns:

  • (String)


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

def number
  @number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/new_store_api/models/tax_exemption.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  mclass = hash.key?('class') ? hash['class'] : SKIP
  number = hash.key?('number') ? hash['number'] : SKIP

  # Create object from extracted values.
  TaxExemption.new(mclass,
                   number)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/new_store_api/models/tax_exemption.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mclass'] = 'class'
  @_hash['number'] = 'number'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
41
42
43
# File 'lib/new_store_api/models/tax_exemption.rb', line 38

def self.nullables
  %w[
    mclass
    number
  ]
end

.optionalsObject

An array for optional fields



30
31
32
33
34
35
# File 'lib/new_store_api/models/tax_exemption.rb', line 30

def self.optionals
  %w[
    mclass
    number
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



70
71
72
73
# File 'lib/new_store_api/models/tax_exemption.rb', line 70

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} mclass: #{@mclass.inspect}, number: #{@number.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



64
65
66
67
# File 'lib/new_store_api/models/tax_exemption.rb', line 64

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} mclass: #{@mclass}, number: #{@number}>"
end