GSS.Client (elixir_google_spreadsheets v1.0.1)

Copy Markdown

Model of Client abstraction This process is a Producer for this GenStage pipeline.

Summary

Functions

Read config settings scoped for GSS client.

Divide request into to partitions :read and :write

Issues an HTTP request with the given method to the given URL using Finch.

Starts a task with request that must be awaited on.

Types

event()

@type event() :: {:request, GenStage.from(), GSS.Client.RequestParams.t()}

headers()

@type headers() :: [{binary(), binary()}] | %{optional(binary()) => binary()}

partition()

@type partition() :: :write | :read

response()

@type response() :: {:ok, Finch.Response.t()} | {:error, Exception.t()}

Functions

config(key, default \\ nil)

@spec config(atom(), any()) :: any()

Read config settings scoped for GSS client.

dispatcher_hash(event)

@spec dispatcher_hash(event()) :: {event(), partition()}

Divide request into to partitions :read and :write

request(method, url, body \\ "", headers \\ [], options \\ [])

@spec request(atom(), binary(), binary() | iodata(), headers(), Keyword.t()) ::
  {:ok, Finch.Response.t()} | {:error, Exception.t()}

Issues an HTTP request with the given method to the given URL using Finch.

This function is usually used indirectly by helper functions such as get/3, post/4, put/4, etc.

Arguments

  • method: HTTP method as an atom (e.g., :get, :head, :post, :put, :delete, etc.).
  • url: Target URL as a binary string.
  • body: Request body as a binary() or iodata().
  • headers: HTTP headers as a list of two-element tuples (e.g., [{"Accept", "application/json"}]).
  • options: A keyword list of options.
    • :result_timeout – timeout (in milliseconds) for the underlying GenStage.call/3. This key is consumed by the library and is not forwarded to Finch. When omitted it falls back to the :result_timeout client config. May be an integer or :infinity.
    • :pool_timeout, :receive_timeout, :request_timeout – forwarded to Finch.request/3 (see the Finch documentation for their semantics). Any other keys are ignored by the request worker.

Returns

  • On success, returns {:ok, %Finch.Response{}}.
  • On failure, returns {:error, reason} where reason is an exception.

Examples

request(:post, "https://my.website.com", "{"foo": 3}", [{"Accept", "application/json"}])

request_async(method, url, body \\ "", headers \\ [], options \\ [])

@spec request_async(atom(), binary(), binary() | iodata(), headers(), Keyword.t()) ::
  Task.t()

Starts a task with request that must be awaited on.

start_link(args \\ [])

@spec start_link(any()) :: GenServer.on_start()