Automations — a trigger plus the steps it runs.
{:ok, automation} =
FoPost.Automations.create(client,
workspace_id: workspace.id,
name: "Cross-post the blog",
trigger_type: "rss_feed",
trigger_config: %{"url" => "https://example.com/feed.xml"},
steps: [%{action_type: "publish", action_config: %{"accounts" => [account.id]}}]
)A step is a FoPost.AutomationStep or a map of :action_type and :action_config;
snake_case keys are converted to the wire's camelCase for you.
Summary
Functions
Adds an automation.
Same as create/2, but raises FoPost.Error.
Removes an automation.
Same as delete/2, but raises FoPost.Error.
One automation, with its steps.
Same as get/2, but raises FoPost.Error.
The automations the key can reach.
Same as list/1, but raises FoPost.Error.
One execution, with a log per step.
Same as run/3, but raises FoPost.Error.
One page of an automation's executions. Paging: :page, :per_page.
Same as runs/3, but raises FoPost.Error.
Automation counts and the runs of the last day.
Same as stats/1, but raises FoPost.Error.
Switches an automation on or off.
Same as toggle/2, but raises FoPost.Error.
Fires an api_webhook automation with a payload its steps can read.
Same as trigger/3, but raises FoPost.Error.
Edits an automation. Only the keys you pass are sent, but :steps replaces the whole
list when given.
Same as update/3, but raises FoPost.Error.
Functions
@spec create( FoPost.Client.t(), keyword() ) :: {:ok, FoPost.Automation.t()} | {:error, FoPost.Error.t()}
Adds an automation.
Required: :workspace_id, :name, :trigger_type, :steps. Optional:
:trigger_config, :active.
For an api_webhook trigger the response carries the signing secret once — store it.
Same as create/2, but raises FoPost.Error.
@spec delete(FoPost.Client.t(), String.t()) :: {:ok, FoPost.Message.t()} | {:error, FoPost.Error.t()}
Removes an automation.
Same as delete/2, but raises FoPost.Error.
@spec get(FoPost.Client.t(), String.t()) :: {:ok, FoPost.Automation.t()} | {:error, FoPost.Error.t()}
One automation, with its steps.
Same as get/2, but raises FoPost.Error.
@spec list(FoPost.Client.t()) :: {:ok, [FoPost.Automation.t()]} | {:error, FoPost.Error.t()}
The automations the key can reach.
Same as list/1, but raises FoPost.Error.
@spec run(FoPost.Client.t(), String.t(), String.t() | integer()) :: {:ok, FoPost.AutomationRun.t()} | {:error, FoPost.Error.t()}
One execution, with a log per step.
Same as run/3, but raises FoPost.Error.
@spec runs(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Page.t()} | {:error, FoPost.Error.t()}
One page of an automation's executions. Paging: :page, :per_page.
Same as runs/3, but raises FoPost.Error.
@spec stats(FoPost.Client.t()) :: {:ok, FoPost.AutomationStats.t()} | {:error, FoPost.Error.t()}
Automation counts and the runs of the last day.
Same as stats/1, but raises FoPost.Error.
@spec toggle(FoPost.Client.t(), String.t()) :: {:ok, FoPost.Automation.t()} | {:error, FoPost.Error.t()}
Switches an automation on or off.
Same as toggle/2, but raises FoPost.Error.
@spec trigger(FoPost.Client.t(), String.t(), map()) :: {:ok, FoPost.AutomationTrigger.t()} | {:error, FoPost.Error.t()}
Fires an api_webhook automation with a payload its steps can read.
Same as trigger/3, but raises FoPost.Error.
@spec update(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Automation.t()} | {:error, FoPost.Error.t()}
Edits an automation. Only the keys you pass are sent, but :steps replaces the whole
list when given.
Same as update/3, but raises FoPost.Error.