Packages

Low-level Elixir implementation of the W3C WebDriver BiDi Protocol.

Current section

Files

Jump to
bibbidi lib bibbidi commands browsing_context get_tree.ex
Raw

lib/bibbidi/commands/browsing_context/get_tree.ex

# Generated by mix bibbidi.gen — do not edit manually
defmodule Bibbidi.Commands.BrowsingContext.GetTree do
@moduledoc """
Command struct for `browsingContext.getTree`.
[WebDriver BiDi Spec](https://w3c.github.io/webdriver-bidi/#command-browsingContext-getTree)
## Fields
- `max_depth` - `t:Bibbidi.Types.JsUint.t/0` (optional)
- `root` - `t:Bibbidi.Types.BrowsingContext.t/0` (optional)
"""
@derive Bibbidi.Telemetry.Metadata
@schema Zoi.struct(__MODULE__, %{
max_depth: Bibbidi.Types.JsUint.schema() |> Zoi.optional(),
root: Bibbidi.Types.BrowsingContext.schema() |> Zoi.optional(),
meta: Zoi.any() |> Zoi.optional()
})
@opts_schema Zoi.keyword(
max_depth: Zoi.any() |> Zoi.optional(),
root: Zoi.any() |> Zoi.optional()
)
@result_schema Zoi.map(%{contexts: Bibbidi.Types.BrowsingContext.InfoList.schema()})
@type t :: unquote(Zoi.type_spec(@schema))
@type opts :: unquote(Zoi.type_spec(@opts_schema))
@type result :: unquote(Zoi.type_spec(@result_schema))
@enforce_keys Zoi.Struct.enforce_keys(@schema)
defstruct Zoi.Struct.struct_fields(@schema)
@doc "Returns the Zoi schema for this command struct."
def schema, do: @schema
@doc "Returns the Zoi schema for the keyword options."
def opts_schema, do: @opts_schema
@doc "Returns the Zoi schema for the result type."
def result_schema, do: @result_schema
defimpl Bibbidi.Encodable do
def method(_), do: "browsingContext.getTree"
def params(cmd) do
optional = [
{:maxDepth, cmd.max_depth},
{:root, cmd.root}
]
Enum.reduce(optional, %{}, fn
{_key, nil}, acc -> acc
{key, value}, acc -> Map.put(acc, key, value)
end)
end
end
end