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.



43870
43871
43872
43873
43874
43875
43876
43877
43878
43879
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43870

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.



43868
43869
43870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43868

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



43868
43869
43870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43868

def ends_at
  @ends_at
end

#regionsObject (readonly)

Returns the value of attribute regions.



43868
43869
43870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43868

def regions
  @regions
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



43868
43869
43870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43868

def starts_at
  @starts_at
end

#weightObject (readonly)

Returns the value of attribute weight.



43868
43869
43870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43868

def weight
  @weight
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43885
43886
43887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43885

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

#subtype_to_hashObject



43889
43890
43891
43892
43893
43894
43895
43896
43897
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43889

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



43881
43882
43883
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43881

def to_json
  JSON.dump(to_hash)
end