Class: Io::Flow::V0::Models::Settlement

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 = {}) ⇒ Settlement

Returns a new instance of Settlement.



15434
15435
15436
15437
15438
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15434

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



15432
15433
15434
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15432

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15448

def Settlement.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[settlement] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::SETTLEMENT_NO_PAYOUT; SettlementNoPayout.new(hash)
    when Types::SETTLEMENT_PAYOUT; SettlementPayout.new(hash)
    else SettlementUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



15440
15441
15442
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15440

def subtype_to_hash
  raise 'Cannot serialize an instance of settlement directly - must use one of the specific types: settlement_no_payout, settlement_payout'
end

#to_hashObject



15444
15445
15446
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15444

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