Class: Sift::Client
- Inherits:
-
Object
- Object
- Sift::Client
- Includes:
- HTTParty
- Defined in:
- lib/sift/client.rb,
lib/sift/client/decision.rb,
lib/sift/client/decision/apply_to.rb
Overview
This class wraps accesses through the API
Defined Under Namespace
Classes: Decision
Constant Summary collapse
- API_ENDPOINT =
ENV["SIFT_RUBY_API_URL"] || 'https://api.siftscience.com'
- API3_ENDPOINT =
ENV["SIFT_RUBY_API3_URL"] || 'https://api3.siftscience.com'
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.
Class Method Summary collapse
Instance Method Summary collapse
- #apply_decision(configs = {}) ⇒ Object
- #apply_decision!(configs = {}) ⇒ Object
- #build_default_headers_post(api_key) ⇒ Object
- #create_psp_merchant_profile(properties = {}, opts = {}) ⇒ Object
- #decisions(opts = {}) ⇒ Object
- #decisions!(opts = {}) ⇒ Object
- #get_a_psp_merchant_profile(merchant_id, opts = {}) ⇒ Object
-
#get_content_decisions(user_id, content_id, opts = {}) ⇒ Object
Gets the decision status of a piece of content.
-
#get_order_decisions(order_id, opts = {}) ⇒ Object
Gets the decision status of an order.
- #get_psp_merchant_profiles(batch_size = nil, batch_token = nil, opts = {}) ⇒ Object
-
#get_session_decisions(user_id, session_id, opts = {}) ⇒ Object
Gets the decision status of a session.
-
#get_user_decisions(user_id, opts = {}) ⇒ Object
Gets the decision status of a user.
-
#get_user_score(user_id, opts = {}) ⇒ Object
Fetches the latest score(s) computed for the specified user and abuse types.
-
#get_workflow_status(run_id, opts = {}) ⇒ Object
Gets the status of a workflow run.
-
#initialize(opts = {}) ⇒ Client
constructor
Constructor.
-
#label(user_id, properties = {}, opts = {}) ⇒ Object
Labels a user.
-
#rescore_user(user_id, opts = {}) ⇒ Object
Rescores the specified user for the specified abuse types and returns the resulting score(s).
-
#score(user_id, opts = {}) ⇒ Object
Retrieves a user’s fraud score from the Sift Science API.
-
#track(event, properties = {}, opts = {}) ⇒ Object
Sends an event to the Sift Science Events API.
-
#unlabel(user_id, opts = {}) ⇒ Object
Unlabels a user.
- #update_psp_merchant_profile(merchant_id, properties = {}, opts = {}) ⇒ Object
- #user_agent ⇒ Object
- #verification_check(properties = {}, opts = {}) ⇒ Object
- #verification_resend(properties = {}, opts = {}) ⇒ Object
- #verification_send(properties = {}, opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Constructor
Parameters:
- opts (optional)
-
A Hash of optional parameters for this Client –
- :api_key
-
The Sift Science API key associated with your account. Sift.api_key is used if this parameter is not set.
- :account_id
-
The ID of your Sift Science account. Sift.account_id is used if this parameter is not set.
- :timeout
-
The number of seconds to wait before failing a request. By default this is configured to 2 seconds.
- :version
-
The version of the Events API, Score API, and Labels API to call. By default, version 205.
- :path
-
The URL path to use for Events API path. By default, the official path of the specified-version of the Events API.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sift/client.rb', line 138 def initialize(opts = {}) @api_key = opts[:api_key] || Sift.api_key @account_id = opts[:account_id] || Sift.account_id @version = opts[:version] || API_VERSION @timeout = opts[:timeout] || 2 # 2-second timeout by default @path = opts[:path] || Sift.rest_api_path(@version) raise("api_key") if !@api_key.is_a?(String) || @api_key.empty? raise("path must be a non-empty string") if !@path.is_a?(String) || @path.empty? end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
100 101 102 |
# File 'lib/sift/client.rb', line 100 def account_id @account_id end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
100 101 102 |
# File 'lib/sift/client.rb', line 100 def api_key @api_key end |
Class Method Details
.build_auth_header(api_key) ⇒ Object
102 103 104 |
# File 'lib/sift/client.rb', line 102 def self.build_auth_header(api_key) { "Authorization" => "Basic #{Base64.encode64(api_key)}" } end |
.user_agent ⇒ Object
106 107 108 |
# File 'lib/sift/client.rb', line 106 def self.user_agent "sift-ruby/#{VERSION}" end |
Instance Method Details
#apply_decision(configs = {}) ⇒ Object
740 741 742 |
# File 'lib/sift/client.rb', line 740 def apply_decision(configs = {}) decision_instance.apply_to(configs) end |
#apply_decision!(configs = {}) ⇒ Object
744 745 746 |
# File 'lib/sift/client.rb', line 744 def apply_decision!(configs = {}) handle_response(apply_decision(configs)) end |
#build_default_headers_post(api_key) ⇒ Object
748 749 750 751 752 753 754 |
# File 'lib/sift/client.rb', line 748 def build_default_headers_post(api_key) { "Authorization" => "Basic #{Base64.encode64(api_key+":")}", "User-Agent" => "SiftScience/v#{@version} sift-ruby/#{VERSION}", "Content-Type" => "application/json" } end |
#create_psp_merchant_profile(properties = {}, opts = {}) ⇒ Object
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'lib/sift/client.rb', line 813 def create_psp_merchant_profile(properties = {}, opts = {}) # Create a new PSP Merchant profile # Args: # properties: A dict of merchant profile data. # Returns # A sift.client.Response object if the call succeeded, else raises an ApiException account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout raise("api_key cannot be empty") if api_key.empty? raise("account_id cannot be empty") if account_id.empty? raise("properties cannot be empty") if properties.empty? = { :body => MultiJson.dump(delete_nils(properties)), :headers => { "User-Agent" => user_agent, "Content-Type" => "application/json" }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(API_ENDPOINT + Sift.psp_merchant_api_path(account_id), ) Response.new(response.body, response.code, response.response) end |
#decisions(opts = {}) ⇒ Object
732 733 734 |
# File 'lib/sift/client.rb', line 732 def decisions(opts = {}) decision_instance.list(opts) end |
#decisions!(opts = {}) ⇒ Object
736 737 738 |
# File 'lib/sift/client.rb', line 736 def decisions!(opts = {}) handle_response(decisions(opts)) end |
#get_a_psp_merchant_profile(merchant_id, opts = {}) ⇒ Object
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
# File 'lib/sift/client.rb', line 865 def get_a_psp_merchant_profile(merchant_id, opts = {}) # Gets a PSP merchant profile using merchant id. # Args: # merchant_id: id of merchant # Returns # A sift.client.Response object if the call succeeded, else raises an ApiException account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout raise("api_key cannot be empty") if api_key.empty? raise("account_id cannot be empty") if account_id.empty? raise("merchant_id cannot be empty") if merchant_id.empty? = { :headers => { "User-Agent" => user_agent, "Content-Type" => "application/json" }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.get(API_ENDPOINT + Sift.psp_merchant_id_api_path(account_id, merchant_id), ) Response.new(response.body, response.code, response.response) end |
#get_content_decisions(user_id, content_id, opts = {}) ⇒ Object
Gets the decision status of a piece of content.
See siftscience.com/developers/docs/ruby/decisions-api/decision-status .
Parameters
- user_id
-
The ID of the owner of the content.
- content_id
-
The ID of a piece of content.
- opts (optional)
-
A Hash of optional parameters for this request –
- :account_id
-
Overrides the API key for this call.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
# File 'lib/sift/client.rb', line 716 def get_content_decisions(user_id, content_id, opts = {}) account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout = { :headers => { "User-Agent" => user_agent }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? uri = API3_ENDPOINT + Sift.content_decisions_api_path(account_id, user_id, content_id) response = self.class.get(uri, ) Response.new(response.body, response.code, response.response) end |
#get_order_decisions(order_id, opts = {}) ⇒ Object
Gets the decision status of an order.
See siftscience.com/developers/docs/ruby/decisions-api/decision-status .
Parameters
- order_id
-
The ID of an order.
- opts (optional)
-
A Hash of optional parameters for this request –
- :account_id
-
Overrides the API key for this call.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/sift/client.rb', line 636 def get_order_decisions(order_id, opts = {}) account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout = { :headers => { "User-Agent" => user_agent }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? uri = API3_ENDPOINT + Sift.order_decisions_api_path(account_id, order_id) response = self.class.get(uri, ) Response.new(response.body, response.code, response.response) end |
#get_psp_merchant_profiles(batch_size = nil, batch_token = nil, opts = {}) ⇒ Object
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
# File 'lib/sift/client.rb', line 889 def get_psp_merchant_profiles(batch_size = nil, batch_token = nil, opts = {}) # Get all PSP merchant profiles. # Args: # batch_size : Batch or page size of the paginated sequence. # batch_token : Batch or page position of the paginated sequence. # Returns # A sift.client.Response object if the call succeeded, else raises an ApiException account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout raise("api_key cannot be empty") if api_key.empty? raise("account_id cannot be empty") if account_id.empty? query = {} query["batch_size"] = batch_size if batch_size query["batch_token"] = batch_token if batch_token = { :headers => { "User-Agent" => user_agent, "Content-Type" => "application/json" }, :basic_auth => { :username => api_key, :password => "" }, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.get(API_ENDPOINT + Sift.psp_merchant_api_path(account_id), ) Response.new(response.body, response.code, response.response) end |
#get_session_decisions(user_id, session_id, opts = {}) ⇒ Object
Gets the decision status of a session.
See siftscience.com/developers/docs/ruby/decisions-api/decision-status .
Parameters
- user_id
-
The ID of the user in the session.
- session_id
-
The ID of a session.
- opts (optional)
-
A Hash of optional parameters for this request –
- :account_id
-
Overrides the account id for this call.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
# File 'lib/sift/client.rb', line 676 def get_session_decisions(user_id, session_id, opts = {}) account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout = { :headers => { "User-Agent" => user_agent }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? uri = API3_ENDPOINT + Sift.session_decisions_api_path(account_id, user_id, session_id) response = self.class.get(uri, ) Response.new(response.body, response.code, response.response) end |
#get_user_decisions(user_id, opts = {}) ⇒ Object
Gets the decision status of a user.
See siftscience.com/developers/docs/ruby/decisions-api/decision-status .
Parameters
- user_id
-
The ID of user.
- opts (optional)
-
A Hash of optional parameters for this request –
- :account_id
-
Overrides the API key for this call.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/sift/client.rb', line 598 def get_user_decisions(user_id, opts = {}) account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout = { :headers => { "User-Agent" => user_agent }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? uri = API3_ENDPOINT + Sift.user_decisions_api_path(account_id, user_id) response = self.class.get(uri, ) Response.new(response.body, response.code, response.response) end |
#get_user_score(user_id, opts = {}) ⇒ Object
Fetches the latest score(s) computed for the specified user and abuse types.
As opposed to client.score() and client.rescore_user(), this *does not* compute a new score for the user; it simply fetches the latest score(s) which have computed. These scores may be arbitrarily old.
See siftscience.com/developers/docs/ruby/score-api/get-score for more details.
Parameters:
- user_id
-
A user’s id. This id should be the same as the user_id used in event calls.
- opts (optional)
-
A Hash of optional parameters for the request –
- :abuse_types
-
List of abuse types, specifying for which abuse types a score should be returned. By default, a score is returned for every abuse type to which you are subscribed.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
- :include_score_percentiles
-
include_score_percentiles(optional) : Whether to add new parameter in the query parameter.
Returns:
A Response object containing a status code, status message, and, if successful, the user’s score(s).
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
# File 'lib/sift/client.rb', line 362 def get_user_score(user_id, opts = {}) abuse_types = opts[:abuse_types] api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout include_score_percentiles = opts[:include_score_percentiles] raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty? raise("Bad api_key parameter") if api_key.empty? query = {} query["api_key"] = api_key query["abuse_types"] = abuse_types.join(",") if abuse_types if include_score_percentiles == "true" query["fields"] = "SCORE_PERCENTILES" end = { :headers => {"User-Agent" => user_agent}, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.get(Sift.user_score_api_path(user_id, @version), ) Response.new(response.body, response.code, response.response) end |
#get_workflow_status(run_id, opts = {}) ⇒ Object
Gets the status of a workflow run.
See siftscience.com/developers/docs/ruby/workflows-api/workflow-status .
Parameters
- run_id
-
The ID of a workflow run.
- opts (optional)
-
A Hash of optional parameters for this request –
- :account_id
-
Overrides the API key for this call.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/sift/client.rb', line 560 def get_workflow_status(run_id, opts = {}) account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout = { :headers => { "User-Agent" => user_agent }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? uri = API3_ENDPOINT + Sift.workflow_status_path(account_id, run_id) response = self.class.get(uri, ) Response.new(response.body, response.code, response.response) end |
#label(user_id, properties = {}, opts = {}) ⇒ Object
Labels a user.
See siftscience.com/developers/docs/ruby/labels-api/label-user .
Parameters:
- user_id
-
A user’s id. This id should be the same as the user_id used in event calls.
- properties
-
A hash of name-value pairs that specify the label attributes. This parameter must be specified.
- opts (optional)
-
A Hash of optional parameters for the request –
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
- :version
-
Overrides the version of the Events API to call.
Returns:
In the case of a connection error (timeout, broken connection, etc.), this method returns nil; otherwise, a Response object is returned that captures the status message and status code.
473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/sift/client.rb', line 473 def label(user_id, properties = {}, opts = {}) api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout version = opts[:version] || @version path = Sift.users_label_api_path(user_id, version) raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty? track("$label", delete_nils(properties), :path => path, :api_key => api_key, :timeout => timeout) end |
#rescore_user(user_id, opts = {}) ⇒ Object
Rescores the specified user for the specified abuse types and returns the resulting score(s).
See siftscience.com/developers/docs/ruby/score-api/rescore for more details.
Parameters:
- user_id
-
A user’s id. This id should be the same as the user_id used in event calls.
- opts (optional)
-
A Hash of optional parameters for the request –
- :abuse_types
-
List of abuse types, specifying for which abuse types a score should be returned. By default, a score is returned for every abuse type to which you are subscribed.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
Returns:
A Response object containing a status code, status message, and, if successful, the user’s score(s).
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/sift/client.rb', line 418 def rescore_user(user_id, opts = {}) abuse_types = opts[:abuse_types] api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty? raise("Bad api_key parameter") if api_key.empty? query = {} query["api_key"] = api_key query["abuse_types"] = abuse_types.join(",") if abuse_types = { :headers => {"User-Agent" => user_agent}, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(Sift.user_score_api_path(user_id, @version), ) Response.new(response.body, response.code, response.response) end |
#score(user_id, opts = {}) ⇒ Object
Retrieves a user’s fraud score from the Sift Science API.
See siftscience.com/developers/docs/ruby/score-api/score-api .
Parameters:
- user_id
-
A user’s id. This id should be the same as the user_id used in event calls.
- opts (optional)
-
A Hash of optional parameters for the request –
- :abuse_types
-
List of abuse types, specifying for which abuse types a score should be returned. By default, a score is returned for every abuse type to which you are subscribed.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
- :version
-
Overrides the version of the Events API to call.
- :include_score_percentiles
-
include_score_percentiles(optional) : Whether to add new parameter in the query parameter.
Returns:
A Response object containing a status code, status message, and, if successful, the user’s score(s).
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/sift/client.rb', line 298 def score(user_id, opts = {}) abuse_types = opts[:abuse_types] api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout version = opts[:version] || @version include_score_percentiles = opts[:include_score_percentiles] raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty? raise("Bad api_key parameter") if api_key.empty? query = {} query["api_key"] = api_key query["abuse_types"] = abuse_types.join(",") if abuse_types if include_score_percentiles == "true" query["fields"] = "SCORE_PERCENTILES" end = { :headers => {"User-Agent" => user_agent}, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.get(Sift.score_api_path(user_id, version), ) Response.new(response.body, response.code, response.response) end |
#track(event, properties = {}, opts = {}) ⇒ Object
Sends an event to the Sift Science Events API.
See siftscience.com/developers/docs/ruby/events-api .
Parameters:
- event
-
The name of the event to send. This can be either a reserved event name, like $transaction or $label or a custom event name (that does not start with a $). This parameter must be specified.
- properties
-
A hash of name-value pairs that specify the event-specific attributes to track. This parameter must be specified.
- opts (optional)
-
A Hash of optional parameters for the request –
- :return_score
-
If true, requests that the response include a score for this user, computed using the submitted event. See siftscience.com/developers/docs/ruby/score-api/synchronous-scores
- :abuse_types
-
List of abuse types, specifying for which abuse types a score should be returned (if scoring was requested). By default, a score is returned for every abuse type to which you are subscribed.
- :return_action
-
If true, requests that the response include any actions triggered as a result of the tracked event.
- :return_workflow_status
-
If true, requests that the response include the status of any workflow run as a result of the tracked event. See siftscience.com/developers/docs/ruby/workflows-api/workflow-decisions
- :timeout
-
Overrides the timeout (in seconds) for this call.
- :api_key
-
Overrides the API key for this call.
- :version
-
Overrides the version of the Events API to call.
- :path
-
Overrides the URI path for this API call.
- :include_score_percentiles
-
include_score_percentiles(optional) : Whether to add new parameter in the query parameter.
- :warnings
-
warnings(optional) : Whether to add list of warnings (if any) to response.
Returns:
In the case of a network error (timeout, broken connection, etc.), this method propagates the exception, otherwise, a Response object is returned that captures the status message and status code.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/sift/client.rb', line 217 def track(event, properties = {}, opts = {}) api_key = opts[:api_key] || @api_key version = opts[:version] || @version path = opts[:path] || (version && Sift.rest_api_path(version)) || @path timeout = opts[:timeout] || @timeout return_score = opts[:return_score] return_action = opts[:return_action] return_workflow_status = opts[:return_workflow_status] return_route_info = opts[:return_route_info] force_workflow_run = opts[:force_workflow_run] abuse_types = opts[:abuse_types] include_score_percentiles = opts[:include_score_percentiles] warnings = opts[:warnings] raise("event must be a non-empty string") if (!event.is_a? String) || event.empty? raise("properties cannot be empty") if properties.empty? raise("api_key cannot be empty") if api_key.empty? query = {} query["return_score"] = "true" if return_score query["return_action"] = "true" if return_action query["return_workflow_status"] = "true" if return_workflow_status query["return_route_info"] = "true" if return_route_info query["force_workflow_run"] = "true" if force_workflow_run query["abuse_types"] = abuse_types.join(",") if abuse_types if include_score_percentiles == "true" || warnings == "true" fields = [] fields << "SCORE_PERCENTILES" if include_score_percentiles == "true" fields << "WARNINGS" if warnings == "true" query["fields"] = fields.join(",") end = { :body => MultiJson.dump(delete_nils(properties).merge({"$type" => event, "$api_key" => api_key})), :headers => {"User-Agent" => user_agent}, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(path, ) Response.new(response.body, response.code, response.response) end |
#unlabel(user_id, opts = {}) ⇒ Object
Unlabels a user.
See siftscience.com/developers/docs/ruby/labels-api/unlabel-user .
Parameters:
- user_id
-
A user’s id. This id should be the same as the user_id used in event calls.
- opts (optional)
-
A Hash of optional parameters for this request –
- :abuse_type
-
The abuse type for which the user should be unlabeled. If omitted, the user is unlabeled for all abuse types.
- :api_key
-
Overrides the API key for this call.
- :timeout
-
Overrides the timeout (in seconds) for this call.
- :version
-
Overrides the version of the Events API to call.
Returns:
A Response object is returned with only an http code of 204.
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'lib/sift/client.rb', line 516 def unlabel(user_id, opts = {}) abuse_type = opts[:abuse_type] api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout version = opts[:version] || @version raise("user_id must be a non-empty string") if (!user_id.is_a? String) || user_id.to_s.empty? query = {} query[:api_key] = api_key query[:abuse_type] = abuse_type if abuse_type = { :headers => {}, :query => query } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.delete(Sift.users_label_api_path(user_id, version), ) Response.new(response.body, response.code, response.response) end |
#update_psp_merchant_profile(merchant_id, properties = {}, opts = {}) ⇒ Object
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 |
# File 'lib/sift/client.rb', line 838 def update_psp_merchant_profile(merchant_id, properties = {}, opts = {}) # Update an existing PSP Merchant profile # Args: # merchant_id: id of merchant # properties: A dict of merchant profile data. # Returns # A sift.client.Response object if the call succeeded, else raises an ApiException account_id = opts[:account_id] || @account_id api_key = opts[:api_key] || @api_key timeout = opts[:timeout] || @timeout raise("api_key cannot be empty") if api_key.empty? raise("account_id cannot be empty") if account_id.empty? raise("merchant_id cannot be empty") if merchant_id.empty? raise("properties cannot be empty") if properties.empty? = { :body => MultiJson.dump(delete_nils(properties)), :headers => { "User-Agent" => user_agent, "Content-Type" => "application/json" }, :basic_auth => { :username => api_key, :password => "" } } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.put(API_ENDPOINT + Sift.psp_merchant_id_api_path(account_id, merchant_id), ) Response.new(response.body, response.code, response.response) end |
#user_agent ⇒ Object
149 150 151 |
# File 'lib/sift/client.rb', line 149 def user_agent "SiftScience/v#{@version} sift-ruby/#{VERSION}" end |
#verification_check(properties = {}, opts = {}) ⇒ Object
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
# File 'lib/sift/client.rb', line 794 def verification_check(properties = {}, opts = {}) api_key = opts[:api_key] || @api_key version = opts[:version] || @version timeout = opts[:timeout] || @timeout raise("properties cannot be empty") if properties.empty? raise("api_key cannot be empty") if api_key.empty? = { :body => MultiJson.dump(delete_nils(properties)), :headers => build_default_headers_post(api_key) } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(Sift.verification_api_check_path(@version), ) Response.new(response.body, response.code, response.response) end |
#verification_resend(properties = {}, opts = {}) ⇒ Object
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/sift/client.rb', line 775 def verification_resend(properties = {}, opts = {}) api_key = opts[:api_key] || @api_key version = opts[:version] || @version timeout = opts[:timeout] || @timeout raise("properties cannot be empty") if properties.empty? raise("api_key cannot be empty") if api_key.empty? = { :body => MultiJson.dump(delete_nils(properties)), :headers => build_default_headers_post(api_key) } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(Sift.verification_api_resend_path(@version), ) Response.new(response.body, response.code, response.response) end |
#verification_send(properties = {}, opts = {}) ⇒ Object
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
# File 'lib/sift/client.rb', line 756 def verification_send(properties = {}, opts = {}) api_key = opts[:api_key] || @api_key version = opts[:version] || @version timeout = opts[:timeout] || @timeout raise("properties cannot be empty") if properties.empty? raise("api_key cannot be empty") if api_key.empty? = { :body => MultiJson.dump(delete_nils(properties)), :headers => build_default_headers_post(api_key) } .merge!(:timeout => timeout) unless timeout.nil? response = self.class.post(Sift.verification_api_send_path(@version), ) Response.new(response.body, response.code, response.response) end |