Class: Io::Flow::V0::Models::AuthorizationForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::AuthorizationForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Flow provides several different options for creating an authorization
Direct Known Subclasses
AuthorizationFormUndefinedType, DirectAuthorizationForm, MerchantOfRecordAuthorizationForm, PaypalAuthorizationForm
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ AuthorizationForm
constructor
A new instance of AuthorizationForm.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ AuthorizationForm
4830 4831 4832 4833 4834 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4830 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
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
4828 4829 4830 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4828 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4844 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::DIRECT_AUTHORIZATION_FORM; DirectAuthorizationForm.new(hash) when Types::MERCHANT_OF_RECORD_AUTHORIZATION_FORM; MerchantOfRecordAuthorizationForm.new(hash) when Types::PAYPAL_AUTHORIZATION_FORM; PaypalAuthorizationForm.new(hash) else AuthorizationFormUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
4836 4837 4838 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4836 def subtype_to_hash raise 'Cannot serialize an instance of authorization_form directly - must use one of the specific types: direct_authorization_form, merchant_of_record_authorization_form, paypal_authorization_form' end |
#to_hash ⇒ Object
4840 4841 4842 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4840 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |