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.



53305
53306
53307
53308
53309
53310
53311
53312
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53305

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.



53303
53304
53305
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53303

def id
  @id
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



53303
53304
53305
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53303

def outcome
  @outcome
end

#positionObject (readonly)

Returns the value of attribute position.



53303
53304
53305
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53303

def position
  @position
end

#queryObject (readonly)

Returns the value of attribute query.



53303
53304
53305
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53303

def query
  @query
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



53318
53319
53320
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53318

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

#to_hashObject



53322
53323
53324
53325
53326
53327
53328
53329
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53322

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

#to_jsonObject



53314
53315
53316
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53314

def to_json
  JSON.dump(to_hash)
end