Current section
Files
Jump to
Current section
Files
lib/campaign_flow/mock_server/storage.ex
defmodule CampaignFlow.MockServer.Storage do
@moduledoc """
Storage behaviour for mock server persistence.
The mock server uses PostgreSQL for storage via the host application's
Ecto Repo.
## Configuration
Configure the mock server with your repo:
config :campaign_flow, :mock_server,
enabled: true,
repo: MyApp.Repo
"""
@callback create_referral(params :: map()) :: {:ok, map()} | {:error, term()}
@callback get_referral(id :: integer()) :: {:ok, map()} | :not_found
@callback list_referrals() :: [map()]
@callback get_campaign(id :: integer()) :: {:ok, map()} | :not_found
@callback update_campaign_status(id :: integer(), new_status :: String.t()) ::
{:ok, struct(), String.t()} | :not_found | {:error, term()}
@callback create_finance_application(campaign_id :: integer()) ::
{:ok, struct()} | :not_found | {:error, term()}
@callback get_finance_application(id :: integer()) :: {:ok, struct()} | :not_found
@callback update_finance_application_status(id :: integer(), new_status :: String.t()) ::
{:ok, struct(), String.t()} | :not_found | {:error, term()}
@callback clear_all() :: :ok
@doc """
Returns the configured Ecto repo, or nil if not configured.
"""
@spec repo() :: module() | nil
def repo do
Application.get_env(:campaign_flow, :mock_server, [])[:repo]
end
end