class

Sonarr::Query

Inherits Reference < Object

Structured, URI-encoded query-string builder for typed endpoints.

Handles Sonarr's paging parameters (page, pageSize, sortKey, sortDirection) plus arbitrary filters:

  • nil values are dropped.
  • Array values are emitted as repeated keys (seriesIds=1&seriesIds=2), matching Sonarr's ASP.NET Core model binding.
  • enum values are serialized via #to_sonarr_value when available (so the exact schema string, e.g. ascending, is sent), Time via RFC 3339, everything else via #to_s.

Insertion order is preserved, so rendering is deterministic and the class is pure/unit-testable — it performs no I/O and never touches the client.

Sonarr::Query.paging(page: 2, page_size: 50, sort_key: "date")
  .add("seriesIds", [1, 2])
  .to_s # => "page=2&pageSize=50&sortKey=date&seriesIds=1&seriesIds=2"

Constructors

build

Yields a fresh query for block-style construction.

Source
from(params) : self

Builds a query from a plain hash of params. Used by the generic verbs for backwards compatibility.

Source
paging(page = nil, page_size = nil, sort_key = nil, sort_direction = nil) : self

Builds a query pre-populated with paging parameters.

Source

Instance methods

add(key : String, value) : self

Appends value under key. Arrays expand to repeated keys; nil is dropped. Chainable.

Source
empty?
Source
paging(page = nil, page_size = nil, sort_key = nil, sort_direction = nil) : self

Appends the standard paging parameters (nil ones are skipped). Chainable.

Source
pairs

Rendered key/value pairs, in insertion order.

Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source