Class: Io::Flow::V0::Models::ExclusionRule

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

Overview

A global exclusion rule allows the user to select 1 or more items by query and to globally exclude those items from sale in one or more regions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ExclusionRule

Returns a new instance of ExclusionRule.



28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28840

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :q, :query, :regions, :status, :statistics], 'ExclusionRule')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String)
  @query = (x = opts.delete(:query); x.is_a?(::Io::Flow::V0::Models::Query) ? x : ::Io::Flow::V0::Models::Query.new(x))
  @regions = HttpClient::Preconditions.assert_class('regions', opts.delete(:regions), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Region) ? x : ::Io::Flow::V0::Models::Region.new(x)) }
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SubcatalogItemStatus) ? x : ::Io::Flow::V0::Models::SubcatalogItemStatus.apply(x))
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @statistics = (x = opts.delete(:statistics); x.is_a?(::Io::Flow::V0::Models::ExclusionRuleStatistic) ? x : ::Io::Flow::V0::Models::ExclusionRuleStatistic.new(x))
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def id
  @id
end

#qObject (readonly)

Returns the value of attribute q.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def q
  @q
end

#queryObject (readonly)

Returns the value of attribute query.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def query
  @query
end

#regionsObject (readonly)

Returns the value of attribute regions.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def regions
  @regions
end

#statisticsObject (readonly)

Returns the value of attribute statistics.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def statistics
  @statistics
end

#statusObject (readonly)

Returns the value of attribute status.



28838
28839
28840
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28838

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28856
28857
28858
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28856

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

#to_hashObject



28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28860

def to_hash
  {
    :id => id,
    :q => q,
    :query => query.to_hash,
    :regions => regions.map { |o| o.to_hash },
    :status => status.value,
    :description => description,
    :statistics => statistics.to_hash
  }
end

#to_jsonObject



28852
28853
28854
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28852

def to_json
  JSON.dump(to_hash)
end