class Io::Flow::V0::Models::PeakSurchargeByWeightServiceFee

Attributes

amount[R]
ends_at[R]
regions[R]
starts_at[R]
weight[R]

Public Class Methods

new(incoming={}) click to toggle source
Calls superclass method Io::Flow::V0::Models::ServiceFee::new
# File lib/flow_commerce/flow_api_v0_client.rb, line 59430
def initialize(incoming={})
  super(:discriminator => ServiceFee::Types::PEAK_SURCHARGE_BY_WEIGHT_SERVICE_FEE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount, :weight], 'PeakSurchargeByWeightServiceFee')
  @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

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 59445
def copy(incoming={})
  PeakSurchargeByWeightServiceFee.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
subtype_to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 59449
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_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 59441
def to_json
  JSON.dump(to_hash)
end