Class: Io::Flow::V0::Models::TokenReference
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::TokenReference
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
OrganizationTokenReference, PartnerTokenReference, TokenReferenceUndefinedType
Defined Under Namespace
Modules: Types
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ TokenReference
constructor
A new instance of TokenReference.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ TokenReference
Returns a new instance of TokenReference.
4924 4925 4926 4927 4928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4924 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name], 'TokenReference') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) end |
Class Method Details
.from_json(hash) ⇒ Object
4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4938 def TokenReference.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_reference] requires a field named 'discriminator'" end case discriminator when Types::ORGANIZATION_TOKEN_REFERENCE; OrganizationTokenReference.new(hash) when Types::PARTNER_TOKEN_REFERENCE; PartnerTokenReference.new(hash) else TokenReferenceUndefinedType.new(:name => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
4930 4931 4932 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4930 def subtype_to_hash raise 'Cannot serialize an instance of token_reference directly - must use one of the specific types: organization_token_reference, partner_token_reference' end |
#to_hash ⇒ Object
4934 4935 4936 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4934 def to_hash subtype_to_hash.merge(:discriminator => @name) end |