Class: DigifiApi::MLRulesEngine

Inherits:
Base
  • Object
show all
Defined in:
lib/digifi_api/ml_rules_engine.rb

Class Method Summary collapse

Methods inherited from Base

headers, payload, post

Class Method Details

.submit(strategy_name, strategy_status, variables_hash, options = {}) ⇒ Object

strategy_name:string required strategy_status:string required variables:object required client_transaction_id opt return_input_variables:bool opt return_processing_detail:bool opt return_data_sources:bool opt



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/digifi_api/ml_rules_engine.rb', line 16

def self.submit(strategy_name, strategy_status, variables_hash, options={})

  return { error: "strategy_name is required" } if strategy_name.nil?
  return { error: "strategy_status is required" } if strategy_status.nil?

  elements = Hash.new
  # Required Elements
  elements['strategy_name'] = strategy_name
  elements['strategy_status'] = strategy_status
  elements['variables'] = variables_hash

  # Optional Elements
  if options[:client_transaction_id]
    elements['client_transaction_id'] = options[:client_transaction_id]
  end

  if options[:return_input_variables]
    if options[:return_input_variables] == true || options[:return_input_variables] == 'true'
      elements['return_input_variables'] = true
    end
  end

  if options[:return_processing_detail]
    if options[:return_processing_detail] == true || options[:return_processing_detail] == 'true'
      elements['return_processing_detail'] = true
    end
  end

  if options[:return_data_sources]
    if options[:return_data_sources] == true || options[:return_data_sources] == 'true'
      elements['return_data_sources'] = true
    end
  end
  
  response = self.post(@resource_uri, elements)
end