Class: ForestAdminDatasourceZendesk::Query::ConditionTreeTranslator
- Inherits:
-
Object
- Object
- ForestAdminDatasourceZendesk::Query::ConditionTreeTranslator
- Defined in:
- lib/forest_admin_datasource_zendesk/query/condition_tree_translator.rb
Overview
See developer.zendesk.com/api-reference/ticketing/ticket-management/search/
Unsupported operators raise UnsupportedOperatorError rather than silently producing the wrong query. Only the AND aggregator is supported (Zendesk Search has no general OR).
Constant Summary collapse
- Operators =
ForestAdminDatasourceToolkit::Components::Query::ConditionTree::Operators
- Branch =
ForestAdminDatasourceToolkit::Components::Query::ConditionTree::Nodes::ConditionTreeBranch
- Leaf =
ForestAdminDatasourceToolkit::Components::Query::ConditionTree::Nodes::ConditionTreeLeaf
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(timezone: nil, custom_fields: {}) ⇒ ConditionTreeTranslator
constructor
A new instance of ConditionTreeTranslator.
- #translate(node) ⇒ Object
Constructor Details
#initialize(timezone: nil, custom_fields: {}) ⇒ ConditionTreeTranslator
Returns a new instance of ConditionTreeTranslator.
21 22 23 24 |
# File 'lib/forest_admin_datasource_zendesk/query/condition_tree_translator.rb', line 21 def initialize(timezone: nil, custom_fields: {}) @timezone = timezone || 'UTC' @custom_fields = custom_fields || {} end |
Class Method Details
.call(condition_tree, timezone: nil, custom_fields: {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/forest_admin_datasource_zendesk/query/condition_tree_translator.rb', line 15 def self.call(condition_tree, timezone: nil, custom_fields: {}) return '' if condition_tree.nil? new(timezone: timezone, custom_fields: custom_fields).translate(condition_tree) end |
Instance Method Details
#translate(node) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/forest_admin_datasource_zendesk/query/condition_tree_translator.rb', line 26 def translate(node) case node when Branch then translate_branch(node) when Leaf then translate_leaf(node) else raise UnsupportedOperatorError, "Unknown condition node: #{node.class}" end end |