Class: Io::Flow::V0::Models::RatecardFee

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RatecardFee

Returns a new instance of RatecardFee.



14854
14855
14856
14857
14858
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14854

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

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



14852
14853
14854
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14852

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14868

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)
    when Types::EMERGENCY_SITUATION_SURCHARGE_RATECARD_FEE; EmergencySituationSurchargeRatecardFee.new(hash)
    when Types::PEAK_SURCHARGE_RATECARD_FEE; PeakSurchargeRatecardFee.new(hash)
    when Types::DUTIES_TAXES_PAID_SURCHARGE_RATECARD_FEE; DutiesTaxesPaidSurchargeRatecardFee.new(hash)
    else RatecardFeeUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



14860
14861
14862
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14860

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, emergency_situation_surcharge_ratecard_fee, peak_surcharge_ratecard_fee, duties_taxes_paid_surcharge_ratecard_fee'
end

#to_hashObject



14864
14865
14866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14864

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end