Class: Io::Flow::V0::Models::ConfirmationDetails

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

Returns a new instance of ConfirmationDetails.



10294
10295
10296
10297
10298
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10294

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



10292
10293
10294
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10292

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10308

def ConfirmationDetails.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[confirmation_details] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::DIRECT_DEBIT; DirectDebit.new(hash)
    when Types::CARD_CONFIRMATION_SUMMARY; CardConfirmationSummary.new(hash)
    else ConfirmationDetailsUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



10300
10301
10302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10300

def subtype_to_hash
  raise 'Cannot serialize an instance of confirmation_details directly - must use one of the specific types: direct_debit, card_confirmation_summary'
end

#to_hashObject



10304
10305
10306
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10304

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