Class: Io::Flow::V0::Models::TierRule

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

Overview

System to filter incoming quote for a shipment request based on a query and output corresponding outcomes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TierRule

Returns a new instance of TierRule.



65758
65759
65760
65761
65762
65763
65764
65765
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65758

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :position, :query, :outcome], 'TierRule')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer)
  @query = HttpClient::Preconditions.assert_class('query', opts.delete(:query), String)
  @outcome = (x = opts.delete(:outcome); x.is_a?(::Io::Flow::V0::Models::TierRuleOutcome) ? x : ::Io::Flow::V0::Models::TierRuleOutcome.from_json(x))
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



65756
65757
65758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65756

def id
  @id
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



65756
65757
65758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65756

def outcome
  @outcome
end

#positionObject (readonly)

Returns the value of attribute position.



65756
65757
65758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65756

def position
  @position
end

#queryObject (readonly)

Returns the value of attribute query.



65756
65757
65758
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65756

def query
  @query
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



65771
65772
65773
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65771

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

#to_hashObject



65775
65776
65777
65778
65779
65780
65781
65782
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65775

def to_hash
  {
    :id => id,
    :position => position,
    :query => query,
    :outcome => outcome.to_hash
  }
end

#to_jsonObject



65767
65768
65769
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65767

def to_json
  JSON.dump(to_hash)
end