Class: Io::Flow::V0::Models::QueryBuilder
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::QueryBuilder
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The query builder model is used to build a query using structured filters. The end result is a single ‘q’ string - e.g. ‘category:jewelry and brand:Flow’
Instance Attribute Summary collapse
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ QueryBuilder
constructor
A new instance of QueryBuilder.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ QueryBuilder
Returns a new instance of QueryBuilder.
45937 45938 45939 45940 45941 45942 45943 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45937 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:q, :filters, :available], 'QueryBuilder') @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String) @filters = HttpClient::Preconditions.assert_class('filters', opts.delete(:filters), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::QueryFilter) ? x : ::Io::Flow::V0::Models::QueryFilter.from_json(x)) } @available = HttpClient::Preconditions.assert_class('available', opts.delete(:available), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AvailableFilter) ? x : ::Io::Flow::V0::Models::AvailableFilter.from_json(x)) } end |
Instance Attribute Details
#available ⇒ Object (readonly)
Returns the value of attribute available.
45935 45936 45937 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45935 def available @available end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
45935 45936 45937 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45935 def filters @filters end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
45935 45936 45937 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45935 def q @q end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
45949 45950 45951 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45949 def copy(incoming={}) QueryBuilder.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
45953 45954 45955 45956 45957 45958 45959 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45953 def to_hash { :q => q, :filters => filters.map { |o| o.to_hash }, :available => available.map { |o| o.to_hash } } end |
#to_json ⇒ Object
45945 45946 45947 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45945 def to_json JSON.dump(to_hash) end |