Class: Io::Flow::V0::Models::RatecardEstimate
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::RatecardEstimate
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Here for backards compatibility with estimates we store in databases
Direct Known Subclasses
RatecardEstimateUndefinedType, RatecardEstimateV1, RatecardEstimateV2, RatecardEstimateV3, RatecardEstimateV4
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 = {}) ⇒ RatecardEstimate
constructor
A new instance of RatecardEstimate.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ RatecardEstimate
Returns a new instance of RatecardEstimate.
14784 14785 14786 14787 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14784 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'ratecard_estimate_v1', String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
14782 14783 14784 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14782 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14797 def RatecardEstimate.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[ratecard_estimate] requires a field named 'discriminator'" end case discriminator when Types::RATECARD_ESTIMATE_V1; RatecardEstimateV1.new(hash) when Types::RATECARD_ESTIMATE_V2; RatecardEstimateV2.new(hash) when Types::RATECARD_ESTIMATE_V3; RatecardEstimateV3.new(hash) when Types::RATECARD_ESTIMATE_V4; RatecardEstimateV4.new(hash) else RatecardEstimateUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
14789 14790 14791 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14789 def subtype_to_hash raise 'Cannot serialize an instance of ratecard_estimate directly - must use one of the specific types: ratecard_estimate_v1, ratecard_estimate_v2, ratecard_estimate_v3, ratecard_estimate_v4' end |
#to_hash ⇒ Object
14793 14794 14795 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14793 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |