Class: Io::Flow::V0::Models::PeakSurchargeByWeightServiceFee

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 = {}) ⇒ PeakSurchargeByWeightServiceFee

Returns a new instance of PeakSurchargeByWeightServiceFee.



59430
59431
59432
59433
59434
59435
59436
59437
59438
59439
# 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

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



59428
59429
59430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59428

def amount
  @amount
end

#ends_atObject (readonly)

Returns the value of attribute ends_at.



59428
59429
59430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59428

def ends_at
  @ends_at
end

#regionsObject (readonly)

Returns the value of attribute regions.



59428
59429
59430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59428

def regions
  @regions
end

#starts_atObject (readonly)

Returns the value of attribute starts_at.



59428
59429
59430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59428

def starts_at
  @starts_at
end

#weightObject (readonly)

Returns the value of attribute weight.



59428
59429
59430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59428

def weight
  @weight
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



59445
59446
59447
# 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_hashObject



59449
59450
59451
59452
59453
59454
59455
59456
59457
# 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_jsonObject



59441
59442
59443
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 59441

def to_json
  JSON.dump(to_hash)
end