Class: Io::Flow::V0::Models::OversizedShipmentRatecardFee

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

Instance Attribute Summary collapse

Attributes inherited from RatecardFee

#discriminator

Instance Method Summary collapse

Methods inherited from RatecardFee

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ OversizedShipmentRatecardFee



40336
40337
40338
40339
40340
40341
40342
40343
40344
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40336

def initialize(incoming={})
  super(:discriminator => RatecardFee::Types::OVERSIZED_SHIPMENT_RATECARD_FEE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:weight_threshold, :weight_unit], 'OversizedShipmentRatecardFee')
  @weight_threshold = HttpClient::Preconditions.assert_class('weight_threshold', HttpClient::Helper.to_big_decimal(opts.delete(:weight_threshold)), BigDecimal)
  @weight_unit = (x = opts.delete(:weight_unit); x.is_a?(::Io::Flow::V0::Models::UnitOfMeasurement) ? x : ::Io::Flow::V0::Models::UnitOfMeasurement.apply(x))
  @margin = (x = opts.delete(:margin); x.nil? ? nil : HttpClient::Preconditions.assert_class('margin', x, Numeric))
  @amount = (x = opts.delete(:amount); x.nil? ? nil : HttpClient::Preconditions.assert_class('amount', x, Numeric))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



40334
40335
40336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40334

def amount
  @amount
end

#marginObject (readonly)

Returns the value of attribute margin.



40334
40335
40336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40334

def margin
  @margin
end

#weight_thresholdObject (readonly)

Returns the value of attribute weight_threshold.



40334
40335
40336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40334

def weight_threshold
  @weight_threshold
end

#weight_unitObject (readonly)

Returns the value of attribute weight_unit.



40334
40335
40336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40334

def weight_unit
  @weight_unit
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40350
40351
40352
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40350

def copy(incoming={})
  OversizedShipmentRatecardFee.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



40354
40355
40356
40357
40358
40359
40360
40361
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40354

def subtype_to_hash
  {
    :weight_threshold => weight_threshold.to_f.to_s,
    :weight_unit => weight_unit.value,
    :margin => margin,
    :amount => amount
  }
end

#to_jsonObject



40346
40347
40348
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40346

def to_json
  JSON.dump(to_hash)
end