Sheetshow.Client (Sheetshow v0.1.0)

Copy Markdown View Source

How to reach one Google spreadsheet: which one, with which credentials.

A client is a value you hold and pass in, not a process Sheetshow runs. It is the Google backend's half of a Sheetshow.Workbook: Workbook.google/2 builds one for you, and Sheetshow.connect/1 fills in the token.

iex> client = Sheetshow.Client.new("1AbC")
iex> client.spreadsheet_id
"1AbC"
iex> client.scopes
["https://www.googleapis.com/auth/spreadsheets"]

Which sheets the spreadsheet has is the workbook's business, not the client's: see Sheetshow.Workbook.

Summary

Functions

Builds a client for one spreadsheet.

Whether the client holds a token that is still good. Takes the moment to judge by, so a margin is yours to choose, as in Sheetshow.Token.expired?/2.

Types

t()

@type t() :: %Sheetshow.Client{
  base_url: String.t(),
  credentials: Sheetshow.ServiceAccount.t() | Sheetshow.UserAccount.t() | nil,
  http: keyword(),
  scopes: [String.t()],
  spreadsheet_id: String.t(),
  token: Sheetshow.Token.t() | nil
}

Functions

new(spreadsheet_id, opts \\ [])

@spec new(String.t(), keyword()) :: t()

Builds a client for one spreadsheet.

Options: :credentials (a Sheetshow.ServiceAccount or a Sheetshow.UserAccount), :token (one you already hold), :scopes, :base_url and :http, which passes :timeout, :connect_timeout and :ssl through to the HTTP client.

iex> Sheetshow.Client.new("1AbC", http: [timeout: 5_000]).http
[timeout: 5_000]

ready?(client, at \\ DateTime.utc_now())

@spec ready?(t(), DateTime.t()) :: boolean()

Whether the client holds a token that is still good. Takes the moment to judge by, so a margin is yours to choose, as in Sheetshow.Token.expired?/2.

iex> Sheetshow.Client.ready?(Sheetshow.Client.new("1AbC"))
false
iex> token = Sheetshow.Token.new("ya29.abc", ~U[2026-09-12 09:00:00Z])
iex> Sheetshow.Client.ready?(Sheetshow.Client.new("1AbC", token: token), ~U[2026-09-12 08:00:00Z])
true