Class: Io::Flow::V0::Models::AuthorizationPayloadParameters

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

Returns a new instance of AuthorizationPayloadParameters.



9723
9724
9725
9726
9727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9723

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



9721
9722
9723
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9721

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9737

def AuthorizationPayloadParameters.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[authorization_payload_parameters] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::GOOGLE_PAY_AUTHORIZATION_PAYLOAD; GooglePayAuthorizationPayload.new(hash)
    when Types::APPLE_PAY_MERCHANT_VALIDATION_PAYLOAD; ApplePayMerchantValidationPayload.new(hash)
    else AuthorizationPayloadParametersUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



9729
9730
9731
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9729

def subtype_to_hash
  raise 'Cannot serialize an instance of authorization_payload_parameters directly - must use one of the specific types: google_pay_authorization_payload, apple_pay_merchant_validation_payload'
end

#to_hashObject



9733
9734
9735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9733

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