Class: Io::Flow::V0::Models::Settlement
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Settlement
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
SettlementNoPayout, SettlementPayout, SettlementUndefinedType
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 = {}) ⇒ Settlement
constructor
A new instance of Settlement.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Settlement
Returns a new instance of Settlement.
15434 15435 15436 15437 15438 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15434 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'Settlement') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
15432 15433 15434 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15432 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15448 def Settlement.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[settlement] requires a field named 'discriminator'" end case discriminator when Types::SETTLEMENT_NO_PAYOUT; SettlementNoPayout.new(hash) when Types::SETTLEMENT_PAYOUT; SettlementPayout.new(hash) else SettlementUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
15440 15441 15442 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15440 def subtype_to_hash raise 'Cannot serialize an instance of settlement directly - must use one of the specific types: settlement_no_payout, settlement_payout' end |
#to_hash ⇒ Object
15444 15445 15446 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15444 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |