Class: Io::Flow::V0::Models::ServiceFee
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ServiceFee
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
EmergencySituationSurchargeServiceFee, FuelSurchargeServiceFee, RemoteAreaServiceFee, ServiceFeeUndefinedType
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 = {}) ⇒ ServiceFee
constructor
A new instance of ServiceFee.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ServiceFee
Returns a new instance of ServiceFee.
11834 11835 11836 11837 11838 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11834 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'ServiceFee') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
11832 11833 11834 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11832 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
11848 11849 11850 11851 11852 11853 11854 11855 11856 11857 11858 11859 11860 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11848 def ServiceFee.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[service_fee] requires a field named 'discriminator'" end case discriminator when Types::FUEL_SURCHARGE_SERVICE_FEE; FuelSurchargeServiceFee.new(hash) when Types::REMOTE_AREA_SERVICE_FEE; RemoteAreaServiceFee.new(hash) when Types::EMERGENCY_SITUATION_SURCHARGE_SERVICE_FEE; EmergencySituationSurchargeServiceFee.new(hash) else ServiceFeeUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
11840 11841 11842 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11840 def subtype_to_hash raise 'Cannot serialize an instance of service_fee directly - must use one of the specific types: fuel_surcharge_service_fee, remote_area_service_fee, emergency_situation_surcharge_service_fee' end |
#to_hash ⇒ Object
11844 11845 11846 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11844 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |