GoogleSheets v2.0.12 GoogleSheets View Source

Main starting point of the application and public API for library. For introduction on how to configure and use the library, see README.

Link to this section Summary

Functions

Fetches previously loaded spreadsheet data from ETS matching the given version and returns it as a {:ok, data} tuple

Fetches previously loaded spreadsheet data from ETS matching the given version. KeyError is raised if no spreadsheet data is found with the given version

Returns true, if there is a version stored for the spreadsheet identified by spreadsheet_id argument

Returns {:ok, version, data} tuple for the latest stored version for the spreadsheet identified by spreadsheet_id argument. If there is no version available, :not_found is returned

Returns {version, data} tuple for the latest stored version for the spreadsheet identified by spreadsheet_id argument. If no version is found, KeyError exception is raised

Returns {:ok, data} tuple for the latest stored entry for the spreadsheet identified by spreadsheet_id argument. If no entry is found, :not_found is returned

Returns the latest stored entry for the spreadsheet identified by spreadsheet_id argument. If no entry is found, KeyError exception is raised

Returns {:ok, version} tuple or the latest stored version for the spreadsheet identified by spreadsheet_id argument. If no version is found, :not_found is returned

Returns the latest version stored for the spreadsheet identified by spreadsheet_id argument. If no version is found, KeyError exception is raised

Manually triggers an update for fetching new data for the given spreadsheet_id argument

To support storing custom version into ETS table. Required use case for this is to support validation of parsed configuration before it’s stored when using APIs which expect a version to be passed as parameter

To remove a spcific version from ETS table

Link to this section Functions

Link to this function fetch(version) View Source
fetch(term()) :: {:ok, term()} | :not_found

Fetches previously loaded spreadsheet data from ETS matching the given version and returns it as a {:ok, data} tuple.

Examples

iex> GoogleSheets.fetch "fccb56afd7d7f1cdf457e8b9b841ec75"
{:ok, [
  %GoogleSheets.WorkSheet{
    csv: "Key,Value\r\nInteger,1\r\nFloat,1.1\r\nString,string",
    name: "KeyValue"
  }]
}

iex> GoogleSheets.fetch "not_a_valid_version"
:not_found
Link to this function fetch!(version) View Source
fetch!(term()) :: term() | no_return()

Fetches previously loaded spreadsheet data from ETS matching the given version. KeyError is raised if no spreadsheet data is found with the given version.

Examples

iex> GoogleSheets.fetch! "fccb56afd7d7f1cdf457e8b9b841ec75"
[%GoogleSheets.WorkSheet{
  csv: "Key,Value\r\nInteger,1\r\nFloat,1.1\r\nString,string",
  name: "KeyValue"}
]

iex> GoogleSheets.fetch! "not_a_valid_version"
** (KeyError) key "not_a_valid_version" not found
Link to this function has_version?(spreadsheet_id) View Source
has_version?(atom()) :: boolean()

Returns true, if there is a version stored for the spreadsheet identified by spreadsheet_id argument.

Link to this function latest(spreadsheet_id) View Source
latest(atom()) :: {:ok, term(), term()} | :not_found

Returns {:ok, version, data} tuple for the latest stored version for the spreadsheet identified by spreadsheet_id argument. If there is no version available, :not_found is returned.

Link to this function latest!(spreadsheet_id) View Source
latest!(atom()) :: {term(), term()} | no_return()

Returns {version, data} tuple for the latest stored version for the spreadsheet identified by spreadsheet_id argument. If no version is found, KeyError exception is raised.

Link to this function latest_data(spreadsheet_id) View Source
latest_data(atom()) :: {:ok, term()} | :not_found

Returns {:ok, data} tuple for the latest stored entry for the spreadsheet identified by spreadsheet_id argument. If no entry is found, :not_found is returned.

Link to this function latest_data!(spreadsheet_id) View Source
latest_data!(atom()) :: term() | no_return()

Returns the latest stored entry for the spreadsheet identified by spreadsheet_id argument. If no entry is found, KeyError exception is raised.

Link to this function latest_version(spreadsheet_id) View Source
latest_version(atom()) :: {:ok, term()} | :not_found

Returns {:ok, version} tuple or the latest stored version for the spreadsheet identified by spreadsheet_id argument. If no version is found, :not_found is returned.

Link to this function latest_version!(spreadsheet_id) View Source
latest_version!(atom()) :: term() | no_return()

Returns the latest version stored for the spreadsheet identified by spreadsheet_id argument. If no version is found, KeyError exception is raised.

Link to this function update(spreadsheet_id, timeout \\ 60000) View Source
update(spreadseheet_id :: atom(), timeout :: non_neg_integer()) ::
  {:ok, :updated, String.t()} |
  {:ok, :unchanged} |
  {:error, term()}

Manually triggers an update for fetching new data for the given spreadsheet_id argument.

Return values:

  • {:ok, :updated, version} - Spreadsheet was updated and stored with the version
  • {:ok, :unchanged} - Spreadsheet contents haven’t been changed since last update.
  • {:error, reason} - The update failed because of reason.
Link to this function version_add(id, version, data) View Source
version_add(atom(), term(), term()) :: true

To support storing custom version into ETS table. Required use case for this is to support validation of parsed configuration before it’s stored when using APIs which expect a version to be passed as parameter.

Examples

iex> GoogleSheets.version_add :config, "add-test-configuration", %{data: "test-data"}
iex> GoogleSheets.fetch "add-test-configuration"
{:ok, %{data: "test-data"}}
Link to this function version_remove(version) View Source
version_remove(term()) :: true

To remove a spcific version from ETS table.

Examples

iex> GoogleSheets.version_add :config, "remove-test-configuration", %{data: "test-data"}
iex> GoogleSheets.version_remove "remove-test-configuration"
true