Class: Sift::Client::Decision

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

Defined Under Namespace

Classes: ApplyTo

Constant Summary collapse

FILTER_PARAMS =
%w{ limit entity_type abuse_types from }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, account_id) ⇒ Decision

Returns a new instance of Decision.



15
16
17
18
# File 'lib/sift/client/decision.rb', line 15

def initialize(api_key, )
  @account_id = 
  @api_key = api_key
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



13
14
15
# File 'lib/sift/client/decision.rb', line 13

def 
  @account_id
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



13
14
15
# File 'lib/sift/client/decision.rb', line 13

def api_key
  @api_key
end

Instance Method Details

#apply_to(configs = {}) ⇒ Object



43
44
45
46
47
48
# File 'lib/sift/client/decision.rb', line 43

def apply_to(configs = {})
  getter = Utils::HashGetter.new(configs)
  configs[:account_id] = 

  ApplyTo.new(api_key, getter.get(:decision_id), configs).run
end

#build_query(getter) ⇒ Object



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

def build_query(getter)
  FILTER_PARAMS.inject({}) do |result, filter|
    if value = getter.get(filter)
      result[filter] = value.is_a?(Array) ? value.join(",") : value
    end

    result
  end
end

#index_pathObject



50
51
52
# File 'lib/sift/client/decision.rb', line 50

def index_path
  "#{Client::API3_ENDPOINT}/v3/accounts/#{}/decisions"
end

#list(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sift/client/decision.rb', line 20

def list(options = {})
  getter = Utils::HashGetter.new(options)

  if path = getter.get(:next_ref)
    request_next_page(path)
  else
    Router.get(index_path, {
      query: build_query(getter),
      headers: auth_header
    })
  end
end