Class: Lithic::Resources::AuthRules::V2::Backtests
- Inherits:
-
Object
- Object
- Lithic::Resources::AuthRules::V2::Backtests
- Defined in:
- lib/lithic/resources/auth_rules/v2/backtests.rb
Instance Method Summary collapse
-
#create(auth_rule_token, end_: nil, start: nil, request_options: {}) ⇒ Lithic::Models::AuthRules::V2::BacktestCreateResponse
Initiates a request to asynchronously generate a backtest for an Auth rule.
-
#initialize(client:) ⇒ Backtests
constructor
private
A new instance of Backtests.
-
#retrieve(auth_rule_backtest_token, auth_rule_token:, request_options: {}) ⇒ Lithic::Models::AuthRules::V2::BacktestResults
Returns the backtest results of an Auth rule (if available).
Constructor Details
#initialize(client:) ⇒ Backtests
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Backtests.
103 104 105 |
# File 'lib/lithic/resources/auth_rules/v2/backtests.rb', line 103 def initialize(client:) @client = client end |
Instance Method Details
#create(auth_rule_token, end_: nil, start: nil, request_options: {}) ⇒ Lithic::Models::AuthRules::V2::BacktestCreateResponse
Initiates a request to asynchronously generate a backtest for an Auth rule. During backtesting, both the active version (if one exists) and the draft version of the Auth Rule are evaluated by replaying historical transaction data against the rule’s conditions. This process allows customers to simulate and understand the effects of proposed rule changes before deployment. The generated backtest report provides detailed results showing whether the draft version of the Auth Rule would have approved or declined historical transactions which were processed during the backtest period. These reports help evaluate how changes to rule configurations might affect overall transaction approval rates.
The generated backtest report will be delivered asynchronously through a webhook with ‘event_type` = `auth_rules.backtest_report.created`. See the docs on setting up [webhook subscriptions](docs.lithic.com/docs/events-api). It is also possible to request backtest reports on-demand through the `/v2/auth_rules/auth_rule_token/backtests/auth_rule_backtest_token` endpoint.
Lithic currently supports backtesting for ‘CONDITIONAL_BLOCK` / `CONDITIONAL_ACTION` rules. Backtesting for `VELOCITY_LIMIT` rules is generally not supported. In specific cases (i.e. where Lithic has pre-calculated the requested velocity metrics for historical transactions), a backtest may be feasible. However, such cases are uncommon and customers should not anticipate support for velocity backtests under most configurations. If a historical transaction does not feature the required inputs to evaluate the rule, then it will not be included in the final backtest report.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lithic/resources/auth_rules/v2/backtests.rb', line 47 def create(auth_rule_token, params = {}) parsed, = Lithic::AuthRules::V2::BacktestCreateParams.dump_request(params) @client.request( method: :post, path: ["v2/auth_rules/%1$s/backtests", auth_rule_token], body: parsed, model: Lithic::Models::AuthRules::V2::BacktestCreateResponse, options: ) end |
#retrieve(auth_rule_backtest_token, auth_rule_token:, request_options: {}) ⇒ Lithic::Models::AuthRules::V2::BacktestResults
Returns the backtest results of an Auth rule (if available).
Backtesting is an asynchronous process that requires time to complete. If a customer retrieves the backtest results using this endpoint before the report is fully generated, the response will return null for ‘results.current_version` and `results.draft_version`. Customers are advised to wait for the backtest creation process to complete (as indicated by the webhook event auth_rules.backtest_report.created) before retrieving results from this endpoint.
Backtesting is an asynchronous process, while the backtest is being processed, results will not be available which will cause ‘results.current_version` and `results.draft_version` objects to contain `null`. The entries in `results` will also always represent the configuration of the rule at the time requests are made to this endpoint. For example, the results for `current_version` in the served backtest report will be consistent with which version of the rule is currently activated in the respective event stream, regardless of which version of the rule was active in the event stream at the time a backtest is requested.
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/lithic/resources/auth_rules/v2/backtests.rb', line 86 def retrieve(auth_rule_backtest_token, params) parsed, = Lithic::AuthRules::V2::BacktestRetrieveParams.dump_request(params) auth_rule_token = parsed.delete(:auth_rule_token) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["v2/auth_rules/%1$s/backtests/%2$s", auth_rule_token, auth_rule_backtest_token], model: Lithic::AuthRules::V2::BacktestResults, options: ) end |