Class: Io::Flow::V0::Models::OnlineAuthorizationDetails

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

Returns a new instance of OnlineAuthorizationDetails.



12993
12994
12995
12996
12997
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12993

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



12991
12992
12993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12991

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13007

def OnlineAuthorizationDetails.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[online_authorization_details] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::CRYPTOPAY_AUTHORIZATION_DETAILS; CryptopayAuthorizationDetails.new(hash)
    when Types::PAYPAL_AUTHORIZATION_DETAILS; PaypalAuthorizationDetails.new(hash)
    when Types::REDIRECT_AUTHORIZATION_DETAILS; RedirectAuthorizationDetails.new(hash)
    when Types::INLINE_AUTHORIZATION_DETAILS; InlineAuthorizationDetails.new(hash)
    else OnlineAuthorizationDetailsUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



12999
13000
13001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12999

def subtype_to_hash
  raise 'Cannot serialize an instance of online_authorization_details directly - must use one of the specific types: cryptopay_authorization_details, paypal_authorization_details, redirect_authorization_details, inline_authorization_details'
end

#to_hashObject



13003
13004
13005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13003

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