Class: Io::Flow::V0::Models::ExpandableCard
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ExpandableCard
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
Card, CardReference, CardSummary, ExpandableCardUndefinedType
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 = {}) ⇒ ExpandableCard
constructor
A new instance of ExpandableCard.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ExpandableCard
Returns a new instance of ExpandableCard.
11439 11440 11441 11442 11443 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11439 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'ExpandableCard') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
11437 11438 11439 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11437 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11453 def ExpandableCard.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[expandable_card] requires a field named 'discriminator'" end case discriminator when Types::CARD; Card.new(hash) when Types::CARD_REFERENCE; CardReference.new(hash) when Types::CARD_SUMMARY; CardSummary.new(hash) else ExpandableCardUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
11445 11446 11447 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11445 def subtype_to_hash raise 'Cannot serialize an instance of expandable_card directly - must use one of the specific types: card, card_reference, card_summary' end |
#to_hash ⇒ Object
11449 11450 11451 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11449 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |