Class: Io::Flow::V0::Models::AuthorizationForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Flow provides several different options for creating an authorization

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AuthorizationForm

Returns a new instance of AuthorizationForm.



8068
8069
8070
8071
8072
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8068

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



8066
8067
8068
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8066

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8082

def AuthorizationForm.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_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::AUTHORIZATION_COPY_FORM; AuthorizationCopyForm.new(hash)
    when Types::DIRECT_AUTHORIZATION_FORM; DirectAuthorizationForm.new(hash)
    when Types::MERCHANT_OF_RECORD_AUTHORIZATION_FORM; MerchantOfRecordAuthorizationForm.new(hash)
    when Types::PAYPAL_AUTHORIZATION_FORM; PaypalAuthorizationForm.new(hash)
    when Types::REDIRECT_AUTHORIZATION_FORM; RedirectAuthorizationForm.new(hash)
    when Types::INLINE_AUTHORIZATION_FORM; InlineAuthorizationForm.new(hash)
    when Types::ACH_AUTHORIZATION_FORM; AchAuthorizationForm.new(hash)
    when Types::CARD_PAYMENT_SOURCE_AUTHORIZATION_FORM; CardPaymentSourceAuthorizationForm.new(hash)
    when Types::ONLINE_PAYMENT_AUTHORIZATION_FORM; OnlinePaymentAuthorizationForm.new(hash)
    else AuthorizationFormUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



8074
8075
8076
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8074

def subtype_to_hash
  raise 'Cannot serialize an instance of authorization_form directly - must use one of the specific types: authorization_copy_form, direct_authorization_form, merchant_of_record_authorization_form, paypal_authorization_form, redirect_authorization_form, inline_authorization_form, ach_authorization_form, card_payment_source_authorization_form, online_payment_authorization_form'
end

#to_hashObject



8078
8079
8080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8078

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