Class: Io::Flow::V0::Models::TokenForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::TokenForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
OrganizationTokenForm, PartnerTokenForm, TokenFormUndefinedType
Defined Under Namespace
Modules: Types
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ TokenForm
constructor
A new instance of TokenForm.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ TokenForm
Returns a new instance of TokenForm.
4864 4865 4866 4867 4868 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4864 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name], 'TokenForm') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) end |
Class Method Details
.from_json(hash) ⇒ Object
4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4878 def TokenForm.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[token_form] requires a field named 'discriminator'" end case discriminator when Types::ORGANIZATION_TOKEN_FORM; OrganizationTokenForm.new(hash) when Types::PARTNER_TOKEN_FORM; PartnerTokenForm.new(hash) else TokenFormUndefinedType.new(:name => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
4870 4871 4872 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4870 def subtype_to_hash raise 'Cannot serialize an instance of token_form directly - must use one of the specific types: organization_token_form, partner_token_form' end |
#to_hash ⇒ Object
4874 4875 4876 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4874 def to_hash subtype_to_hash.merge(:discriminator => @name) end |