Class: Plaid::Signal::Client
- Inherits:
-
Object
- Object
- Plaid::Signal::Client
- Defined in:
- lib/plaid/signal/client.rb
Instance Method Summary collapse
-
#evaluate(request_options: {}, **params) ⇒ Plaid::Types::SignalEvaluateResponse
Use
/signal/evaluateto evaluate a planned ACH transaction to get a return risk assessment and additional risk signals. - #initialize(client:) ⇒ void constructor
-
#prepare(request_options: {}, **params) ⇒ Plaid::Types::SignalPrepareResponse
When an Item is not initialized with
signal, call/signal/prepareto opt-in that Item to the data collection process used to develop a Signal Transaction Score. -
#report_decision(request_options: {}, **params) ⇒ Plaid::Types::SignalDecisionReportResponse
After you call
/signal/evaluate, Plaid will normally infer the outcome from your Signal Rules. -
#report_return(request_options: {}, **params) ⇒ Plaid::Types::SignalReturnReportResponse
Call the
/signal/return/reportendpoint to report a returned transaction that was previously sent to the/signal/evaluateendpoint. -
#schedule(request_options: {}, **params) ⇒ Plaid::Types::SignalScheduleResponse
Use
/signal/scheduleto schedule a planned ACH transaction.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/plaid/signal/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#evaluate(request_options: {}, **params) ⇒ Plaid::Types::SignalEvaluateResponse
Use /signal/evaluate to evaluate a planned ACH transaction to get a return risk assessment and additional risk
signals.
Before using /signal/evaluate, you must first create a ruleset
in the Dashboard under Signal->Rules.
/signal/evaluate can be used with either Signal Transaction Scores or the Balance product. Which product is
used will be determined by the ruleset_key that you provide. For more details, see Signal
Rules.
Note: This request may have higher latency when using a Balance-only ruleset. This is because Plaid must communicate directly with the institution to request data. Balance-only rulesets may have latency of up to 30 seconds or more; if you encounter errors, you may find it necessary to adjust your timeout period when making requests.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/plaid/signal/client.rb', line 45 def evaluate(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "signal/evaluate", body: Plaid::Signal::Types::SignalEvaluateRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::SignalEvaluateResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#prepare(request_options: {}, **params) ⇒ Plaid::Types::SignalPrepareResponse
When an Item is not initialized with signal, call /signal/prepare to opt-in that Item to the data collection
process used to develop a Signal Transaction Score. This should be done on Items where signal was added in the
additional_consented_products array but not in the products, optional_products, or
required_if_supported_products array. If /signal/prepare is skipped on an Item that is not initialized with
signal, the initial call to /signal/evaluate on that Item will be less accurate, because Plaid will have
access to less data for computing the Signal Transaction Score.
If your integration is purely Balance-only, this endpoint will have no effect, as Balance-only rulesets do not calculate a Signal Transaction Score.
If run on an Item that is already initialized with signal, this endpoint will return a 200 response and will
not modify the Item.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/plaid/signal/client.rb', line 284 def prepare(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "signal/prepare", body: Plaid::Signal::Types::SignalPrepareRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::SignalPrepareResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#report_decision(request_options: {}, **params) ⇒ Plaid::Types::SignalDecisionReportResponse
After you call /signal/evaluate, Plaid will normally infer the outcome from your Signal Rules. However, if you
are not using Signal Rules, if the Signal Rules outcome was REVIEW, or if you take a different action than the
one determined by the Signal Rules, you will need to call /signal/decision/report. This helps improve Signal
Transaction Score accuracy for your account and is necessary for proper functioning of the rule performance and
rule tuning capabilities in the Dashboard. If your effective decision changes after calling
/signal/decision/report (for example, you indicated that you accepted a transaction, but later on, your
payment processor rejected it, so it was never initiated), call /signal/decision/report again for the
transaction to correct Plaid's records.
If you are using Plaid Transfer as your payment processor, you also do not need to call
/signal/decision/report, as Plaid can infer outcomes from your Transfer activity.
If using a Balance-only ruleset, this endpoint will not impact scores (Balance does not use scores), but is necessary to view accurate transaction outcomes and tune rule logic in the Dashboard.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/plaid/signal/client.rb', line 166 def report_decision(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "signal/decision/report", body: Plaid::Signal::Types::SignalDecisionReportRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::SignalDecisionReportResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#report_return(request_options: {}, **params) ⇒ Plaid::Types::SignalReturnReportResponse
Call the /signal/return/report endpoint to report a returned transaction that was previously sent to the
/signal/evaluate endpoint. Your feedback will be used by the model to incorporate the latest risk trends into
your scores and tune rule logic. If using a Balance-only ruleset, this endpoint will not impact scores (as
Balance does not use scores), but is necessary to view accurate transaction outcomes and tune rule logic in the
Dashboard.
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 |
# File 'lib/plaid/signal/client.rb', line 223 def report_return(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "signal/return/report", body: Plaid::Signal::Types::SignalReturnReportRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::SignalReturnReportResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |
#schedule(request_options: {}, **params) ⇒ Plaid::Types::SignalScheduleResponse
Use /signal/schedule to schedule a planned ACH transaction.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/plaid/signal/client.rb', line 100 def schedule(request_options: {}, **params) params = Plaid::Internal::Types::Utils.normalize_keys(params) request = Plaid::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "signal/schedule", body: Plaid::Signal::Types::SignalScheduleRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Plaid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) begin (response.body.to_s.empty? ? nil : Plaid::Types::SignalScheduleResponse.load(response.body)) rescue ::JSON::ParserError raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash) end else error_class = Plaid::Errors::ResponseError.subclass_for_code(code) error_types = { 400 => Plaid::Types::PlaidError, 401 => Plaid::Types::PlaidError, 429 => Plaid::Types::PlaidError, 500 => Plaid::Types::PlaidError, (400..499) => Plaid::Types::PlaidError, (500..599) => Plaid::Types::PlaidError } error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types) raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash) end end |