Class: Io::Flow::V0::Models::RatecardRate

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

Overview

Specific line item in a ratecard lane with information on a weight threshold and corresponding amount to charge

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RatecardRate

Returns a new instance of RatecardRate.



41463
41464
41465
41466
41467
41468
41469
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41463

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :amount, :weight], 'RatecardRate')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @weight = HttpClient::Preconditions.assert_class('weight', opts.delete(:weight), Numeric)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



41461
41462
41463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41461

def amount
  @amount
end

#idObject (readonly)

Returns the value of attribute id.



41461
41462
41463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41461

def id
  @id
end

#weightObject (readonly)

Returns the value of attribute weight.



41461
41462
41463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41461

def weight
  @weight
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41475
41476
41477
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41475

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

#to_hashObject



41479
41480
41481
41482
41483
41484
41485
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41479

def to_hash
  {
    :id => id,
    :amount => amount,
    :weight => weight
  }
end

#to_jsonObject



41471
41472
41473
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41471

def to_json
  JSON.dump(to_hash)
end