Scalar Ruby Test

This library provides convenient access to the Scalar Ruby Test REST API from Ruby.

The full API of this library can be found in api.md.


Contents


Installation

gem install amritk-scalar-test

Usage

response = client.ping.ping
puts response.inspect

The examples in the following sections assume a client configured as shown above.

See the API reference for every available operation.


Authentication

This API does not declare a global authentication scheme.


Errors

Non-success responses throw generated API errors. Error objects expose status, headers, response body, and request metadata where the target runtime supports it.

begin
  response = client.ping.ping
  puts response.inspect
rescue ScalarRubyTest::APIError => error
  puts "#{error.status}: #{error.message}"
  raise

Client Options

Configure the generated client by setting any of these options when you create it.

require "amritk-scalar-test"

client = ScalarRubyTest::Client.new(
  timeout: 60.0,
  max_retries: 2,
  logger: $stderr,
)
Option Type Default Description
base_url String - Override the default API base URL.
timeout Numeric 60.0 Seconds to wait for a response before timing out.
max_retries Integer 2 Maximum number of retries for temporary failures.
logger `Callable \ #puts \ nil` - Receives lightweight request/response debug lines.
default_headers Hash - Headers included with every request.
default_query Hash - Query parameters included with every request.

Request Options

Option Type Default Description
idempotency_key String - Value for the configured idempotency header.
extra_headers Hash - Additional headers for one request.
extra_query Hash - Additional query parameters for one request.
extra_body Hash - Additional body fields for one request.
timeout Numeric - Override timeout for one request.
max_retries Integer - Override retry count for one request.
base_url String - Override the base URL for one request.
url String - Exact URL to request (used internally by link-header pagination).
allow_auth_to_base_url Boolean - Send auth to a different base URL origin.

Retries and Timeouts

Generated clients support request timeouts and retry temporary failures such as network errors, 408, 409, 429, and 5xx responses. Retry delays honor Retry-After headers when present. Tune the retry and timeout client options shown above, or override them per request.


Helpers

  • Use with_raw_response companions when you need status, headers, or unparsed response bodies.
  • Use with_result companions when you want success data or HTTP error bodies without raising status errors.
  • WebSocket helpers use Ruby stdlib sockets (ws:// and wss://) and expose typed serialize_send / deserialize_receive helpers.

Requirements

  • Ruby >= 3.2

Powered by Scalar.