Class: Io::Flow::V0::Models::TaxSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxSetting

Returns a new instance of TaxSetting.



15808
15809
15810
15811
15812
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15808

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:discriminator], 'TaxSetting')
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



15806
15807
15808
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15806

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15822

def TaxSetting.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip
  if discriminator.empty?
    raise "Union type[tax_setting] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::AVALARA_TAX_SETTING; AvalaraTaxSetting.new(hash)
    when Types::AVALARA_TAX_CSV_SETTING; AvalaraTaxCsvSetting.new(hash)
    else TaxSettingUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



15814
15815
15816
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15814

def subtype_to_hash
  raise 'Cannot serialize an instance of tax_setting directly - must use one of the specific types: avalara_tax_setting, avalara_tax_csv_setting'
end

#to_hashObject



15818
15819
15820
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15818

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end