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
Defined Under Namespace
Modules: Types
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
Returns a new instance of AuthorizationForm.
3901 3902 3903 3904 3905 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3901 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name], 'AuthorizationForm') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) end |
Class Method Details
.from_json(hash) ⇒ Object
3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3915 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) else AuthorizationFormUndefinedType.new(:name => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
3907 3908 3909 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3907 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' end |
#to_hash ⇒ Object
3911 3912 3913 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 3911 def to_hash subtype_to_hash.merge(:discriminator => @name) end |