Class: Sift::Client::Decision
- Inherits:
-
Object
- Object
- Sift::Client::Decision
- 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
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
Instance Method Summary collapse
- #apply_to(configs = {}) ⇒ Object
- #build_query(getter) ⇒ Object
- #index_path ⇒ Object
-
#initialize(api_key, account_id) ⇒ Decision
constructor
A new instance of Decision.
- #list(options = {}) ⇒ Object
Constructor Details
#initialize(api_key, account_id) ⇒ Decision
Returns a new instance of Decision.
16 17 18 19 |
# File 'lib/sift/client/decision.rb', line 16 def initialize(api_key, account_id) @account_id = account_id @api_key = api_key end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
14 15 16 |
# File 'lib/sift/client/decision.rb', line 14 def account_id @account_id end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
14 15 16 |
# File 'lib/sift/client/decision.rb', line 14 def api_key @api_key end |
Instance Method Details
#apply_to(configs = {}) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/sift/client/decision.rb', line 44 def apply_to(configs = {}) getter = Utils::HashGetter.new(configs) configs[:account_id] = account_id ApplyTo.new(api_key, getter.get(:decision_id), configs).run end |
#build_query(getter) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/sift/client/decision.rb', line 34 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_path ⇒ Object
51 52 53 |
# File 'lib/sift/client/decision.rb', line 51 def index_path "#{Client::API3_ENDPOINT}/v3/accounts/#{account_id}/decisions" end |
#list(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sift/client/decision.rb', line 21 def list( = {}) getter = Utils::HashGetter.new() if path = getter.get(:next_ref) request_next_page(path) else Router.get(index_path, { query: build_query(getter), headers: auth_header }) end end |