Class: Io::Flow::V0::Models::FraudOrderReference

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

Returns a new instance of FraudOrderReference.



12167
12168
12169
12170
12171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12167

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



12165
12166
12167
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12165

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12181

def FraudOrderReference.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[fraud_order_reference] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::FRAUD_FLOW_ORDER_REFERENCE; FraudFlowOrderReference.new(hash)
    when Types::FRAUD_PAYMENT_REQUEST_REFERENCE; FraudPaymentRequestReference.new(hash)
    else FraudOrderReferenceUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



12173
12174
12175
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12173

def subtype_to_hash
  raise 'Cannot serialize an instance of fraud_order_reference directly - must use one of the specific types: fraud_flow_order_reference, fraud_payment_request_reference'
end

#to_hashObject



12177
12178
12179
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12177

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