Class: Io::Flow::V0::Models::QueryFilter

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

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ QueryFilter

Returns a new instance of QueryFilter.



14659
14660
14661
14662
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14659

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator) || 'query_filter_structured', String)
end

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



14657
14658
14659
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14657

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14672

def QueryFilter.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip
  if discriminator.empty?
    raise "Union type[query_filter] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::QUERY_FILTER_STRUCTURED; QueryFilterStructured.new(hash)
    when Types::QUERY_FILTER_UNSTRUCTURED; QueryFilterUnstructured.new(hash)
    else QueryFilterUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



14664
14665
14666
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14664

def subtype_to_hash
  raise 'Cannot serialize an instance of query_filter directly - must use one of the specific types: query_filter_structured, query_filter_unstructured'
end

#to_hashObject



14668
14669
14670
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14668

def to_hash
  subtype_to_hash.merge(:discriminator => @discriminator)
end