Glific v0.3.1 Glific View Source

Glific keeps the contexts that define your domain and business logic.

Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others.

For now we'll keep some commonly used functions here, until we need a new file

Link to this section Summary

Functions

Return a time object where you go back x units. We introduce the notion of hour and minute

See if the current time is within the past time units

Wrapper to return :ok/:error when parsing strings to potential integers

Lets get rid of all non valid characters. We are assuming any language and hence using unicode syntax and not restricting ourselves to alphanumeric

Validates inputed shortcode, if shortcode is invalid it returns message that the shortcode is invalid along with the valid shortcode.

Link to this section Functions

Link to this function

go_back_time(go_back, time \\ DateTime.utc_now(), unit \\ :hour)

View Source

Specs

go_back_time(integer(), DateTime.t(), atom()) :: DateTime.t()

Return a time object where you go back x units. We introduce the notion of hour and minute

Link to this function

in_past_time(time, units \\ :hours, back \\ 24)

View Source

Specs

in_past_time(DateTime.t(), atom(), integer()) :: boolean()

See if the current time is within the past time units

Link to this function

parse_maybe_integer(value)

View Source

Specs

parse_maybe_integer(String.t() | integer()) :: {:ok, integer()} | :error

Wrapper to return :ok/:error when parsing strings to potential integers

Specs

string_clean(String.t() | nil) :: String.t() | nil

Lets get rid of all non valid characters. We are assuming any language and hence using unicode syntax and not restricting ourselves to alphanumeric

Link to this function

validate_shortcode(changeset)

View Source

Specs

validate_shortcode(Ecto.Changeset.t()) ::
  Ecto.Changeset.t() | Ecto.Changeset.t()

Validates inputed shortcode, if shortcode is invalid it returns message that the shortcode is invalid along with the valid shortcode.