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.



54066
54067
54068
54069
54070
54071
54072
54073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54066

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.



54064
54065
54066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54064

def id
  @id
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



54064
54065
54066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54064

def outcome
  @outcome
end

#positionObject (readonly)

Returns the value of attribute position.



54064
54065
54066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54064

def position
  @position
end

#queryObject (readonly)

Returns the value of attribute query.



54064
54065
54066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54064

def query
  @query
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



54079
54080
54081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54079

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

#to_hashObject



54083
54084
54085
54086
54087
54088
54089
54090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54083

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

#to_jsonObject



54075
54076
54077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54075

def to_json
  JSON.dump(to_hash)
end