Class: Sift::Client::Decision::ApplyTo

Inherits:
Object
  • Object
show all
Defined in:
lib/sift/client/decision/apply_to.rb

Constant Summary collapse

PROPERTIES =
%w{
  source
  analyst
  description
  order_id
  session_id
  content_id
  user_id
  account_id
  time
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, decision_id, configs) ⇒ ApplyTo

Returns a new instance of ApplyTo.



34
35
36
37
38
39
# File 'lib/sift/client/decision/apply_to.rb', line 34

def initialize(api_key, decision_id, configs)
  @api_key = api_key
  @decision_id = decision_id
  @configs = configs
  @getter = Utils::HashGetter.new(configs)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



24
25
26
# File 'lib/sift/client/decision/apply_to.rb', line 24

def api_key
  @api_key
end

#configsObject (readonly)

Returns the value of attribute configs.



24
25
26
# File 'lib/sift/client/decision/apply_to.rb', line 24

def configs
  @configs
end

#decision_idObject (readonly)

Returns the value of attribute decision_id.



24
25
26
# File 'lib/sift/client/decision/apply_to.rb', line 24

def decision_id
  @decision_id
end

#getterObject (readonly)

Returns the value of attribute getter.



24
25
26
# File 'lib/sift/client/decision/apply_to.rb', line 24

def getter
  @getter
end

Instance Method Details

#runObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sift/client/decision/apply_to.rb', line 41

def run
  if errors.empty?
    send_request
  else
    Response.new(
      MultiJson.dump({
        status: 55,
        error_message: errors.join(", ")
      }),
      400,
      nil
    )
  end
end