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.



28023
28024
28025
28026
28027
28028
28029
28030
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28023

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.



28021
28022
28023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28021

def id
  @id
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



28021
28022
28023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28021

def outcome
  @outcome
end

#positionObject (readonly)

Returns the value of attribute position.



28021
28022
28023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28021

def position
  @position
end

#queryObject (readonly)

Returns the value of attribute query.



28021
28022
28023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28021

def query
  @query
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28036
28037
28038
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28036

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

#to_hashObject



28040
28041
28042
28043
28044
28045
28046
28047
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28040

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

#to_jsonObject



28032
28033
28034
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28032

def to_json
  JSON.dump(to_hash)
end