Class: Io::Flow::V0::Models::RatecardFee
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::RatecardFee
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
CrossdockRatecardFee, DdpRatecardFee, FuelSurchargeRatecardFee, OversizedShipmentRatecardFee, RatecardFeeUndefinedType, RemoteAreaRatecardFee, ReturnPackageRatecardFee
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 = {}) ⇒ RatecardFee
constructor
A new instance of RatecardFee.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ RatecardFee
Returns a new instance of RatecardFee.
10379 10380 10381 10382 10383 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10379 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'RatecardFee') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
10377 10378 10379 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10377 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10393 def RatecardFee.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_fee] requires a field named 'discriminator'" end case discriminator when Types::DDP_RATECARD_FEE; DdpRatecardFee.new(hash) when Types::FUEL_SURCHARGE_RATECARD_FEE; FuelSurchargeRatecardFee.new(hash) when Types::OVERSIZED_SHIPMENT_RATECARD_FEE; OversizedShipmentRatecardFee.new(hash) when Types::RETURN_PACKAGE_RATECARD_FEE; ReturnPackageRatecardFee.new(hash) when Types::CROSSDOCK_RATECARD_FEE; CrossdockRatecardFee.new(hash) when Types::REMOTE_AREA_RATECARD_FEE; RemoteAreaRatecardFee.new(hash) else RatecardFeeUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
10385 10386 10387 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10385 def subtype_to_hash raise 'Cannot serialize an instance of ratecard_fee directly - must use one of the specific types: ddp_ratecard_fee, fuel_surcharge_ratecard_fee, oversized_shipment_ratecard_fee, return_package_ratecard_fee, crossdock_ratecard_fee, remote_area_ratecard_fee' end |
#to_hash ⇒ Object
10389 10390 10391 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10389 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |