CampaignFlow.MockServer (CampaignFlow Client v2.2.0)
View SourceMock Campaign Flow server for development and testing.
This module provides a mock implementation of the Campaign Flow API that can run embedded in your application. It's useful for:
- Local development without API credentials
- Integration testing without hitting the real API
- End-to-end testing of referral workflows
Configuration
Add to your config files:
# config/test.exs
config :campaign_flow, :mock_server,
enabled: true,
repo: MyApp.RepoMigrations
Generate a migration in your application:
mix ecto.gen.migration add_campaign_flow_mock_serverThen call the migration functions:
defmodule MyApp.Repo.Migrations.AddCampaignFlowMockServer do
use Ecto.Migration
def up, do: CampaignFlow.MockServer.Migrations.up(version: 1)
def down, do: CampaignFlow.MockServer.Migrations.down(version: 1)
endEmbedded Mode (Phoenix Integration)
Mount the mock server router in your Phoenix router:
# In your Phoenix router
forward "/campaign-flow-mock", CampaignFlow.MockServer.RouterConfigure your Campaign Flow client to use your Phoenix URL:
config :campaign_flow,
environments: [
mock: [
base_url: "http://localhost:4000/campaign-flow-mock/api/v2",
client_id: "test_key",
client_secret: "test_secret"
]
]
Summary
Functions
Returns the configured base URL for the mock server.
Returns the child spec for starting the mock server under a supervisor.
Clears all mock server state.
Returns all stored webhook events, newest first.
Sets the status of a mock campaign and enqueues a campaign_status_change
webhook for delivery.
Starts the mock server.
Functions
@spec base_url() :: String.t()
Returns the configured base URL for the mock server.
Returns the child spec for starting the mock server under a supervisor.
Clears all mock server state.
Useful for resetting state between tests.
Returns all stored webhook events, newest first.
Sets the status of a mock campaign and enqueues a campaign_status_change
webhook for delivery.
Starts the mock server.
Returns :ignore if the mock server is not enabled in config.