Class: Io::Flow::V0::Models::FuelSurchargeAmountByWeightServiceFee

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

Instance Attribute Summary collapse

Attributes inherited from ServiceFee

#discriminator

Instance Method Summary collapse

Methods inherited from ServiceFee

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FuelSurchargeAmountByWeightServiceFee

Returns a new instance of FuelSurchargeAmountByWeightServiceFee.



40651
40652
40653
40654
40655
40656
40657
40658
40659
40660
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40651

def initialize(incoming={})
  super(:discriminator => ServiceFee::Types::FUEL_SURCHARGE_AMOUNT_BY_WEIGHT_SERVICE_FEE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount, :weight], 'FuelSurchargeAmountByWeightServiceFee')
  @amount = (x = opts.delete(:amount); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))
  @weight = (x = opts.delete(:weight); x.is_a?(::Io::Flow::V0::Models::FeeWeight) ? x : ::Io::Flow::V0::Models::FeeWeight.new(x))
  @regions = (x = opts.delete(:regions); x.nil? ? nil : HttpClient::Preconditions.assert_class('regions', x, Array).map { |v| HttpClient::Preconditions.assert_class('regions', v, String) })
  @starts_at = (x = opts.delete(:starts_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('starts_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @ends_at = (x = opts.delete(:ends_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('ends_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



40649
40650
40651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40649

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



40649
40650
40651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40649

def ends_at
  @ends_at
end

#regionsObject (readonly)

Returns the value of attribute regions.



40649
40650
40651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40649

def regions
  @regions
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



40649
40650
40651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40649

def starts_at
  @starts_at
end

#weightObject (readonly)

Returns the value of attribute weight.



40649
40650
40651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40649

def weight
  @weight
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40666
40667
40668
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40666

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

#subtype_to_hashObject



40670
40671
40672
40673
40674
40675
40676
40677
40678
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40670

def subtype_to_hash
  {
    :amount => amount.to_hash,
    :weight => weight.to_hash,
    :regions => regions.nil? ? nil : regions,
    :starts_at => starts_at,
    :ends_at => ends_at
  }
end

#to_jsonObject



40662
40663
40664
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40662

def to_json
  JSON.dump(to_hash)
end